Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT-LLVM] Move RhpPInvoke and undefine BACKGROUND_GC #2481

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,9 @@ inline void FATAL_GC_ERROR()
#define FEATURE_PREMORTEM_FINALIZATION
#define GC_HISTORY

#ifndef TARGET_WASM
#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)
#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)
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/nativeaot/Runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 18 additions & 7 deletions src/coreclr/nativeaot/Runtime/wasm/PInvoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}