diff options
author | Sean Gillespie <segilles@microsoft.com> | 2017-10-26 10:46:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 10:46:21 -0700 |
commit | 165ffa6a0bb2d8b57e83aa95a395a798ad5f5f4f (patch) | |
tree | c72c44d082e2ade2f30f04a8e31f44d26173a51c | |
parent | 47b0adbb645b0e1072703be106042eb5c832601d (diff) | |
download | coreclr-165ffa6a0bb2d8b57e83aa95a395a798ad5f5f4f.tar.gz coreclr-165ffa6a0bb2d8b57e83aa95a395a798ad5f5f4f.tar.bz2 coreclr-165ffa6a0bb2d8b57e83aa95a395a798ad5f5f4f.zip |
[Local GC] Move IsGCThread and IsGCSpecialThread to GCToEEInterface (#14685)
* [Local GC] Move IsGCThread and IsGCSpecialThread to GCToEEInterface
* Fix the windows and sample builds
-rw-r--r-- | src/gc/env/gcenv.base.h | 12 | ||||
-rw-r--r-- | src/gc/env/gcenv.ee.h | 2 | ||||
-rw-r--r-- | src/gc/gc.cpp | 12 | ||||
-rw-r--r-- | src/gc/gcenv.ee.standalone.inl | 12 | ||||
-rw-r--r-- | src/gc/gcinterface.ee.h | 11 | ||||
-rw-r--r-- | src/gc/sample/gcenv.ee.cpp | 10 | ||||
-rw-r--r-- | src/vm/gcenv.ee.cpp | 10 | ||||
-rw-r--r-- | src/vm/gcenv.ee.h | 2 |
8 files changed, 53 insertions, 18 deletions
diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h index fb2f9da488..6c878c1c21 100644 --- a/src/gc/env/gcenv.base.h +++ b/src/gc/env/gcenv.base.h @@ -420,12 +420,6 @@ typedef PTR_PTR_Object PTR_UNCHECKED_OBJECTREF; class Thread; -inline bool IsGCSpecialThread() -{ - // [LOCALGC TODO] this is not correct - return false; -} - inline bool dbgOnly_IsSpecialEEThread() { return false; @@ -454,12 +448,6 @@ namespace ETW } GC_ROOT_KIND; }; -inline bool IsGCThread() -{ - // [LOCALGC TODO] this is not correct - return false; -} - inline bool FitsInU1(uint64_t val) { return val == (uint64_t)(uint8_t)val; diff --git a/src/gc/env/gcenv.ee.h b/src/gc/env/gcenv.ee.h index e7103b15a5..3d2f659a75 100644 --- a/src/gc/env/gcenv.ee.h +++ b/src/gc/env/gcenv.ee.h @@ -80,6 +80,8 @@ public: static bool GetIntConfigValue(const char* key, int64_t* value); static bool GetStringConfigValue(const char* key, const char** value); static void FreeStringConfigValue(const char* key); + static bool IsGCThread(); + static bool IsGCSpecialThread(); }; #endif // __GCENV_EE_H__ diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 8cee415081..7df1911668 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -1740,7 +1740,7 @@ static BOOL try_enter_spin_lock(GCSpinLock *pSpinLock) inline static void leave_spin_lock(GCSpinLock *pSpinLock) { - BOOL gc_thread_p = IsGCSpecialThread(); + bool gc_thread_p = GCToEEInterface::IsGCSpecialThread(); // _ASSERTE((pSpinLock->holding_thread == GCToEEInterface::GetThread()) || gc_thread_p || pSpinLock->released_by_gc_p); pSpinLock->released_by_gc_p = gc_thread_p; pSpinLock->holding_thread = (Thread*) -1; @@ -7450,7 +7450,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start, // Either this thread was the thread that did the suspension which means we are suspended; or this is called // from a GC thread which means we are in a blocking GC and also suspended. - BOOL is_runtime_suspended = IsGCThread(); + bool is_runtime_suspended = GCToEEInterface::IsGCThread(); if (!is_runtime_suspended) { // Note on points where the runtime is suspended anywhere in this function. Upon an attempt to suspend the @@ -7513,7 +7513,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start, // to be changed, so we are doing this after all global state has // been updated. See the comment above suspend_EE() above for more // info. - stomp_write_barrier_resize(!!IsGCThread(), la != saved_g_lowest_address); + stomp_write_barrier_resize(GCToEEInterface::IsGCThread(), la != saved_g_lowest_address); } @@ -15519,8 +15519,8 @@ void gc_heap::gc1() #endif //BACKGROUND_GC { #ifndef FEATURE_REDHAWK - // IsGCThread() always returns false on CoreRT, but this assert is useful in CoreCLR. - assert(!!IsGCThread()); + // GCToEEInterface::IsGCThread() always returns false on CoreRT, but this assert is useful in CoreCLR. + assert(GCToEEInterface::IsGCThread()); #endif // FEATURE_REDHAWK adjust_ephemeral_limits(); } @@ -34013,7 +34013,7 @@ bool GCHeap::StressHeap(gc_alloc_context * context) #ifdef BACKGROUND_GC // don't trigger a GC from the GC threads but still trigger GCs from user threads. - if (IsGCSpecialThread()) + if (GCToEEInterface::IsGCSpecialThread()) { return FALSE; } diff --git a/src/gc/gcenv.ee.standalone.inl b/src/gc/gcenv.ee.standalone.inl index 0dcf05da4d..0b6a1cfb11 100644 --- a/src/gc/gcenv.ee.standalone.inl +++ b/src/gc/gcenv.ee.standalone.inl @@ -246,4 +246,16 @@ inline void GCToEEInterface::FreeStringConfigValue(const char* value) g_theGCToCLR->FreeStringConfigValue(value); } +inline bool GCToEEInterface::IsGCThread() +{ + assert(g_theGCToCLR != nullptr); + return g_theGCToCLR->IsGCThread(); +} + +inline bool GCToEEInterface::IsGCSpecialThread() +{ + assert(g_theGCToCLR != nullptr); + return g_theGCToCLR->IsGCSpecialThread(); +} + #endif // __GCTOENV_EE_STANDALONE_INL__ diff --git a/src/gc/gcinterface.ee.h b/src/gc/gcinterface.ee.h index 1e08043b02..d65da60678 100644 --- a/src/gc/gcinterface.ee.h +++ b/src/gc/gcinterface.ee.h @@ -191,6 +191,17 @@ public: virtual void FreeStringConfigValue(const char* value) = 0; + + // Asks the EE about whether or not the current thread is a GC thread: + // a server GC thread, background GC thread, or the thread that suspended + // the EE at the start of a GC. + virtual + bool IsGCThread() = 0; + + // Asks the EE about whether or not the current thread is a GC "special" + // thread: a server GC thread or a background GC thread. + virtual + bool IsGCSpecialThread() = 0; }; #endif // _GCINTERFACE_EE_H_ diff --git a/src/gc/sample/gcenv.ee.cpp b/src/gc/sample/gcenv.ee.cpp index de1a2ad5ee..8fd4487192 100644 --- a/src/gc/sample/gcenv.ee.cpp +++ b/src/gc/sample/gcenv.ee.cpp @@ -316,6 +316,16 @@ void GCToEEInterface::FreeStringConfigValue(const char *value) } +bool GCToEEInterface::IsGCThread() +{ + return false; +} + +bool GCToEEInterface::IsGCSpecialThread() +{ + return false; +} + MethodTable* GCToEEInterface::GetFreeObjectMethodTable() { return g_pFreeObjectMethodTable; diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index 83935c378f..959687b7b8 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -1169,3 +1169,13 @@ void GCToEEInterface::FreeStringConfigValue(const char* value) { delete [] value; } + +bool GCToEEInterface::IsGCThread() +{ + return !!::IsGCThread(); +} + +bool GCToEEInterface::IsGCSpecialThread() +{ + return !!::IsGCSpecialThread(); +} diff --git a/src/vm/gcenv.ee.h b/src/vm/gcenv.ee.h index c9000b2485..063fa2554e 100644 --- a/src/vm/gcenv.ee.h +++ b/src/vm/gcenv.ee.h @@ -58,6 +58,8 @@ public: bool GetIntConfigValue(const char* key, int64_t* value); bool GetStringConfigValue(const char* key, const char** value); void FreeStringConfigValue(const char* value); + bool IsGCThread(); + bool IsGCSpecialThread(); }; } // namespace standalone |