diff options
author | David Mason <davmason@microsoft.com> | 2018-03-13 01:24:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-13 01:24:20 -0700 |
commit | 8edb3ef2529cc0beb0c034482fdb32fa4c95c606 (patch) | |
tree | 369d8ecf4ca45f42341fc50b750ca7fe13086834 /src/gc/gcee.cpp | |
parent | 0c4344f5a999d817b431b9e3934600ccb97d0e4b (diff) | |
download | coreclr-8edb3ef2529cc0beb0c034482fdb32fa4c95c606.tar.gz coreclr-8edb3ef2529cc0beb0c034482fdb32fa4c95c606.tar.bz2 coreclr-8edb3ef2529cc0beb0c034482fdb32fa4c95c606.zip |
[local gc] refactor apis for threading and suspension to avoid redundant calls in to the runtime (#16765)
* [Local GC] Refactor calls involving thread modes, suspension, and alloc contexts to always operate on current thread
* BOOL -> bool for enable/disable preemptive routines, also remove an unused call to GetThread
* avoid one indirection by having GCToEEInterface::EnablePreemptiveGC return a bool indicating whether the mode was changed
* Callback on IGCHeap for the runtime to notify the GC when it is trapping threads
* use g_fSuspensionPending instead of GCToEEInterface::CatchAtSafePoint for allow_fgc
* Remove CatchAtSafePoint
* Remove GetThread from WaitLongerNoInstru
* code review feedback
* code review feedback
* change BOOL to bool
Diffstat (limited to 'src/gc/gcee.cpp')
-rw-r--r-- | src/gc/gcee.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/gc/gcee.cpp b/src/gc/gcee.cpp index b399cde14f..52f2eb3179 100644 --- a/src/gc/gcee.cpp +++ b/src/gc/gcee.cpp @@ -455,24 +455,19 @@ void gc_heap::fire_etw_pin_object_event (uint8_t* object, uint8_t** ppObject) uint32_t gc_heap::user_thread_wait (GCEvent *event, BOOL no_mode_change, int time_out_ms) { Thread* pCurThread = NULL; - bool mode = false; + bool bToggleGC = false; uint32_t dwWaitResult = NOERROR; if (!no_mode_change) { - pCurThread = GCToEEInterface::GetThread(); - mode = pCurThread ? GCToEEInterface::IsPreemptiveGCDisabled(pCurThread) : false; - if (mode) - { - GCToEEInterface::EnablePreemptiveGC(pCurThread); - } + bToggleGC = GCToEEInterface::EnablePreemptiveGC(); } dwWaitResult = event->Wait(time_out_ms, FALSE); - if (!no_mode_change && mode) + if (bToggleGC) { - GCToEEInterface::DisablePreemptiveGC(pCurThread); + GCToEEInterface::DisablePreemptiveGC(); } return dwWaitResult; @@ -608,6 +603,18 @@ bool GCHeap::RuntimeStructuresValid() return GCScan::GetGcRuntimeStructuresValid(); } +void GCHeap::SetSuspensionPending(bool fSuspensionPending) +{ + if (fSuspensionPending) + { + Interlocked::Increment(&g_fSuspensionPending); + } + else + { + Interlocked::Decrement(&g_fSuspensionPending); + } +} + void GCHeap::ControlEvents(GCEventKeyword keyword, GCEventLevel level) { GCEventStatus::Set(GCEventProvider_Default, keyword, level); |