Welcome! Log In Create A New Profile

Advanced

[njs] Native methods called with Function.prototype.call() and

December 05, 2016 10:18AM
details: http://hg.nginx.org/njs/rev/15ec6a09cece
branches:
changeset: 273:15ec6a09cece
user: Igor Sysoev <igor@sysoev.ru>
date: Mon Dec 05 17:45:02 2016 +0300
description:
Native methods called with Function.prototype.call() and
Functon.prototype.apply() should run via continuation to
normilize arguments.

diffstat:

njs/njs_function.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r eba4f3a30bb4 -r 15ec6a09cece njs/njs_function.c
--- a/njs/njs_function.c Mon Dec 05 17:35:33 2016 +0300
+++ b/njs/njs_function.c Mon Dec 05 17:45:02 2016 +0300
@@ -484,18 +484,29 @@ static njs_ret_t
njs_function_activate(njs_vm_t *vm, njs_function_t *function, njs_value_t *this,
njs_value_t *args, nxt_uint_t nargs, njs_index_t retval)
{
- njs_ret_t ret;
+ njs_ret_t ret;
+ njs_continuation_t *cont;

if (function->native) {
- ret = njs_function_native_frame(vm, function, this, args,
- nargs, 0, 0);
+ ret = njs_function_native_frame(vm, function, this, args, nargs,
+ NJS_CONTINUATION_SIZE, 0);
if (nxt_slow_path(ret != NXT_OK)) {
return ret;
}

- /* Skip the "apply" method frame. */
+ /* Skip the "call/apply" method frame. */
vm->frame->previous->skip = 1;

+ cont = njs_continuation(vm->frame);
+
+ cont->function = function->u.native;
+ cont->args_types = function->args_types;
+ cont->retval = retval;
+
+ cont->return_address = vm->current
+ + sizeof(njs_vmcode_function_call_t);;
+ vm->current = (u_char *) njs_continuation_nexus;
+
return NJS_APPLIED;
}

@@ -505,7 +516,7 @@ njs_function_activate(njs_vm_t *vm, njs_
return ret;
}

- /* Skip the "apply" method frame. */
+ /* Skip the "call/apply" method frame. */
vm->frame->previous->skip = 1;

return njs_function_call(vm, retval, sizeof(njs_vmcode_function_call_t));
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Native methods called with Function.prototype.call() and

Igor Sysoev 891 December 05, 2016 10:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready