5#ifndef INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
6#define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
22class CrossThreadPersistentRegion;
23class FatalOutOfMemoryHandler;
61 bool IsUsed()
const {
return trace_; }
80 using PersistentNodeSlots = std::array<PersistentNode, 256u>;
102 node = free_list_head_;
115 free_list_head_ = node;
124 template <
typename PersistentBaseClass>
125 void ClearAllUsedNodes();
127 void RefillFreeList();
129 std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
131 size_t nodes_in_use_ = 0;
132 const FatalOutOfMemoryHandler& oom_handler_;
150 auto* node = TryAllocateNodeFromFreeList(owner, trace);
155 return RefillFreeListAndAllocateNode(owner, trace);
160 PersistentRegionBase::FreeNode(node);
164 bool IsCreationThread();
166 int creation_thread_id_;
193 PersistentRegionLock::AssertLocked();
194 auto* node = TryAllocateNodeFromFreeList(owner, trace);
197 return RefillFreeListAndAllocateNode(owner, trace);
201 PersistentRegionLock::AssertLocked();
202 PersistentRegionBase::FreeNode(node);
CrossThreadPersistentRegion(const CrossThreadPersistentRegion &)=delete
size_t NodesInUse() const
~CrossThreadPersistentRegion()
V8_INLINE PersistentNode * AllocateNode(void *owner, TraceCallback trace)
CrossThreadPersistentRegion(const FatalOutOfMemoryHandler &)
CrossThreadPersistentRegion & operator=(const CrossThreadPersistentRegion &)=delete
V8_INLINE void FreeNode(PersistentNode *node)
void UpdateOwner(void *owner)
PersistentNode(const PersistentNode &)=delete
PersistentNode * FreeListNext() const
void InitializeAsUsedNode(void *owner, TraceCallback trace)
void InitializeAsFreeNode(PersistentNode *next)
PersistentNode & operator=(const PersistentNode &)=delete
void Trace(Visitor *visitor) const
PersistentNode * TryAllocateNodeFromFreeList(void *owner, TraceCallback trace)
PersistentRegionBase(const FatalOutOfMemoryHandler &oom_handler)
size_t NodesInUse() const
PersistentRegionBase & operator=(const PersistentRegionBase &)=delete
PersistentRegionBase(const PersistentRegionBase &)=delete
void FreeNode(PersistentNode *node)
PersistentNode * RefillFreeListAndAllocateNode(void *owner, TraceCallback trace)
~PersistentRegion()=default
PersistentRegion & operator=(const PersistentRegion &)=delete
V8_INLINE PersistentNode * AllocateNode(void *owner, TraceCallback trace)
PersistentRegion(const FatalOutOfMemoryHandler &)
PersistentRegion(const PersistentRegion &)=delete
V8_INLINE void FreeNode(PersistentNode *node)
static void AssertLocked()
#define CPPGC_DCHECK(condition)
#define CPPGC_CHECK(condition)
void(*)(Visitor *visitor, const void *object) TraceCallback
#define V8_LIKELY(condition)