Improve ecma_string_t descriptor (#3016)
This patch introduces several changes conntect to ecma-strings: - Extend the size of the reference counter to 28 bytes from 13 - Extend the size of the string hash to 32 bytes from 16 to use the extact FNV-1a hash - Introduce ECMA_STATIC_STRING_FLAG to reduce the number of string ref/derefs for static strings. - Introduce ECMA_STRING_CONTAINER_ASCII_STRING to store run-time allocated ASCII strings more efficiently - Remove ECMA_STRING_CONTAINER_LIT_NUMBER to half the storage size of the parsing time allocated floating point numbers - Rework the global number storage, to store only the floating point numbers - Optimize the lookup in the global number/string/symbol tables via reduce the number of NULL checks during decompressing the next element pointers - Reduce the code duplication in ecma_concat_ecma_strings and ecma_append_chars_to_string - Improve ecma_string_get_char with optional arguments to make it more reusable. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -102,11 +102,14 @@ ecma_builtin_symbol_for_helper (ecma_value_t value_to_find) /**< symbol or ecma-
|
||||
string_p = ecma_get_symbol_from_value (value_to_find);
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *symbol_list_p = JERRY_CONTEXT (symbol_list_first_p);
|
||||
jmem_cpointer_t symbol_list_cp = JERRY_CONTEXT (symbol_list_first_cp);
|
||||
jmem_cpointer_t *empty_cpointer_p = NULL;
|
||||
|
||||
while (symbol_list_p != NULL)
|
||||
while (symbol_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *symbol_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
symbol_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
@@ -145,7 +148,7 @@ ecma_builtin_symbol_for_helper (ecma_value_t value_to_find) /**< symbol or ecma-
|
||||
}
|
||||
}
|
||||
|
||||
symbol_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, symbol_list_p->next_cp);
|
||||
symbol_list_cp = symbol_list_p->next_cp;
|
||||
}
|
||||
|
||||
if (!is_for)
|
||||
@@ -175,8 +178,8 @@ ecma_builtin_symbol_for_helper (ecma_value_t value_to_find) /**< symbol or ecma-
|
||||
new_item_p->values[i] = JMEM_CP_NULL;
|
||||
}
|
||||
|
||||
JMEM_CP_SET_POINTER (new_item_p->next_cp, JERRY_CONTEXT (symbol_list_first_p));
|
||||
JERRY_CONTEXT (symbol_list_first_p) = new_item_p;
|
||||
new_item_p->next_cp = JERRY_CONTEXT (symbol_list_first_cp);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (symbol_list_first_cp), new_item_p);
|
||||
|
||||
return ecma_copy_value (ecma_make_symbol_value (new_symbol_p));
|
||||
} /* ecma_builtin_symbol_for_helper */
|
||||
|
||||
@@ -659,9 +659,9 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (string_p)))
|
||||
{
|
||||
if (string_p->hash & ECMA_GLOBAL_SYMBOL_FLAG)
|
||||
if (string_p->u.hash & ECMA_GLOBAL_SYMBOL_FLAG)
|
||||
{
|
||||
magic_string_id = (string_p->hash >> ECMA_GLOBAL_SYMBOL_SHIFT);
|
||||
magic_string_id = (string_p->u.hash >> ECMA_GLOBAL_SYMBOL_SHIFT);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
@@ -802,7 +802,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
|
||||
ecma_string_t *symbol_p = ecma_new_symbol_from_descriptor_string (symbol_desc_value);
|
||||
lit_magic_string_id_t symbol_id = (lit_magic_string_id_t) curr_property_p->value;
|
||||
symbol_p->hash = (uint16_t) ((symbol_id << ECMA_GLOBAL_SYMBOL_SHIFT) | ECMA_GLOBAL_SYMBOL_FLAG);
|
||||
symbol_p->u.hash = (uint16_t) ((symbol_id << ECMA_GLOBAL_SYMBOL_SHIFT) | ECMA_GLOBAL_SYMBOL_FLAG);
|
||||
|
||||
value = ecma_make_symbol_value (symbol_p);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user