22 : oom_handler_(oom_handler) {}
26template <
typename PersistentBaseClass>
28 for (
auto& slots :
nodes_) {
29 for (
auto& node : *slots) {
30 if (!node.IsUsed())
continue;
32 static_cast<PersistentBaseClass*
>(node.owner())->ClearFromGC();
55 const size_t accumulated_nodes_in_use_ = std::accumulate(
56 nodes_.cbegin(),
nodes_.cend(), 0u, [](
size_t acc,
const auto& slots) {
57 return acc + std::count_if(slots->cbegin(), slots->cend(),
58 [](const PersistentNode& node) {
62 DCHECK_EQ(accumulated_nodes_in_use_, nodes_in_use_);
67void PersistentRegionBase::RefillFreeList() {
68 auto node_slots = std::make_unique<PersistentNodeSlots>();
69 if (!node_slots.get()) {
70 oom_handler_(
"Oilpan: PersistentRegionBase::RefillFreeList()");
72 nodes_.push_back(std::move(node_slots));
73 for (
auto& node : *
nodes_.back()) {
74 node.InitializeAsFreeNode(free_list_head_);
75 free_list_head_ = &
node;
82 auto* node = TryAllocateNodeFromFreeList(owner, trace);
87void PersistentRegionBase::Iterate(
RootVisitor& root_visitor) {
88 free_list_head_ =
nullptr;
89 for (
auto& slots :
nodes_) {
91 for (
auto& node : *slots) {
93 node.Trace(root_visitor);
96 node.InitializeAsFreeNode(free_list_head_);
97 free_list_head_ = &
node;
104 CPPGC_DCHECK(!first_next || first_next < &slots->front() ||
105 first_next > &slots->back());
106 free_list_head_ = first_next;
111 [](
const auto& ptr) { return !ptr; }),
115bool PersistentRegion::IsCreationThread() {
116 return heap_.CurrentThreadIsHeapThread();
119PersistentRegionLock::PersistentRegionLock() {
120 ProcessGlobalLock::Lock<
121 ProcessGlobalLock::Reason::kForCrossThreadHandleCreation>();
124PersistentRegionLock::~PersistentRegionLock() {
125 ProcessGlobalLock::Unlock<
126 ProcessGlobalLock::Reason::kForCrossThreadHandleCreation>();
130void PersistentRegionLock::AssertLocked() { ProcessGlobalLock::AssertHeld(); }
132CrossThreadPersistentRegion::CrossThreadPersistentRegion(
size_t NodesInUse() const
~CrossThreadPersistentRegion()
void Iterate(RootVisitor &)
PersistentNode * FreeListNext() const
std::vector< std::unique_ptr< PersistentNodeSlots > > nodes_
size_t NodesInUse() const
void Iterate(RootVisitor &)
PersistentRegionBase(const PersistentRegionBase &)=delete
PersistentNode * free_list_head_
static void AssertLocked()
ZoneLinkedList< BFEntry > nodes_
#define CPPGC_DCHECK(condition)
void(*)(RootVisitor &, const void *object) TraceRootCallback
#define DCHECK_EQ(v1, v2)