[njs] Removed remnants of GC code.
Vadim Zhestikov
v.zhestikov at f5.com
Thu Nov 30 04:48:04 UTC 2023
details: https://hg.nginx.org/njs/rev/439ea33e531c
branches:
changeset: 2244:439ea33e531c
user: Vadim Zhestikov <v.zhestikov at f5.com>
date: Wed Nov 29 20:46:36 2023 -0800
description:
Removed remnants of GC code.
The code never worked and comments are in a broken state.
diffstat:
src/njs_array.c | 10 ---------
src/njs_function.c | 3 --
src/njs_iterator.c | 2 -
src/njs_object.c | 5 ----
src/njs_object.h | 1 -
src/njs_scope.c | 1 -
src/njs_string.c | 6 -----
src/njs_string.h | 1 -
src/njs_value.c | 57 ------------------------------------------------------
src/njs_value.h | 29 ---------------------------
src/njs_vmcode.c | 6 +----
11 files changed, 1 insertions(+), 120 deletions(-)
diffs (343 lines):
diff -r a3364db5fdef -r 439ea33e531c src/njs_array.c
--- a/src/njs_array.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_array.c Wed Nov 29 20:46:36 2023 -0800
@@ -163,8 +163,6 @@ njs_array_convert_to_slow_array(njs_vm_t
}
}
- /* GC: release value. */
-
njs_mp_free(vm->mem_pool, array->data);
array->start = NULL;
@@ -338,7 +336,6 @@ njs_array_add(njs_vm_t *vm, njs_array_t
ret = njs_array_expand(vm, array, 0, 1);
if (njs_fast_path(ret == NJS_OK)) {
- /* GC: retain value. */
array->start[array->length++] = *value;
}
@@ -466,7 +463,6 @@ njs_array_constructor(njs_vm_t *vm, njs_
} else {
while (size != 0) {
- njs_retain(args);
*value++ = *args++;
size--;
}
@@ -967,7 +963,6 @@ njs_array_prototype_push(njs_vm_t *vm, n
}
for (i = 1; i < nargs; i++) {
- /* GC: njs_retain(&args[i]); */
array->start[array->length++] = args[i];
}
}
@@ -1094,7 +1089,6 @@ njs_array_prototype_unshift(njs_vm_t *vm
do {
n--;
- /* GC: njs_retain(&args[n]); */
array->start--;
array->start[0] = args[n];
} while (n > 1);
@@ -2133,8 +2127,6 @@ njs_array_iterator_call(njs_vm_t *vm, nj
{
njs_value_t arguments[3];
- /* GC: array elt, array */
-
arguments[0] = *entry;
njs_set_number(&arguments[1], n);
njs_value_assign(&arguments[2], &args->value);
@@ -2303,8 +2295,6 @@ njs_array_handler_reduce(njs_vm_t *vm, n
return NJS_OK;
}
- /* GC: array elt, array */
-
njs_set_undefined(&arguments[0]);
njs_value_assign(&arguments[1], &args->argument);
arguments[2] = *entry;
diff -r a3364db5fdef -r 439ea33e531c src/njs_function.c
--- a/src/njs_function.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_function.c Wed Nov 29 20:46:36 2023 -0800
@@ -310,7 +310,6 @@ njs_function_rest_parameters_init(njs_vm
return NJS_ERROR;
}
- /* GC: retain. */
njs_set_array(rest_arguments, array);
vm->top_frame->local[n] = rest_arguments;
@@ -1419,8 +1418,6 @@ njs_function_prototype_bind(njs_vm_t *vm
function->bound = values;
- /* GC: ? retain args. */
-
memcpy(values, args, size);
njs_set_function(retval, function);
diff -r a3364db5fdef -r 439ea33e531c src/njs_iterator.c
--- a/src/njs_iterator.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_iterator.c Wed Nov 29 20:46:36 2023 -0800
@@ -50,7 +50,6 @@ njs_array_iterator_create(njs_vm_t *vm,
return NJS_ERROR;
}
- /* GC retain it->target */
it->target = *target;
it->next = 0;
it->kind = kind;
@@ -163,7 +162,6 @@ njs_array_iterator_next(njs_vm_t *vm, nj
release:
- /* GC release it->target */
njs_mp_free(vm->mem_pool, it);
njs_set_invalid(njs_object_value(iterator));
diff -r a3364db5fdef -r 439ea33e531c src/njs_object.c
--- a/src/njs_object.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_object.c Wed Nov 29 20:46:36 2023 -0800
@@ -279,7 +279,6 @@ njs_object_create(njs_vm_t *vm, njs_valu
}
if (!njs_is_null(value)) {
- /* GC */
object->__proto__ = njs_object(value);
} else {
@@ -2022,8 +2021,6 @@ njs_property_prototype_create(njs_vm_t *
return NULL;
}
- /* GC */
-
njs_set_type_object(njs_prop_value(prop), prototype, prototype->type);
lhq.value = prop;
@@ -2273,8 +2270,6 @@ njs_property_constructor_set(njs_vm_t *v
return NULL;
}
- /* GC */
-
njs_value_assign(njs_prop_value(prop), constructor);
prop->enumerable = 0;
diff -r a3364db5fdef -r 439ea33e531c src/njs_object.h
--- a/src/njs_object.h Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_object.h Wed Nov 29 20:46:36 2023 -0800
@@ -196,7 +196,6 @@ njs_primitive_value_to_key(njs_vm_t *vm,
case NJS_SYMBOL:
case NJS_STRING:
- /* GC: njs_retain(src); */
value = src;
break;
diff -r a3364db5fdef -r 439ea33e531c src/njs_scope.c
--- a/src/njs_scope.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_scope.c Wed Nov 29 20:46:36 2023 -0800
@@ -235,7 +235,6 @@ njs_scope_value_index(njs_vm_t *vm, cons
string->start = (u_char *) string + sizeof(njs_string_t);
string->length = src->long_string.data->length;
- string->retain = 0xffff;
memcpy(string->start, start, size);
}
diff -r a3364db5fdef -r 439ea33e531c src/njs_string.c
--- a/src/njs_string.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_string.c Wed Nov 29 20:46:36 2023 -0800
@@ -120,7 +120,6 @@ njs_string_set(njs_vm_t *vm, njs_value_t
string->start = (u_char *) start;
string->length = 0;
- string->retain = 1;
}
return NJS_OK;
@@ -233,7 +232,6 @@ njs_string_alloc(njs_vm_t *vm, njs_value
string->start = (u_char *) string + sizeof(njs_string_t);
string->length = length;
- string->retain = 1;
if (map_offset != 0) {
map = (uint32_t *) (string->start + map_offset);
@@ -520,8 +518,6 @@ void
njs_string_copy(njs_value_t *dst, njs_value_t *src)
{
*dst = *src;
-
- /* GC: long string retain */
}
@@ -701,8 +697,6 @@ njs_string_instance_length(njs_vm_t *vm,
njs_set_number(retval, length);
- njs_release(vm, value);
-
return NJS_OK;
}
diff -r a3364db5fdef -r 439ea33e531c src/njs_string.h
--- a/src/njs_string.h Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_string.h Wed Nov 29 20:46:36 2023 -0800
@@ -73,7 +73,6 @@
struct njs_string_s {
u_char *start;
uint32_t length; /* Length in UTF-8 characters. */
- uint32_t retain; /* Link counter. */
};
diff -r a3364db5fdef -r 439ea33e531c src/njs_value.c
--- a/src/njs_value.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_value.c Wed Nov 29 20:46:36 2023 -0800
@@ -58,61 +58,6 @@ const njs_value_t njs_string_anonymous
const njs_value_t njs_string_memory_error = njs_string("MemoryError");
-void
-njs_value_retain(njs_value_t *value)
-{
- njs_string_t *string;
-
- if (njs_is_string(value)) {
-
- if (value->long_string.external != 0xff) {
- string = value->long_string.data;
-
- njs_thread_log_debug("retain:%uxD \"%*s\"", string->retain,
- value->long_string.size, string->start);
-
- if (string->retain != 0xffff) {
- string->retain++;
- }
- }
- }
-}
-
-
-void
-njs_value_release(njs_vm_t *vm, njs_value_t *value)
-{
- njs_string_t *string;
-
- if (njs_is_string(value)) {
-
- if (value->long_string.external != 0xff) {
- string = value->long_string.data;
-
- njs_thread_log_debug("release:%uxD \"%*s\"", string->retain,
- value->long_string.size, string->start);
-
- if (string->retain != 0xffff) {
- string->retain--;
-
-#if 0
- if (string->retain == 0) {
- if ((u_char *) string + sizeof(njs_string_t)
- != string->start)
- {
- njs_memcache_pool_free(vm->mem_pool,
- string->start);
- }
-
- njs_memcache_pool_free(vm->mem_pool, string);
- }
-#endif
- }
- }
- }
-}
-
-
/*
* A hint value is 0 for numbers and 1 for strings. The value chooses
* method calls order specified by ECMAScript 5.1: "valueOf", "toString"
@@ -140,7 +85,6 @@ njs_value_to_primitive(njs_vm_t *vm, njs
if (njs_is_primitive(value)) {
- /* GC */
*dst = *value;
return NJS_OK;
}
@@ -1622,7 +1566,6 @@ njs_primitive_value_to_string(njs_vm_t *
return NJS_ERROR;
case NJS_STRING:
- /* GC: njs_retain(src); */
value = src;
break;
diff -r a3364db5fdef -r 439ea33e531c src/njs_value.h
--- a/src/njs_value.h Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_value.h Wed Nov 29 20:46:36 2023 -0800
@@ -1029,35 +1029,6 @@ njs_set_object_value(njs_value_t *value,
#define njs_set_invalid(value) \
(value)->type = NJS_INVALID
-
-#if 0 /* GC: todo */
-
-#define njs_retain(value) \
- do { \
- if ((value)->data.truth == NJS_STRING_LONG) { \
- njs_value_retain(value); \
- } \
- } while (0)
-
-
-#define njs_release(vm, value) \
- do { \
- if ((value)->data.truth == NJS_STRING_LONG) { \
- njs_value_release((vm), (value)); \
- } \
- } while (0)
-
-#else
-
-#define njs_retain(value)
-#define njs_release(vm, value)
-
-#endif
-
-
-
-void njs_value_retain(njs_value_t *value);
-void njs_value_release(njs_vm_t *vm, njs_value_t *value);
njs_int_t njs_value_to_primitive(njs_vm_t *vm, njs_value_t *dst,
njs_value_t *value, njs_uint_t hint);
njs_array_t *njs_value_enumerate(njs_vm_t *vm, njs_value_t *value,
diff -r a3364db5fdef -r 439ea33e531c src/njs_vmcode.c
--- a/src/njs_vmcode.c Wed Nov 29 20:46:32 2023 -0800
+++ b/src/njs_vmcode.c Wed Nov 29 20:46:36 2023 -0800
@@ -2030,7 +2030,6 @@ njs_vmcode_property_init(njs_vm_t *vm, n
array->length = index + 1;
}
- /* GC: retain. */
array->start[index] = *init;
break;
@@ -2569,10 +2568,7 @@ njs_vmcode_return(njs_vm_t *vm, njs_valu
frame = (njs_frame_t *) vm->top_frame;
if (frame->native.ctor) {
- if (njs_is_object(retval)) {
- njs_release(vm, frame->native.local[0]);
-
- } else {
+ if (!njs_is_object(retval)) {
retval = frame->native.local[0];
}
}
More information about the nginx-devel
mailing list