diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index ec3ea813dd30..9b71e294f741 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -14076,7 +14076,7 @@ HRESULT gc_heap::initialize_gc (size_t soh_segment_size, #ifdef WRITE_WATCH hardware_write_watch_api_supported(); -#ifdef BACKGROUND_GC_SUPPORTED +#ifdef BACKGROUND_GC if (can_use_write_watch_for_gc_heap() && GCConfig::GetConcurrentGC()) { gc_can_use_concurrent = true; diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index 6cecb63ad1c1..567593f30fcf 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -185,12 +185,9 @@ inline void FATAL_GC_ERROR() #define FEATURE_PREMORTEM_FINALIZATION #define GC_HISTORY -#define BACKGROUND_GC //concurrent background GC (requires WRITE_WATCH) - -// It is no longer possible to build without BACKGROUND_GC defined, so we have to use this duplicate #if !defined(TARGET_WASM) || defined(FEATURE_WASM_THREADS) -#define BACKGROUND_GC_SUPPORTED -#endif // !defined(TARGET_WASM) || defined(FEATURE_WASM_THREADS) +#define BACKGROUND_GC //concurrent background GC (requires WRITE_WATCH) +#endif // We need the lower 3 bits in the MT to do our bookkeeping so doubly linked free list is only for 64-bit #if defined(BACKGROUND_GC) && defined(HOST_64BIT) diff --git a/src/coreclr/nativeaot/Runtime/thread.cpp b/src/coreclr/nativeaot/Runtime/thread.cpp index 693dc9097960..78d6c8d5003a 100644 --- a/src/coreclr/nativeaot/Runtime/thread.cpp +++ b/src/coreclr/nativeaot/Runtime/thread.cpp @@ -1297,17 +1297,7 @@ COOP_PINVOKE_HELPER(void, RhpReversePInvokeReturn, (ReversePInvokeFrame * pFrame #ifdef USE_PORTABLE_HELPERS -#ifdef HOST_WASM -extern "C" void RhpSetShadowStackTop(void*); -COOP_PINVOKE_HELPER(void, RhpPInvoke, (void* pShadowStack, PInvokeTransitionFrame* pFrame)) -{ - // The implementation has to live in this file because of "FORCEINLINE" on "Thread::InlinePInvoke". - // Ideally, "InlinePInvoke" would be in "thread.inl", and this function - in "wasm/PInvoke.cpp". - RhpSetShadowStackTop(pShadowStack); - Thread* pCurThread = ThreadStore::RawGetCurrentThread(); - pCurThread->InlinePInvoke(pFrame); -} -#else // !HOST_WASM +#ifndef HOST_WASM COOP_PINVOKE_HELPER(void, RhpPInvoke, (PInvokeTransitionFrame* pFrame)) { Thread * pCurThread = ThreadStore::RawGetCurrentThread(); diff --git a/src/coreclr/nativeaot/Runtime/wasm/PInvoke.cpp b/src/coreclr/nativeaot/Runtime/wasm/PInvoke.cpp index fc5c547d88f6..5ada6305b79d 100644 --- a/src/coreclr/nativeaot/Runtime/wasm/PInvoke.cpp +++ b/src/coreclr/nativeaot/Runtime/wasm/PInvoke.cpp @@ -9,10 +9,24 @@ #include "daccess.h" #include "PalRedhawkCommon.h" #include "PalRedhawk.h" +#include "thread.h" +#include "threadstore.h" +#include "thread.inl" +#include "threadstore.inl" thread_local void* t_pShadowStackBottom = nullptr; thread_local void* t_pShadowStackTop = nullptr; +void* GetShadowStackBottom() +{ + return t_pShadowStackBottom; +} + +void* GetShadowStackTop() +{ + return t_pShadowStackTop; +} + COOP_PINVOKE_HELPER(void*, RhpGetOrInitShadowStackTop, ()) { void* pShadowStack = t_pShadowStackTop; @@ -41,12 +55,9 @@ COOP_PINVOKE_HELPER(void, RhpSetShadowStackTop, (void* pShadowStack)) t_pShadowStackTop = pShadowStack; } -void* GetShadowStackBottom() -{ - return t_pShadowStackBottom; -} - -void* GetShadowStackTop() +COOP_PINVOKE_HELPER(void, RhpPInvoke, (void* pShadowStack, PInvokeTransitionFrame* pFrame)) { - return t_pShadowStackTop; + RhpSetShadowStackTop(pShadowStack); + Thread* pCurThread = ThreadStore::RawGetCurrentThread(); + pCurThread->InlinePInvoke(pFrame); }