Rework built-in processing of JerryScript (#4347)
- All built-ins are native functions now - Native handlers have a built-in id: ECMA_BUILTIN_ID_HANDLER - Built-in routine identifiers start from 1 - Built-in routines have an own flag set - Name property of routines is resolved dynamically - Style fixes JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -44,7 +44,7 @@ typedef const ecma_builtin_property_descriptor_t *ecma_builtin_property_list_ref
|
||||
/**
|
||||
* Definition of built-in dispatch routine function pointer.
|
||||
*/
|
||||
typedef ecma_value_t (*ecma_builtin_dispatch_routine_t) (uint16_t builtin_routine_id,
|
||||
typedef ecma_value_t (*ecma_builtin_dispatch_routine_t) (uint8_t builtin_routine_id,
|
||||
ecma_value_t this_arg,
|
||||
const ecma_value_t arguments_list[],
|
||||
uint32_t arguments_number);
|
||||
@@ -329,11 +329,11 @@ ecma_builtin_get_global (void)
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_builtin_function_is_routine (ecma_object_t *func_obj_p) /**< function object */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (func_obj_p));
|
||||
|
||||
ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) func_obj_p;
|
||||
return (ext_func_obj_p->u.built_in.routine_id >= ECMA_BUILTIN_ID__COUNT);
|
||||
return (ext_func_obj_p->u.built_in.routine_id != 0);
|
||||
} /* ecma_builtin_function_is_routine */
|
||||
|
||||
/**
|
||||
@@ -376,13 +376,13 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */
|
||||
|
||||
size_t property_count = ecma_builtin_get_property_count (obj_builtin_id);
|
||||
|
||||
if (property_count > 32)
|
||||
if (property_count > ECMA_BUILTIN_INSTANTIATED_BITSET_MIN_SIZE)
|
||||
{
|
||||
/* Only 64 extra properties supported at the moment.
|
||||
* This can be extended to 256 later. */
|
||||
JERRY_ASSERT (property_count <= (32 + 64));
|
||||
JERRY_ASSERT (property_count <= (ECMA_BUILTIN_INSTANTIATED_BITSET_MIN_SIZE + 64));
|
||||
|
||||
ext_object_size += sizeof (uint32_t) * 2;
|
||||
ext_object_size += sizeof (uint64_t);
|
||||
}
|
||||
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p, ext_object_size, obj_type);
|
||||
@@ -415,21 +415,19 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */
|
||||
}
|
||||
|
||||
built_in_props_p->id = (uint8_t) obj_builtin_id;
|
||||
built_in_props_p->routine_id = (uint16_t) obj_builtin_id;
|
||||
built_in_props_p->u.instantiated_bitset[0] = 0;
|
||||
built_in_props_p->routine_id = 0;
|
||||
built_in_props_p->u.length_and_bitset_size = 0;
|
||||
built_in_props_p->u2.instantiated_bitset[0] = 0;
|
||||
built_in_props_p->continue_instantiated_bitset[0] = 0;
|
||||
|
||||
if (property_count > 32)
|
||||
if (property_count > 40)
|
||||
{
|
||||
built_in_props_p->length_and_bitset_size = 1 << ECMA_BUILT_IN_BITSET_SHIFT;
|
||||
built_in_props_p->u.length_and_bitset_size = 1 << ECMA_BUILT_IN_BITSET_SHIFT;
|
||||
|
||||
uint32_t *instantiated_bitset_p = built_in_props_p->u.instantiated_bitset;
|
||||
uint32_t *instantiated_bitset_p = built_in_props_p->continue_instantiated_bitset;
|
||||
instantiated_bitset_p[1] = 0;
|
||||
instantiated_bitset_p[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
built_in_props_p->length_and_bitset_size = 0;
|
||||
}
|
||||
|
||||
/** Initializing [[PrimitiveValue]] properties of built-in prototype objects */
|
||||
switch (obj_builtin_id)
|
||||
@@ -569,33 +567,29 @@ ecma_finalize_builtins (void)
|
||||
*/
|
||||
static ecma_object_t *
|
||||
ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**< identifier of built-in object */
|
||||
uint16_t routine_id, /**< builtin-wide identifier of the built-in
|
||||
* object's routine property */
|
||||
uint16_t name_id, /**< magic string id of 'name' property */
|
||||
uint16_t flags, /**< see also: ecma_builtin_routine_flags */
|
||||
uint8_t length_prop_value) /**< value of 'length' property */
|
||||
uint8_t routine_id, /**< builtin-wide identifier of the built-in
|
||||
* object's routine property */
|
||||
uint32_t routine_index, /**< property descriptor index of routine */
|
||||
uint8_t flags) /**< see also: ecma_builtin_routine_flags */
|
||||
{
|
||||
JERRY_ASSERT (length_prop_value < (1 << ECMA_BUILT_IN_BITSET_SHIFT));
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
|
||||
size_t ext_object_size = sizeof (ecma_extended_object_t);
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_create_object (prototype_obj_p,
|
||||
ext_object_size,
|
||||
ECMA_OBJECT_TYPE_FUNCTION);
|
||||
ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
|
||||
ecma_set_object_is_builtin (func_obj_p);
|
||||
|
||||
JERRY_ASSERT (routine_id >= ECMA_BUILTIN_ID__COUNT);
|
||||
JERRY_ASSERT (routine_id > 0);
|
||||
JERRY_ASSERT (routine_index <= UINT8_MAX);
|
||||
|
||||
ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) func_obj_p;
|
||||
ext_func_obj_p->u.built_in.id = (uint8_t) builtin_id;
|
||||
ext_func_obj_p->u.built_in.routine_id = routine_id;
|
||||
ext_func_obj_p->u.built_in.u.builtin_routine.name = name_id;
|
||||
ext_func_obj_p->u.built_in.u.builtin_routine.bitset = flags;
|
||||
|
||||
ext_func_obj_p->u.built_in.length_and_bitset_size = length_prop_value;
|
||||
ext_func_obj_p->u.built_in.u.routine_index = (uint8_t) routine_index;
|
||||
ext_func_obj_p->u.built_in.u2.routine_flags = flags;
|
||||
|
||||
return func_obj_p;
|
||||
} /* ecma_builtin_make_function_object_for_routine */
|
||||
@@ -607,15 +601,15 @@ ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**
|
||||
*/
|
||||
static ecma_object_t *
|
||||
ecma_builtin_make_function_object_for_getter_accessor (ecma_builtin_id_t builtin_id, /**< id of built-in object */
|
||||
uint16_t routine_id, /**< builtin-wide id of the built-in
|
||||
uint8_t routine_id, /**< builtin-wide id of the built-in
|
||||
* object's routine property */
|
||||
uint16_t name_id) /**< magic string id of 'name' property */
|
||||
uint32_t routine_index) /**< property descriptor index
|
||||
* of routine */
|
||||
{
|
||||
return ecma_builtin_make_function_object_for_routine (builtin_id,
|
||||
routine_id,
|
||||
name_id,
|
||||
ECMA_BUILTIN_ROUTINE_GETTER,
|
||||
0);
|
||||
routine_index,
|
||||
ECMA_BUILTIN_ROUTINE_GETTER);
|
||||
} /* ecma_builtin_make_function_object_for_getter_accessor */
|
||||
|
||||
/**
|
||||
@@ -625,17 +619,70 @@ ecma_builtin_make_function_object_for_getter_accessor (ecma_builtin_id_t builtin
|
||||
*/
|
||||
static ecma_object_t *
|
||||
ecma_builtin_make_function_object_for_setter_accessor (ecma_builtin_id_t builtin_id, /**< id of built-in object */
|
||||
uint16_t routine_id, /**< builtin-wide id of the built-in
|
||||
uint8_t routine_id, /**< builtin-wide id of the built-in
|
||||
* object's routine property */
|
||||
uint16_t name_id) /**< magic string id of 'name' property */
|
||||
uint32_t routine_index) /**< property descriptor index
|
||||
* of routine */
|
||||
{
|
||||
return ecma_builtin_make_function_object_for_routine (builtin_id,
|
||||
routine_id,
|
||||
name_id,
|
||||
ECMA_BUILTIN_ROUTINE_SETTER,
|
||||
1);
|
||||
routine_index,
|
||||
ECMA_BUILTIN_ROUTINE_SETTER);
|
||||
} /* ecma_builtin_make_function_object_for_setter_accessor */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Create specification defined properties for built-in native handlers.
|
||||
*
|
||||
* @return pointer property, if one was instantiated,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
static ecma_property_t *
|
||||
ecma_builtin_native_handler_try_to_instantiate_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *property_name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION
|
||||
&& ecma_get_object_is_builtin (object_p));
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_property_t *prop_p = NULL;
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_NAME))
|
||||
{
|
||||
if ((ext_obj_p->u.built_in.u2.routine_flags & ECMA_NATIVE_HANDLER_FLAGS_NAME_INITIALIZED) == 0)
|
||||
{
|
||||
ecma_property_value_t *value_p = ecma_create_named_data_property (object_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&prop_p);
|
||||
|
||||
value_p->value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
ext_obj_p->u.built_in.u2.routine_flags |= ECMA_NATIVE_HANDLER_FLAGS_NAME_INITIALIZED;
|
||||
}
|
||||
}
|
||||
else if (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_LENGTH))
|
||||
{
|
||||
if ((ext_obj_p->u.built_in.u2.routine_flags & ECMA_NATIVE_HANDLER_FLAGS_LENGTH_INITIALIZED) == 0)
|
||||
{
|
||||
ecma_property_value_t *value_p = ecma_create_named_data_property (object_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&prop_p);
|
||||
|
||||
const uint8_t length = ecma_builtin_handler_get_length (ext_obj_p->u.built_in.routine_id);
|
||||
value_p->value = ecma_make_integer_value (length);
|
||||
|
||||
ext_obj_p->u.built_in.u2.routine_flags |= ECMA_NATIVE_HANDLER_FLAGS_LENGTH_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
return prop_p;
|
||||
} /* ecma_builtin_native_handler_try_to_instantiate_property */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Lazy instantiation of builtin routine property of builtin object
|
||||
*
|
||||
@@ -650,24 +697,34 @@ ecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, /**<
|
||||
ecma_string_t *string_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (object_p));
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_builtin_function_is_routine (object_p));
|
||||
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (ext_func_p->u.built_in.id == ECMA_BUILTIN_ID_HANDLER))
|
||||
{
|
||||
return ecma_builtin_native_handler_try_to_instantiate_property (object_p, string_p);
|
||||
}
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (ecma_string_is_length (string_p))
|
||||
{
|
||||
/*
|
||||
* Lazy instantiation of 'length' property
|
||||
*/
|
||||
|
||||
ecma_property_t *len_prop_p;
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint16_t *bitset_p = &ext_func_p->u.built_in.u.builtin_routine.bitset;
|
||||
uint8_t *bitset_p = &ext_func_p->u.built_in.u2.routine_flags;
|
||||
|
||||
if (*bitset_p & ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED)
|
||||
{
|
||||
/* length property was already instantiated */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We mark that the property was lazily instantiated,
|
||||
* as it is configurable and so can be deleted (ECMA-262 v6, 19.2.4.1) */
|
||||
*bitset_p |= ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED;
|
||||
@@ -684,11 +741,25 @@ ecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, /**<
|
||||
&len_prop_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
uint8_t length = ext_func_p->u.built_in.length_and_bitset_size;
|
||||
JERRY_ASSERT (length < (1 << ECMA_BUILT_IN_BITSET_SHIFT));
|
||||
uint8_t length = 0;
|
||||
|
||||
if (ext_func_p->u.built_in.u2.routine_flags & ECMA_BUILTIN_ROUTINE_SETTER)
|
||||
{
|
||||
length = 1;
|
||||
}
|
||||
else if (!(ext_func_p->u.built_in.u2.routine_flags & ECMA_BUILTIN_ROUTINE_GETTER))
|
||||
{
|
||||
uint8_t routine_index = ext_func_p->u.built_in.u.routine_index;
|
||||
const ecma_builtin_property_descriptor_t *property_list_p;
|
||||
|
||||
property_list_p = ecma_builtin_property_list_references[ext_func_p->u.built_in.id];
|
||||
|
||||
JERRY_ASSERT (property_list_p[routine_index].type == ECMA_BUILTIN_PROPERTY_ROUTINE);
|
||||
|
||||
length = ECMA_GET_ROUTINE_LENGTH (property_list_p[routine_index].value);
|
||||
}
|
||||
|
||||
len_prop_value_p->value = ecma_make_integer_value (length);
|
||||
|
||||
return len_prop_p;
|
||||
}
|
||||
|
||||
@@ -698,8 +769,7 @@ ecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, /**<
|
||||
*/
|
||||
if (ecma_compare_ecma_string_to_magic_id (string_p, LIT_MAGIC_STRING_NAME))
|
||||
{
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
uint16_t *bitset_p = &ext_func_p->u.built_in.u.builtin_routine.bitset;
|
||||
uint8_t *bitset_p = &ext_func_p->u.built_in.u2.routine_flags;
|
||||
|
||||
if (*bitset_p & ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED)
|
||||
{
|
||||
@@ -715,8 +785,17 @@ ecma_builtin_routine_try_to_instantiate_property (ecma_object_t *object_p, /**<
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&name_prop_p);
|
||||
|
||||
uint8_t routine_index = ext_func_p->u.built_in.u.routine_index;
|
||||
const ecma_builtin_property_descriptor_t *property_list_p;
|
||||
|
||||
property_list_p = ecma_builtin_property_list_references[ext_func_p->u.built_in.id];
|
||||
|
||||
JERRY_ASSERT (property_list_p[routine_index].type == ECMA_BUILTIN_PROPERTY_ROUTINE
|
||||
|| property_list_p[routine_index].type == ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_WRITE
|
||||
|| property_list_p[routine_index].type == ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_ONLY);
|
||||
|
||||
lit_magic_string_id_t name_id = property_list_p[routine_index].magic_string_id;
|
||||
ecma_string_t *name_p;
|
||||
lit_magic_string_id_t name_id = ext_func_p->u.built_in.u.builtin_routine.name;
|
||||
|
||||
if (JERRY_UNLIKELY (name_id > LIT_NON_INTERNAL_MAGIC_STRING__COUNT))
|
||||
{
|
||||
@@ -828,10 +907,8 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
}
|
||||
|
||||
uint32_t index = (uint32_t) (curr_property_p - property_list_p);
|
||||
|
||||
uint32_t *bitset_p = built_in_props_p->u.instantiated_bitset + (index >> 5);
|
||||
|
||||
uint32_t bit_for_index = (uint32_t) (1u << (index & 0x1f));
|
||||
uint8_t *bitset_p = built_in_props_p->u2.instantiated_bitset + (index >> 3);
|
||||
uint8_t bit_for_index = (uint8_t) (1u << (index & 0x7));
|
||||
|
||||
if (*bitset_p & bit_for_index)
|
||||
{
|
||||
@@ -969,23 +1046,18 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
ecma_object_t *func_obj_p;
|
||||
func_obj_p = ecma_builtin_make_function_object_for_routine (builtin_id,
|
||||
ECMA_GET_ROUTINE_ID (curr_property_p->value),
|
||||
curr_property_p->magic_string_id,
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS,
|
||||
ECMA_GET_ROUTINE_LENGTH (curr_property_p->value));
|
||||
index,
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS);
|
||||
value = ecma_make_object_value (func_obj_p);
|
||||
break;
|
||||
}
|
||||
case ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_WRITE:
|
||||
{
|
||||
is_accessor = true;
|
||||
uint16_t getter_id = ECMA_ACCESSOR_READ_WRITE_GET_GETTER_ID (curr_property_p->value);
|
||||
uint16_t setter_id = ECMA_ACCESSOR_READ_WRITE_GET_SETTER_ID (curr_property_p->value);
|
||||
getter_p = ecma_builtin_make_function_object_for_getter_accessor (builtin_id,
|
||||
getter_id,
|
||||
curr_property_p->magic_string_id);
|
||||
setter_p = ecma_builtin_make_function_object_for_setter_accessor (builtin_id,
|
||||
setter_id,
|
||||
curr_property_p->magic_string_id);
|
||||
uint8_t getter_id = ECMA_ACCESSOR_READ_WRITE_GET_GETTER_ID (curr_property_p->value);
|
||||
uint8_t setter_id = ECMA_ACCESSOR_READ_WRITE_GET_SETTER_ID (curr_property_p->value);
|
||||
getter_p = ecma_builtin_make_function_object_for_getter_accessor (builtin_id, getter_id, index);
|
||||
setter_p = ecma_builtin_make_function_object_for_setter_accessor (builtin_id, setter_id, index);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -993,9 +1065,8 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
JERRY_ASSERT (curr_property_p->type == ECMA_BUILTIN_PROPERTY_ACCESSOR_READ_ONLY);
|
||||
|
||||
is_accessor = true;
|
||||
getter_p = ecma_builtin_make_function_object_for_getter_accessor (builtin_id,
|
||||
curr_property_p->value,
|
||||
curr_property_p->magic_string_id);
|
||||
uint8_t getter_id = (uint8_t) curr_property_p->value;
|
||||
getter_p = ecma_builtin_make_function_object_for_getter_accessor (builtin_id, getter_id, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1035,6 +1106,36 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
return prop_p;
|
||||
} /* ecma_builtin_try_to_instantiate_property */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* List names of an Built-in native handler object's lazy instantiated properties,
|
||||
* adding them to corresponding string collections
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_native_handler_list_lazy_property_names (ecma_object_t *object_p, /**< function object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION
|
||||
&& ecma_get_object_is_builtin (object_p));
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
if ((ext_obj_p->u.built_in.u2.routine_flags & ECMA_NATIVE_HANDLER_FLAGS_NAME_INITIALIZED) == 0)
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_NAME));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
|
||||
if ((ext_obj_p->u.built_in.u2.routine_flags & ECMA_NATIVE_HANDLER_FLAGS_LENGTH_INITIALIZED) == 0)
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
} /* ecma_builtin_native_handler_list_lazy_property_names */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* List names of a built-in function's lazy instantiated properties
|
||||
*
|
||||
@@ -1047,18 +1148,25 @@ ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p, /**< a b
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (object_p));
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_builtin_function_is_routine (object_p));
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
if (!(ext_func_p->u.built_in.u.builtin_routine.bitset & ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED))
|
||||
|
||||
if (JERRY_UNLIKELY (ext_func_p->u.built_in.id == ECMA_BUILTIN_ID_HANDLER))
|
||||
{
|
||||
ecma_builtin_native_handler_list_lazy_property_names (object_p, prop_names_p, prop_counter_p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(ext_func_p->u.built_in.u2.routine_flags & ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED))
|
||||
{
|
||||
/* Unintialized 'length' property is non-enumerable (ECMA-262 v6, 19.2.4.1) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
if (!(ext_func_p->u.built_in.u.builtin_routine.bitset & ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED))
|
||||
if (!(ext_func_p->u.built_in.u2.routine_flags & ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED))
|
||||
{
|
||||
/* Unintialized 'name' property is non-enumerable (ECMA-262 v6, 19.2.4.2) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_NAME));
|
||||
@@ -1106,11 +1214,11 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
|
||||
const ecma_builtin_property_descriptor_t *curr_property_p = ecma_builtin_property_list_references[builtin_id];
|
||||
|
||||
uint32_t index = 0;
|
||||
uint32_t *bitset_p = built_in_props_p->u.instantiated_bitset;
|
||||
uint8_t *bitset_p = built_in_props_p->u2.instantiated_bitset;
|
||||
|
||||
while (curr_property_p->magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
if (index == 32)
|
||||
if (index == 8)
|
||||
{
|
||||
bitset_p++;
|
||||
index = 0;
|
||||
@@ -1211,13 +1319,21 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< arguments list length */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (obj_p));
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ecma_builtin_function_is_routine (obj_p))
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (ext_obj_p->u.built_in.id == ECMA_BUILTIN_ID_HANDLER))
|
||||
{
|
||||
ecma_native_handler_t handler = ecma_builtin_handler_get (ext_obj_p->u.built_in.routine_id);
|
||||
return handler (ecma_make_object_value (obj_p), this_arg_value, arguments_list_p, arguments_list_len);
|
||||
}
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return ecma_builtin_dispatch_routine (ext_obj_p,
|
||||
this_arg_value,
|
||||
arguments_list_p,
|
||||
@@ -1240,7 +1356,7 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< arguments list length */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (obj_p));
|
||||
|
||||
if (ecma_builtin_function_is_routine (obj_p))
|
||||
|
||||
Reference in New Issue
Block a user