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