Rework array hole calculation for fast access mode arrays (#3248)
This patch gives possibility to Array.prototype builtin routine optimizations. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -425,8 +425,7 @@ ecma_builtin_array_prototype_object_pop (ecma_object_t *obj_p, /**< array object
|
||||
return get_value;
|
||||
}
|
||||
|
||||
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY
|
||||
&& ((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode)
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
if (!ecma_get_object_extensible (obj_p))
|
||||
{
|
||||
@@ -478,8 +477,7 @@ ecma_builtin_array_prototype_object_push (const ecma_value_t *argument_list_p, /
|
||||
{
|
||||
ecma_number_t n = (ecma_number_t) length;
|
||||
|
||||
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY
|
||||
&& ((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode)
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
if (!ecma_get_object_extensible (obj_p))
|
||||
{
|
||||
@@ -497,6 +495,7 @@ ecma_builtin_array_prototype_object_push (const ecma_value_t *argument_list_p, /
|
||||
}
|
||||
|
||||
uint32_t new_length = length + arguments_number;
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
ecma_value_t *buffer_p = ecma_fast_array_extend (obj_p, new_length) + length;
|
||||
|
||||
for (uint32_t index = 0; index < arguments_number; index++)
|
||||
@@ -504,6 +503,8 @@ ecma_builtin_array_prototype_object_push (const ecma_value_t *argument_list_p, /
|
||||
buffer_p[index] = ecma_copy_value_if_not_object (argument_list_p[index]);
|
||||
}
|
||||
|
||||
ext_obj_p->u.array.u.hole_count -= ECMA_FAST_ARRAY_HOLE_ONE * arguments_number;
|
||||
|
||||
return ecma_make_uint32_value (new_length);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ ecma_builtin_helper_object_get_properties (ecma_object_t *obj_p, /**< object */
|
||||
return new_array;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (((ecma_extended_object_t *) new_array_p)->u.array.is_fast_mode);
|
||||
JERRY_ASSERT (ecma_op_object_is_fast_array (new_array_p));
|
||||
|
||||
ecma_value_t *buffer_p = props_p->buffer_p;
|
||||
ecma_value_t *values_p = ecma_fast_array_extend (new_array_p, props_p->item_count);
|
||||
|
||||
@@ -1460,8 +1460,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
|
||||
|
||||
if (separator_is_regexp)
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (match_obj_p) != ECMA_OBJECT_TYPE_ARRAY
|
||||
|| !((ecma_extended_object_t *) match_obj_p)->u.array.is_fast_mode);
|
||||
JERRY_ASSERT (!ecma_op_object_is_fast_array (match_obj_p));
|
||||
|
||||
ecma_property_value_t *index_prop_value_p = ecma_get_named_data_property (match_obj_p, magic_index_str_p);
|
||||
ecma_number_t index_num = ecma_get_number_from_value (index_prop_value_p->value);
|
||||
|
||||
@@ -431,9 +431,7 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
ext_object_p->u.array.length = 0;
|
||||
ext_object_p->u.array.length_prop = ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROPERTY_TYPE_VIRTUAL;
|
||||
ext_object_p->u.array.is_fast_mode = false;
|
||||
ext_object_p->u.array.hole_count = 0;
|
||||
ext_object_p->u.array.u.length_prop = ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROPERTY_TYPE_VIRTUAL;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
Reference in New Issue
Block a user