Skip to content

Instantly share code, notes, and snippets.

@xeioex
Created February 3, 2019 08:31
Show Gist options
  • Save xeioex/d266dfa24611ece3ab35e5b88881cfa8 to your computer and use it in GitHub Desktop.
Save xeioex/d266dfa24611ece3ab35e5b88881cfa8 to your computer and use it in GitHub Desktop.
# HG changeset patch
# User hongzhidao <[email protected]>
# Date 1549094499 -28800
# Sat Feb 02 16:01:39 2019 +0800
# Node ID d57755edf40bbbc2d3cc10c6d7841b8a8dc34a44
# Parent 596d26bb5feabb5c7be1ca84f889eb4b185a02bf
Introduced njs_vm_invoke().
diff --git a/njs/njs.c b/njs/njs.c
--- 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);
@@ -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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment