5#ifndef INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
6#define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
19class CrossThreadPersistentRegion;
20class FatalOutOfMemoryHandler;
57 trace_(root_visitor,
owner_);
60 bool IsUsed()
const {
return trace_; }
79 using PersistentNodeSlots = std::array<PersistentNode, 256u>;
101 node = free_list_head_;
114 free_list_head_ = node;
123 template <
typename PersistentBaseClass>
124 void ClearAllUsedNodes();
126 void RefillFreeList();
128 std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
130 size_t nodes_in_use_ = 0;
131 const FatalOutOfMemoryHandler& oom_handler_;
141 const FatalOutOfMemoryHandler& oom_handler)
153 auto* node = TryAllocateNodeFromFreeList(owner, trace);
158 return RefillFreeListAndAllocateNode(owner, trace);
163 PersistentRegionBase::FreeNode(node);
167 bool IsCreationThread();
169 const HeapBase& heap_;
196 PersistentRegionLock::AssertLocked();
197 auto* node = TryAllocateNodeFromFreeList(owner, trace);
200 return RefillFreeListAndAllocateNode(owner, trace);
204 PersistentRegionLock::AssertLocked();
205 PersistentRegionBase::FreeNode(node);
Definition: persistent-node.h:185
void FreeNode(PersistentNode *node)
Definition: persistent-node.h:203
CrossThreadPersistentRegion & operator=(const CrossThreadPersistentRegion &)=delete
size_t NodesInUse() const
PersistentNode * AllocateNode(void *owner, TraceRootCallback trace)
Definition: persistent-node.h:195
~CrossThreadPersistentRegion()
CrossThreadPersistentRegion(const FatalOutOfMemoryHandler &)
void Iterate(RootVisitor &)
CrossThreadPersistentRegion(const CrossThreadPersistentRegion &)=delete
Definition: persistent-node.h:27
void UpdateOwner(void *owner)
Definition: persistent-node.h:45
void InitializeAsFreeNode(PersistentNode *next)
Definition: persistent-node.h:40
void Trace(RootVisitor &root_visitor) const
Definition: persistent-node.h:55
bool IsUsed() const
Definition: persistent-node.h:60
PersistentNode(const PersistentNode &)=delete
PersistentNode * FreeListNext() const
Definition: persistent-node.h:50
PersistentNode * next_
Definition: persistent-node.h:73
void * owner() const
Definition: persistent-node.h:62
void InitializeAsUsedNode(void *owner, TraceRootCallback trace)
Definition: persistent-node.h:34
void * owner_
Definition: persistent-node.h:72
PersistentNode & operator=(const PersistentNode &)=delete
Definition: persistent-node.h:78
PersistentRegionBase(const FatalOutOfMemoryHandler &oom_handler)
PersistentRegionBase & operator=(const PersistentRegionBase &)=delete
PersistentNode * RefillFreeListAndAllocateNode(void *owner, TraceRootCallback trace)
PersistentNode * TryAllocateNodeFromFreeList(void *owner, TraceRootCallback trace)
Definition: persistent-node.h:97
void FreeNode(PersistentNode *node)
Definition: persistent-node.h:110
size_t NodesInUse() const
void Iterate(RootVisitor &)
PersistentRegionBase(const PersistentRegionBase &)=delete
Definition: persistent-node.h:174
static void AssertLocked()
Definition: persistent-node.h:138
PersistentRegion(const PersistentRegion &)=delete
~PersistentRegion()=default
PersistentRegion(const HeapBase &heap, const FatalOutOfMemoryHandler &oom_handler)
Definition: persistent-node.h:140
PersistentNode * AllocateNode(void *owner, TraceRootCallback trace)
Definition: persistent-node.h:151
PersistentRegion & operator=(const PersistentRegion &)=delete
void FreeNode(PersistentNode *node)
Definition: persistent-node.h:161
Definition: visitor.h:441
#define CPPGC_DCHECK(condition)
Definition: logging.h:36
#define CPPGC_CHECK(condition)
Definition: logging.h:45
void(*)(RootVisitor &, const void *object) TraceRootCallback
Definition: trace-trait.h:21
Definition: allocation.h:38
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_LIKELY(condition)
Definition: v8config.h:650