From: Dmitry Volyntsev Date: Fri, 2 Aug 2019 17:12:01 +0000 (+0300) Subject: Removed vm->count. X-Git-Tag: 0.3.4~29 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/%7B@url%7D?a=commitdiff_plain;h=946ffe9c21848509d9f224018c15045835f20e62;p=njs.git Removed vm->count. Previously it was used to catch infinite recursion. This is redundant, because NJS_MAX_STACK_SIZE is used for the same purpose. --- diff --git a/src/njs_vm.h b/src/njs_vm.h index 4b377cf7..5daaaa38 100644 --- a/src/njs_vm.h +++ b/src/njs_vm.h @@ -8,7 +8,7 @@ #define _NJS_VM_H_INCLUDED_ -#define NJS_MAX_STACK_SIZE (16 * 1024 * 1024) +#define NJS_MAX_STACK_SIZE (256 * 1024) /* @@ -229,8 +229,6 @@ struct njs_vm_s { /* njs_vm_t must be aligned to njs_value_t due to scratch value. */ njs_value_t retval; - njs_uint_t count; - njs_arr_t *paths; u_char *start; diff --git a/src/njs_vmcode.c b/src/njs_vmcode.c index 782cae85..eee0662f 100644 --- a/src/njs_vmcode.c +++ b/src/njs_vmcode.c @@ -105,13 +105,6 @@ njs_vmcode_interpreter(njs_vm_t *vm, u_char *pc) njs_vmcode_try_return_t *try_return; njs_vmcode_function_frame_t *function_frame; - if (njs_slow_path(vm->count > 128)) { - njs_range_error(vm, "Maximum call stack size exceeded"); - return NJS_ERROR; - } - - vm->count++; - next: for ( ;; ) { @@ -588,8 +581,7 @@ next: value2 = njs_vmcode_operand(vm, value2); vm->retval = *value2; - ret = NJS_OK; - goto done; + return NJS_OK; case NJS_VMCODE_JUMP: ret = (njs_jump_off_t) value2; @@ -671,8 +663,7 @@ next: njs_function_frame_free(vm, &frame->native); - ret = NJS_OK; - goto done; + return NJS_OK; case NJS_VMCODE_FUNCTION_FRAME: function_frame = (njs_vmcode_function_frame_t *) pc; @@ -800,7 +791,7 @@ next: switch (ret) { case NJS_OK: - goto done; + return NJS_OK; case NJS_ERROR: goto error; } @@ -822,8 +813,6 @@ next: error: - ret = NJS_ERROR; - for ( ;; ) { frame = (njs_frame_t *) vm->top_frame; @@ -864,11 +853,7 @@ error: } } -done: - - vm->count--; - - return ret; + return NJS_ERROR; } diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 43d6b1e2..f3232d1c 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -4154,10 +4154,12 @@ static njs_unit_test_t njs_test[] = "Array.prototype.fill.call(o, 2).a"), njs_str("4") }, +#if (!NJS_HAVE_MEMORY_SANITIZER) /* MSAN limits stack size */ { njs_str("var o = Object({length: 3});" "Object.defineProperty(o, '0', {set: function(v){this[0] = 2 * v}});" "Array.prototype.fill.call(o, 2)"), njs_str("RangeError: Maximum call stack size exceeded") }, +#endif { njs_str("var a = [];" "a.filter(function(v, i, a) { return v > 1 })"), @@ -6410,8 +6412,10 @@ static njs_unit_test_t njs_test[] = { njs_str("{ function f() {} { var f }}"), njs_str("SyntaxError: \"f\" has already been declared in 1") }, +#if (!NJS_HAVE_MEMORY_SANITIZER) /* MSAN limits stack size */ { njs_str("function f() { return f() } f()"), njs_str("RangeError: Maximum call stack size exceeded") }, +#endif { njs_str("function () { } f()"), njs_str("SyntaxError: Unexpected token \"(\" in 1") },