@@ -686,19 +686,45 @@ typedef enum
686
686
ECMA_STRING_CONTAINER_UINT32_IN_DESC , /**< actual data is UInt32-represeneted Number
687
687
stored locally in the string's descriptor */
688
688
ECMA_STRING_CONTAINER_MAGIC_STRING , /**< the ecma-string is equal to one of ECMA magic strings */
689
- ECMA_STRING_CONTAINER_MAGIC_STRING_EX /**< the ecma-string is equal to one of external magic strings */
689
+ ECMA_STRING_CONTAINER_MAGIC_STRING_EX , /**< the ecma-string is equal to one of external magic strings */
690
+
691
+ ECMA_STRING_CONTAINER__MAX = ECMA_STRING_CONTAINER_MAGIC_STRING_EX /**< maximum value */
690
692
} ecma_string_container_t ;
691
693
694
+ /**
695
+ * Mask for getting the container of a string.
696
+ */
697
+ #define ECMA_STRING_CONTAINER_MASK 0x7u
698
+
699
+ /**
700
+ * Value for increasing or decreasing the reference counter.
701
+ */
702
+ #define ECMA_STRING_REF_ONE (1u << 3)
703
+
704
+ /**
705
+ * Maximum value of the reference counter (8191).
706
+ */
707
+ #define ECMA_STRING_MAX_REF (0x1fffu << 3)
708
+
709
+ /**
710
+ * Set reference counter to zero (for refs_and_container member below).
711
+ */
712
+ #define ECMA_STRING_SET_REF_TO_ONE (refs_and_container ) \
713
+ ((uint16_t) (((refs_and_container) & ECMA_STRING_CONTAINER_MASK) | ECMA_STRING_REF_ONE))
714
+
715
+ /**
716
+ * Returns with the container type of a string.
717
+ */
718
+ #define ECMA_STRING_GET_CONTAINER (string_desc_p ) \
719
+ ((ecma_string_container_t) ((string_desc_p)->refs_and_container & ECMA_STRING_CONTAINER_MASK))
720
+
692
721
/**
693
722
* ECMA string-value descriptor
694
723
*/
695
724
typedef struct ecma_string_t
696
725
{
697
726
/** 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 ;
727
+ uint16_t refs_and_container ;
702
728
703
729
/** Hash of the string (calculated from two last characters of the string) */
704
730
lit_string_hash_t hash ;
@@ -712,10 +738,10 @@ typedef struct ecma_string_t
712
738
mem_cpointer_t lit_cp ;
713
739
714
740
/** Compressed pointer to an ecma_collection_header_t */
715
- __extension__ mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH ;
741
+ mem_cpointer_t collection_cp ;
716
742
717
743
/** Compressed pointer to an ecma_number_t */
718
- __extension__ mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH ;
744
+ mem_cpointer_t number_cp ;
719
745
720
746
/** UInt32-represented number placed locally in the descriptor */
721
747
uint32_t uint32_number ;
0 commit comments