Implement fast access mode arrays (#3028)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-08-30 15:18:15 +02:00
committed by GitHub
parent c6a4a86257
commit 2f1908f894
15 changed files with 982 additions and 262 deletions
@@ -282,24 +282,22 @@ ecma_builtin_helper_object_get_properties (ecma_object_t *obj_p, /**< object */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, opts);
if (props_p->item_count == 0)
{
ecma_free_values_collection (props_p, 0);
return new_array;
}
JERRY_ASSERT (((ecma_extended_object_t *) new_array_p)->u.array.is_fast_mode);
ecma_value_t *values_p = ecma_fast_array_extend (new_array_p, props_p->item_count);
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
while (ecma_value_p != NULL)
{
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
index_string_p,
*ecma_value_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
JERRY_ASSERT (ecma_is_value_true (completion));
ecma_deref_ecma_string (index_string_p);
values_p[index++] = ecma_copy_value_if_not_object (*ecma_value_p);
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
index++;
}
ecma_free_values_collection (props_p, 0);
@@ -321,7 +321,7 @@ ecma_builtin_object_object_get_own_property_symbols (ecma_object_t *obj_p) /**<
static ecma_value_t
ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument */
{
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, ECMA_LIST_NO_OPTS);
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, ECMA_LIST_CONVERT_FAST_ARRAYS);
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
@@ -380,7 +380,7 @@ ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument *
static ecma_value_t
ecma_builtin_object_object_freeze (ecma_object_t *obj_p) /**< routine's argument */
{
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, ECMA_LIST_NO_OPTS);
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, ECMA_LIST_CONVERT_FAST_ARRAYS);
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
@@ -597,7 +597,8 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
ecma_object_t *props_p = ecma_get_object_from_value (props);
/* 3. */
ecma_collection_header_t *prop_names_p = ecma_op_object_get_property_names (props_p, ECMA_LIST_ENUMERABLE);
ecma_collection_header_t *prop_names_p = ecma_op_object_get_property_names (props_p, ECMA_LIST_CONVERT_FAST_ARRAYS
| ECMA_LIST_ENUMERABLE);
uint32_t property_number = prop_names_p->item_count;
ecma_value_t ret_value = ECMA_VALUE_ERROR;
@@ -820,7 +821,8 @@ ecma_builtin_object_object_assign (const ecma_value_t arguments_list_p[], /**< a
/* 5.b.iii */
/* TODO: extends this collection if symbols will be supported */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (from_obj_p, ECMA_LIST_ENUMERABLE);
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (from_obj_p, ECMA_LIST_CONVERT_FAST_ARRAYS
| ECMA_LIST_ENUMERABLE);
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
@@ -432,6 +432,8 @@ ecma_instantiate_builtin (ecma_builtin_id_t obj_builtin_id) /**< built-in id */
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;
break;
}
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */