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:
committed by
Dániel Bátyai
parent
d0435e1db0
commit
ee1da14577
@@ -804,12 +804,10 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
if (ecma_is_value_found (get_value))
|
||||
{
|
||||
/* 10.c.ii */
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
n,
|
||||
get_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
ecma_free_value (get_value);
|
||||
}
|
||||
@@ -1187,12 +1185,10 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
if (ecma_is_value_found (get_value))
|
||||
{
|
||||
/* 9.c.ii */
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
k,
|
||||
get_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
ecma_free_value (get_value);
|
||||
@@ -1748,12 +1744,11 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
|
||||
}
|
||||
|
||||
/* 8.c.iii */
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
index,
|
||||
mapped_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
ecma_free_value (mapped_value);
|
||||
@@ -1848,12 +1843,10 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
|
||||
/* 9.c.iii */
|
||||
if (ecma_op_to_boolean (call_value))
|
||||
{
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
new_array_index,
|
||||
get_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
new_array_index++;
|
||||
}
|
||||
|
||||
@@ -291,8 +291,7 @@ ecma_builtin_helper_object_get_properties (ecma_object_t *obj_p, /**< object */
|
||||
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
|
||||
index_string_p,
|
||||
*ecma_value_p,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
@@ -438,8 +437,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p,
|
||||
new_array_index_string_p,
|
||||
get_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
ecma_deref_ecma_string (new_array_index_string_p);
|
||||
@@ -464,9 +462,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p,
|
||||
new_array_index_string_p,
|
||||
value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
ecma_deref_ecma_string (new_array_index_string_p);
|
||||
@@ -802,24 +798,21 @@ ecma_value_t
|
||||
ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, /**< object */
|
||||
uint32_t index, /**< property index */
|
||||
ecma_value_t value, /**< value */
|
||||
uint32_t opts, /**< any combination of ecma_property_flag_t bits */
|
||||
bool is_throw) /**< is_throw */
|
||||
uint32_t opts) /**< any combination of ecma_property_flag_t bits */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_builtin_helper_def_prop (obj_p,
|
||||
ECMA_CREATE_DIRECT_UINT32_STRING (index),
|
||||
value,
|
||||
opts,
|
||||
is_throw);
|
||||
opts);
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_value_t ret_value = ecma_builtin_helper_def_prop (obj_p,
|
||||
index_str_p,
|
||||
value,
|
||||
opts,
|
||||
is_throw);
|
||||
opts);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
@@ -839,27 +832,18 @@ ecma_value_t
|
||||
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */
|
||||
ecma_string_t *index_p, /**< index string */
|
||||
ecma_value_t value, /**< value */
|
||||
uint32_t opts, /**< any combination of ecma_property_flag_t bits */
|
||||
bool is_throw) /**< is_throw */
|
||||
uint32_t opts) /**< any combination of ecma_property_flag_t bits
|
||||
* with the optional ECMA_IS_THROW flag */
|
||||
{
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
|
||||
prop_desc.flags = (uint16_t) (ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS | opts);
|
||||
|
||||
prop_desc.is_value_defined = true;
|
||||
prop_desc.value = value;
|
||||
|
||||
prop_desc.is_writable_defined = true;
|
||||
prop_desc.is_writable = (opts & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
|
||||
|
||||
prop_desc.is_enumerable_defined = true;
|
||||
prop_desc.is_enumerable = (opts & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
|
||||
|
||||
prop_desc.is_configurable_defined = true;
|
||||
prop_desc.is_configurable = (opts & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
|
||||
|
||||
return ecma_op_object_define_own_property (obj_p,
|
||||
index_p,
|
||||
&prop_desc,
|
||||
is_throw);
|
||||
&prop_desc);
|
||||
} /* ecma_builtin_helper_def_prop */
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,11 +58,10 @@ bool
|
||||
ecma_builtin_helper_string_find_index (ecma_string_t *original_str_p, ecma_string_t *search_str_p, bool first_index,
|
||||
ecma_length_t start_pos, ecma_length_t *ret_index_p);
|
||||
ecma_value_t
|
||||
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value,
|
||||
uint32_t opts, bool is_throw);
|
||||
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value, uint32_t opts);
|
||||
|
||||
ecma_value_t
|
||||
ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value,
|
||||
uint32_t opts, bool is_throw);
|
||||
ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value, uint32_t opts);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_DATE)
|
||||
|
||||
|
||||
@@ -543,8 +543,7 @@ ecma_builtin_json_define_value_property (ecma_object_t *obj_p, /**< this object
|
||||
ecma_value_t completion_value = ecma_builtin_helper_def_prop (obj_p,
|
||||
property_name_p,
|
||||
value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (completion_value));
|
||||
} /* ecma_builtin_json_define_value_property */
|
||||
@@ -683,8 +682,7 @@ ecma_builtin_json_parse_value (ecma_json_token_t *token_p) /**< token argument *
|
||||
ecma_value_t completion = ecma_builtin_helper_def_prop (array_p,
|
||||
index_str_p,
|
||||
value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
@@ -918,8 +916,7 @@ static ecma_value_t ecma_builtin_json_str_helper (const ecma_value_t arg1, /**<
|
||||
ecma_value_t put_comp_val = ecma_builtin_helper_def_prop (obj_wrapper_p,
|
||||
empty_str_p,
|
||||
arg1,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false);
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp_val));
|
||||
|
||||
|
||||
@@ -339,13 +339,13 @@ ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument *
|
||||
}
|
||||
|
||||
/* 2.b */
|
||||
prop_desc.is_configurable = false;
|
||||
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
|
||||
prop_desc.flags |= ECMA_PROP_IS_THROW;
|
||||
|
||||
/* 2.c */
|
||||
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
|
||||
property_name_p,
|
||||
&prop_desc,
|
||||
true);
|
||||
&prop_desc);
|
||||
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
|
||||
@@ -398,19 +398,20 @@ ecma_builtin_object_object_freeze (ecma_object_t *obj_p) /**< routine's argument
|
||||
}
|
||||
|
||||
/* 2.b */
|
||||
if (prop_desc.is_writable_defined && prop_desc.is_writable)
|
||||
if ((prop_desc.flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE))
|
||||
== (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE))
|
||||
{
|
||||
prop_desc.is_writable = false;
|
||||
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_WRITABLE;
|
||||
}
|
||||
|
||||
/* 2.c */
|
||||
prop_desc.is_configurable = false;
|
||||
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
|
||||
prop_desc.flags |= ECMA_PROP_IS_THROW;
|
||||
|
||||
/* 2.d */
|
||||
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
|
||||
property_name_p,
|
||||
&prop_desc,
|
||||
true);
|
||||
&prop_desc);
|
||||
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
|
||||
@@ -620,6 +621,8 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
|
||||
ecma_value_t conv_result = ecma_op_to_property_descriptor (desc_obj,
|
||||
&property_descriptors[property_descriptor_number]);
|
||||
|
||||
property_descriptors[property_descriptor_number].flags |= ECMA_PROP_IS_THROW;
|
||||
|
||||
ecma_free_value (desc_obj);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (conv_result))
|
||||
@@ -641,8 +644,7 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
|
||||
{
|
||||
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
|
||||
ecma_get_string_from_value (*ecma_value_p),
|
||||
&property_descriptors[index],
|
||||
true);
|
||||
&property_descriptors[index]);
|
||||
if (ECMA_IS_VALUE_ERROR (define_own_prop_ret))
|
||||
{
|
||||
goto cleanup;
|
||||
@@ -743,10 +745,11 @@ ecma_builtin_object_object_define_property (ecma_object_t *obj_p, /**< routine's
|
||||
return conv_result;
|
||||
}
|
||||
|
||||
prop_desc.flags |= ECMA_PROP_IS_THROW;
|
||||
|
||||
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
|
||||
name_str_p,
|
||||
&prop_desc,
|
||||
true);
|
||||
&prop_desc);
|
||||
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
ecma_free_value (conv_result);
|
||||
@@ -834,9 +837,9 @@ ecma_builtin_object_object_assign (const ecma_value_t arguments_list_p[], /**< a
|
||||
}
|
||||
|
||||
/* 5.c.iii */
|
||||
if (prop_desc.is_enumerable
|
||||
&& ((prop_desc.is_value_defined && !ecma_is_value_undefined (prop_desc.value))
|
||||
|| prop_desc.is_get_defined))
|
||||
if ((prop_desc.flags & ECMA_PROP_IS_ENUMERABLE)
|
||||
&& (((prop_desc.flags & ECMA_PROP_IS_VALUE_DEFINED) && !ecma_is_value_undefined (prop_desc.value))
|
||||
|| (prop_desc.flags & ECMA_PROP_IS_GET_DEFINED)))
|
||||
{
|
||||
/* 5.c.iii.1 */
|
||||
ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p);
|
||||
|
||||
@@ -482,8 +482,7 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
|
||||
ecma_value_t put_ret = ecma_builtin_helper_def_prop (ecma_get_object_from_value (value_array),
|
||||
index_to_str_p,
|
||||
undefined_val,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false);
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
ecma_deref_ecma_string (index_to_str_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (put_ret))
|
||||
|
||||
@@ -462,8 +462,7 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_to_string_value, /
|
||||
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_obj_p,
|
||||
current_index_str_p,
|
||||
match_string_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
@@ -1358,8 +1357,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
|
||||
zero_str_p,
|
||||
this_to_string_val,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
@@ -1435,8 +1433,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
|
||||
zero_str_p,
|
||||
this_to_string_val,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
ecma_deref_ecma_string (zero_str_p);
|
||||
@@ -1520,13 +1517,13 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint32_t opts = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
|
||||
ecma_string_t *separator_str_p = ecma_get_string_from_value (separator);
|
||||
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (match_obj_p,
|
||||
zero_str_p,
|
||||
ecma_make_string_value (separator_str_p),
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
true); /* Failure handling */
|
||||
opts);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
@@ -1571,8 +1568,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
|
||||
array_length_str_p,
|
||||
ecma_make_string_value (substr_str_p),
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
@@ -1616,8 +1612,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
put_comp = ecma_builtin_helper_def_prop (new_array_p,
|
||||
new_array_idx_str_p,
|
||||
match_comp_value,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
@@ -1662,8 +1657,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
|
||||
array_length_string_p,
|
||||
ecma_make_string_value (substr_str_p),
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
false); /* Failure handling */
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_comp));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user