Optimize lexenv binding creation (#4502)

- Declarative environment no longer need to lookup the created binding for setting it's value
- Unfold vm_decl_var and vm_set_var into vm_loop to reduce error checks
- Reduce code duplication in ecma_module_connect_imports
- Fix deleted binding setting in `ecma_op_set_mutable_binding` (fixes #4468)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2021-01-18 17:38:54 +01:00
committed by GitHub
parent 3b77117a2e
commit 2ade072e53
8 changed files with 104 additions and 119 deletions
+33 -4
View File
@@ -1395,23 +1395,52 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
}
#endif /* ENABLED (JERRY_ESNEXT) && !JERRY_NDEBUG */
result = vm_var_decl (lex_env_p, name_p, (frame_ctx_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL) != 0);
/* 'Variable declaration' */
result = ecma_op_has_binding (lex_env_p, name_p);
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_IS_VALUE_ERROR (result))
{
goto error;
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
if (lit_value != ECMA_VALUE_UNDEFINED)
ecma_property_t *prop_p = NULL;
if (ecma_is_value_false (result))
{
result = vm_set_var (lex_env_p, name_p, is_strict, lit_value);
bool is_configurable = (frame_ctx_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL) != 0;
prop_p = ecma_op_create_mutable_binding (lex_env_p, name_p, is_configurable);
if (ECMA_IS_VALUE_ERROR (result))
if (JERRY_UNLIKELY (prop_p == ECMA_PROPERTY_POINTER_ERROR))
{
result = ECMA_VALUE_ERROR;
goto error;
}
}
if (lit_value != ECMA_VALUE_UNDEFINED)
{
JERRY_ASSERT (ecma_is_value_object (lit_value));
if (prop_p != NULL)
{
JERRY_ASSERT (ecma_is_value_undefined (ECMA_PROPERTY_VALUE_PTR (prop_p)->value));
JERRY_ASSERT (ecma_is_property_writable (*prop_p));
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = lit_value;
ecma_free_object (lit_value);
}
else
{
result = ecma_op_put_value_lex_env_base (lex_env_p, name_p, is_strict, lit_value);
ecma_free_object (lit_value);
if (ECMA_IS_VALUE_ERROR (result))
{
goto error;
}
}
}
continue;
}
#if ENABLED (JERRY_ESNEXT)