@@ -689,16 +689,35 @@ typedef enum
689
689
ECMA_STRING_CONTAINER_MAGIC_STRING_EX /**< the ecma-string is equal to one of external magic strings */
690
690
} ecma_string_container_t ;
691
691
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
+
692
714
/**
693
715
* ECMA string-value descriptor
694
716
*/
695
717
typedef struct ecma_string_t
696
718
{
697
719
/** 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 ;
702
721
703
722
/** Hash of the string (calculated from two last characters of the string) */
704
723
lit_string_hash_t hash ;
@@ -712,10 +731,10 @@ typedef struct ecma_string_t
712
731
mem_cpointer_t lit_cp ;
713
732
714
733
/** 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 ;
716
735
717
736
/** Compressed pointer to an ecma_number_t */
718
- __extension__ mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH ;
737
+ mem_cpointer_t number_cp ;
719
738
720
739
/** UInt32-represented number placed locally in the descriptor */
721
740
uint32_t uint32_number ;
0 commit comments