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:
@@ -40,78 +40,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'Variable declaration' opcode handler.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.5 - Declaration binding instantiation (block 8).
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if no the operation fails
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
vm_var_decl (ecma_object_t *lex_env_p, /**< target lexical environment */
|
||||
ecma_string_t *var_name_str_p, /**< variable name */
|
||||
bool is_configurable_bindings) /**< true if the binding can be deleted */
|
||||
{
|
||||
ecma_value_t has_binding = ecma_op_has_binding (lex_env_p, var_name_str_p);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_IS_VALUE_ERROR (has_binding))
|
||||
{
|
||||
return has_binding;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
if (ecma_is_value_false (has_binding))
|
||||
{
|
||||
ecma_value_t completion_value = ecma_op_create_mutable_binding (lex_env_p,
|
||||
var_name_str_p,
|
||||
is_configurable_bindings);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_IS_VALUE_ERROR (completion_value))
|
||||
{
|
||||
return completion_value;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_empty (completion_value));
|
||||
|
||||
/* Skipping SetMutableBinding as we have already checked that there were not
|
||||
* any binding with specified name in current lexical environment
|
||||
* and CreateMutableBinding sets the created binding's value to undefined */
|
||||
JERRY_ASSERT (ecma_is_value_undefined (ecma_op_get_binding_value (lex_env_p,
|
||||
var_name_str_p,
|
||||
vm_is_strict_mode ())));
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* vm_var_decl */
|
||||
|
||||
/**
|
||||
* Set var binding to a function literal value.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if no the operation fails
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
vm_set_var (ecma_object_t *lex_env_p, /**< target lexical environment */
|
||||
ecma_string_t *var_name_str_p, /**< variable name */
|
||||
bool is_strict, /**< true, if the engine is in strict mode */
|
||||
ecma_value_t lit_value) /**< function value */
|
||||
{
|
||||
ecma_value_t put_value_result;
|
||||
put_value_result = ecma_op_put_value_lex_env_base (lex_env_p, var_name_str_p, is_strict, lit_value);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (put_value_result)
|
||||
|| ecma_is_value_empty (put_value_result)
|
||||
|| ECMA_IS_VALUE_ERROR (put_value_result));
|
||||
|
||||
ecma_free_value (lit_value);
|
||||
|
||||
return put_value_result;
|
||||
} /* vm_set_var */
|
||||
|
||||
/**
|
||||
* 'typeof' opcode handler.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user