Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 087e750

Browse files
authored
GC update from CoreRT (#6429)
https://github.com/dotnet/corert/tree/master/src/Native/gc 91d7a9c8e2b393314422b6106adedec683c0ae51
1 parent ac01e27 commit 087e750

File tree

3 files changed

+41
-453
lines changed

3 files changed

+41
-453
lines changed

src/gc/env/gcenv.base.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
176176

177177
#endif // _MSC_VER
178178

179+
typedef struct _PROCESSOR_NUMBER {
180+
uint16_t Group;
181+
uint8_t Number;
182+
uint8_t Reserved;
183+
} PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
184+
179185
#endif // _INC_WINDOWS
180186

181187
// -----------------------------------------------------------------------------------------------------------
@@ -600,4 +606,21 @@ class GCStress
600606
};
601607
#endif // STRESS_HEAP
602608

609+
class NumaNodeInfo
610+
{
611+
public:
612+
static bool CanEnableGCNumaAware();
613+
static void GetGroupForProcessor(uint16_t processor_number, uint16_t * group_number, uint16_t * group_processor_number);
614+
static bool GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, uint16_t * node_no);
615+
};
616+
617+
class CPUGroupInfo
618+
{
619+
public:
620+
static bool CanEnableGCCPUGroups();
621+
static uint32_t GetNumActiveProcessors();
622+
static void GetGroupForProcessor(uint16_t processor_number, uint16_t * group_number, uint16_t * group_processor_number);
623+
};
624+
625+
603626
#endif // __GCENV_BASE_INCLUDED__

src/gc/gc.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ SPTR_IMPL_NS(PTR_gc_heap, SVR, gc_heap, g_heaps);
22712271
size_t* gc_heap::g_promoted;
22722272

22732273
#ifdef MH_SC_MARK
2274-
BOOL* gc_heap::g_mark_stack_busy;
2274+
int* gc_heap::g_mark_stack_busy;
22752275
#endif //MH_SC_MARK
22762276

22772277

@@ -4921,7 +4921,7 @@ class heap_select
49214921
return TRUE;
49224922
}
49234923

4924-
static void init_cpu_mapping(gc_heap *heap, int heap_number)
4924+
static void init_cpu_mapping(gc_heap * /*heap*/, int heap_number)
49254925
{
49264926
if (GCToOSInterface::CanGetCurrentProcessorNumber())
49274927
{
@@ -4942,8 +4942,10 @@ class heap_select
49424942
sniff_buffer[(1 + heap_number*n_sniff_buffers + sniff_index)*HS_CACHE_LINE_SIZE] &= 1;
49434943
}
49444944

4945-
static int select_heap(alloc_context* acontext, int hint)
4945+
static int select_heap(alloc_context* acontext, int /*hint*/)
49464946
{
4947+
UNREFERENCED_PARAMETER(acontext); // only referenced by dprintf
4948+
49474949
if (GCToOSInterface::CanGetCurrentProcessorNumber())
49484950
return proc_no_to_heap_no[GCToOSInterface::GetCurrentProcessorNumber() % gc_heap::n_heaps];
49494951

@@ -5103,7 +5105,7 @@ void gc_heap::destroy_thread_support ()
51035105
}
51045106
}
51055107

5106-
#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
5108+
#if !defined(FEATURE_PAL)
51075109
void set_thread_group_affinity_for_heap(int heap_number, GCThreadAffinity* affinity)
51085110
{
51095111
affinity->Group = GCThreadAffinity::None;
@@ -5183,7 +5185,7 @@ void set_thread_affinity_mask_for_heap(int heap_number, GCThreadAffinity* affini
51835185
}
51845186
}
51855187
}
5186-
#endif // !FEATURE_REDHAWK && !FEATURE_CORECLR
5188+
#endif // !FEATURE_PAL
51875189

51885190
bool gc_heap::create_gc_thread ()
51895191
{
@@ -5193,7 +5195,7 @@ bool gc_heap::create_gc_thread ()
51935195
affinity.Group = GCThreadAffinity::None;
51945196
affinity.Processor = GCThreadAffinity::None;
51955197

5196-
#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
5198+
#if !defined(FEATURE_PAL)
51975199
if (!gc_thread_no_affinitize_p)
51985200
{
51995201
//We are about to set affinity for GC threads, it is a good place to setup NUMA and
@@ -5204,7 +5206,7 @@ bool gc_heap::create_gc_thread ()
52045206
else
52055207
set_thread_affinity_mask_for_heap(heap_number, &affinity);
52065208
}
5207-
#endif // !FEATURE_REDHAWK && !FEATURE_PAL
5209+
#endif // !FEATURE_PAL
52085210

52095211
return GCToOSInterface::CreateThread(gc_thread_stub, this, &affinity);
52105212
}
@@ -13179,7 +13181,7 @@ void gc_heap::balance_heaps (alloc_context* acontext)
1317913181
org_hp->alloc_context_count--;
1318013182
max_hp->alloc_context_count++;
1318113183
acontext->alloc_heap = GCHeap::GetHeap(max_hp->heap_number);
13182-
#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
13184+
#if !defined(FEATURE_PAL)
1318313185
if (CPUGroupInfo::CanEnableGCCPUGroups())
1318413186
{ //only set ideal processor when max_hp and org_hp are in the same cpu
1318513187
//group. DO NOT MOVE THREADS ACROSS CPU GROUPS
@@ -13213,7 +13215,7 @@ void gc_heap::balance_heaps (alloc_context* acontext)
1321313215
org_hp->heap_number));
1321413216
}
1321513217
}
13216-
#endif // !FEATURE_REDHAWK && !FEATURE_PAL
13218+
#endif // !FEATURE_PAL
1321713219
dprintf (3, ("Switching context %p (home heap %d) ",
1321813220
acontext,
1321913221
acontext->home_heap->pGenGCHeap->heap_number));
@@ -13232,7 +13234,7 @@ void gc_heap::balance_heaps (alloc_context* acontext)
1323213234
acontext->alloc_count++;
1323313235
}
1323413236

13235-
gc_heap* gc_heap::balance_heaps_loh (alloc_context* acontext, size_t size)
13237+
gc_heap* gc_heap::balance_heaps_loh (alloc_context* acontext, size_t /*size*/)
1323613238
{
1323713239
gc_heap* org_hp = acontext->alloc_heap->pGenGCHeap;
1323813240
//dprintf (1, ("LA: %Id", size));
@@ -17762,8 +17764,8 @@ gc_heap::mark_steal()
1776217764
if (((size_t)o > 4) && !partial_object_p (o))
1776317765
{
1776417766
//this is a normal object, not a partial mark tuple
17765-
//success = (FastInterlockCompareExchangePointer (&ref_mark_stack (hp, level), 0, o)==o);
17766-
success = (FastInterlockCompareExchangePointer (&ref_mark_stack (hp, level), 4, o)==o);
17767+
//success = (Interlocked::CompareExchangePointer (&ref_mark_stack (hp, level), 0, o)==o);
17768+
success = (Interlocked::CompareExchangePointer (&ref_mark_stack (hp, level), (uint8_t*)4, o)==o);
1776717769
#ifdef SNOOP_STATS
1776817770
snoop_stat.interlocked_count++;
1776917771
if (success)
@@ -17798,7 +17800,7 @@ gc_heap::mark_steal()
1779817800
if (o && start)
1779917801
{
1780017802
//steal the object
17801-
success = (FastInterlockCompareExchangePointer (&ref_mark_stack (hp, level+1), stolen, next)==next);
17803+
success = (Interlocked::CompareExchangePointer (&ref_mark_stack (hp, level+1), (uint8_t*)stolen, next)==next);
1780217804
#ifdef SNOOP_STATS
1780317805
snoop_stat.interlocked_count++;
1780417806
if (success)
@@ -23303,13 +23305,8 @@ uint8_t* tree_search (uint8_t* tree, uint8_t* old_address)
2330323305
#ifdef FEATURE_BASICFREEZE
2330423306
bool gc_heap::frozen_object_p (Object* obj)
2330523307
{
23306-
#ifdef MULTIPLE_HEAPS
23307-
ptrdiff_t delta = 0;
23308-
heap_segment* pSegment = segment_of ((uint8_t*)obj, delta);
23309-
#else //MULTIPLE_HEAPS
2331023308
heap_segment* pSegment = gc_heap::find_segment ((uint8_t*)obj, FALSE);
2331123309
_ASSERTE(pSegment);
23312-
#endif //MULTIPLE_HEAPS
2331323310

2331423311
return heap_segment_read_only_p(pSegment);
2331523312
}
@@ -23326,6 +23323,7 @@ void gc_heap::relocate_address (uint8_t** pold_address THREAD_NUMBER_DCL)
2332623323
if (!((old_address >= gc_low) && (old_address < gc_high)))
2332723324
#ifdef MULTIPLE_HEAPS
2332823325
{
23326+
UNREFERENCED_PARAMETER(thread);
2332923327
if (old_address == 0)
2333023328
return;
2333123329
gc_heap* hp = heap_of (old_address);
@@ -35426,7 +35424,7 @@ int GCHeap::GetHomeHeapNumber ()
3542635424
{
3542735425
if (pThread)
3542835426
{
35429-
GCHeap *hp = pThread->GetAllocContext()->home_heap;
35427+
GCHeap *hp = GCToEEInterface::GetAllocContext(pThread)->home_heap;
3543035428
if (hp == gc_heap::g_heaps[i]->vm_heap) return i;
3543135429
}
3543235430
}

0 commit comments

Comments
 (0)