[njs] Eliminating vm->main_index introduced in ea2ec4c3ed7d.
Dmitry Volyntsev
xeioex at nginx.com
Wed Feb 24 14:51:04 UTC 2021
details: https://hg.nginx.org/njs/rev/0efac7257447
branches:
changeset: 1611:0efac7257447
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Wed Feb 24 14:50:14 2021 +0000
description:
Eliminating vm->main_index introduced in ea2ec4c3ed7d.
The vm->main_index was only needed for the disassembler in the
accumulative mode. It was used to prevent from disassembling the code
from the previous iterations in the CLI.
The same result can be achieved without introducing the VM level field.
diffstat:
src/njs_disassembler.c | 12 ++++++++++--
src/njs_vm.c | 1 -
src/njs_vm.h | 2 --
3 files changed, 10 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r 1f22e9008cc3 -r 0efac7257447 src/njs_disassembler.c
--- a/src/njs_disassembler.c Wed Feb 24 14:48:20 2021 +0000
+++ b/src/njs_disassembler.c Wed Feb 24 14:50:14 2021 +0000
@@ -146,8 +146,16 @@ njs_disassembler(njs_vm_t *vm)
njs_vm_code_t *code;
code = vm->codes->start;
- code += vm->main_index;
- n = vm->codes->items - vm->main_index;
+ n = vm->codes->items;
+
+ while (n != 0) {
+ if (code->start == vm->start) {
+ break;
+ }
+
+ code++;
+ n--;
+ }
while (n != 0) {
njs_printf("%V:%V\n", &code->file, &code->name);
diff -r 1f22e9008cc3 -r 0efac7257447 src/njs_vm.c
--- a/src/njs_vm.c Wed Feb 24 14:48:20 2021 +0000
+++ b/src/njs_vm.c Wed Feb 24 14:50:14 2021 +0000
@@ -156,7 +156,6 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
return NJS_ERROR;
}
- vm->main_index = code - (njs_vm_code_t *) vm->codes->start;
vm->start = generator.code_start;
vm->global_scope = generator.local_scope;
vm->scope_size = generator.scope_size;
diff -r 1f22e9008cc3 -r 0efac7257447 src/njs_vm.h
--- a/src/njs_vm.h Wed Feb 24 14:48:20 2021 +0000
+++ b/src/njs_vm.h Wed Feb 24 14:50:14 2021 +0000
@@ -233,9 +233,7 @@ struct njs_vm_s {
njs_object_t string_object;
njs_object_t global_object;
- njs_uint_t main_index;
njs_arr_t *codes; /* of njs_vm_code_t */
-
njs_arr_t *functions_name_cache;
njs_trace_t trace;
More information about the nginx-devel
mailing list