5 #ifndef V8_OBJECTS_NAME_INL_H_ 6 #define V8_OBJECTS_NAME_INL_H_ 8 #include "src/objects/name.h" 10 #include "src/heap/heap-inl.h" 11 #include "src/heap/heap-write-barrier.h" 12 #include "src/objects/map-inl.h" 15 #include "src/objects/object-macros.h" 20 OBJECT_CONSTRUCTORS_IMPL(Name, HeapObjectPtr)
21 OBJECT_CONSTRUCTORS_IMPL(Symbol, Name)
24 CAST_ACCESSOR2(Symbol)
26 ACCESSORS(Symbol, name, Object, kNameOffset)
27 INT_ACCESSORS(Symbol, flags, kFlagsOffset)
28 BIT_FIELD_ACCESSORS(Symbol, flags, is_private, Symbol::IsPrivateBit)
29 BIT_FIELD_ACCESSORS(Symbol, flags, is_well_known_symbol,
30 Symbol::IsWellKnownSymbolBit)
31 BIT_FIELD_ACCESSORS(Symbol, flags, is_public, Symbol::IsPublicBit)
32 BIT_FIELD_ACCESSORS(Symbol, flags, is_interesting_symbol,
33 Symbol::IsInterestingSymbolBit)
35 bool Symbol::is_private_name()
const {
36 bool value = Symbol::IsPrivateNameBit::decode(flags());
37 DCHECK_IMPLIES(value, is_private());
41 void Symbol::set_is_private_name() {
44 set_flags(Symbol::IsPrivateBit::update(flags(),
true));
45 set_flags(Symbol::IsPrivateNameBit::update(flags(),
true));
48 bool Name::IsUniqueName()
const {
49 uint32_t type = map()->instance_type();
50 return (type & (kIsNotStringMask | kIsNotInternalizedMask)) !=
51 (kStringTag | kNotInternalizedTag);
55 return READ_UINT32_FIELD(
this, kHashFieldOffset);
58 void Name::set_hash_field(
uint32_t value) {
59 WRITE_UINT32_FIELD(
this, kHashFieldOffset, value);
62 bool Name::Equals(Name other) {
63 if (other == *
this)
return true;
64 if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
65 this->IsSymbol() || other->IsSymbol()) {
68 return String::cast(*this)->SlowEquals(String::cast(other));
71 bool Name::Equals(Isolate* isolate, Handle<Name> one, Handle<Name> two) {
72 if (one.is_identical_to(two))
return true;
73 if ((one->IsInternalizedString() && two->IsInternalizedString()) ||
74 one->IsSymbol() || two->IsSymbol()) {
77 return String::SlowEquals(isolate, Handle<String>::cast(one),
78 Handle<String>::cast(two));
81 bool Name::IsHashFieldComputed(
uint32_t field) {
82 return (field & kHashNotComputedMask) == 0;
85 bool Name::HasHashCode() {
return IsHashFieldComputed(hash_field()); }
90 if (IsHashFieldComputed(field))
return field >> kHashShift;
94 return String::cast(*this)->ComputeAndSetHash(
95 Heap::FromWritableHeapObject(
this)->isolate());
98 bool Name::IsInterestingSymbol()
const {
99 return IsSymbol() && Symbol::cast(*this)->is_interesting_symbol();
102 bool Name::IsPrivate() {
103 return this->IsSymbol() && Symbol::cast(*this)->is_private();
106 bool Name::IsPrivateName() {
107 bool is_private_name =
108 this->IsSymbol() && Symbol::cast(*this)->is_private_name();
109 DCHECK_IMPLIES(is_private_name, IsPrivate());
110 return is_private_name;
113 bool Name::AsArrayIndex(
uint32_t* index) {
114 return IsString() && String::cast(*this)->AsArrayIndex(index);
118 bool Name::ContainsCachedArrayIndex(
uint32_t hash) {
119 return (hash & Name::kDoesNotContainCachedArrayIndexMask) == 0;
125 #include "src/objects/object-macros-undef.h" 127 #endif // V8_OBJECTS_NAME_INL_H_