Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out addresses that are not in bookkeeping range during background promote #77067

Merged
merged 4 commits into from
Oct 21, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25188,6 +25188,13 @@ void gc_heap::background_promote (Object** ppObject, ScanContext* sc, uint32_t f
if (o == 0)
return;

#if defined(FEATURE_CONSERVATIVE_GC) && defined(USE_REGIONS)
cshung marked this conversation as resolved.
Show resolved Hide resolved
if (!is_in_bookkeeping_range (o))
cshung marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
#endif

#ifdef DEBUG_DestroyedHandleValue
// we can race with destroy handle during concurrent scan
if (o == (uint8_t*)DEBUG_DestroyedHandleValue)
Expand Down Expand Up @@ -35952,6 +35959,13 @@ void gc_heap::background_promote_callback (Object** ppObject, ScanContext* sc,
if (o == 0)
return;

#if defined(FEATURE_CONSERVATIVE_GC) && defined(USE_REGIONS)
if (!is_in_bookkeeping_range (o))
cshung marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
#endif

HEAP_FROM_THREAD;

gc_heap* hp = gc_heap::heap_of (o);
Expand Down Expand Up @@ -45881,6 +45895,13 @@ void GCHeap::Promote(Object** ppObject, ScanContext* sc, uint32_t flags)
if (o == 0)
return;

#if defined(FEATURE_CONSERVATIVE_GC) && defined(USE_REGIONS)
if (!gc_heap::is_in_bookkeeping_range (o))
{
return;
}
#endif

#ifdef DEBUG_DestroyedHandleValue
// we can race with destroy handle during concurrent scan
if (o == (uint8_t*)DEBUG_DestroyedHandleValue)
Expand All @@ -45892,7 +45913,7 @@ void GCHeap::Promote(Object** ppObject, ScanContext* sc, uint32_t flags)
gc_heap* hp = gc_heap::heap_of (o);

#ifdef USE_REGIONS
if (!gc_heap::is_in_bookkeeping_range (o) || !gc_heap::is_in_condemned_gc (o))
if (!gc_heap::is_in_condemned_gc (o))
#else //USE_REGIONS
if ((o < hp->gc_low) || (o >= hp->gc_high))
#endif //USE_REGIONS
Expand Down Expand Up @@ -45952,11 +45973,11 @@ void GCHeap::Relocate (Object** ppObject, ScanContext* sc,
dprintf (3, ("R: %Ix", (size_t)ppObject));

if (!object
#ifdef USE_REGIONS
#if defined(USE_REGIONS) && defined(FEATURE_CONSERVATIVE_GC)
|| !gc_heap::is_in_bookkeeping_range (object))
#else //USE_REGIONS
#else //USE_REGIONS && FEATURE_CONSERVATIVE_GC
|| !((object >= g_gc_lowest_address) && (object < g_gc_highest_address)))
#endif //USE_REGIONS
#endif //USE_REGIONS && FEATURE_CONSERVATIVE_GC
return;

gc_heap* hp = gc_heap::heap_of (object);
Expand Down Expand Up @@ -46408,20 +46429,21 @@ GCHeap::GetContainingObject (void *pInteriorPtr, bool fCollectedGenOnly)
{
uint8_t *o = (uint8_t*)pInteriorPtr;

#if defined(FEATURE_CONSERVATIVE_GC) && defined(USE_REGIONS)
if (!gc_heap::is_in_bookkeeping_range (o))
{
return NULL;
}
#endif

gc_heap* hp = gc_heap::heap_of (o);

#ifdef USE_REGIONS
if (gc_heap::is_in_bookkeeping_range (o))
{
if (fCollectedGenOnly && !gc_heap::is_in_condemned_gc (o))
{
return NULL;
}
}
else
if (fCollectedGenOnly && !gc_heap::is_in_condemned_gc (o))
{
return NULL;
}

#else //USE_REGIONS

uint8_t* lowest = (fCollectedGenOnly ? hp->gc_low : hp->lowest_address);
Expand Down