Skip to content

Commit

Permalink
Cleanup some FEATURE_... ifdefs in the GC (#103200)
Browse files Browse the repository at this point in the history
Fixes #103198
  • Loading branch information
jkotas authored Jun 11, 2024
1 parent 0686ce6 commit c897ce6
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 53 deletions.
28 changes: 8 additions & 20 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5660,8 +5660,7 @@ void* virtual_alloc (size_t size, bool use_large_pages_p, uint16_t numa_node)

if ((gc_heap::reserved_memory_limit - gc_heap::reserved_memory) < requested_size)
{
gc_heap::reserved_memory_limit =
GCScan::AskForMoreReservedMemory (gc_heap::reserved_memory_limit, requested_size);
gc_heap::reserved_memory_limit = gc_heap::reserved_memory_limit + requested_size;
if ((gc_heap::reserved_memory_limit - gc_heap::reserved_memory) < requested_size)
{
return 0;
Expand Down Expand Up @@ -7275,23 +7274,16 @@ void gc_heap::gc_thread_function ()

bool gc_heap::virtual_alloc_commit_for_heap (void* addr, size_t size, int h_number)
{
#if defined(MULTIPLE_HEAPS) && !defined(FEATURE_NATIVEAOT)
// Currently there is no way for us to specific the numa node to allocate on via hosting interfaces to
// a host. This will need to be added later.
#if !defined(FEATURE_CORECLR) && !defined(BUILD_AS_STANDALONE)
if (!CLRMemoryHosted())
#endif
#ifdef MULTIPLE_HEAPS
if (GCToOSInterface::CanEnableGCNumaAware())
{
if (GCToOSInterface::CanEnableGCNumaAware())
{
uint16_t numa_node = heap_select::find_numa_node_from_heap_no(h_number);
if (GCToOSInterface::VirtualCommit (addr, size, numa_node))
return true;
}
uint16_t numa_node = heap_select::find_numa_node_from_heap_no(h_number);
if (GCToOSInterface::VirtualCommit (addr, size, numa_node))
return true;
}
#else //MULTIPLE_HEAPS && !FEATURE_NATIVEAOT
#else //MULTIPLE_HEAPS
UNREFERENCED_PARAMETER(h_number);
#endif //MULTIPLE_HEAPS && !FEATURE_NATIVEAOT
#endif //MULTIPLE_HEAPS

//numa aware not enabled, or call failed --> fallback to VirtualCommit()
return GCToOSInterface::VirtualCommit(addr, size);
Expand Down Expand Up @@ -43942,11 +43934,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
#ifdef HOST_64BIT
max(min(min(soh_segment_size/32, dd_max_size (dd0)), (generation_size (max_generation) / 10)), (size_t)desired_allocation);
#else
#ifdef FEATURE_CORECLR
desired_allocation;
#else
dd_max_size (dd0);
#endif //FEATURE_CORECLR
#endif // HOST_64BIT

uint8_t *decommit_target = heap_segment_allocated (ephemeral_heap_segment) + slack_space;
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/gc/gcee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,12 @@ void gc_heap::fire_etw_allocation_event (size_t allocation_amount,
uint8_t* object_address,
size_t object_size)
{
#ifdef FEATURE_NATIVEAOT
FIRE_EVENT(GCAllocationTick_V1, (uint32_t)allocation_amount, (uint32_t)gen_to_oh (gen_number));
#else
FIRE_EVENT(GCAllocationTick_V4,
allocation_amount,
(uint32_t)gen_to_oh (gen_number),
heap_number,
object_address,
object_size);
#endif //FEATURE_NATIVEAOT
}

void gc_heap::fire_etw_pin_object_event (uint8_t* object, uint8_t** ppObject)
Expand Down
22 changes: 0 additions & 22 deletions src/coreclr/gc/gcscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,28 +233,6 @@ void GCScan::GcPromotionsGranted (int condemned, int max_gen, ScanContext* sc)
GCToEEInterface::SyncBlockCachePromotionsGranted(max_gen);
}


size_t GCScan::AskForMoreReservedMemory (size_t old_size, size_t need_size)
{
LIMITED_METHOD_CONTRACT;

#if !defined(FEATURE_CORECLR) && !defined(FEATURE_NATIVEAOT)
// call the host....

IGCHostControl *pGCHostControl = CorHost::GetGCHostControl();

if (pGCHostControl)
{
size_t new_max_limit_size = need_size;
pGCHostControl->RequestVirtualMemLimit (old_size,
(SIZE_T*)&new_max_limit_size);
return new_max_limit_size;
}
#endif

return old_size + need_size;
}

void GCScan::VerifyHandleTable(int condemned, int max_gen, ScanContext* sc)
{
LIMITED_METHOD_CONTRACT;
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/gc/gcscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class GCScan
// post-promotions callback some roots were demoted
static void GcDemote (int condemned, int max_gen, ScanContext* sc);

static size_t AskForMoreReservedMemory (size_t old_size, size_t need_size);

static void VerifyHandleTable(int condemned, int max_gen, ScanContext* sc);

static VOLATILE(int32_t) m_GcStructuresInvalidCnt;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/handletableconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define FEATURE_REFCOUNTED_HANDLES

// Build support for obsolete handles types into standalone GC to make it usable with older runtimes
#if defined(BUILD_AS_STANDALONE) && !defined(FEATURE_NATIVEAOT)
#ifdef BUILD_AS_STANDALONE
#define FEATURE_ASYNC_PINNED_HANDLES // No longer used in .NET 8+
#define FEATURE_WEAK_NATIVE_COM_HANDLES // No longer used in .NET 8+
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/gc/objecthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ void Ref_Shutdown()
}
}

#ifndef FEATURE_NATIVEAOT
bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket)
{
CONTRACTL
Expand Down Expand Up @@ -825,7 +824,6 @@ bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket)
offset = last->dwMaxIndex;
}
}
#endif // !FEATURE_NATIVEAOT

void Ref_RemoveHandleTableBucket(HandleTableBucket *pBucket)
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/nativeaot/Runtime/gctoclreventsink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void GCToCLREventSink::FireGCGlobalHeapHistory_V4(uint64_t finalYoungestDesired,
void GCToCLREventSink::FireGCAllocationTick_V1(uint32_t allocationAmount,
uint32_t allocationKind)
{
ASSERT(!"Superseded by FireGCAllocationTick_V4");
}

MethodTable* GetLastAllocEEType();
Expand Down Expand Up @@ -273,7 +274,7 @@ void GCToCLREventSink::FireBGC1stConEnd()

void GCToCLREventSink::FireBGC1stSweepEnd(uint32_t genNumber)
{
//FireEtwBGC1stSweepEnd(genNumber, GetClrInstanceId()); TODO
FireEtwBGC1stSweepEnd(genNumber, GetClrInstanceId());
}

void GCToCLREventSink::FireBGC2ndNonConBegin()
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/gctoclreventsink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void GCToCLREventSink::FireGCAllocationTick_V1(uint32_t allocationAmount, uint32
{
LIMITED_METHOD_CONTRACT;

FireEtwGCAllocationTick_V1(allocationAmount, allocationKind, GetClrInstanceId());
_ASSERTE(!"Superseded by FireGCAllocationTick_V4");
}

void GCToCLREventSink::FireGCAllocationTick_V4(uint64_t allocationAmount,
Expand Down

0 comments on commit c897ce6

Please sign in to comment.