Skip to content

Commit 24a9813

Browse files
committed
Improve the string descriptor.
Separate the utf-8 and ascii strings. In case of ascii strings the size is equal to the length, so we able to store this information in the string descriptor instead of using the string header to store it. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent 19b972b commit 24a9813

File tree

2 files changed

+186
-51
lines changed

2 files changed

+186
-51
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ typedef struct
717717
typedef enum
718718
{
719719
ECMA_STRING_CONTAINER_LIT_TABLE, /**< actual data is in literal table */
720-
ECMA_STRING_CONTAINER_HEAP_CHUNKS, /**< actual data is on the heap
721-
in a ecma_collection_chunk_t chain */
720+
ECMA_STRING_CONTAINER_HEAP_ASCII_STRING, /**< actual data is on the heap as an ascii string */
722721
ECMA_STRING_CONTAINER_HEAP_NUMBER, /**< actual data is on the heap as a ecma_number_t */
722+
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */
723723
ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
724724
stored locally in the string's descriptor */
725725
ECMA_STRING_CONTAINER_MAGIC_STRING, /**< the ecma-string is equal to one of ECMA magic strings */
@@ -775,7 +775,18 @@ typedef struct ecma_string_t
775775
mem_cpointer_t lit_cp;
776776

777777
/** Compressed pointer to an ecma_collection_header_t */
778-
mem_cpointer_t collection_cp;
778+
mem_cpointer_t utf8_collection_cp;
779+
780+
/**
781+
* Actual data of an ascii string type
782+
*/
783+
struct
784+
{
785+
/** Compressed pointer to a raw character array */
786+
mem_cpointer_t ascii_collection_cp;
787+
/** Size of ascii string in bytes */
788+
uint16_t size;
789+
} ascii_string_t;
779790

780791
/** Compressed pointer to an ecma_number_t */
781792
mem_cpointer_t number_cp;

0 commit comments

Comments
 (0)