summaryrefslogtreecommitdiff
path: root/src/vm/threadsuspend.cpp
diff options
context:
space:
mode:
authorSean Gillespie <segilles@microsoft.com>2016-09-08 11:27:24 -0700
committerSean Gillespie <segilles@microsoft.com>2016-09-08 11:27:24 -0700
commit6519911fbccbec049f9592484f69c213b4b78264 (patch)
treecfb37485afcc96a1780e106a4f99d192ff42ab2a /src/vm/threadsuspend.cpp
parentcda9b0fc9a5f206b391b1bd104e43bd6c29aad7f (diff)
downloadcoreclr-6519911fbccbec049f9592484f69c213b4b78264.tar.gz
coreclr-6519911fbccbec049f9592484f69c213b4b78264.tar.bz2
coreclr-6519911fbccbec049f9592484f69c213b4b78264.zip
Introduce an interface separating the GC and the VM,
modifying the VM to utilize this interface. Introduce an interface separating the GC and the rest of the VM Remove static members of both IGCHeap and IGCHeapInternal and move the management of the singular GC heap to the VM. Rename uses of IGCHeap in the VM to GCHeapHolder, as well as other misc. renames throughout the VM and GC. Split each interface function into categories, document them, use consistent formatting across the interface Undo some accidental find/replace collateral damage Remove all ifdefs from the GC interface Deduplicate function declarations between IGCHeap and IGCHeapInternal, expose AllocAlign8 through the interface and the reference to alloc_context to repair the ARM build Paper cut: false -> nullptr Repair the ARM and x86 builds Rename GCHeapHolder -> GCHeapUtilities and address documentation feedback Rebase against master Rename gcholder.h/cpp -> gcheaputilities.h/cpp Fix an uninitialized field on alloc_context causing test failures on clang Rename the include guard for gcheaputilities.h Un-breaks SOS by making the following changes: 1) Instructs the DAC to look for IGCHeap::gcHeapType by name, instead of assuming that it exists near g_pGCHeap, 2) Eliminate all virtual calls on IGCHeap in the DAC, since we cannot dispatch on an object in another process, 3) Because of 2, expose the number of generations past the GC interface using a static variable on IGCHeap that the DAC can read directly. repair the Windows build
Diffstat (limited to 'src/vm/threadsuspend.cpp')
-rw-r--r--src/vm/threadsuspend.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp
index c71855f45f..0458b7dd57 100644
--- a/src/vm/threadsuspend.cpp
+++ b/src/vm/threadsuspend.cpp
@@ -3276,7 +3276,7 @@ void Thread::RareDisablePreemptiveGC()
__SwitchToThread(0, CALLER_LIMITS_SPINNING);
}
- if (!GCHeap::IsGCHeapInitialized())
+ if (!GCHeapUtilities::IsGCHeapInitialized())
{
goto Exit;
}
@@ -3284,7 +3284,7 @@ void Thread::RareDisablePreemptiveGC()
// Note IsGCInProgress is also true for say Pause (anywhere SuspendEE happens) and GCThread is the
// thread that did the Pause. While in Pause if another thread attempts Rev/Pinvoke it should get inside the following and
// block until resume
- if (((GCHeap::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
+ if (((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
(m_State & (TS_UserSuspendPending | TS_DebugSuspendPending | TS_StackCrawlNeeded))) &&
(!g_fSuspendOnShutdown || IsFinalizerThread() || IsShutdownSpecialThread()))
{
@@ -3350,7 +3350,7 @@ void Thread::RareDisablePreemptiveGC()
DWORD status = S_OK;
SetThreadStateNC(TSNC_WaitUntilGCFinished);
- status = GCHeap::GetGCHeap()->WaitUntilGCComplete();
+ status = GCHeapUtilities::GetGCHeap()->WaitUntilGCComplete();
ResetThreadStateNC(TSNC_WaitUntilGCFinished);
if (status == (DWORD)COR_E_STACKOVERFLOW)
@@ -3359,7 +3359,7 @@ void Thread::RareDisablePreemptiveGC()
// 1. GC is suspending the process. GC needs to wait.
// 2. GC is proceeding after suspension. The current thread needs to spin.
SetThreadState(TS_BlockGCForSO);
- while (GCHeap::IsGCInProgress() && m_fPreemptiveGCDisabled.Load() == 0)
+ while (GCHeapUtilities::IsGCInProgress() && m_fPreemptiveGCDisabled.Load() == 0)
{
#undef Sleep
// We can not go to a host for blocking operation due ot lack of stack.
@@ -3376,7 +3376,7 @@ void Thread::RareDisablePreemptiveGC()
break;
}
}
- if (!GCHeap::IsGCInProgress())
+ if (!GCHeapUtilities::IsGCInProgress())
{
if (HasThreadState(TS_StackCrawlNeeded))
{
@@ -3411,7 +3411,7 @@ void Thread::RareDisablePreemptiveGC()
// thread while in this loop. This happens if you use the COM+
// debugger to suspend this thread and then release it.
- } while ((GCHeap::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
+ } while ((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
(m_State & (TS_UserSuspendPending | TS_DebugSuspendPending | TS_StackCrawlNeeded)));
}
STRESS_LOG0(LF_SYNC, LL_INFO1000, "RareDisablePreemptiveGC: leaving\n");
@@ -3705,7 +3705,7 @@ void Thread::PerformPreemptiveGC()
if (!GCStressPolicy::IsEnabled() || !GCStress<cfg_transition>::IsEnabled())
return;
- if (!GCHeap::IsGCHeapInitialized())
+ if (!GCHeapUtilities::IsGCHeapInitialized())
return;
if (!m_GCOnTransitionsOK
@@ -3713,8 +3713,8 @@ void Thread::PerformPreemptiveGC()
|| RawGCNoTrigger()
#endif
|| g_fEEShutDown
- || GCHeap::IsGCInProgress(TRUE)
- || GCHeap::GetGCHeap()->GetGcCount() == 0 // Need something that works for isolated heap.
+ || GCHeapUtilities::IsGCInProgress(TRUE)
+ || GCHeapUtilities::GetGCHeap()->GetGcCount() == 0 // Need something that works for isolated heap.
|| ThreadStore::HoldingThreadStore())
return;
@@ -3738,7 +3738,7 @@ void Thread::PerformPreemptiveGC()
{
GCX_COOP();
m_bGCStressing = TRUE;
- GCHeap::GetGCHeap()->StressHeap();
+ GCHeapUtilities::GetGCHeap()->StressHeap();
m_bGCStressing = FALSE;
}
m_GCOnTransitionsOK = TRUE;
@@ -4846,7 +4846,7 @@ HRESULT ThreadSuspend::SuspendRuntime(ThreadSuspend::SUSPEND_REASON reason)
// Caller is expected to be holding the ThreadStore lock. Also, caller must
// have set GcInProgress before coming here, or things will break;
_ASSERTE(ThreadStore::HoldingThreadStore() || IsAtProcessExit());
- _ASSERTE(GCHeap::IsGCInProgress() );
+ _ASSERTE(GCHeapUtilities::IsGCInProgress() );
STRESS_LOG1(LF_SYNC, LL_INFO1000, "Thread::SuspendRuntime(reason=0x%x)\n", reason);
@@ -5547,7 +5547,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded)
// reset GcInProgress, or threads will continue to suspend themselves and won't
// be resumed until the next GC.
_ASSERTE(IsGCSpecialThread() || ThreadStore::HoldingThreadStore());
- _ASSERTE(!GCHeap::IsGCInProgress() );
+ _ASSERTE(!GCHeapUtilities::IsGCInProgress() );
STRESS_LOG2(LF_SYNC, LL_INFO1000, "Thread::ResumeRuntime(finishedGC=%d, SuspendSucceeded=%d) - Start\n", bFinishedGC, SuspendSucceded);
@@ -5564,7 +5564,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded)
{
// If we the suspension was for a GC, tell the host what generation GC.
DWORD Generation = (bFinishedGC
- ? GCHeap::GetGCHeap()->GetCondemnedGeneration()
+ ? GCHeapUtilities::GetGCHeap()->GetCondemnedGeneration()
: ~0U);
pGCThreadControl->SuspensionEnding(Generation);
@@ -5574,7 +5574,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded)
{
// If we the suspension was for a GC, tell the host what generation GC.
DWORD Generation = (bFinishedGC
- ? GCHeap::GetGCHeap()->GetCondemnedGeneration()
+ ? GCHeapUtilities::GetGCHeap()->GetCondemnedGeneration()
: ~0U);
BEGIN_SO_TOLERANT_CODE_CALLING_HOST(GetThread());
@@ -7898,7 +7898,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded)
// Revert to being a normal thread
//
ClrFlsClearThreadType (ThreadType_DynamicSuspendEE);
- GCHeap::GetGCHeap()->SetGCInProgress(FALSE);
+ GCHeapUtilities::GetGCHeap()->SetGCInProgress(FALSE);
//
// Allow threads to enter COOP mode (though we still need to wake the ones
@@ -7906,7 +7906,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded)
//
// Note: this is the last barrier that keeps managed threads
// from entering cooperative mode. If the sequence changes,
- // you may have to change routine GCHeap::SafeToRestartManagedThreads
+ // you may have to change routine GCHeapUtilities::SafeToRestartManagedThreads
// as well.
//
ThreadStore::TrapReturningThreads(FALSE);
@@ -7915,7 +7915,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded)
//
// Any threads that are waiting in WaitUntilGCComplete will continue now.
//
- GCHeap::GetGCHeap()->GetWaitForGCEvent()->Set();
+ GCHeapUtilities::GetGCHeap()->GetWaitForGCEvent()->Set();
_ASSERTE(IsGCSpecialThread() || ThreadStore::HoldingThreadStore());
ResumeRuntime(bFinishedGC, SuspendSucceded);
@@ -7964,7 +7964,7 @@ void ThreadSuspend::SuspendEE(SUSPEND_REASON reason)
ETW::GCLog::ETW_GC_INFO Info;
Info.SuspendEE.Reason = reason;
Info.SuspendEE.GcCount = (((reason == SUSPEND_FOR_GC) || (reason == SUSPEND_FOR_GC_PREP)) ?
- (ULONG)GCHeap::GetGCHeap()->GetGcCount() : (ULONG)-1);
+ (ULONG)GCHeapUtilities::GetGCHeap()->GetGcCount() : (ULONG)-1);
FireEtwGCSuspendEEBegin_V1(Info.SuspendEE.Reason, Info.SuspendEE.GcCount, GetClrInstanceId());
@@ -8041,7 +8041,7 @@ retry_for_debugger:
//
// First, we reset the event that we're about to tell other threads to wait for.
//
- GCHeap::GetGCHeap()->GetWaitForGCEvent()->Reset();
+ GCHeapUtilities::GetGCHeap()->GetWaitForGCEvent()->Reset();
//
// Remember that we're the one doing the GC. Actually, maybe we're not doing a GC -
@@ -8066,7 +8066,7 @@ retry_for_debugger:
// It seems like much of the above is redundant. We should investigate reducing the number
// of mechanisms we use to indicate that a suspension is in progress.
//
- GCHeap::GetGCHeap()->SetGCInProgress(TRUE);
+ GCHeapUtilities::GetGCHeap()->SetGCInProgress(TRUE);
//
// Gratuitous memory barrier. (may be needed - but I'm not sure why.)
@@ -8357,7 +8357,7 @@ void ThreadSuspend::Initialize()
BOOL Debug_IsLockedViaThreadSuspension()
{
LIMITED_METHOD_CONTRACT;
- return GCHeap::IsGCInProgress() &&
+ return GCHeapUtilities::IsGCInProgress() &&
(dbgOnly_IsSpecialEEThread() ||
IsGCSpecialThread() ||
GetThread() == ThreadSuspend::GetSuspensionThread());
@@ -8485,7 +8485,7 @@ void SuspendStatistics::EndSuspend(BOOL bForGC)
// details on suspends...
if (!bForGC)
cntNonGCSuspends++;
- if (GCHeap::GetGCHeap()->IsConcurrentGCInProgress())
+ if (GCHeapUtilities::GetGCHeap()->IsConcurrentGCInProgress())
{
cntSuspendsInBGC++;
if (!bForGC)