5#ifndef V8_OBJECTS_HEAP_OBJECT_H_
6#define V8_OBJECTS_HEAP_OBJECT_H_
24class PrimitiveHeapObject;
25class ExternalPointerSlot;
26class IndirectPointerSlot;
27class ExposedTrustedObject;
29class WritableFreeSpace;
43 template <
typename IsolateT>
49 template <
typename IsolateT>
58 template <
typename IsolateT>
89 inline int Size()
const;
105 void PrintHeader(std::ostream& os,
const char*
id);
158 template <
typename IsolateT>
178 template <
typename IsolateT>
180 template <
typename IsolateT>
186 inline bool release_compare_and_swap_map_word_forwarded(
191 inline bool relaxed_compare_and_swap_map_word_forwarded(
196 template <
typename IsolateT>
240 requires(std::is_arithmetic_v<T> || std::is_enum_v<T> ||
241 std::is_pointer_v<T>)
248 requires(std::is_arithmetic_v<T> || std::is_enum_v<T> ||
249 std::is_pointer_v<T>)
257 inline T Relaxed_ReadField(
size_t offset)
const
258 requires((std::is_arithmetic_v<T> || std::is_enum_v<T>) &&
259 !std::is_floating_point_v<T>);
264 inline void Relaxed_WriteField(
size_t offset, T value)
265 requires((std::is_arithmetic_v<T> || std::is_enum_v<T>) &&
266 !std::is_floating_point_v<T>);
271 inline T Acquire_ReadField(
size_t offset)
const
272 requires((std::is_arithmetic_v<T> || std::is_enum_v<T>) &&
273 !std::is_floating_point_v<T>);
277 template <
typename CompareAndSwapImpl>
280 CompareAndSwapImpl compare_and_swap_impl);
302 template <ExternalPo
interTag tag>
306 template <ExternalPo
interTagRange tag_range>
310 template <CppHeapPo
interTag lower_bound, CppHeapPo
interTag upper_bound>
316 template <ExternalPo
interTag tag>
334 inline bool IsLazilyInitializedExternalPointerFieldInitialized(
343 template <ExternalPo
interTag tag>
344 inline void WriteLazilyInitializedExternalPointerField(
347 inline void SetupLazilyInitializedCppHeapPointerField(
size_t offset);
348 template <CppHeapPo
interTag tag>
373 template <IndirectPo
interTag tag>
376 template <IndirectPo
interTag tag>
381 template <IndirectPo
interTag tag>
385 template <IndirectPo
interTag tag>
386 inline void WriteTrustedPointerField(
size_t offset,
394 inline bool IsTrustedPointerFieldEmpty(
size_t offset)
const;
395 inline bool IsTrustedPointerFieldUnpublished(
size_t offset,
398 inline void ClearTrustedPointerField(
size_t offest);
411 inline bool IsCodePointerFieldEmpty(
size_t offset)
const;
412 inline void ClearCodePointerField(
size_t offest);
424 template <
typename ObjectType>
434 inline ObjectSlot RawField(
int byte_offset)
const;
452 void HeapObjectShortPrint(std::ostream& os);
457 void PrintHeader(std::ostream& os,
const char*
id);
463 inline void VerifySmiField(
int offset);
464 inline void VerifyMaybeObjectField(
Isolate* isolate,
int offset);
487 template <
typename IsolateT>
488 void RehashBasedOnMap(IsolateT* isolate);
498 inline Address GetFieldAddress(
int field_offset)
const;
513 template <
typename T>
514 static bool IsSmi(T obj);
515 template <
typename T>
525 kPotentialLayoutChange,
533 template <EmitWriteBarrier emit_write_barrier,
typename MemoryOrder,
567#define IS_TYPE_FUNCTION_DECL(Type) \
568 V8_INLINE bool Is##Type(Tagged<HeapObject> obj); \
569 V8_INLINE bool Is##Type(Tagged<HeapObject> obj, PtrComprCageBase cage_base); \
570 V8_INLINE bool Is##Type(HeapObject obj); \
571 V8_INLINE bool Is##Type(HeapObject obj, PtrComprCageBase cage_base); \
572 V8_INLINE bool Is##Type(const HeapObjectLayout* obj); \
573 V8_INLINE bool Is##Type(const HeapObjectLayout* obj, \
574 PtrComprCageBase cage_base);
579#undef IS_TYPE_FUNCTION_DECL
583#define IS_TYPE_FUNCTION_DECL(Type, Value, _) \
584 V8_INLINE bool Is##Type(Tagged<HeapObject> obj); \
585 V8_INLINE bool Is##Type(HeapObject obj); \
586 V8_INLINE bool Is##Type(const HeapObjectLayout* obj, Isolate* isolate); \
587 V8_INLINE bool Is##Type(const HeapObjectLayout* obj);
591#undef IS_TYPE_FUNCTION_DECL
593#define DECL_STRUCT_PREDICATE(NAME, Name, name) \
594 V8_INLINE bool Is##Name(Tagged<HeapObject> obj); \
595 V8_INLINE bool Is##Name(Tagged<HeapObject> obj, PtrComprCageBase cage_base); \
596 V8_INLINE bool Is##Name(HeapObject obj); \
597 V8_INLINE bool Is##Name(HeapObject obj, PtrComprCageBase cage_base); \
598 V8_INLINE bool Is##Name(const HeapObjectLayout* obj); \
599 V8_INLINE bool Is##Name(const HeapObjectLayout* obj, \
600 PtrComprCageBase cage_base);
602#undef DECL_STRUCT_PREDICATE
#define DCHECK_TAG_ALIGNED(address)
void set_map_safe_transition_no_write_barrier(Isolate *isolate, Tagged< Map > value, RelaxedStoreTag=kRelaxedStore)
MapWord map_word(RelaxedLoadTag) const
WriteBarrierMode GetWriteBarrierMode(const DisallowGarbageCollection &promise)
void set_map_after_allocation(IsolateT *isolate, Tagged< Map > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
ReadOnlyRoots EarlyGetReadOnlyRoots() const
void set_map(Isolate *isolate, Tagged< Map > value)
Tagged< Map > map() const
void set_map_word_forwarded(Tagged< HeapObject > target_object, ReleaseStoreTag)
void set_map_safe_transition(IsolateT *isolate, Tagged< Map > value, ReleaseStoreTag)
HeapObjectLayout()=delete
HeapObjectLayout(HeapObjectLayout &&) V8_NOEXCEPT=delete
void set_map_no_write_barrier(Isolate *isolate, Tagged< Map > value, RelaxedStoreTag=kRelaxedStore)
V8_EXPORT_PRIVATE int SizeFromMap(Tagged< Map > map) const
const HeapObject * operator->() const
static Tagged< HeapObject > FromAddress(Address address)
constexpr HeapObject()=default
V8_INLINE void set_map(IsolateT *isolate, Tagged< Map > value, MemoryOrder order, VerificationMode mode)
Address field_address(size_t offset) const
T ReadField(size_t offset) const
HeapObject * operator->()
V8_INLINE constexpr HeapObject(Address ptr, HeapObject::SkipTypeCheckTag)
void WriteField(size_t offset, T value) const
static const int kHeapObjectMapOffset
constexpr bool IsSmi() const
constexpr bool IsHeapObject() const
V8_INLINE T * ToRawPtr() const
V8_INLINE constexpr decltype(auto) operator*() const
V8_INLINE constexpr decltype(auto) operator->() const
#define DECL_STRUCT_PREDICATE(NAME, Name, name)
#define IS_TYPE_FUNCTION_DECL(Type)
V8_INLINE void WriteExternalPointerField(Address field_address, IsolateForSandbox isolate, Address value)
V8_INLINE Address ReadCppHeapPointerField(Address field_address, IsolateForPointerCompression isolate)
V8_INLINE Address ReadCodeEntrypointViaCodePointerField(Address field_address, CodeEntrypointTag tag)
constexpr int kTaggedSize
bool operator!=(ExternalReference lhs, ExternalReference rhs)
V8_INLINE size_t ReadBoundedSizeField(Address field_address)
Tagged(T object) -> Tagged< T >
static void WriteMaybeUnalignedValue(Address p, V value)
V8_INLINE Address ReadSandboxedPointerField(Address field_address, PtrComprCageBase cage_base)
V8_INLINE void WriteLazilyInitializedCppHeapPointerField(Address field_address, IsolateForPointerCompression isolate, Address value)
V8_INLINE void WriteBoundedSizeField(Address field_address, size_t value)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
kInterpreterTrampolineOffset Tagged< HeapObject >
V8_INLINE Address ReadExternalPointerField(Address field_address, IsolateForSandbox isolate)
void Print(Tagged< Object > obj)
v8::internal::LoadHandler V8_OBJECT_END
V8_INLINE bool OutsideSandboxOrInReadonlySpace(Tagged< HeapObject > obj)
V8_INLINE void InitSelfIndirectPointerField(Address field_address, IsolateForSandbox isolate, Tagged< HeapObject > host, IndirectPointerTag tag, TrustedPointerPublishingScope *opt_publishing_scope)
V8_INLINE constexpr bool IsHeapObject(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE void InitExternalPointerField(Address host_address, Address field_address, IsolateForSandbox isolate, Address value)
NameDictionary PropertyDictionary
V8_INLINE void SetupLazilyInitializedExternalPointerField(Address field_address)
V8_INLINE void WriteSandboxedPointerField(Address field_address, PtrComprCageBase cage_base, Address pointer)
bool operator==(ExternalReference lhs, ExternalReference rhs)
constexpr bool kAllCodeObjectsLiveInTrustedSpace
static V ReadMaybeUnalignedValue(Address p)
V8_INLINE void WriteCodeEntrypointViaCodePointerField(Address field_address, Address value, CodeEntrypointTag tag)
V8_INLINE constexpr bool FastInReadOnlySpaceOrSmallSmi(Tagged_t obj)
static constexpr RelaxedStoreTag kRelaxedStore
#define HEAP_OBJECT_TYPE_LIST(V)
#define DECL_GETTER(name,...)
#define DECL_ACQUIRE_GETTER(name,...)
#define DECL_RELAXED_GETTER(name,...)
#define DECL_PRINTER(Name)
#define EXPORT_DECL_VERIFIER(Name)
#define V8_EXPORT_PRIVATE
typename T::BodyDescriptor BodyDescriptor