summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorSean Gillespie <sean@swgillespie.me>2017-04-01 14:25:07 -0700
committerGitHub <noreply@github.com>2017-04-01 14:25:07 -0700
commited57233f4d26114d45b1293ced80a09f879f72cf (patch)
tree19eb9884c7cd1a5f51efd5e065042e44e14b6634 /src/vm
parent036ff00ad33e3bdd8f0eef7513af331eb841d5b9 (diff)
downloadcoreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.tar.gz
coreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.tar.bz2
coreclr-ed57233f4d26114d45b1293ced80a09f879f72cf.zip
[Local GC] Remove static fields from GC interface (#10566)
* Remove max_generation from GC interface * [Local GC] Clean up the GC interface by removing all static fields from it: 1) gcHeapType is replaced by g_heap_type (EE side) and g_gc_heap_type (GC side), each of which is set on initialization. g_heap_type is read by the DAC to determine what kind of heap is being used. 2) maxGeneration is not necessary due to the GC DAC changes. * Rebase against master * Comments and cleanup * Use a heap allocation instead of alloca * Code review feedback: remove a redundant cast and allocate generation count table once, on first use * Address code review feedback: cache some calls to GetMaxGeneration
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/ceemain.cpp1
-rw-r--r--src/vm/crossgencompile.cpp4
-rw-r--r--src/vm/gcenv.ee.cpp1
-rw-r--r--src/vm/gcheaputilities.cpp1
-rw-r--r--src/vm/gcheaputilities.h8
-rw-r--r--src/vm/threads.cpp29
-rw-r--r--src/vm/threads.h1
7 files changed, 31 insertions, 14 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp
index 602ccc92bd..b8c1387b8b 100644
--- a/src/vm/ceemain.cpp
+++ b/src/vm/ceemain.cpp
@@ -483,6 +483,7 @@ void InitializeStartupFlags()
InitializeHeapType((flags & STARTUP_SERVER_GC) != 0);
+ g_heap_type = (flags & STARTUP_SERVER_GC) == 0 ? GC_HEAP_WKS : GC_HEAP_SVR;
#ifdef FEATURE_LOADER_OPTIMIZATION
g_dwGlobalSharePolicy = (flags&STARTUP_LOADER_OPTIMIZATION_MASK)>>1;
diff --git a/src/vm/crossgencompile.cpp b/src/vm/crossgencompile.cpp
index c29d3cc60b..b106ecc918 100644
--- a/src/vm/crossgencompile.cpp
+++ b/src/vm/crossgencompile.cpp
@@ -133,9 +133,7 @@ BOOL g_fEEComActivatedStartup=FALSE;
GVAL_IMPL_INIT(DWORD, g_fHostConfig, 0);
-#ifdef FEATURE_SVR_GC
-SVAL_IMPL_INIT(uint32_t,IGCHeap,gcHeapType,IGCHeap::GC_HEAP_WKS);
-#endif
+GVAL_IMPL_INIT(GCHeapType, g_heap_type, GC_HEAP_WKS);
void UpdateGCSettingFromHost()
{
diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp
index e8619953ff..cf2728d6cb 100644
--- a/src/vm/gcenv.ee.cpp
+++ b/src/vm/gcenv.ee.cpp
@@ -1016,6 +1016,7 @@ void GCProfileWalkHeapWorker(BOOL fProfilerPinned, BOOL fShouldWalkHeapRootsForE
{
{
ProfilingScanContext SC(fProfilerPinned);
+ unsigned max_generation = GCHeapUtilities::GetGCHeap()->GetMaxGeneration();
// **** Scan roots: Only scan roots if profiling API wants them or ETW wants them.
if (fProfilerPinned || fShouldWalkHeapRootsForEtw)
diff --git a/src/vm/gcheaputilities.cpp b/src/vm/gcheaputilities.cpp
index 730728927a..91640d30a2 100644
--- a/src/vm/gcheaputilities.cpp
+++ b/src/vm/gcheaputilities.cpp
@@ -14,6 +14,7 @@
GPTR_IMPL_INIT(uint32_t, g_card_table, nullptr);
GPTR_IMPL_INIT(uint8_t, g_lowest_address, nullptr);
GPTR_IMPL_INIT(uint8_t, g_highest_address, nullptr);
+GVAL_IMPL_INIT(GCHeapType, g_heap_type, GC_HEAP_INVALID);
uint8_t* g_ephemeral_low = (uint8_t*)1;
uint8_t* g_ephemeral_high = (uint8_t*)~0;
diff --git a/src/vm/gcheaputilities.h b/src/vm/gcheaputilities.h
index 064165bc11..baa2558b8e 100644
--- a/src/vm/gcheaputilities.h
+++ b/src/vm/gcheaputilities.h
@@ -16,6 +16,7 @@ extern "C" {
GPTR_DECL(uint8_t,g_lowest_address);
GPTR_DECL(uint8_t,g_highest_address);
GPTR_DECL(uint32_t,g_card_table);
+GVAL_DECL(GCHeapType, g_heap_type);
#ifndef DACCESS_COMPILE
}
#endif // !DACCESS_COMPILE
@@ -120,10 +121,11 @@ public:
inline static bool IsServerHeap()
{
LIMITED_METHOD_CONTRACT;
+
#ifdef FEATURE_SVR_GC
- _ASSERTE(IGCHeap::gcHeapType != IGCHeap::GC_HEAP_INVALID);
- return (IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR);
-#else // FEATURE_SVR_GC
+ _ASSERTE(g_heap_type != GC_HEAP_INVALID);
+ return g_heap_type == GC_HEAP_SVR;
+#else
return false;
#endif // FEATURE_SVR_GC
}
diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp
index da805bdd46..68a81bf606 100644
--- a/src/vm/threads.cpp
+++ b/src/vm/threads.cpp
@@ -5750,6 +5750,7 @@ void ThreadStore::InitThreadStore()
}
s_DeadThreadGCTriggerPeriodMilliseconds =
CLRConfig::GetConfigValue(CLRConfig::INTERNAL_Thread_DeadThreadGCTriggerPeriodMilliseconds);
+ s_DeadThreadGenerationCounts = nullptr;
}
// Enter and leave the critical section around the thread store. Clients should
@@ -5986,6 +5987,7 @@ void ThreadStore::TransferStartedThread(Thread *thread, BOOL bRequiresTSL)
LONG ThreadStore::s_DeadThreadCountThresholdForGCTrigger = 0;
DWORD ThreadStore::s_DeadThreadGCTriggerPeriodMilliseconds = 0;
+SIZE_T *ThreadStore::s_DeadThreadGenerationCounts = nullptr;
void ThreadStore::IncrementDeadThreadCountForGCTrigger()
{
@@ -6012,7 +6014,7 @@ void ThreadStore::IncrementDeadThreadCountForGCTrigger()
return;
}
- SIZE_T gcLastMilliseconds = gcHeap->GetLastGCStartTime(max_generation);
+ SIZE_T gcLastMilliseconds = gcHeap->GetLastGCStartTime(gcHeap->GetMaxGeneration());
SIZE_T gcNowMilliseconds = gcHeap->GetNow();
if (gcNowMilliseconds - gcLastMilliseconds < s_DeadThreadGCTriggerPeriodMilliseconds)
{
@@ -6088,11 +6090,22 @@ void ThreadStore::TriggerGCForDeadThreadsIfNecessary()
return;
}
- int gcGenerationToTrigger = 0;
+ unsigned gcGenerationToTrigger = 0;
IGCHeap *gcHeap = GCHeapUtilities::GetGCHeap();
_ASSERTE(gcHeap != nullptr);
SIZE_T generationCountThreshold = static_cast<SIZE_T>(s_DeadThreadCountThresholdForGCTrigger) / 2;
- SIZE_T newDeadThreadGenerationCounts[max_generation + 1] = {0};
+ unsigned maxGeneration = gcHeap->GetMaxGeneration();
+ if (!s_DeadThreadGenerationCounts)
+ {
+ // initialize this field on first use with an entry for every table.
+ s_DeadThreadGenerationCounts = new (nothrow) SIZE_T[maxGeneration + 1];
+ if (!s_DeadThreadGenerationCounts)
+ {
+ return;
+ }
+ }
+
+ memset(s_DeadThreadGenerationCounts, 0, sizeof(SIZE_T) * (maxGeneration + 1));
{
ThreadStoreLockHolder threadStoreLockHolder;
GCX_COOP();
@@ -6114,12 +6127,12 @@ void ThreadStore::TriggerGCForDeadThreadsIfNecessary()
continue;
}
- int exposedObjectGeneration = gcHeap->WhichGeneration(exposedObject);
- SIZE_T newDeadThreadGenerationCount = ++newDeadThreadGenerationCounts[exposedObjectGeneration];
+ unsigned exposedObjectGeneration = gcHeap->WhichGeneration(exposedObject);
+ SIZE_T newDeadThreadGenerationCount = ++s_DeadThreadGenerationCounts[exposedObjectGeneration];
if (exposedObjectGeneration > gcGenerationToTrigger && newDeadThreadGenerationCount >= generationCountThreshold)
{
gcGenerationToTrigger = exposedObjectGeneration;
- if (gcGenerationToTrigger >= max_generation)
+ if (gcGenerationToTrigger >= maxGeneration)
{
break;
}
@@ -6153,8 +6166,8 @@ void ThreadStore::TriggerGCForDeadThreadsIfNecessary()
continue;
}
- if (gcGenerationToTrigger < max_generation &&
- static_cast<int>(gcHeap->WhichGeneration(exposedObject)) > gcGenerationToTrigger)
+ if (gcGenerationToTrigger < maxGeneration &&
+ gcHeap->WhichGeneration(exposedObject) > gcGenerationToTrigger)
{
continue;
}
diff --git a/src/vm/threads.h b/src/vm/threads.h
index f34066feb3..697ffea454 100644
--- a/src/vm/threads.h
+++ b/src/vm/threads.h
@@ -5555,6 +5555,7 @@ private:
private:
static LONG s_DeadThreadCountThresholdForGCTrigger;
static DWORD s_DeadThreadGCTriggerPeriodMilliseconds;
+ static SIZE_T *s_DeadThreadGenerationCounts;
public: