5 #ifndef V8_OBJECTS_HEAP_OBJECT_H_ 6 #define V8_OBJECTS_HEAP_OBJECT_H_ 8 #include "src/globals.h" 10 #include "src/objects.h" 13 #include "src/objects/object-macros.h" 23 constexpr
ObjectPtr() : ptr_(kNullAddress) {}
27 operator Object*()
const {
return reinterpret_cast<Object*
>(ptr()); }
29 bool operator==(
const ObjectPtr other)
const {
30 return this->ptr() == other.ptr();
32 bool operator!=(
const ObjectPtr other)
const {
33 return this->ptr() != other.ptr();
36 bool operator<(
const ObjectPtr other)
const {
37 return this->ptr() < other.ptr();
41 constexpr
Address ptr()
const {
return ptr_; }
44 const ObjectPtr* operator->()
const {
return this; }
46 #define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const; 47 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
48 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
49 #undef IS_TYPE_FUNCTION_DECL 50 #define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const; 51 STRUCT_LIST(DECL_STRUCT_PREDICATE)
52 #undef DECL_STRUCT_PREDICATE 53 #define IS_TYPE_FUNCTION_DECL(Type, Value) \ 54 V8_INLINE bool Is##Type(Isolate* isolate) const; \ 55 V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \ 56 V8_INLINE bool Is##Type() const; 57 ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
58 #undef IS_TYPE_FUNCTION_DECL 59 inline bool IsHashTableBase()
const;
60 V8_INLINE
bool IsSmallOrderedHashTable()
const;
62 inline bool IsObject()
const {
return true; }
63 inline double Number()
const;
64 inline bool ToInt32(int32_t* value)
const;
65 inline bool ToUint32(
uint32_t* value)
const;
68 bool BooleanValue(
Isolate* isolate);
70 inline bool FilterKey(PropertyFilter filter);
84 V8_EXPORT_PRIVATE
bool SameValue(
Object* other);
89 V8_WARN_UNUSED_RESULT
inline bool ToArrayIndex(
uint32_t* index)
const;
92 void ObjectVerify(
Isolate* isolate) {
93 reinterpret_cast<Object*
>(ptr())->ObjectVerify(isolate);
99 inline void ShortPrint(FILE* out = stdout);
100 void ShortPrint(std::ostream& os);
102 inline void Print(std::ostream& os);
106 size_t operator()(
const ObjectPtr o)
const {
107 return std::hash<v8::internal::Address>{}(o.ptr());
117 bool ObjectPtr::IsSmi()
const {
return HAS_SMI_TAG(ptr()); }
118 bool ObjectPtr::IsHeapObject()
const {
119 DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr()));
126 inline Map map()
const;
127 inline void set_map(
Map value);
128 inline void set_map_after_allocation(
129 Map value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
133 inline void set_map_no_write_barrier(
Map value);
136 inline MapWord map_word()
const;
137 inline void set_map_word(
MapWord map_word);
140 inline void synchronized_set_map(
Map value);
141 inline void synchronized_set_map_word(
MapWord map_word);
143 inline WriteBarrierMode GetWriteBarrierMode(
149 return reinterpret_cast<const HeapObject*
>(ptr());
152 bool is_null()
const {
return ptr() == kNullAddress; }
154 bool IsHeapObjectPtr()
const {
return IsHeapObject(); }
158 #define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const; 159 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
160 #undef IS_TYPE_FUNCTION_DECL 163 inline Address address()
const {
return ptr() - kHeapObjectTag; }
165 inline int Size()
const;
166 inline int SizeFromMap(
Map map)
const;
168 inline ObjectSlot RawField(
int byte_offset)
const;
172 void PrintHeader(std::ostream& os,
const char*
id);
174 void HeapObjectVerify(
Isolate* isolate);
180 inline void VerifyObjectField(
Isolate* isolate,
int offset);
181 inline void VerifySmiField(
int offset);
182 inline void VerifyMaybeObjectField(
Isolate* isolate,
int offset);
185 static const int kMapOffset = HeapObject::kMapOffset;
186 static const int kHeaderSize = HeapObject::kHeaderSize;
188 inline Address GetFieldAddress(
int field_offset)
const;
193 enum class AllowInlineSmiStorage { kRequireHeapObjectTag, kAllowBeingASmi };
217 #include "src/objects/object-macros-undef.h" 219 #endif // V8_OBJECTS_HEAP_OBJECT_H_