Skip to content

Commit cb6e5e7

Browse files
authored
filtering out addresses conservatively reported that land in the GC range but not in bookkeeping range (#76737)
this fixes the last issue standing in the way of enabling regions for AoT. AoT could conservatively report addresses that land in the GC heap range but not in range that bookkeeping covers. so these need to filtered out.
1 parent 415a417 commit cb6e5e7

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

src/coreclr/gc/gc.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7925,18 +7925,12 @@ bool gc_heap::is_in_condemned_gc (uint8_t* o)
79257925
return true;
79267926
}
79277927

7928-
// REGIONS TODO -
7929-
// This method can be called by GCHeap::Promote/Relocate which means
7930-
// it could be in the heap range but not actually in a valid region.
7931-
// This would return true but find_object will return 0. But this
7932-
// seems counter-intuitive so we should consider a better implementation.
7928+
// This needs to check the range that's covered by bookkeeping because find_object will
7929+
// need to look at the brick table.
79337930
inline
7934-
bool gc_heap::is_in_condemned (uint8_t* o)
7931+
bool gc_heap::is_in_bookkeeping_range (uint8_t* o)
79357932
{
7936-
if ((o >= g_gc_lowest_address) && (o < g_gc_highest_address))
7937-
return is_in_condemned_gc (o);
7938-
else
7939-
return false;
7933+
return ((o >= g_gc_lowest_address) && (o < bookkeeping_covered_committed));
79407934
}
79417935

79427936
inline
@@ -45898,7 +45892,7 @@ void GCHeap::Promote(Object** ppObject, ScanContext* sc, uint32_t flags)
4589845892
gc_heap* hp = gc_heap::heap_of (o);
4589945893

4590045894
#ifdef USE_REGIONS
45901-
if (!gc_heap::is_in_condemned (o))
45895+
if (!gc_heap::is_in_bookkeeping_range (o) || !gc_heap::is_in_condemned_gc (o))
4590245896
#else //USE_REGIONS
4590345897
if ((o < hp->gc_low) || (o >= hp->gc_high))
4590445898
#endif //USE_REGIONS
@@ -45957,7 +45951,12 @@ void GCHeap::Relocate (Object** ppObject, ScanContext* sc,
4595745951
//dprintf (3, ("Relocate location %Ix\n", (size_t)ppObject));
4595845952
dprintf (3, ("R: %Ix", (size_t)ppObject));
4595945953

45960-
if (!object || !((object >= g_gc_lowest_address) && (object < g_gc_highest_address)))
45954+
if (!object
45955+
#ifdef USE_REGIONS
45956+
|| !gc_heap::is_in_bookkeeping_range (object))
45957+
#else //USE_REGIONS
45958+
|| !((object >= g_gc_lowest_address) && (object < g_gc_highest_address)))
45959+
#endif //USE_REGIONS
4596145960
return;
4596245961

4596345962
gc_heap* hp = gc_heap::heap_of (object);
@@ -46412,17 +46411,16 @@ GCHeap::GetContainingObject (void *pInteriorPtr, bool fCollectedGenOnly)
4641246411
gc_heap* hp = gc_heap::heap_of (o);
4641346412

4641446413
#ifdef USE_REGIONS
46415-
if (fCollectedGenOnly)
46414+
if (gc_heap::is_in_bookkeeping_range (o))
4641646415
{
46417-
if (!gc_heap::is_in_condemned (o))
46416+
if (fCollectedGenOnly && !gc_heap::is_in_condemned_gc (o))
4641846417
{
4641946418
return NULL;
4642046419
}
4642146420
}
4642246421
else
4642346422
{
46424-
if (!((o >= g_gc_lowest_address) && (o < g_gc_highest_address)))
46425-
return NULL;
46423+
return NULL;
4642646424
}
4642746425
#else //USE_REGIONS
4642846426

src/coreclr/gc/gcpriv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ inline void FATAL_GC_ERROR()
5252
// This means any empty regions can be freely used for any generation. For
5353
// Server GC we will balance regions between heaps.
5454
// For now disable regions for StandAlone GC, NativeAOT and MacOS builds
55-
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(FEATURE_NATIVEAOT)
55+
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__)
5656
#define USE_REGIONS
5757
#endif //HOST_64BIT && BUILD_AS_STANDALONE
5858

@@ -3142,7 +3142,7 @@ class gc_heap
31423142
bool is_in_condemned_gc (uint8_t* o);
31433143
// requires checking if o is in the heap range first.
31443144
PER_HEAP_ISOLATED
3145-
bool is_in_condemned (uint8_t* o);
3145+
bool is_in_bookkeeping_range (uint8_t* o);
31463146
PER_HEAP_ISOLATED
31473147
bool should_check_brick_for_reloc (uint8_t* o);
31483148
#endif //USE_REGIONS

0 commit comments

Comments
 (0)