Skip to content

Commit 97be8bf

Browse files
committed
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
1 parent 41337db commit 97be8bf

File tree

3 files changed

+275
-364
lines changed

3 files changed

+275
-364
lines changed

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,7 @@ typedef struct
817817
*/
818818
typedef enum
819819
{
820-
ECMA_STRING_CONTAINER_HEAP_ASCII_STRING, /**< actual data is on the heap as an ascii string */
821-
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */
820+
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 (cesu8) string */
822821
ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
823822
stored locally in the string's descriptor */
824823
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
880879
*/
881880
union
882881
{
883-
/** Index of string in literal table */
884-
jmem_cpointer_t lit_cp;
885-
886-
/** Compressed pointer to an ecma_collection_header_t */
887-
jmem_cpointer_t utf8_collection_cp;
888-
889882
/**
890-
* Actual data of an ascii string type
883+
* Actual data of an utf-8 string type
891884
*/
892885
struct
893886
{
894-
/** Compressed pointer to a raw character array */
895-
jmem_cpointer_t ascii_collection_cp;
896-
/** Size of ascii string in bytes */
897-
uint16_t size;
898-
} ascii_string;
899-
900-
/** Compressed pointer to an ecma_number_t */
901-
jmem_cpointer_t number_cp;
887+
uint16_t size; /**< Size of this utf-8 string in bytes */
888+
uint16_t length; /**< Length of this utf-8 string in characters */
889+
} utf8_string;
902890

903891
/** UInt32-represented number placed locally in the descriptor */
904892
uint32_t uint32_number;

0 commit comments

Comments
 (0)