[njs] Introduced njs_vm_invoke().

Dmitry Volyntsev xeioex at nginx.com
Sun Feb 3 09:40:49 UTC 2019


details:   https://hg.nginx.org/njs/rev/d57755edf40b
branches:  
changeset: 753:d57755edf40b
user:      hongzhidao <hongzhidao at gmail.com>
date:      Sat Feb 02 16:01:39 2019 +0800
description:
Introduced njs_vm_invoke().

diffstat:

 njs/njs.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 596d26bb5fea -r d57755edf40b njs/njs.c
--- a/njs/njs.c	Sat Feb 02 14:21:26 2019 +0800
+++ b/njs/njs.c	Sat Feb 02 16:01:39 2019 +0800
@@ -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);
 
 
@@ -455,6 +457,14 @@ 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;
     njs_value_t  *this;
@@ -465,12 +475,15 @@ njs_vm_call(njs_vm_t *vm, njs_function_t
 
     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;


More information about the nginx-devel mailing list