Dmitry Volyntsev
April 05, 2023 01:52AM
details: https://hg.nginx.org/njs/rev/b2cacf654542
branches:
changeset: 2079:b2cacf654542
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Apr 04 22:17:26 2023 -0700
description:
VM: removed vm->global_items.

diffstat:

src/njs_vm.c | 15 ++++++++-------
src/njs_vm.h | 1 -
2 files changed, 8 insertions(+), 8 deletions(-)

diffs (71 lines):

diff -r 8dcea0ba0bf8 -r b2cacf654542 src/njs_vm.c
--- a/src/njs_vm.c Wed Mar 29 20:28:33 2023 -0700
+++ b/src/njs_vm.c Tue Apr 04 22:17:26 2023 -0700
@@ -145,6 +145,7 @@ njs_vm_destroy(njs_vm_t *vm)
njs_int_t
njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end)
{
+ size_t global_items;
njs_int_t ret;
njs_str_t ast;
njs_chb_t chain;
@@ -156,6 +157,8 @@ njs_vm_compile(njs_vm_t *vm, u_char **st

vm->codes = NULL;

+ global_items = (vm->global_scope != NULL) ? vm->global_scope->items : 0;
+
ret = njs_parser_init(vm, &parser, vm->global_scope, &vm->options.file,
*start, end, 0);
if (njs_slow_path(ret != NJS_OK)) {
@@ -202,9 +205,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
return NJS_ERROR;
}

- vm->global_scope = scope;
-
- if (scope->items > vm->global_items) {
+ if (scope->items > global_items) {
global = vm->levels[NJS_LEVEL_GLOBAL];

new = njs_scope_make(vm, scope->items);
@@ -215,8 +216,8 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
vm->levels[NJS_LEVEL_GLOBAL] = new;

if (global != NULL) {
- while (vm->global_items != 0) {
- vm->global_items--;
+ while (global_items != 0) {
+ global_items--;

*new++ = *global++;
}
@@ -228,7 +229,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st

vm->start = generator.code_start;
vm->variables_hash = &scope->variables;
- vm->global_items = scope->items;
+ vm->global_scope = scope;

if (vm->options.disassemble) {
njs_disassembler(vm);
@@ -351,7 +352,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_
goto fail;
}

- global = njs_scope_make(nvm, nvm->global_items);
+ global = njs_scope_make(nvm, nvm->global_scope->items);
if (njs_slow_path(global == NULL)) {
goto fail;
}
diff -r 8dcea0ba0bf8 -r b2cacf654542 src/njs_vm.h
--- a/src/njs_vm.h Wed Mar 29 20:28:33 2023 -0700
+++ b/src/njs_vm.h Tue Apr 04 22:17:26 2023 -0700
@@ -126,7 +126,6 @@ struct njs_vm_s {

njs_arr_t *scope_absolute;
njs_value_t **levels[NJS_LEVEL_MAX];
- size_t global_items;

njs_external_ptr_t external;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] VM: removed vm->global_items.

Dmitry Volyntsev 504 April 05, 2023 01:52AM



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

Online Users

Guests: 129
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready