Update the name handling of anonymous functions to ES11 (#4279)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
@@ -340,6 +340,19 @@ ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_is_value_symbol */
|
||||
|
||||
/**
|
||||
* Check if the value is a specific magic string.
|
||||
*
|
||||
* @return true - if the value the magic string value,
|
||||
* false - otherwise
|
||||
*/
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
lit_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
return value == ecma_make_magic_string_value (id);
|
||||
} /* ecma_is_value_magic_string */
|
||||
|
||||
/**
|
||||
* Check if the value is bigint.
|
||||
*
|
||||
|
||||
@@ -234,6 +234,7 @@ bool JERRY_ATTR_CONST ecma_is_value_float_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_magic_string (ecma_value_t value, lit_magic_string_id_t id);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_bigint (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_prop_name (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_direct_string (ecma_value_t value);
|
||||
|
||||
@@ -1787,19 +1787,16 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**<
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
ecma_value_t value = *ecma_compiled_code_resolve_function_name (bytecode_data_p);
|
||||
if (value != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
|
||||
/* Initialize 'name' property */
|
||||
ecma_property_t *value_prop_p;
|
||||
ecma_property_value_t *value_p = ecma_create_named_data_property (object_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&value_prop_p);
|
||||
value_p->value = ecma_copy_value (value);
|
||||
return value_prop_p;
|
||||
}
|
||||
/* Initialize 'name' property */
|
||||
ecma_property_t *value_prop_p;
|
||||
ecma_property_value_t *value_p = ecma_create_named_data_property (object_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&value_prop_p);
|
||||
value_p->value = ecma_copy_value (value);
|
||||
return value_prop_p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,6 +277,12 @@ void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
#define JMEM_CP_GET_NON_NULL_POINTER_FROM_POINTER_TAG(type, cp_value) \
|
||||
((type *) (jmem_decompress_pointer ((cp_value & ~JMEM_TAG_MASK) >> JMEM_TAG_SHIFT)))
|
||||
|
||||
/**
|
||||
* Extract tag bits from pointer-tag value
|
||||
*/
|
||||
#define JMEM_CP_GET_POINTER_TAG_BITS(cp_value) \
|
||||
(cp_value & (JMEM_FIRST_TAG_BIT_MASK | JMEM_SECOND_TAG_BIT_MASK | JMEM_THIRD_TAG_BIT_MASK))
|
||||
|
||||
/**
|
||||
* Get value of each tag from specified pointer-tag value
|
||||
*/
|
||||
|
||||
@@ -1358,7 +1358,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
|
||||
{
|
||||
*(--base_p) = ECMA_VALUE_EMPTY;
|
||||
*(--base_p) = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
|
||||
if (context_p->argument_length != UINT16_MAX)
|
||||
@@ -2625,9 +2625,10 @@ parser_check_anonymous_function_declaration (parser_context_t *context_p) /**< c
|
||||
|
||||
const ecma_compiled_code_t *bytecode_p;
|
||||
bytecode_p = (const ecma_compiled_code_t *) (PARSER_GET_LITERAL (literal_index)->u.bytecode_p);
|
||||
ecma_value_t *func_name_start_p = ecma_compiled_code_resolve_function_name (bytecode_p);
|
||||
bool is_anon = ecma_is_value_magic_string (*ecma_compiled_code_resolve_function_name (bytecode_p),
|
||||
LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
return (*func_name_start_p == ECMA_VALUE_EMPTY ? literal_index : PARSER_NAMED_FUNCTION);
|
||||
return (is_anon ? literal_index : PARSER_NAMED_FUNCTION);
|
||||
} /* parser_check_anonymous_function_declaration */
|
||||
|
||||
/**
|
||||
@@ -2659,7 +2660,7 @@ parser_compiled_code_set_function_name (parser_context_t *context_p, /**< contex
|
||||
ecma_value_t *func_name_start_p;
|
||||
func_name_start_p = ecma_compiled_code_resolve_function_name ((const ecma_compiled_code_t *) bytecode_p);
|
||||
|
||||
if (JERRY_UNLIKELY (*func_name_start_p != ECMA_VALUE_EMPTY))
|
||||
if (JERRY_UNLIKELY (!ecma_is_value_magic_string (*func_name_start_p, LIT_MAGIC_STRING__EMPTY)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,10 @@ opfunc_set_home_object (ecma_object_t *func_p, /**< function object */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_get_object_is_builtin (func_p));
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (((ecma_extended_object_t *) func_p)->u.function.scope_cp, parent_env_p, 0);
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) func_p;
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (ext_func_p->u.function.scope_cp,
|
||||
parent_env_p,
|
||||
JMEM_CP_GET_POINTER_TAG_BITS (ext_func_p->u.function.scope_cp));
|
||||
}
|
||||
} /* opfunc_set_home_object */
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ assertMethodName(func2, 'bar');
|
||||
|
||||
var func3 = (function () {}).prototype.constructor;
|
||||
assert(typeof func3 === 'function');
|
||||
assertNameNotExists(func3);
|
||||
assertMethodName(func3, '');
|
||||
|
||||
var func4;
|
||||
func4 = function () {}
|
||||
@@ -80,7 +80,7 @@ assertMethodName(func5, 'bar');
|
||||
|
||||
var func6;
|
||||
(func6) = function () {}
|
||||
assertNameNotExists(func6);
|
||||
assertMethodName(func6, '');
|
||||
|
||||
var func7;
|
||||
(func7) = function bar () {}
|
||||
@@ -290,7 +290,7 @@ let arFunc;
|
||||
let array = [];
|
||||
array['original'] = array;
|
||||
array['original'][arFunc = ()=>{ }]=function(){}
|
||||
assertNameNotExists(array[arFunc]);
|
||||
assertMethodName(array[arFunc], '');
|
||||
|
||||
var o = { 0 : class {} };
|
||||
|
||||
|
||||
@@ -333,4 +333,8 @@
|
||||
<test id="language/statements/class/strict-mode/arguments-caller.js"><reason>ES11: arguments object no longer has caller property</reason></test>
|
||||
<test id="built-ins/Proxy/create-handler-is-revoked-proxy.js"><reason>ES11+: ProxyCreate does not check Proxy handler and target.</reason></test>
|
||||
<test id="built-ins/Proxy/create-target-is-revoked-proxy.js"><reason>ES11+: ProxyCreate does not check Proxy handler and target.</reason></test>
|
||||
<test id="language/expressions/assignment/fn-name-lhs-cover.js"><reason>Outdated test, anonymous funtions should now have a name property</reason></test>
|
||||
<test id="language/expressions/assignment/fn-name-lhs-member.js"><reason>Outdated test, anonymous funtions should now have a name property</reason></test>
|
||||
<test id="language/expressions/function/name.js"><reason>Outdated test, anonymous funtions should now have a name property</reason></test>
|
||||
<test id="language/expressions/generators/name.js"><reason>Outdated test, anonymous funtions should now have a name property</reason></test>
|
||||
</excludeList>
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
<test id="built-ins/Promise/all/invoke-resolve-get-error.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Promise/all/resolve-non-callable.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Promise/race/invoke-resolve-get-error.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Promise/race/resolve-element-function-name.js"><reason></reason></test>
|
||||
<test id="built-ins/Promise/race/resolve-non-callable.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Proxy/preventExtensions/trap-is-undefined-target-is-proxy.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/setPrototypeOf/toboolean-trap-result-false.js"><reason></reason></test>
|
||||
@@ -217,7 +216,6 @@
|
||||
<test id="language/expressions/arrow-function/dstr/ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/arrow-function/dstr/dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/arrow-function/eval-var-scope-syntax-err.js"><reason></reason></test>
|
||||
<test id="language/expressions/arrow-function/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/arrow-function/param-dflt-yield-expr.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/S11.13.1_A5_T1.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/S11.13.1_A5_T2.js"><reason></reason></test>
|
||||
@@ -260,14 +258,9 @@
|
||||
<test id="language/expressions/assignment/dstr/array-rest-iter-thrw-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/dstr/array-rest-lref-err.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/dstr/array-rest-lref.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/fn-name-lhs-cover.js"><reason></reason></test>
|
||||
<test id="language/expressions/assignment/fn-name-lhs-member.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-arrow-function/await-as-param-nested-arrow-parameter-position.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-arrow-function/await-as-param-rest-nested-arrow-parameter-position.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-arrow-function/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-function/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/async-generator/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/call/eval-spread-empty-leading.js"><reason></reason></test>
|
||||
<test id="language/expressions/call/eval-spread-empty-trailing.js"><reason></reason></test>
|
||||
<test id="language/expressions/call/eval-spread.js"><reason></reason></test>
|
||||
@@ -302,11 +295,9 @@
|
||||
<test id="language/expressions/function/dstr/ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/function/dstr/dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/function/eval-var-scope-syntax-err.js"><reason></reason></test>
|
||||
<test id="language/expressions/function/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/generators/dstr/ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/generators/dstr/dflt-ary-init-iter-no-close.js"><reason></reason></test>
|
||||
<test id="language/expressions/generators/eval-var-scope-syntax-err.js"><reason></reason></test>
|
||||
<test id="language/expressions/generators/name.js"><reason></reason></test>
|
||||
<test id="language/expressions/import.meta/distinct-for-each-module.js"><reason></reason></test>
|
||||
<test id="language/expressions/import.meta/import-meta-is-an-ordinary-object.js"><reason></reason></test>
|
||||
<test id="language/expressions/import.meta/same-object-returned.js"><reason></reason></test>
|
||||
|
||||
Reference in New Issue
Block a user