summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Gillespie <segilles@microsoft.com>2017-06-05 22:23:46 -0700
committerGitHub <noreply@github.com>2017-06-05 22:23:46 -0700
commitbab2cc30b1516cd257aba763c7a1c06497219ede (patch)
tree3023dac80e77ae51a30f9620f69290712f493e6b
parent5b9680fcc9b6fe9429f4a649bf5215de273fcbec (diff)
downloadcoreclr-bab2cc30b1516cd257aba763c7a1c06497219ede.tar.gz
coreclr-bab2cc30b1516cd257aba763c7a1c06497219ede.tar.bz2
coreclr-bab2cc30b1516cd257aba763c7a1c06497219ede.zip
[Local GC] Add TrapReturningThreads to the GC/EE interface (#12067)
-rw-r--r--src/gc/env/gcenv.ee.h1
-rw-r--r--src/gc/gc.cpp6
-rw-r--r--src/gc/gcenv.ee.standalone.inl6
-rw-r--r--src/gc/gcimpl.h2
-rw-r--r--src/gc/gcinterface.ee.h4
-rw-r--r--src/gc/sample/gcenv.ee.cpp5
-rw-r--r--src/vm/gcenv.ee.cpp6
-rw-r--r--src/vm/gcenv.ee.h1
8 files changed, 27 insertions, 4 deletions
diff --git a/src/gc/env/gcenv.ee.h b/src/gc/env/gcenv.ee.h
index bb335c6834..ed5173f4e2 100644
--- a/src/gc/env/gcenv.ee.h
+++ b/src/gc/env/gcenv.ee.h
@@ -49,6 +49,7 @@ public:
static bool IsPreemptiveGCDisabled(Thread * pThread);
static void EnablePreemptiveGC(Thread * pThread);
static void DisablePreemptiveGC(Thread * pThread);
+ static bool TrapReturningThreads();
static gc_alloc_context * GetAllocContext(Thread * pThread);
static bool CatchAtSafePoint(Thread * pThread);
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 962e09b445..47de5a4b28 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -1496,7 +1496,7 @@ void WaitLongerNoInstru (int i)
}
// if we're waiting for gc to finish, we should block immediately
- if (!g_TrapReturningThreads)
+ if (!GCToEEInterface::TrapReturningThreads())
{
if (g_num_processors > 1)
{
@@ -1516,7 +1516,7 @@ void WaitLongerNoInstru (int i)
// is in a tight loop. If the thread has high priority, the perf is going to be very BAD.
if (pCurThread)
{
- if (bToggleGC || g_TrapReturningThreads)
+ if (bToggleGC || GCToEEInterface::TrapReturningThreads())
{
#ifdef _DEBUG
// In debug builds, all enter_spin_lock operations go through this code. If a GC has
@@ -1537,7 +1537,7 @@ void WaitLongerNoInstru (int i)
}
}
}
- else if (g_TrapReturningThreads)
+ else if (GCToEEInterface::TrapReturningThreads())
{
g_theGCHeap->WaitUntilGCComplete();
}
diff --git a/src/gc/gcenv.ee.standalone.inl b/src/gc/gcenv.ee.standalone.inl
index 642d150976..a673e73517 100644
--- a/src/gc/gcenv.ee.standalone.inl
+++ b/src/gc/gcenv.ee.standalone.inl
@@ -134,6 +134,12 @@ ALWAYS_INLINE void GCToEEInterface::DisablePreemptiveGC(Thread * pThread)
g_theGCToCLR->DisablePreemptiveGC(pThread);
}
+ALWAYS_INLINE bool GCToEEInterface::TrapReturningThreads()
+{
+ assert(g_theGCToCLR != nullptr);
+ return g_theGCToCLR->TrapReturningThreads();
+}
+
ALWAYS_INLINE gc_alloc_context * GCToEEInterface::GetAllocContext(Thread * pThread)
{
assert(g_theGCToCLR != nullptr);
diff --git a/src/gc/gcimpl.h b/src/gc/gcimpl.h
index 8ac16c5107..c0efa69531 100644
--- a/src/gc/gcimpl.h
+++ b/src/gc/gcimpl.h
@@ -254,7 +254,7 @@ private:
// to threads returning to cooperative mode is down after gc.
// In other words, if the sequence in GCHeap::RestartEE changes,
// the condition here may have to change as well.
- return g_TrapReturningThreads == 0;
+ return !GCToEEInterface::TrapReturningThreads();
}
public:
//return TRUE if GC actually happens, otherwise FALSE
diff --git a/src/gc/gcinterface.ee.h b/src/gc/gcinterface.ee.h
index 32dcc039ef..b6a1d82345 100644
--- a/src/gc/gcinterface.ee.h
+++ b/src/gc/gcinterface.ee.h
@@ -77,6 +77,10 @@ public:
virtual
void DisablePreemptiveGC(Thread * pThread) = 0;
+ // Returns whether or not a thread suspension is pending.
+ virtual
+ bool TrapReturningThreads() = 0;
+
// Retrieves the alloc context associated with a given thread.
virtual
gc_alloc_context * GetAllocContext(Thread * pThread) = 0;
diff --git a/src/gc/sample/gcenv.ee.cpp b/src/gc/sample/gcenv.ee.cpp
index 03d960819a..1867f1c7f8 100644
--- a/src/gc/sample/gcenv.ee.cpp
+++ b/src/gc/sample/gcenv.ee.cpp
@@ -190,6 +190,11 @@ void GCToEEInterface::DisablePreemptiveGC(Thread * pThread)
pThread->DisablePreemptiveGC();
}
+bool GCToEEInterface::TrapReturningThreads()
+{
+ return !!g_TrapReturningThreads;
+}
+
gc_alloc_context * GCToEEInterface::GetAllocContext(Thread * pThread)
{
return pThread->GetAllocContext();
diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp
index 38c8ef0340..f520c1a2bb 100644
--- a/src/vm/gcenv.ee.cpp
+++ b/src/vm/gcenv.ee.cpp
@@ -356,6 +356,12 @@ void GCToEEInterface::DisablePreemptiveGC(Thread * pThread)
pThread->DisablePreemptiveGC();
}
+bool GCToEEInterface::TrapReturningThreads()
+{
+ WRAPPER_NO_CONTRACT;
+ return !!g_TrapReturningThreads;
+}
+
struct BackgroundThreadStubArgs
{
Thread* thread;
diff --git a/src/vm/gcenv.ee.h b/src/vm/gcenv.ee.h
index 6b02f5cfa1..4871e51260 100644
--- a/src/vm/gcenv.ee.h
+++ b/src/vm/gcenv.ee.h
@@ -31,6 +31,7 @@ public:
bool IsPreemptiveGCDisabled(Thread * pThread);
void EnablePreemptiveGC(Thread * pThread);
void DisablePreemptiveGC(Thread * pThread);
+ bool TrapReturningThreads();
gc_alloc_context * GetAllocContext(Thread * pThread);
bool CatchAtSafePoint(Thread * pThread);
void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);