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:
Robert Fancsik
2019-08-30 15:16:27 +02:00
committed by GitHub
parent f0578b2c25
commit c6a4a86257
15 changed files with 799 additions and 618 deletions
+29 -4
View File
@@ -24,9 +24,6 @@ JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
JERRY_STATIC_ASSERT (((sizeof (ecma_property_value_t) - 1) & sizeof (ecma_property_value_t)) == 0,
size_of_ecma_property_value_t_must_be_power_of_2);
JERRY_STATIC_ASSERT (sizeof (ecma_string_t) == sizeof (uint64_t),
size_of_ecma_string_t_must_be_less_than_or_equal_to_8_bytes);
JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <= sizeof (uint64_t),
size_of_ecma_extended_object_part_must_be_less_than_or_equal_to_8_bytes);
@@ -155,7 +152,35 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
} /* ecma_dealloc_string */
/**
* Allocate memory for string with character data
* Allocate memory for extended ecma-string descriptor
*
* @return pointer to allocated memory
*/
inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_extended_string (void)
{
#if ENABLED (JERRY_MEM_STATS)
jmem_stats_allocate_string_bytes (sizeof (ecma_extended_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */
return (ecma_extended_string_t *) jmem_heap_alloc_block (sizeof (ecma_extended_string_t));
} /* ecma_alloc_extended_string */
/**
* Dealloc memory from extended ecma-string descriptor
*/
inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extended string to be freed */
{
#if ENABLED (JERRY_MEM_STATS)
jmem_stats_free_string_bytes (sizeof (ecma_extended_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
} /* ecma_dealloc_extended_string */
/**
* Allocate memory for an string with character data
*
* @return pointer to allocated memory
*/