Skip to content

Commit bfb049f

Browse files
committed
MSFT:17387958 Large tracked RecyclerVisited objects need to clear the NewTrackBit after they are processed.
1 parent e8e9baa commit bfb049f

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

lib/Common/Memory/LargeHeapBlock.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,11 +1003,7 @@ LargeHeapBlock::VerifyMark()
10031003

10041004
unsigned char attributes = header->GetAttributes(this->heapInfo->recycler->Cookie);
10051005

1006-
// In case of OOM we may not have completed processing of trackable objects and the NewFinalizeBit may not have been cleared.
1007-
if ((attributes & (TrackBit | NewTrackBit)) == (TrackBit | NewTrackBit))
1008-
{
1009-
Assert((attributes & NewFinalizeBit) == 0);
1010-
}
1006+
Assert((attributes & NewFinalizeBit) == 0);
10111007

10121008
if ((attributes & LeafBit) != 0)
10131009
{
@@ -1304,7 +1300,7 @@ LargeHeapBlock::RescanOnePage(Recycler * recycler)
13041300
// As such, our finalizeCount is not correct. Update it now.
13051301

13061302
RECYCLER_STATS_INC(recycler, finalizeCount);
1307-
header->SetAttributes(this->heapInfo->recycler->Cookie, (attributes & ~NewFinalizeBit));
1303+
header->SetAttributes(recycler->Cookie, (attributes & ~NewFinalizeBit));
13081304
}
13091305
#endif
13101306

@@ -1332,6 +1328,12 @@ LargeHeapBlock::RescanOnePage(Recycler * recycler)
13321328
if (attributes & TrackBit)
13331329
{
13341330
noOOMDuringMark = recycler->AddPreciselyTracedMark(reinterpret_cast<IRecyclerVisitedObject*>(objectAddress));
1331+
if (noOOMDuringMark)
1332+
{
1333+
// Object has been successfully processed, so clear NewTrackBit
1334+
header->SetAttributes(recycler->Cookie, (attributes & ~NewTrackBit));
1335+
RECYCLER_STATS_INTERLOCKED_INC(recycler, trackCount);
1336+
}
13351337
}
13361338
else
13371339
#endif
@@ -1418,7 +1420,7 @@ LargeHeapBlock::RescanMultiPage(Recycler * recycler)
14181420
continue;
14191421
}
14201422

1421-
unsigned char attributes = header->GetAttributes(this->heapInfo->recycler->Cookie);
1423+
unsigned char attributes = header->GetAttributes(recycler->Cookie);
14221424

14231425
#ifdef RECYCLER_STATS
14241426
if (((attributes & FinalizeBit) != 0) && ((attributes & NewFinalizeBit) != 0))
@@ -1427,7 +1429,7 @@ LargeHeapBlock::RescanMultiPage(Recycler * recycler)
14271429
// As such, our finalizeCount is not correct. Update it now.
14281430

14291431
RECYCLER_STATS_INC(recycler, finalizeCount);
1430-
header->SetAttributes(this->heapInfo->recycler->Cookie, (attributes & ~NewFinalizeBit));
1432+
header->SetAttributes(recycler->Cookie, (attributes & ~NewFinalizeBit));
14311433
}
14321434
#endif
14331435

@@ -1460,6 +1462,12 @@ LargeHeapBlock::RescanMultiPage(Recycler * recycler)
14601462
if (attributes & TrackBit)
14611463
{
14621464
noOOMDuringMark = recycler->AddPreciselyTracedMark(reinterpret_cast<IRecyclerVisitedObject*>(objectAddress));
1465+
if (noOOMDuringMark)
1466+
{
1467+
// Object has been successfully processed, so clear NewTrackBit
1468+
header->SetAttributes(recycler->Cookie, (attributes & ~NewTrackBit));
1469+
RECYCLER_STATS_INTERLOCKED_INC(recycler, trackCount);
1470+
}
14631471
}
14641472
else
14651473
#endif
@@ -1570,6 +1578,12 @@ LargeHeapBlock::RescanMultiPage(Recycler * recycler)
15701578
header->markOnOOMRescan = true;
15711579
}
15721580
}
1581+
else
1582+
{
1583+
// Object has been successfully processed, so clear NewTrackBit
1584+
header->SetAttributes(recycler->Cookie, (attributes & ~NewTrackBit));
1585+
RECYCLER_STATS_INTERLOCKED_INC(recycler, trackCount);
1586+
}
15731587

15741588
rescanCount = objectSize / AutoSystemInfo::PageSize +
15751589
(objectSize % AutoSystemInfo::PageSize != 0 ? 1 : 0);
@@ -1989,11 +2003,7 @@ LargeHeapBlock::SweepObjects(Recycler * recycler)
19892003
{
19902004
#if DBG
19912005
unsigned char attributes = header->GetAttributes(recycler->Cookie);
1992-
// In case of OOM we may not have completed processing of trackable objects and the NewFinalizeBit may not have been cleared.
1993-
if ((attributes & (TrackBit | NewTrackBit)) == (TrackBit | NewTrackBit))
1994-
{
1995-
Assert((attributes & NewFinalizeBit) == 0);
1996-
}
2006+
Assert((attributes & NewFinalizeBit) == 0);
19972007
#endif
19982008

19992009
RECYCLER_STATS_ADD(recycler, largeHeapBlockUsedByteCount, this->GetHeaderByIndex(i)->objectSize);

0 commit comments

Comments
 (0)