@@ -689,16 +689,35 @@ typedef enum
689689 ECMA_STRING_CONTAINER_MAGIC_STRING_EX /**< the ecma-string is equal to one of external magic strings */
690690} ecma_string_container_t ;
691691
692+ /**
693+ * ECMA string related constants
694+ */
695+ typedef enum
696+ {
697+ ECMA_STRING_CONTAINER_MASK = 0x7u , /**< container mask */
698+ ECMA_STRING_REF_ONE = 1u << 3 , /**< value for increasing or decreasing the reference counter */
699+ ECMA_STRING_MAX_REF = 0x1fffu << 3 , /**< maximum value of the reference counter (8191) */
700+ } ecma_string_constants_t ;
701+
702+ /**
703+ * Set reference counter to zero (for refs_and_container member below).
704+ */
705+ #define ECMA_STRING_SET_REF_TO_ONE (refs_and_container ) \
706+ ((uint16_t) (((refs_and_container) & ECMA_STRING_CONTAINER_MASK) | ECMA_STRING_REF_ONE))
707+
708+ /**
709+ * Returns with the container type of a string.
710+ */
711+ #define ECMA_STRING_GET_CONTAINER (string_desc_p ) \
712+ ((ecma_string_container_t) ((string_desc_p)->refs_and_container & ECMA_STRING_CONTAINER_MASK))
713+
692714/**
693715 * ECMA string-value descriptor
694716 */
695717typedef struct ecma_string_t
696718{
697719 /** Reference counter for the string */
698- unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH ;
699-
700- /** Where the string's data is placed (ecma_string_container_t) */
701- uint8_t container ;
720+ uint16_t refs_and_container ;
702721
703722 /** Hash of the string (calculated from two last characters of the string) */
704723 lit_string_hash_t hash ;
@@ -712,10 +731,10 @@ typedef struct ecma_string_t
712731 mem_cpointer_t lit_cp ;
713732
714733 /** Compressed pointer to an ecma_collection_header_t */
715- __extension__ mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH ;
734+ mem_cpointer_t collection_cp ;
716735
717736 /** Compressed pointer to an ecma_number_t */
718- __extension__ mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH ;
737+ mem_cpointer_t number_cp ;
719738
720739 /** UInt32-represented number placed locally in the descriptor */
721740 uint32_t uint32_number ;
0 commit comments