From 1afe19dfdf432110a73f7aaa135501e9dc2d42c4 Mon Sep 17 00:00:00 2001 From: hongzhidao Date: Sat, 2 Feb 2019 16:01:39 +0800 Subject: [PATCH] Introduced njs_vm_invoke(). --- njs/njs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/njs/njs.c b/njs/njs.c index 19c4f805..2085241a 100644 --- a/njs/njs.c +++ b/njs/njs.c @@ -10,6 +10,8 @@ static nxt_int_t njs_vm_init(njs_vm_t *vm); +static nxt_int_t njs_vm_invoke(njs_vm_t *vm, njs_function_t *function, + const njs_value_t *args, nxt_uint_t nargs, njs_index_t retval); static nxt_int_t njs_vm_handle_events(njs_vm_t *vm); @@ -454,6 +456,14 @@ njs_vm_init(njs_vm_t *vm) nxt_int_t njs_vm_call(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, nxt_uint_t nargs) +{ + return njs_vm_invoke(vm, function, args, nargs, NJS_INDEX_GLOBAL_RETVAL); +} + + +static nxt_int_t +njs_vm_invoke(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, + nxt_uint_t nargs, njs_index_t retval) { u_char *current; njs_ret_t ret; @@ -465,12 +475,15 @@ njs_vm_call(njs_vm_t *vm, njs_function_t *function, const njs_value_t *args, vm->current = (u_char *) njs_continuation_nexus; - ret = njs_function_activate(vm, function, this, args, nargs, - NJS_INDEX_GLOBAL_RETVAL, + ret = njs_function_activate(vm, function, this, args, nargs, retval, sizeof(njs_vmcode_generic_t)); if (nxt_fast_path(ret == NJS_APPLIED)) { - ret = njs_vm_start(vm); + ret = njs_vmcode_interpreter(vm); + + if (ret == NJS_STOP) { + ret = NXT_OK; + } } vm->current = current; -- 2.47.3