1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-10 01:50:53 +09:00

AppendUnsafe

This commit is contained in:
vsadov 2022-02-28 23:43:54 -08:00
parent 25a8cb6cfe
commit 3ec3cb96a4
3 changed files with 41 additions and 8 deletions

View file

@ -50,6 +50,7 @@ enum class QueueKind
RecyclerStaying,
RecyclerRelocating,
RecyclerRelocated,
RecyclerUpdating,
RecyclerRelocatedToHigherGen,
RecyclerRelocationTarget,
@ -150,6 +151,32 @@ public:
m_tail = item;
}
void AppendUnsafe(SatoriQueue<T>* 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)
{
{

View file

@ -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())

View file

@ -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;