5#ifndef INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
6#define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
19class CrossThreadPersistentRegion;
20class FatalOutOfMemoryHandler;
56 trace_(root_visitor,
owner_);
59 bool IsUsed()
const {
return trace_; }
78 using PersistentNodeSlots = std::array<PersistentNode, 256u>;
100 node = free_list_head_;
113 free_list_head_ = node;
122 template <
typename PersistentBaseClass>
123 void ClearAllUsedNodes();
125 void RefillFreeList();
127 std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
129 size_t nodes_in_use_ = 0;
130 const FatalOutOfMemoryHandler& oom_handler_;
148 auto* node = TryAllocateNodeFromFreeList(owner, trace);
153 return RefillFreeListAndAllocateNode(owner, trace);
158 PersistentRegionBase::FreeNode(node);
162 bool IsCreationThread();
164 int creation_thread_id_;
191 PersistentRegionLock::AssertLocked();
192 auto* node = TryAllocateNodeFromFreeList(owner, trace);
195 return RefillFreeListAndAllocateNode(owner, trace);
199 PersistentRegionLock::AssertLocked();
200 PersistentRegionBase::FreeNode(node);
void Iterate(RootVisitor &)
CrossThreadPersistentRegion(const CrossThreadPersistentRegion &)=delete
size_t NodesInUse() const
~CrossThreadPersistentRegion()
V8_INLINE PersistentNode * AllocateNode(void *owner, TraceRootCallback trace)
CrossThreadPersistentRegion(const FatalOutOfMemoryHandler &)
CrossThreadPersistentRegion & operator=(const CrossThreadPersistentRegion &)=delete
V8_INLINE void FreeNode(PersistentNode *node)
void UpdateOwner(void *owner)
PersistentNode(const PersistentNode &)=delete
void Trace(RootVisitor &root_visitor) const
PersistentNode * FreeListNext() const
void InitializeAsUsedNode(void *owner, TraceRootCallback trace)
void InitializeAsFreeNode(PersistentNode *next)
PersistentNode & operator=(const PersistentNode &)=delete
void Iterate(RootVisitor &)
PersistentRegionBase(const FatalOutOfMemoryHandler &oom_handler)
size_t NodesInUse() const
PersistentNode * RefillFreeListAndAllocateNode(void *owner, TraceRootCallback trace)
PersistentRegionBase & operator=(const PersistentRegionBase &)=delete
PersistentRegionBase(const PersistentRegionBase &)=delete
void FreeNode(PersistentNode *node)
PersistentNode * TryAllocateNodeFromFreeList(void *owner, TraceRootCallback trace)
~PersistentRegion()=default
PersistentRegion & operator=(const PersistentRegion &)=delete
V8_INLINE PersistentNode * AllocateNode(void *owner, TraceRootCallback 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(*)(RootVisitor &, const void *object) TraceRootCallback
#define V8_LIKELY(condition)