Rework ecma collection (#3086)
After this patch the ecma value collection is a resizable buffer of ecma-values where the adjacent elements are allocated next to each other. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Zoltan Herczeg
parent
f3d3c34c30
commit
fc30f003ba
@@ -492,7 +492,7 @@ ecma_fast_array_set_length (ecma_object_t *object_p, /**< fast access mode array
|
||||
*
|
||||
* @return collection of strings - property names
|
||||
*/
|
||||
ecma_collection_header_t *
|
||||
ecma_collection_t *
|
||||
ecma_fast_array_get_property_names (ecma_object_t *object_p, /**< fast access mode array object */
|
||||
uint32_t opts) /**< any combination of ecma_list_properties_options_t values */
|
||||
{
|
||||
@@ -501,7 +501,7 @@ ecma_fast_array_get_property_names (ecma_object_t *object_p, /**< fast access mo
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
JERRY_ASSERT (ext_obj_p->u.array.is_fast_mode);
|
||||
|
||||
ecma_collection_header_t *ret_p = ecma_new_values_collection ();
|
||||
ecma_collection_t *ret_p = ecma_new_collection ();
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
if (opts & ECMA_LIST_SYMBOLS)
|
||||
@@ -518,7 +518,7 @@ ecma_fast_array_get_property_names (ecma_object_t *object_p, /**< fast access mo
|
||||
{
|
||||
if (append_length)
|
||||
{
|
||||
ecma_append_to_values_collection (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH), 0);
|
||||
ecma_collection_push_back (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
}
|
||||
|
||||
return ret_p;
|
||||
@@ -535,12 +535,12 @@ ecma_fast_array_get_property_names (ecma_object_t *object_p, /**< fast access mo
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
ecma_append_to_values_collection (ret_p, ecma_make_string_value (index_str_p), ECMA_COLLECTION_NO_COPY);
|
||||
ecma_collection_push_back (ret_p, ecma_make_string_value (index_str_p));
|
||||
}
|
||||
|
||||
if (append_length)
|
||||
{
|
||||
ecma_append_to_values_collection (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH), 0);
|
||||
ecma_collection_push_back (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
}
|
||||
|
||||
if (opts & ECMA_LIST_CONVERT_FAST_ARRAYS)
|
||||
@@ -1094,19 +1094,16 @@ ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, /**< a String obje
|
||||
* false - list all properties into main
|
||||
* collection.
|
||||
*/
|
||||
ecma_collection_header_t *main_collection_p, /**< 'main'
|
||||
* collection */
|
||||
ecma_collection_header_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
ecma_collection_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
} /* ecma_op_array_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ void
|
||||
ecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
|
||||
ecma_property_value_t *prop_value_p);
|
||||
|
||||
ecma_collection_header_t *
|
||||
ecma_collection_t *
|
||||
ecma_fast_array_get_property_names (ecma_object_t *object_p, uint32_t opts);
|
||||
|
||||
void
|
||||
@@ -87,8 +87,8 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t
|
||||
|
||||
void
|
||||
ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable,
|
||||
ecma_collection_header_t *main_collection_p,
|
||||
ecma_collection_header_t *non_enum_collection_p);
|
||||
ecma_collection_t *main_collection_p,
|
||||
ecma_collection_t *non_enum_collection_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -457,23 +457,22 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
|
||||
ecma_object_t *internal_obj_p = ecma_get_object_from_value (map_object_p->header.u.class_prop.u.value);
|
||||
|
||||
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (internal_obj_p, ECMA_LIST_NO_OPTS);
|
||||
ecma_collection_t *props_p = ecma_op_object_get_property_names (internal_obj_p, ECMA_LIST_NO_OPTS);
|
||||
|
||||
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
|
||||
ecma_value_t *buffer_p = props_p->buffer_p;
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
ecma_ref_object (internal_obj_p);
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < props_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
ecma_property_t *property_p = ecma_find_named_property (internal_obj_p, prop_name_p);
|
||||
JERRY_ASSERT (property_p != NULL);
|
||||
|
||||
if (ecma_is_value_empty (ECMA_PROPERTY_VALUE_PTR (property_p)->value))
|
||||
{
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -497,7 +496,7 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
else
|
||||
{
|
||||
key_arg = *ecma_value_p;
|
||||
key_arg = buffer_p[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,12 +513,10 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
|
||||
ecma_free_value (call_value);
|
||||
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
}
|
||||
|
||||
ecma_deref_object (internal_obj_p);
|
||||
ecma_free_values_collection (props_p, 0);
|
||||
ecma_collection_free (props_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_container_foreach */
|
||||
@@ -664,7 +661,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
ecma_map_object_t *map_object_p = (ecma_map_object_t *) (ecma_get_object_from_value (iterated_value));
|
||||
|
||||
ecma_object_t *internal_obj_p = ecma_get_object_from_value (map_object_p->header.u.class_prop.u.value);
|
||||
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (internal_obj_p, ECMA_LIST_NO_OPTS);
|
||||
ecma_collection_t *props_p = ecma_op_object_get_property_names (internal_obj_p, ECMA_LIST_NO_OPTS);
|
||||
|
||||
uint32_t length = props_p->item_count;
|
||||
uint32_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
@@ -698,34 +695,31 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
if (index >= length)
|
||||
{
|
||||
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY;
|
||||
ecma_free_values_collection (props_p, 0);
|
||||
ecma_collection_free (props_p);
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
|
||||
|
||||
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
|
||||
ecma_value_t *buffer_p = props_p->buffer_p;
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < props_p->item_count; i++)
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
ecma_property_t *property_p = ecma_find_named_property (internal_obj_p, prop_name_p);
|
||||
JERRY_ASSERT (property_p != NULL);
|
||||
|
||||
if (ecma_is_value_empty (ECMA_PROPERTY_VALUE_PTR (property_p)->value))
|
||||
{
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
|
||||
if (ecma_value_p == NULL)
|
||||
if (i == props_p->item_count - 1)
|
||||
{
|
||||
ret_value = ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
@@ -752,7 +746,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
}
|
||||
else
|
||||
{
|
||||
key_arg = *ecma_value_p;
|
||||
key_arg = buffer_p[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,7 +773,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
break;
|
||||
}
|
||||
|
||||
ecma_free_values_collection (props_p, 0);
|
||||
ecma_collection_free (props_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_container_iterator_next */
|
||||
|
||||
@@ -1416,24 +1416,20 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
|
||||
* false - list all properties into main
|
||||
* collection.
|
||||
*/
|
||||
ecma_collection_header_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_header_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
{
|
||||
JERRY_UNUSED (main_collection_p);
|
||||
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
ecma_collection_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
/* 'length' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
|
||||
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
|
||||
|
||||
const ecma_compiled_code_t *bytecode_data_p;
|
||||
|
||||
@@ -1453,14 +1449,10 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
|
||||
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE)
|
||||
{
|
||||
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
|
||||
|
||||
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS));
|
||||
}
|
||||
} /* ecma_op_function_list_lazy_property_names */
|
||||
|
||||
@@ -1480,19 +1472,16 @@ ecma_op_external_function_list_lazy_property_names (bool separate_enumerable, /*
|
||||
* false - list all properties into
|
||||
* main collection.
|
||||
*/
|
||||
ecma_collection_header_t *main_collection_p, /**< 'main'
|
||||
* collection */
|
||||
ecma_collection_header_t *non_enum_collection_p) /**< skipped
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_t *non_enum_collection_p) /**< skipped
|
||||
* collection */
|
||||
{
|
||||
JERRY_UNUSED (main_collection_p);
|
||||
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
ecma_collection_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
|
||||
} /* ecma_op_external_function_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
@@ -1511,30 +1500,23 @@ ecma_op_bound_function_list_lazy_property_names (bool separate_enumerable, /**<
|
||||
* false - list all properties into
|
||||
* main collection.
|
||||
*/
|
||||
ecma_collection_header_t *main_collection_p, /**< 'main'
|
||||
* collection */
|
||||
ecma_collection_header_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
{
|
||||
JERRY_UNUSED (main_collection_p);
|
||||
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
ecma_collection_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
/* 'length' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
|
||||
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
|
||||
|
||||
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS));
|
||||
} /* ecma_op_bound_function_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,18 +97,18 @@ ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p
|
||||
void
|
||||
ecma_op_function_list_lazy_property_names (ecma_object_t *object_p,
|
||||
bool separate_enumerable,
|
||||
ecma_collection_header_t *main_collection_p,
|
||||
ecma_collection_header_t *non_enum_collection_p);
|
||||
ecma_collection_t *main_collection_p,
|
||||
ecma_collection_t *non_enum_collection_p);
|
||||
|
||||
void
|
||||
ecma_op_external_function_list_lazy_property_names (bool separate_enumerable,
|
||||
ecma_collection_header_t *main_collection_p,
|
||||
ecma_collection_header_t *non_enum_collection_p);
|
||||
ecma_collection_t *main_collection_p,
|
||||
ecma_collection_t *non_enum_collection_p);
|
||||
|
||||
void
|
||||
ecma_op_bound_function_list_lazy_property_names (bool separate_enumerable,
|
||||
ecma_collection_header_t *main_collection_p,
|
||||
ecma_collection_header_t *non_enum_collection_p);
|
||||
ecma_collection_t *main_collection_p,
|
||||
ecma_collection_t *non_enum_collection_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1654,7 +1654,7 @@ ecma_op_object_is_prototype_of (ecma_object_t *base_p, /**< base object */
|
||||
*
|
||||
* @return collection of strings - property names
|
||||
*/
|
||||
ecma_collection_header_t *
|
||||
ecma_collection_t *
|
||||
ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
uint32_t opts) /**< any combination of ecma_list_properties_options_t values */
|
||||
{
|
||||
@@ -1671,8 +1671,8 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
}
|
||||
}
|
||||
|
||||
ecma_collection_header_t *ret_p = ecma_new_values_collection ();
|
||||
ecma_collection_header_t *skipped_non_enumerable_p = ecma_new_values_collection ();
|
||||
ecma_collection_t *ret_p = ecma_new_collection ();
|
||||
ecma_collection_t *skipped_non_enumerable_p = ecma_new_collection ();
|
||||
|
||||
const ecma_object_type_t type = ecma_get_object_type (obj_p);
|
||||
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
|
||||
@@ -1696,7 +1696,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t string_named_properties_count = 0;
|
||||
ecma_length_t array_index_named_properties_count = 0;
|
||||
|
||||
ecma_collection_header_t *prop_names_p = ecma_new_values_collection ();
|
||||
ecma_collection_t *prop_names_p = ecma_new_collection ();
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
if (JERRY_LIKELY (!is_symbols_only))
|
||||
@@ -1783,23 +1783,21 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
|
||||
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||
ecma_value_t *buffer_p = prop_names_p->buffer_p;
|
||||
|
||||
const size_t own_names_hashes_bitmap_size = ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size;
|
||||
JERRY_VLA (uint32_t, own_names_hashes_bitmap, own_names_hashes_bitmap_size);
|
||||
memset (own_names_hashes_bitmap, 0, own_names_hashes_bitmap_size * sizeof (own_names_hashes_bitmap[0]));
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < prop_names_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *name_p = ecma_get_string_from_value (*ecma_value_p);
|
||||
ecma_string_t *name_p = ecma_get_string_from_value (buffer_p[i]);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
/* Symbols are never lazy listed */
|
||||
JERRY_ASSERT (!ecma_prop_name_is_symbol (name_p));
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
|
||||
uint8_t hash = (uint8_t) ecma_string_hash (name_p);
|
||||
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
|
||||
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
|
||||
@@ -1839,12 +1837,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
if ((own_names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0)
|
||||
{
|
||||
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||
buffer_p = prop_names_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t j = 0; j < prop_names_p->item_count; j++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[j]);
|
||||
|
||||
if (ecma_compare_ecma_strings (index_str_p, current_name_p))
|
||||
{
|
||||
@@ -1858,9 +1855,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
own_names_hashes_bitmap[bitmap_row] |= (1u << bitmap_column);
|
||||
|
||||
ecma_append_to_values_collection (prop_names_p,
|
||||
ecma_make_string_value (index_str_p),
|
||||
ECMA_COLLECTION_NO_COPY);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_string_value (index_str_p));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1926,12 +1921,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
if ((own_names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0)
|
||||
{
|
||||
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||
buffer_p = prop_names_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t j = 0; j < prop_names_p->item_count; j++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[j]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, current_name_p))
|
||||
{
|
||||
@@ -1945,21 +1939,19 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
own_names_hashes_bitmap[bitmap_row] |= (1u << bitmap_column);
|
||||
|
||||
ecma_append_to_values_collection (prop_names_p,
|
||||
ecma_make_prop_name_value (name_p),
|
||||
0);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_prop_name_value (name_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (is_enumerable_only && !ecma_is_property_enumerable (*property_p));
|
||||
|
||||
ecma_append_to_values_collection (skipped_non_enumerable_p,
|
||||
ecma_make_prop_name_value (name_p),
|
||||
0);
|
||||
ecma_collection_push_back (skipped_non_enumerable_p, ecma_make_prop_name_value (name_p));
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1967,12 +1959,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||
buffer_p = prop_names_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < prop_names_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
|
||||
uint32_t index = ecma_string_get_array_index (name_p);
|
||||
|
||||
@@ -1996,12 +1987,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
uint32_t name_pos = array_index_named_properties_count + string_named_properties_count;
|
||||
uint32_t array_index_name_pos = 0;
|
||||
|
||||
ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||
buffer_p = prop_names_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < prop_names_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
|
||||
uint32_t index = ecma_string_get_array_index (name_p);
|
||||
|
||||
@@ -2062,7 +2052,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (array_index_names_p);
|
||||
|
||||
ecma_free_values_collection (prop_names_p, 0);
|
||||
ecma_collection_free (prop_names_p);
|
||||
|
||||
/* Third pass:
|
||||
* embedding own property names of current object of prototype chain to aggregate property names collection */
|
||||
@@ -2086,12 +2076,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
else
|
||||
{
|
||||
/* Name with same hash has already occured. */
|
||||
ecma_value_p = ecma_collection_iterator_init (ret_p);
|
||||
buffer_p = ret_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t j = 0; j < ret_p->item_count; j++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[j]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, current_name_p))
|
||||
{
|
||||
@@ -2103,12 +2092,11 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
if (is_append)
|
||||
{
|
||||
ecma_value_p = ecma_collection_iterator_init (skipped_non_enumerable_p);
|
||||
buffer_p = skipped_non_enumerable_p->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t j = 0; j < skipped_non_enumerable_p->item_count; j++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (*ecma_value_p);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[j]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, current_name_p))
|
||||
{
|
||||
@@ -2122,10 +2110,13 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT ((names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0);
|
||||
|
||||
ecma_append_to_values_collection (ret_p, ecma_make_prop_name_value (names_p[i]), 0);
|
||||
ecma_collection_push_back (ret_p, ecma_make_prop_name_value (name_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (names_p);
|
||||
@@ -2140,7 +2131,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
prototype_chain_iter_p->u2.prototype_cp);
|
||||
}
|
||||
|
||||
ecma_free_values_collection (skipped_non_enumerable_p, 0);
|
||||
ecma_collection_free (skipped_non_enumerable_p);
|
||||
|
||||
return ret_p;
|
||||
} /* ecma_op_object_get_property_names */
|
||||
|
||||
@@ -57,7 +57,7 @@ bool ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, ecma_s
|
||||
ecma_property_descriptor_t *prop_desc_p);
|
||||
ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value);
|
||||
bool ecma_op_object_is_prototype_of (ecma_object_t *base_p, ecma_object_t *target_p);
|
||||
ecma_collection_header_t * ecma_op_object_get_property_names (ecma_object_t *obj_p, uint32_t opts);
|
||||
ecma_collection_t * ecma_op_object_get_property_names (ecma_object_t *obj_p, uint32_t opts);
|
||||
|
||||
lit_magic_string_id_t ecma_object_get_class_name (ecma_object_t *obj_p);
|
||||
bool ecma_object_class_is (ecma_object_t *object_p, uint32_t class_id);
|
||||
|
||||
@@ -145,15 +145,14 @@ ecma_set_already_resolved_value (ecma_value_t already_resolved, /**< the already
|
||||
* See also: ES2015 25.4.1.8
|
||||
*/
|
||||
static void
|
||||
ecma_promise_trigger_reactions (ecma_collection_header_t *reactions, /**< lists of reactions */
|
||||
ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reactions */
|
||||
ecma_value_t value) /**< value for resolve or reject */
|
||||
{
|
||||
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (reactions);
|
||||
ecma_value_t *buffer_p = reactions->buffer_p;
|
||||
|
||||
while (ecma_value_p != NULL)
|
||||
for (uint32_t i = 0; i < reactions->item_count; i++)
|
||||
{
|
||||
ecma_enqueue_promise_reaction_job (*ecma_value_p, value);
|
||||
ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
|
||||
ecma_enqueue_promise_reaction_job (buffer_p[i], value);
|
||||
}
|
||||
} /* ecma_promise_trigger_reactions */
|
||||
|
||||
@@ -174,19 +173,19 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */
|
||||
ecma_promise_set_result (obj_p, ecma_copy_value_if_not_object (reason));
|
||||
ecma_promise_object_t *promise_p = (ecma_promise_object_t *) obj_p;
|
||||
|
||||
/* GC can be triggered by ecma_new_values_collection so freeing the collection
|
||||
/* GC can be triggered by ecma_new_collection so freeing the collection
|
||||
first and creating a new one might cause a heap after use event. */
|
||||
ecma_collection_header_t *reject_reactions = promise_p->reject_reactions;
|
||||
ecma_collection_header_t *fulfill_reactions = promise_p->fulfill_reactions;
|
||||
ecma_collection_t *reject_reactions = promise_p->reject_reactions;
|
||||
ecma_collection_t *fulfill_reactions = promise_p->fulfill_reactions;
|
||||
|
||||
/* Fulfill reactions will never be triggered. */
|
||||
ecma_promise_trigger_reactions (reject_reactions, reason);
|
||||
|
||||
promise_p->reject_reactions = ecma_new_values_collection ();
|
||||
promise_p->fulfill_reactions = ecma_new_values_collection ();
|
||||
promise_p->reject_reactions = ecma_new_collection ();
|
||||
promise_p->fulfill_reactions = ecma_new_collection ();
|
||||
|
||||
ecma_free_values_collection (reject_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
ecma_free_values_collection (fulfill_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
ecma_collection_free_if_not_object (reject_reactions);
|
||||
ecma_collection_free_if_not_object (fulfill_reactions);
|
||||
} /* ecma_reject_promise */
|
||||
|
||||
/**
|
||||
@@ -206,19 +205,19 @@ ecma_fulfill_promise (ecma_value_t promise, /**< promise */
|
||||
ecma_promise_set_result (obj_p, ecma_copy_value_if_not_object (value));
|
||||
ecma_promise_object_t *promise_p = (ecma_promise_object_t *) obj_p;
|
||||
|
||||
/* GC can be triggered by ecma_new_values_collection so freeing the collection
|
||||
/* GC can be triggered by ecma_new_collection so freeing the collection
|
||||
first and creating a new one might cause a heap after use event. */
|
||||
ecma_collection_header_t *reject_reactions = promise_p->reject_reactions;
|
||||
ecma_collection_header_t *fulfill_reactions = promise_p->fulfill_reactions;
|
||||
ecma_collection_t *reject_reactions = promise_p->reject_reactions;
|
||||
ecma_collection_t *fulfill_reactions = promise_p->fulfill_reactions;
|
||||
|
||||
/* Reject reactions will never be triggered. */
|
||||
ecma_promise_trigger_reactions (fulfill_reactions, value);
|
||||
|
||||
promise_p->reject_reactions = ecma_new_values_collection ();
|
||||
promise_p->fulfill_reactions = ecma_new_values_collection ();
|
||||
promise_p->reject_reactions = ecma_new_collection ();
|
||||
promise_p->fulfill_reactions = ecma_new_collection ();
|
||||
|
||||
ecma_free_values_collection (reject_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
ecma_free_values_collection (fulfill_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
ecma_collection_free_if_not_object (reject_reactions);
|
||||
ecma_collection_free_if_not_object (fulfill_reactions);
|
||||
} /* ecma_fulfill_promise */
|
||||
|
||||
/**
|
||||
@@ -502,8 +501,8 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function
|
||||
/* 5 */
|
||||
ecma_promise_set_state (object_p, ECMA_PROMISE_STATE_PENDING);
|
||||
/* 6-7. */
|
||||
promise_object_p->fulfill_reactions = ecma_new_values_collection ();
|
||||
promise_object_p->reject_reactions = ecma_new_values_collection ();
|
||||
promise_object_p->fulfill_reactions = ecma_new_collection ();
|
||||
promise_object_p->reject_reactions = ecma_new_collection ();
|
||||
/* 8. */
|
||||
ecma_promise_resolving_functions_t *funcs = ecma_promise_create_resolving_functions (object_p);
|
||||
|
||||
@@ -706,13 +705,8 @@ ecma_promise_do_then (ecma_value_t promise, /**< the promise which call 'then' *
|
||||
if (ecma_promise_get_state (obj_p) == ECMA_PROMISE_STATE_PENDING)
|
||||
{
|
||||
/* 7. */
|
||||
ecma_append_to_values_collection (promise_p->fulfill_reactions,
|
||||
ecma_make_object_value (fulfill_reaction_p),
|
||||
ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
|
||||
ecma_append_to_values_collection (promise_p->reject_reactions,
|
||||
ecma_make_object_value (reject_reaction_p),
|
||||
ECMA_COLLECTION_NO_REF_OBJECTS);
|
||||
ecma_collection_push_back (promise_p->fulfill_reactions, ecma_make_object_value (fulfill_reaction_p));
|
||||
ecma_collection_push_back (promise_p->reject_reactions, ecma_make_object_value (reject_reaction_p));
|
||||
}
|
||||
else if (ecma_promise_get_state (obj_p) == ECMA_PROMISE_STATE_FULFILLED)
|
||||
{
|
||||
|
||||
@@ -64,8 +64,8 @@ typedef struct
|
||||
{
|
||||
ecma_extended_object_t ecma_extended_object_t; /**< extended object part */
|
||||
uint8_t state; /**< promise state, see ecma_promise_state_t */
|
||||
ecma_collection_header_t *fulfill_reactions; /**< list of PromiseFullfillReactions */
|
||||
ecma_collection_header_t *reject_reactions; /**< list of PromiseRejectReactions */
|
||||
ecma_collection_t *fulfill_reactions; /**< list of PromiseFullfillReactions */
|
||||
ecma_collection_t *reject_reactions; /**< list of PromiseRejectReactions */
|
||||
} ecma_promise_object_t;
|
||||
|
||||
bool ecma_is_promise (ecma_object_t *obj_p);
|
||||
|
||||
@@ -91,17 +91,16 @@ ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, /**< a String obj
|
||||
* false - list all properties into main
|
||||
* collection.
|
||||
*/
|
||||
ecma_collection_header_t *main_collection_p, /**< 'main'
|
||||
* collection */
|
||||
ecma_collection_header_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p, /**< 'main' collection */
|
||||
ecma_collection_t *non_enum_collection_p) /**< skipped
|
||||
* 'non-enumerable'
|
||||
* collection */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
ecma_collection_header_t *for_enumerable_p = main_collection_p;
|
||||
ecma_collection_t *for_enumerable_p = main_collection_p;
|
||||
|
||||
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
ecma_collection_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
JERRY_ASSERT (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_STRING_UL);
|
||||
@@ -115,14 +114,10 @@ ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, /**< a String obj
|
||||
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
/* the properties are enumerable (ECMA-262 v5, 15.5.5.2.9) */
|
||||
ecma_append_to_values_collection (for_enumerable_p, ecma_make_string_value (name_p), 0);
|
||||
|
||||
ecma_deref_ecma_string (name_p);
|
||||
ecma_collection_push_back (for_enumerable_p, ecma_make_string_value (name_p));
|
||||
}
|
||||
|
||||
ecma_append_to_values_collection (for_non_enumerable_p,
|
||||
ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
|
||||
0);
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
} /* ecma_op_string_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,8 +31,8 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, ecma_length_
|
||||
void
|
||||
ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p,
|
||||
bool separate_enumerable,
|
||||
ecma_collection_header_t *main_collection_p,
|
||||
ecma_collection_header_t *non_enum_collection_p);
|
||||
ecma_collection_t *main_collection_p,
|
||||
ecma_collection_t *non_enum_collection_p);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -765,8 +765,7 @@ ecma_is_typedarray (ecma_value_t value) /**< the target need to be checked */
|
||||
*/
|
||||
void
|
||||
ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, /**< a TypedArray object */
|
||||
ecma_collection_header_t *main_collection_p) /**< 'main'
|
||||
* collection */
|
||||
ecma_collection_t *main_collection_p) /**< 'main' collection */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (obj_p)));
|
||||
|
||||
@@ -776,9 +775,7 @@ ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, /**< a TypedA
|
||||
{
|
||||
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
ecma_append_to_values_collection (main_collection_p, ecma_make_string_value (name_p), 0);
|
||||
|
||||
ecma_deref_ecma_string (name_p);
|
||||
ecma_collection_push_back (main_collection_p, ecma_make_string_value (name_p));
|
||||
}
|
||||
} /* ecma_op_typedarray_list_lazy_property_names */
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void ecma_set_typedarray_element (lit_utf8_byte_t *dst_p,
|
||||
ecma_number_t ecma_get_typedarray_element (lit_utf8_byte_t *src,
|
||||
lit_magic_string_id_t class_id);
|
||||
void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p,
|
||||
ecma_collection_header_t *main_collection_p);
|
||||
ecma_collection_t *main_collection_p);
|
||||
ecma_value_t ecma_op_typedarray_get_index_prop (ecma_object_t *obj_p, uint32_t index);
|
||||
bool ecma_op_typedarray_define_index_prop (ecma_object_t *obj_p,
|
||||
uint32_t index,
|
||||
|
||||
Reference in New Issue
Block a user