Skip to content

Commit cee537e

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 3de4170 commit cee537e

File tree

2 files changed

+197
-51
lines changed

2 files changed

+197
-51
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ typedef struct
697697
typedef enum
698698
{
699699
ECMA_STRING_CONTAINER_LIT_TABLE, /**< actual data is in literal table */
700-
ECMA_STRING_CONTAINER_HEAP_CHUNKS, /**< actual data is on the heap
701-
in a ecma_collection_chunk_t chain */
700+
ECMA_STRING_CONTAINER_HEAP_ASCII_STRING, /**< actual data is on the heap as an ascii string */
701+
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */
702702
ECMA_STRING_CONTAINER_HEAP_NUMBER, /**< actual data is on the heap as a ecma_number_t */
703703
ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
704704
stored locally in the string's descriptor */
@@ -755,7 +755,18 @@ typedef struct ecma_string_t
755755
mem_cpointer_t lit_cp;
756756

757757
/** Compressed pointer to an ecma_collection_header_t */
758-
mem_cpointer_t collection_cp;
758+
mem_cpointer_t utf8_collection_cp;
759+
760+
/**
761+
* Actual data of an ascii string type
762+
*/
763+
struct
764+
{
765+
/** Compressed pointer to a raw character array */
766+
mem_cpointer_t ascii_collection_cp;
767+
/** Size of ascii string in bytes */
768+
uint16_t size;
769+
} ascii_string_t;
759770

760771
/** Compressed pointer to an ecma_number_t */
761772
mem_cpointer_t number_cp;

0 commit comments

Comments
 (0)