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)