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