Simplify string management.

Allocate a single memory block for strings, rather than a separate string header
and string characters block. In the past strings were split into 8 byte chunks,
and large amount of legacy code is designed for that representation. However the
current allocator allows block allocation so we don't need those complicated
algorithms anymore. This patch is a cleanup rather than an optimization.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2016-07-06 03:47:48 -07:00
parent 41337dbd59
commit 97be8bfbc8
3 changed files with 295 additions and 384 deletions
+5 -17
View File
@@ -817,8 +817,7 @@ typedef struct
*/
typedef enum
{
ECMA_STRING_CONTAINER_HEAP_ASCII_STRING, /**< actual data is on the heap as an ascii string */
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 (cesu8) string */
ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
stored locally in the string's descriptor */
ECMA_STRING_CONTAINER_MAGIC_STRING, /**< the ecma-string is equal to one of ECMA magic strings */
@@ -880,25 +879,14 @@ typedef struct ecma_string_t
*/
union
{
/** Index of string in literal table */
jmem_cpointer_t lit_cp;
/** Compressed pointer to an ecma_collection_header_t */
jmem_cpointer_t utf8_collection_cp;
/**
* Actual data of an ascii string type
* Actual data of an utf-8 string type
*/
struct
{
/** Compressed pointer to a raw character array */
jmem_cpointer_t ascii_collection_cp;
/** Size of ascii string in bytes */
uint16_t size;
} ascii_string;
/** Compressed pointer to an ecma_number_t */
jmem_cpointer_t number_cp;
uint16_t size; /**< Size of this utf-8 string in bytes */
uint16_t length; /**< Length of this utf-8 string in characters */
} utf8_string;
/** UInt32-represented number placed locally in the descriptor */
uint32_t uint32_number;