5 #ifndef V8_OBJECTS_NAME_H_ 6 #define V8_OBJECTS_NAME_H_ 8 #include "src/objects.h" 9 #include "src/objects/heap-object.h" 12 #include "src/objects/object-macros.h" 23 inline void set_hash_field(
uint32_t value);
26 inline bool HasHashCode();
32 inline bool Equals(
Name other);
37 inline bool AsArrayIndex(
uint32_t* index);
44 inline bool IsInterestingSymbol()
const;
47 inline bool IsPrivate();
51 inline bool IsPrivateName();
53 inline bool IsUniqueName()
const;
55 static inline bool ContainsCachedArrayIndex(
uint32_t hash);
67 void NameShortPrint();
71 static const int kHashFieldOffset = HeapObject::kHeaderSize;
72 static const int kHeaderSize = kHashFieldOffset + kInt32Size;
79 static const int kHashNotComputedMask = 1;
80 static const int kIsNotArrayIndexMask = 1 << 1;
81 static const int kNofHashBitFields = 2;
84 static const int kHashShift = kNofHashBitFields;
88 static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift;
91 static const int kMaxCachedArrayIndexLength = 7;
95 static const int kMaxArrayIndexSize = 10;
100 static const int kArrayIndexValueBits = 24;
101 static const int kArrayIndexLengthBits =
102 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
104 STATIC_ASSERT(kArrayIndexLengthBits > 0);
105 STATIC_ASSERT(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
108 :
public BitField<unsigned int, kNofHashBitFields, kArrayIndexValueBits> {
111 :
public BitField<unsigned int, kNofHashBitFields + kArrayIndexValueBits,
112 kArrayIndexLengthBits> {};
117 static_assert(base::bits::IsPowerOfTwo(kMaxCachedArrayIndexLength + 1),
118 "(kMaxCachedArrayIndexLength + 1) must be power of two");
122 static const unsigned int kDoesNotContainCachedArrayIndexMask =
123 (~static_cast<
unsigned>(kMaxCachedArrayIndexLength)
124 << ArrayIndexLengthBits::kShift) |
125 kIsNotArrayIndexMask;
128 static const int kEmptyHashField =
129 kIsNotArrayIndexMask | kHashNotComputedMask;
132 static inline bool IsHashFieldComputed(
uint32_t field);
141 DECL_ACCESSORS(name,
Object)
143 DECL_INT_ACCESSORS(flags)
147 DECL_BOOLEAN_ACCESSORS(is_private)
152 DECL_BOOLEAN_ACCESSORS(is_well_known_symbol)
158 DECL_BOOLEAN_ACCESSORS(is_interesting_symbol)
162 DECL_BOOLEAN_ACCESSORS(is_public)
169 inline bool is_private_name()
const;
170 inline void set_is_private_name();
179 #define SYMBOL_FIELDS(V) \ 180 V(kFlagsOffset, kInt32Size) \ 181 V(kNameOffset, kTaggedSize) \ 185 DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize, SYMBOL_FIELDS)
189 #define FLAGS_BIT_FIELDS(V, _) \ 190 V(IsPrivateBit, bool, 1, _) \ 191 V(IsWellKnownSymbolBit, bool, 1, _) \ 192 V(IsPublicBit, bool, 1, _) \ 193 V(IsInterestingSymbolBit, bool, 1, _) \ 194 V(IsPrivateNameBit, bool, 1, _) 196 DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
197 #undef FLAGS_BIT_FIELDS 201 void SymbolShortPrint(std::ostream& os);
204 const char* PrivateSymbolToName()
const;
215 #include "src/objects/object-macros-undef.h" 217 #endif // V8_OBJECTS_NAME_H_