From 3ec3cb96a4168e8816e7a5c17add890791156401 Mon Sep 17 00:00:00 2001 From: vsadov <8218165+VSadov@users.noreply.github.com> Date: Mon, 28 Feb 2022 23:43:54 -0800 Subject: [PATCH] AppendUnsafe --- src/coreclr/gc/satori/SatoriQueue.h | 27 ++++++++++++++++++++++++ src/coreclr/gc/satori/SatoriRecycler.cpp | 19 ++++++++++------- src/coreclr/gc/satori/SatoriRecycler.h | 3 +++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/coreclr/gc/satori/SatoriQueue.h b/src/coreclr/gc/satori/SatoriQueue.h index 00f0080b6d1..43e4b77856e 100644 --- a/src/coreclr/gc/satori/SatoriQueue.h +++ b/src/coreclr/gc/satori/SatoriQueue.h @@ -50,6 +50,7 @@ enum class QueueKind RecyclerStaying, RecyclerRelocating, RecyclerRelocated, + RecyclerUpdating, RecyclerRelocatedToHigherGen, RecyclerRelocationTarget, @@ -150,6 +151,32 @@ public: m_tail = item; } + void AppendUnsafe(SatoriQueue* other) + { + size_t otherCount = other->Count(); + if (otherCount == 0) + { + return; + } + + m_count += otherCount; + + if (m_tail == nullptr) + { + _ASSERTE(m_head == nullptr); + m_head = other->m_head; + } + else + { + other->m_head->m_prev = m_tail; + m_tail->m_next = other->m_head; + } + + m_tail = other->m_tail; + other->m_head = other->m_tail = nullptr; + other->m_count = 0; + } + bool TryRemove(T* item) { { diff --git a/src/coreclr/gc/satori/SatoriRecycler.cpp b/src/coreclr/gc/satori/SatoriRecycler.cpp index c93f64fbe49..dc04dbb6269 100644 --- a/src/coreclr/gc/satori/SatoriRecycler.cpp +++ b/src/coreclr/gc/satori/SatoriRecycler.cpp @@ -86,6 +86,7 @@ void SatoriRecycler::Initialize(SatoriHeap* heap) m_tenuredFinalizationTrackingRegions = new SatoriRegionQueue(QueueKind::RecyclerTenuredFinalizationTracking); m_finalizationPendingRegions = new SatoriRegionQueue(QueueKind::RecyclerFinalizationPending); + m_updateRegions = new SatoriRegionQueue(QueueKind::RecyclerUpdating); m_stayingRegions = new SatoriRegionQueue(QueueKind::RecyclerStaying); m_relocatingRegions = new SatoriRegionQueue(QueueKind::RecyclerRelocating); @@ -2834,6 +2835,15 @@ void SatoriRecycler::Update() RunWithHelp(&SatoriRecycler::UpdateRootsWorker); + + // collect all regions that need updating. + for (int i = 0; i < Satori::FREELIST_COUNT; i++) + { + m_updateRegions->AppendUnsafe(m_relocationTargets[i]); + } + + m_updateRegions->AppendUnsafe(m_stayingRegions); + // must run after updating through cards since update may change generations RunWithHelp(&SatoriRecycler::UpdateRegionsWorker); @@ -2914,14 +2924,7 @@ void SatoriRecycler::UpdateRootsWorker() void SatoriRecycler::UpdateRegionsWorker() { - // update and return target regions - for (int i = 0; i < Satori::FREELIST_COUNT; i++) - { - UpdateRegions(m_relocationTargets[i]); - } - - // update and return staying regions - UpdateRegions(m_stayingRegions); + UpdateRegions(m_updateRegions); // if we saw large objects we may have ranges to update if (!m_workQueue->IsEmpty()) diff --git a/src/coreclr/gc/satori/SatoriRecycler.h b/src/coreclr/gc/satori/SatoriRecycler.h index a9a38ed2724..0c641715e90 100644 --- a/src/coreclr/gc/satori/SatoriRecycler.h +++ b/src/coreclr/gc/satori/SatoriRecycler.h @@ -102,6 +102,9 @@ private: // temporary store while processing finalizables SatoriRegionQueue* m_finalizationPendingRegions; + // temporary store of regions to update + SatoriRegionQueue* m_updateRegions; + // temporary store for planning and relocating SatoriRegionQueue* m_stayingRegions; SatoriRegionQueue* m_relocatingRegions;