From: Dmitry Volyntsev Date: Thu, 13 Apr 2023 01:26:42 +0000 (-0700) Subject: VM: simplified NJS_VMCODE_TEMPLATE_LITERAL instruction. X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=c89eb033d5b5ab62c9f84a421b7b8e92264a4101;p=njs.git VM: simplified NJS_VMCODE_TEMPLATE_LITERAL instruction. --- diff --git a/src/njs_vmcode.c b/src/njs_vmcode.c index a6b00d8b..c6f7b345 100644 --- a/src/njs_vmcode.c +++ b/src/njs_vmcode.c @@ -19,7 +19,7 @@ static njs_jump_off_t njs_vmcode_function(njs_vm_t *vm, u_char *pc); static njs_jump_off_t njs_vmcode_arguments(njs_vm_t *vm, u_char *pc); static njs_jump_off_t njs_vmcode_regexp(njs_vm_t *vm, u_char *pc); static njs_jump_off_t njs_vmcode_template_literal(njs_vm_t *vm, - njs_value_t *inlvd1, njs_value_t *inlvd2); + njs_value_t *retval); static njs_jump_off_t njs_vmcode_function_copy(njs_vm_t *vm, njs_value_t *value, njs_index_t retval); @@ -874,18 +874,14 @@ NEXT_LBL; CASE (NJS_VMCODE_TEMPLATE_LITERAL): njs_vmcode_debug_opcode(); - value2 = (njs_value_t *) vmcode->operand1; + njs_vmcode_operand(vm, vmcode->operand1, retval); - ret = njs_vmcode_template_literal(vm, NULL, value2); + ret = njs_vmcode_template_literal(vm, retval); if (njs_slow_path(ret < 0 && ret >= NJS_PREEMPT)) { goto error; } - njs_vmcode_operand(vm, vmcode->operand1, retval); - njs_release(vm, retval); - *retval = vm->retval; - BREAK; CASE (NJS_VMCODE_PROPERTY_IN): @@ -1987,11 +1983,9 @@ njs_vmcode_regexp(njs_vm_t *vm, u_char *pc) static njs_jump_off_t -njs_vmcode_template_literal(njs_vm_t *vm, njs_value_t *invld1, - njs_value_t *retval) +njs_vmcode_template_literal(njs_vm_t *vm, njs_value_t *retval) { njs_array_t *array; - njs_value_t *value; njs_jump_off_t ret; static const njs_function_t concat = { @@ -1999,22 +1993,14 @@ njs_vmcode_template_literal(njs_vm_t *vm, njs_value_t *invld1, .u.native = njs_string_prototype_concat }; - value = njs_scope_valid_value(vm, (njs_index_t) retval); - - if (!njs_is_primitive(value)) { - array = njs_array(value); + njs_assert(njs_is_array(retval)); - ret = njs_function_frame(vm, (njs_function_t *) &concat, - &njs_string_empty, array->start, - array->length, 0); - if (njs_slow_path(ret != NJS_OK)) { - return ret; - } + array = njs_array(retval); - ret = njs_function_frame_invoke(vm, value); - if (njs_slow_path(ret != NJS_OK)) { - return ret; - } + ret = njs_function_call(vm, (njs_function_t *) &concat, &njs_string_empty, + array->start, array->length, retval); + if (njs_slow_path(ret != NJS_OK)) { + return ret; } return sizeof(njs_vmcode_template_literal_t);