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

enable regions for AoT #76737

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 14 additions & 16 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7925,18 +7925,12 @@ bool gc_heap::is_in_condemned_gc (uint8_t* o)
return true;
}

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

inline
Expand Down Expand Up @@ -45898,7 +45892,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_condemned (o))
if (!gc_heap::is_in_bookkeeping_range (o) || !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 @@ -45957,7 +45951,12 @@ void GCHeap::Relocate (Object** ppObject, ScanContext* sc,
//dprintf (3, ("Relocate location %Ix\n", (size_t)ppObject));
dprintf (3, ("R: %Ix", (size_t)ppObject));

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

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

#ifdef USE_REGIONS
if (fCollectedGenOnly)
if (gc_heap::is_in_bookkeeping_range (o))
{
if (!gc_heap::is_in_condemned (o))
if (fCollectedGenOnly && !gc_heap::is_in_condemned_gc (o))
{
return NULL;
}
}
else
{
if (!((o >= g_gc_lowest_address) && (o < g_gc_highest_address)))
return NULL;
return NULL;
}
#else //USE_REGIONS

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void FATAL_GC_ERROR()
// This means any empty regions can be freely used for any generation. For
// Server GC we will balance regions between heaps.
// For now disable regions for StandAlone GC, NativeAOT and MacOS builds
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(FEATURE_NATIVEAOT)
#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__)
#define USE_REGIONS
#endif //HOST_64BIT && BUILD_AS_STANDALONE

Expand Down Expand Up @@ -3142,7 +3142,7 @@ class gc_heap
bool is_in_condemned_gc (uint8_t* o);
// requires checking if o is in the heap range first.
PER_HEAP_ISOLATED
bool is_in_condemned (uint8_t* o);
bool is_in_bookkeeping_range (uint8_t* o);
PER_HEAP_ISOLATED
bool should_check_brick_for_reloc (uint8_t* o);
#endif //USE_REGIONS
Expand Down