]> git.kaiwu.me - njs.git/commit
Change: native methods are provided with retval argument.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 19 Apr 2023 07:20:37 +0000 (00:20 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 19 Apr 2023 07:20:37 +0000 (00:20 -0700)
commitdbbe69a83bd67788b8a0269f28bde5a29c3b7f8d
treea295f52bfcac07482a50a606e17c53f0c1ddf676
parentc89eb033d5b5ab62c9f84a421b7b8e92264a4101
Change: native methods are provided with retval argument.

Previously, native methods were expected to return
their retval using vm->retval.  This caused problem in the part
(1aa137411b09293fe42c5e1c) because vm->retval can be overwritten
unexpectedly as a side-effect of operations like ToString(), ToNumber().

The fix is to never used a global retval. Instead methods
are provided with a retval argument to store their retval value.

As a part of the change, retval and exception values are split.
The normal value is returned in the retval argument.
The exception value is thrown by njs_vm_throw() or njs_vm_error().
The exception value can be acquired using njs_vm_exception_get().
61 files changed:
external/njs_crypto_module.c
external/njs_fs_module.c
external/njs_query_string_module.c
external/njs_webcrypto_module.c
external/njs_xml_module.c
external/njs_zlib_module.c
nginx/ngx_http_js_module.c
nginx/ngx_js.c
nginx/ngx_js.h
nginx/ngx_js_fetch.c
nginx/ngx_js_fetch.h
nginx/ngx_stream_js_module.c
src/njs.h
src/njs_array.c
src/njs_array.h
src/njs_array_buffer.c
src/njs_async.c
src/njs_async.h
src/njs_boolean.c
src/njs_buffer.c
src/njs_buffer.h
src/njs_builtin.c
src/njs_date.c
src/njs_encoding.c
src/njs_error.c
src/njs_error.h
src/njs_function.c
src/njs_function.h
src/njs_generator.c
src/njs_iterator.c
src/njs_iterator.h
src/njs_json.c
src/njs_math.c
src/njs_module.c
src/njs_module.h
src/njs_number.c
src/njs_number.h
src/njs_object.c
src/njs_object.h
src/njs_object_prop.c
src/njs_parser.c
src/njs_promise.c
src/njs_promise.h
src/njs_regexp.c
src/njs_regexp.h
src/njs_shell.c
src/njs_string.c
src/njs_string.h
src/njs_symbol.c
src/njs_timer.c
src/njs_timer.h
src/njs_typed_array.c
src/njs_typed_array.h
src/njs_value.c
src/njs_vm.c
src/njs_vm.h
src/njs_vmcode.c
src/njs_vmcode.h
src/test/njs_benchmark.c
src/test/njs_externals_test.c
src/test/njs_unit_test.c