Optimize ecma_builtin_helper_def_prop. (#3007)

This patch removes the ecma_property_descriptor_t structure bitfields and substitutes it with an uint16_t flag field
to reduce the cost of the transformation from/into the ecma_property_flags_t.
Also the is_throw last arguments is embedded to the property descriptor structure during the property defining process to reduce the number of arguments of the function.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-08-27 18:28:03 +02:00
committed by Dániel Bátyai
parent d0435e1db0
commit ee1da14577
23 changed files with 291 additions and 354 deletions
+25 -20
View File
@@ -119,8 +119,7 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of
ecma_builtin_helper_def_prop (object_p,
item_name_string_p,
array_items_p[index],
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
false); /* Failure handling */
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
ecma_deref_ecma_string (item_name_string_p);
}
@@ -275,42 +274,44 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
ecma_value_t
ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the array object */
ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property descriptor */
bool is_throw) /**< flag that controls failure handling */
const ecma_property_descriptor_t *property_desc_p) /**< property descriptor */
{
if (ecma_string_is_length (property_name_p))
{
JERRY_ASSERT (property_desc_p->is_configurable_defined || !property_desc_p->is_configurable);
JERRY_ASSERT (property_desc_p->is_enumerable_defined || !property_desc_p->is_enumerable);
JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable);
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
uint32_t flags = 0;
if (is_throw)
if (property_desc_p->flags & ECMA_PROP_IS_THROW)
{
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW;
}
/* Only the writable and data properties can be modified. */
if (property_desc_p->is_configurable
|| property_desc_p->is_enumerable
|| property_desc_p->is_get_defined
|| property_desc_p->is_set_defined)
if (property_desc_p->flags & (ECMA_PROP_IS_CONFIGURABLE
| ECMA_PROP_IS_ENUMERABLE
| ECMA_PROP_IS_GET_DEFINED
| ECMA_PROP_IS_SET_DEFINED))
{
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT;
}
if (property_desc_p->is_writable_defined)
if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
{
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED;
}
if (property_desc_p->is_writable)
if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
{
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE;
}
if (property_desc_p->is_value_defined)
if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{
return ecma_op_array_object_set_length (object_p, property_desc_p->value, flags);
}
@@ -328,7 +329,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
if (index == ECMA_STRING_NOT_ARRAY_INDEX)
{
return ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p, is_throw);
return ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p);
}
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -337,18 +338,22 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
if (update_length && !ecma_is_property_writable (ext_object_p->u.array.length_prop))
{
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
ecma_property_descriptor_t prop_desc;
prop_desc = *property_desc_p;
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_THROW;
ecma_value_t completition = ecma_op_general_object_define_own_property (object_p,
property_name_p,
property_desc_p,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_boolean (completition));
if (ecma_is_value_false (completition))
{
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
if (update_length)
@@ -54,7 +54,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value
ecma_value_t
ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw);
const ecma_property_descriptor_t *property_desc_p);
void
ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable,
+37 -44
View File
@@ -613,48 +613,41 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
ecma_value_t completion;
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
{
prop_desc.is_value_defined = true;
prop_desc.is_writable_defined = true;
prop_desc.is_writable = true;
prop_desc.is_enumerable_defined = true;
prop_desc.is_enumerable = true;
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = true;
prop_desc.flags = (ECMA_PROP_IS_VALUE_DEFINED
| ECMA_PROP_IS_WRITABLE_DEFINED
| ECMA_PROP_IS_WRITABLE
| ECMA_PROP_IS_ENUMERABLE_DEFINED
| ECMA_PROP_IS_ENUMERABLE
| ECMA_PROP_IS_CONFIGURABLE_DEFINED
| ECMA_PROP_IS_CONFIGURABLE);
}
/* 3. */
if (src_prop_desc_p->is_value_defined
|| src_prop_desc_p->is_writable_defined)
if (src_prop_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
{
JERRY_ASSERT (prop_desc.is_value_defined && prop_desc.is_writable_defined);
JERRY_ASSERT ((prop_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
== (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED));
/* a. */
prop_desc.value = src_prop_desc_p->value;
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_VALUE),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */
const bool is_writable = (src_prop_desc_p->is_writable);
prop_desc.value = ecma_make_boolean_value (is_writable);
prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_WRITABLE);
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
}
else
{
/* 4. */
JERRY_ASSERT (src_prop_desc_p->is_get_defined
|| src_prop_desc_p->is_set_defined);
JERRY_ASSERT (src_prop_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED));
/* a. */
if (src_prop_desc_p->get_p == NULL)
@@ -668,8 +661,7 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_GET),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */
@@ -684,27 +676,22 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_SET),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
}
const bool is_enumerable = src_prop_desc_p->is_enumerable;
prop_desc.value = ecma_make_boolean_value (is_enumerable);
prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_ENUMERABLE);
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
const bool is_configurable = src_prop_desc_p->is_configurable;
prop_desc.value = ecma_make_boolean_value (is_configurable);
prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE);
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
return obj_p;
@@ -746,8 +733,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (enumerable_prop_value))
{
prop_desc.is_enumerable_defined = true;
prop_desc.is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (enumerable_prop_value));
uint32_t is_enumerable = (ecma_op_to_boolean (enumerable_prop_value) ? ECMA_PROP_IS_ENUMERABLE
: ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | is_enumerable);
}
ECMA_FINALIZE (enumerable_prop_value);
@@ -763,8 +752,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (configurable_prop_value))
{
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (configurable_prop_value));
uint32_t is_configurable = (ecma_op_to_boolean (configurable_prop_value) ? ECMA_PROP_IS_CONFIGURABLE
: ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | is_configurable);
}
ECMA_FINALIZE (configurable_prop_value);
@@ -781,7 +772,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (value_prop_value))
{
prop_desc.is_value_defined = true;
prop_desc.flags |= ECMA_PROP_IS_VALUE_DEFINED;
prop_desc.value = ecma_copy_value (value_prop_value);
}
@@ -799,8 +790,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (writable_prop_value))
{
prop_desc.is_writable_defined = true;
prop_desc.is_writable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (writable_prop_value));
uint32_t is_writable = (ecma_op_to_boolean (writable_prop_value) ? ECMA_PROP_IS_WRITABLE
: ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_WRITABLE_DEFINED | is_writable);
}
ECMA_FINALIZE (writable_prop_value);
@@ -824,7 +817,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
}
else
{
prop_desc.is_get_defined = true;
prop_desc.flags |= ECMA_PROP_IS_GET_DEFINED;
if (ecma_is_value_undefined (get_prop_value))
{
@@ -863,7 +856,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
}
else
{
prop_desc.is_set_defined = true;
prop_desc.flags |= ECMA_PROP_IS_SET_DEFINED;
if (ecma_is_value_undefined (set_prop_value))
{
@@ -889,8 +882,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 9. */
if ((prop_desc.is_get_defined || prop_desc.is_set_defined)
&& (prop_desc.is_value_defined || prop_desc.is_writable_defined))
if ((prop_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
&& (prop_desc.flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable."));
}
@@ -64,8 +64,7 @@ ecma_create_array_from_iter_element (ecma_value_t value, /**< value */
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
index_string_p,
(index == 0) ? index_value : value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
false); /* Failure handling */
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
/* 4.b */
JERRY_ASSERT (ecma_is_value_true (completion));
+7 -7
View File
@@ -143,18 +143,18 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_value_t completion;
if (!ecma_get_object_extensible (binding_obj_p))
{
return ECMA_VALUE_EMPTY;
}
completion = ecma_builtin_helper_def_prop (binding_obj_p,
name_p,
ECMA_VALUE_UNDEFINED,
is_deletable ? ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE
: ECMA_PROPERTY_ENUMERABLE_WRITABLE,
true); /* Failure handling */
const uint32_t flags = ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
ecma_value_t completion = ecma_builtin_helper_def_prop (binding_obj_p,
name_p,
ECMA_VALUE_UNDEFINED,
is_deletable ? flags | ECMA_PROPERTY_FLAG_CONFIGURABLE
: flags);
if (ECMA_IS_VALUE_ERROR (completion))
{
@@ -155,30 +155,23 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
/* 14. */
prop_desc = ecma_make_empty_property_descriptor ();
{
prop_desc.is_get_defined = true;
prop_desc.get_p = thrower_p;
prop_desc.is_set_defined = true;
prop_desc.set_p = thrower_p;
prop_desc.is_enumerable_defined = true;
prop_desc.is_enumerable = false;
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = false;
prop_desc.flags = (ECMA_PROP_IS_GET_DEFINED
| ECMA_PROP_IS_SET_DEFINED
| ECMA_PROP_IS_ENUMERABLE_DEFINED
| ECMA_PROP_IS_CONFIGURABLE_DEFINED);
}
prop_desc.set_p = thrower_p;
prop_desc.get_p = thrower_p;
ecma_value_t completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CALLER),
&prop_desc,
false);
&prop_desc);
JERRY_ASSERT (ecma_is_value_true (completion));
}
@@ -221,15 +214,13 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
ecma_value_t
ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property
const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */
bool is_throw) /**< flag that controls failure handling */
{
/* 3. */
ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
if (ECMA_IS_VALUE_ERROR (ret_value))
{
@@ -259,15 +250,14 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[index]);
if (property_desc_p->is_get_defined
|| property_desc_p->is_set_defined)
if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
{
ecma_deref_ecma_string (name_p);
arg_Literal_p[index] = ECMA_VALUE_EMPTY;
}
else
{
if (property_desc_p->is_value_defined)
if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{
/* emulating execution of function described by MakeArgSetter */
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
@@ -281,8 +271,8 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
JERRY_ASSERT (ecma_is_value_empty (completion));
}
if (property_desc_p->is_writable_defined
&& !property_desc_p->is_writable)
if ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
&& !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE))
{
ecma_deref_ecma_string (name_p);
arg_Literal_p[index] = ECMA_VALUE_EMPTY;
@@ -28,6 +28,6 @@ ecma_value_t
ecma_op_arguments_object_delete (ecma_object_t *object_p, ecma_string_t *property_name_p, bool is_throw);
ecma_value_t
ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw);
const ecma_property_descriptor_t *property_desc_p);
#endif /* !ECMA_OBJECTS_ARGUMENTS_H */
@@ -271,9 +271,8 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */
ecma_value_t
ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property
const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */
bool is_throw) /**< flag that controls failure handling */
{
JERRY_ASSERT (object_p != NULL
&& !ecma_is_lexical_environment (object_p));
@@ -281,25 +280,27 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ecma_property_types_t property_desc_type = ECMA_PROPERTY_TYPE_GENERIC;
if (property_desc_p->is_value_defined
|| property_desc_p->is_writable_defined)
if (property_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
{
/* A property descriptor cannot be both named data and named accessor. */
JERRY_ASSERT (!property_desc_p->is_get_defined
&& !property_desc_p->is_set_defined);
JERRY_ASSERT ((property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
!= (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED));
property_desc_type = ECMA_PROPERTY_TYPE_NAMEDDATA;
}
else if (property_desc_p->is_get_defined
|| property_desc_p->is_set_defined)
else if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
{
JERRY_ASSERT (!(property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED));
property_desc_type = ECMA_PROPERTY_TYPE_NAMEDACCESSOR;
}
/* These three asserts ensures that a new property is created with the appropriate default flags.
* E.g. if is_configurable_defined is false, the newly created property must be non-configurable. */
JERRY_ASSERT (property_desc_p->is_configurable_defined || !property_desc_p->is_configurable);
JERRY_ASSERT (property_desc_p->is_enumerable_defined || !property_desc_p->is_enumerable);
JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable);
* E.g. if ECMA_PROP_IS_CONFIGURABLE_DEFINED is false, the newly created property must be non-configurable. */
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
/* 1. */
ecma_extended_property_ref_t ext_property_ref = { .property_ref.value_p = NULL, .property_p = NULL };
@@ -316,39 +317,25 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!ecma_get_object_extensible (object_p))
{
/* 2. */
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
/* 4. */
uint8_t prop_attributes = (uint8_t) (property_desc_p->flags & ECMA_PROPERTY_FLAGS_MASK);
if (property_desc_type != ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
{
/* a. */
JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC
|| property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA);
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
if (property_desc_p->is_writable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
}
ecma_property_value_t *new_prop_value_p = ecma_create_named_data_property (object_p,
property_name_p,
prop_attributes,
NULL);
JERRY_ASSERT (property_desc_p->is_value_defined
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
|| ecma_is_value_undefined (property_desc_p->value));
new_prop_value_p->value = ecma_copy_value_if_not_object (property_desc_p->value);
@@ -357,17 +344,6 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{
/* b. */
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
ecma_create_named_accessor_property (object_p,
property_name_p,
property_desc_p->get_p,
@@ -388,16 +364,17 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
|| current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL);
/* 7. a., b. */
bool is_enumberable = (property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE) != 0;
if (!is_current_configurable
&& (property_desc_p->is_configurable
|| (property_desc_p->is_enumerable_defined
&& (property_desc_p->is_enumerable != ecma_is_property_enumerable (current_prop)))))
&& ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE)
|| ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
&& (is_enumberable != ecma_is_property_enumerable (current_prop)))))
{
if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL)
{
ecma_free_value (ext_property_ref.property_ref.virtual_value);
}
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL)
@@ -407,12 +384,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ecma_value_t result = ECMA_VALUE_TRUE;
if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| property_desc_p->is_writable
|| (property_desc_p->is_value_defined
|| (property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
|| ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
&& !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.virtual_value)))
{
result = ecma_reject (is_throw);
result = ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
ecma_free_value (ext_property_ref.property_ref.virtual_value);
@@ -433,12 +410,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{
/* 10. a. i. & ii. */
if (!ecma_is_property_writable (current_prop)
&& (property_desc_p->is_writable
|| (property_desc_p->is_value_defined
&& ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
|| ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
&& !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.value_p->value))))
{
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
}
else
@@ -453,13 +430,13 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ECMA_SET_POINTER (prop_desc_getter_cp, property_desc_p->get_p);
ECMA_SET_POINTER (prop_desc_setter_cp, property_desc_p->set_p);
if ((property_desc_p->is_get_defined
if (((property_desc_p->flags & ECMA_PROP_IS_GET_DEFINED)
&& prop_desc_getter_cp != get_set_pair_p->getter_cp)
|| (property_desc_p->is_set_defined
|| ((property_desc_p->flags & ECMA_PROP_IS_SET_DEFINED)
&& prop_desc_setter_cp != get_set_pair_p->setter_cp))
{
/* i., ii. */
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
}
}
@@ -470,7 +447,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!is_current_configurable)
{
/* a. */
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
ecma_property_value_t *value_p = ext_property_ref.property_ref.value_p;
@@ -515,30 +492,30 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
if (property_desc_p->is_value_defined)
if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{
ecma_named_data_property_assign_value (object_p,
ext_property_ref.property_ref.value_p,
property_desc_p->value);
}
if (property_desc_p->is_writable_defined)
if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
{
ecma_set_property_writable_attr (ext_property_ref.property_p, property_desc_p->is_writable);
ecma_set_property_writable_attr (ext_property_ref.property_p, (property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
}
}
else if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
if (property_desc_p->is_get_defined)
if (property_desc_p->flags & ECMA_PROP_IS_GET_DEFINED)
{
ecma_set_named_accessor_property_getter (object_p,
ext_property_ref.property_ref.value_p,
property_desc_p->get_p);
}
if (property_desc_p->is_set_defined)
if (property_desc_p->flags & ECMA_PROP_IS_SET_DEFINED)
{
ecma_set_named_accessor_property_setter (object_p,
ext_property_ref.property_ref.value_p,
@@ -546,14 +523,16 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
}
}
if (property_desc_p->is_enumerable_defined)
if (property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
{
ecma_set_property_enumerable_attr (ext_property_ref.property_p, property_desc_p->is_enumerable);
ecma_set_property_enumerable_attr (ext_property_ref.property_p,
(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
}
if (property_desc_p->is_configurable_defined)
if (property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
{
ecma_set_property_configurable_attr (ext_property_ref.property_p, property_desc_p->is_configurable);
ecma_set_property_configurable_attr (ext_property_ref.property_p,
(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
}
return ECMA_VALUE_TRUE;
@@ -34,8 +34,7 @@ ecma_object_t *ecma_op_create_object_object_noarg_and_set_prototype (ecma_object
ecma_value_t ecma_op_general_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw);
ecma_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p,
bool is_throw);
const ecma_property_descriptor_t *property_desc_p);
/**
* @}
+18 -25
View File
@@ -1137,8 +1137,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
return ecma_builtin_helper_def_prop (object_p,
property_name_p,
value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
true); /* Failure handling */
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
}
}
@@ -1329,9 +1328,8 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */
ecma_value_t
ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property
const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */
bool is_throw) /**< flag that controls failure handling */
{
JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
@@ -1352,16 +1350,14 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{
return ecma_op_general_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
}
case ECMA_OBJECT_TYPE_ARRAY:
{
return ecma_op_array_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
}
default:
@@ -1378,8 +1374,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
return ecma_op_arguments_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
}
/* ES2015 9.4.5.3 */
@@ -1390,8 +1385,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{
return ecma_op_general_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
uint32_t array_index = ecma_string_get_array_index (property_name_p);
@@ -1407,7 +1401,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
return ECMA_VALUE_TRUE;
}
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
@@ -1417,7 +1411,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{
ecma_deref_ecma_string (num_to_str);
return ecma_reject (is_throw);
return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
}
ecma_deref_ecma_string (num_to_str);
@@ -1425,8 +1419,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
return ecma_op_general_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
property_desc_p);
#else /* !ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
break;
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
@@ -1466,10 +1459,10 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
*prop_desc_p = ecma_make_empty_property_descriptor ();
prop_desc_p->is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_enumerable (property));
prop_desc_p->is_enumerable_defined = true;
prop_desc_p->is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_configurable (property));
prop_desc_p->is_configurable_defined = true;
uint32_t flags = ecma_is_property_enumerable (property) ? ECMA_PROP_IS_ENUMERABLE : ECMA_PROP_NO_OPTS;
flags |= ecma_is_property_configurable (property) ? ECMA_PROP_IS_CONFIGURABLE: ECMA_PROP_NO_OPTS;
prop_desc_p->flags = (uint16_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE_DEFINED | flags);
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (property);
@@ -1485,15 +1478,15 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
prop_desc_p->value = property_ref.virtual_value;
}
prop_desc_p->is_value_defined = true;
prop_desc_p->is_writable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_writable (property));
prop_desc_p->is_writable_defined = true;
prop_desc_p->flags |= (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED);
prop_desc_p->flags = (uint16_t) (prop_desc_p->flags | (ecma_is_property_writable (property) ? ECMA_PROP_IS_WRITABLE
: ECMA_PROP_NO_OPTS));
}
else
{
prop_desc_p->is_get_defined = true;
prop_desc_p->is_set_defined = true;
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (property_ref.value_p);
prop_desc_p->flags |= (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED);
if (get_set_pair_p->getter_cp == JMEM_CP_NULL)
{
+1 -1
View File
@@ -52,7 +52,7 @@ ecma_value_t ecma_op_object_delete_by_uint32_index (ecma_object_t *obj_p, uint32
ecma_value_t ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, ecma_number_t index, bool is_throw);
ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw);
const ecma_property_descriptor_t *property_desc_p);
bool ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, ecma_string_t *property_name_p,
ecma_property_descriptor_t *prop_desc_p);
ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value);
@@ -1141,27 +1141,24 @@ re_set_result_array_properties (ecma_object_t *array_obj_p, /**< result array */
ecma_builtin_helper_def_prop (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_INDEX),
ecma_make_int32_value (index),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
true); /* Failure handling */
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
/* Set input property of the result array */
ecma_builtin_helper_def_prop (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_INPUT),
ecma_make_string_value (input_str_p),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
true); /* Failure handling */
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
/* Set length property of the result array */
{
ecma_property_descriptor_t array_item_prop_desc = ecma_make_empty_property_descriptor ();
array_item_prop_desc.is_value_defined = true;
array_item_prop_desc.flags |= (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_THROW);
array_item_prop_desc.value = ecma_make_uint32_value (num_of_elements);
ecma_op_object_define_own_property (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
&array_item_prop_desc,
true);
&array_item_prop_desc);
}
} /* re_set_result_array_properties */
@@ -831,25 +831,19 @@ ecma_op_typedarray_define_index_prop (ecma_object_t *obj_p, /**< a TypedArray ob
ecma_length_t array_length = ecma_typedarray_get_length (obj_p);
if (index >= array_length)
if ((index >= array_length)
|| (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
|| ((property_desc_p->flags & (ECMA_PROP_IS_CONFIGURABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE))
== (ECMA_PROP_IS_CONFIGURABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE))
|| ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
&& !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE))
|| ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
&& !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE)))
{
return false;
}
if (property_desc_p->is_get_defined
|| property_desc_p->is_set_defined)
{
return false;
}
if ((property_desc_p->is_configurable_defined && property_desc_p->is_configurable)
|| (property_desc_p->is_enumerable_defined && !property_desc_p->is_enumerable)
|| (property_desc_p->is_writable_defined && !property_desc_p->is_writable))
{
return false;
}
if (property_desc_p->is_value_defined)
if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{
return ecma_op_typedarray_set_index_prop (obj_p, index, property_desc_p->value);
}