Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 8 additions & 7 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ void EEStartupHelper()
// the completion of its initialization part that initializes COM as that has to be done
// before the first Thread is attached. Thus we want to give the thread a bit more time.
FinalizerThread::FinalizerThreadCreate();
#endif
#endif // TARGET_WINDOWS

InitPreStubManager();

Expand Down Expand Up @@ -926,17 +926,18 @@ void EEStartupHelper()
}
#endif

#ifdef TARGET_WINDOWS
// On windows the finalizer thread is already partially created and is waiting
// right before doing HasStarted(). We will release it now.
FinalizerThread::EnableFinalization();
#elif defined(TARGET_WASM)
// on wasm we need to run finalizers on main thread as we are single threaded
// active issue: https://github.com/dotnet/runtime/issues/114096
#if !defined(TARGET_WINDOWS) && !defined(TARGET_WASM)
#else
// This isn't done as part of InitializeGarbageCollector() above because
// debugger must be initialized before creating EE thread objects
FinalizerThread::FinalizerThreadCreate();
#else
// On windows the finalizer thread is already partially created and is waiting
// right before doing HasStarted(). We will release it now.
FinalizerThread::EnableFinalization();
#endif
#endif // TARGET_WINDOWS

#ifdef FEATURE_PERFTRACING
// Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup.
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/vm/dllimportcallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,13 @@ UMEntryThunkData* UMEntryThunkData::CreateUMEntryThunk()
AllocMemTracker *pamTracker = &amTracker;

pData = (UMEntryThunkData *)pamTracker->Track(pLoaderAllocator->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(UMEntryThunkData))));
UMEntryThunk* pThunk = (UMEntryThunk*)pamTracker->Track(pLoaderAllocator->GetNewStubPrecodeHeap()->AllocStub());
UMEntryThunk* pThunk;
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
PORTABILITY_ASSERT("WASMTODO: Marshalled delegates are not supported with wasm.");
pThunk = NULL;
#else // !FEATURE_PORTABLE_ENTRYPOINTS
pThunk = (UMEntryThunk*)pamTracker->Track(pLoaderAllocator->GetNewStubPrecodeHeap()->AllocStub());
#endif // FEATURE_PORTABLE_ENTRYPOINTS
#ifdef FEATURE_PERFMAP
PerfMap::LogStubs(__FUNCTION__, "UMEntryThunk", (PCODE)pThunk, sizeof(UMEntryThunk), PerfMapStubType::IndividualWithinBlock);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ void FinalizerThread::EnableFinalization()
{
WRAPPER_NO_CONTRACT;

#ifndef TARGET_WASM
hEventFinalizer->Set();
#endif // !TARGET_WASM
}

namespace
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/loaderallocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,10 +1235,12 @@ void LoaderAllocator::Init(BYTE *pExecutableHeapMemory)

initReservedMem += dwStubHeapReserveSize;

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
m_pNewStubPrecodeHeap = new (&m_NewStubPrecodeHeapInstance) InterleavedLoaderHeap(
&m_stubPrecodeRangeList,
false /* fUnlocked */,
&s_stubPrecodeHeapConfig);
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

#if defined(FEATURE_STUBPRECODE_DYNAMIC_HELPERS) && defined(FEATURE_READYTORUN)
if (IsCollectible())
Expand Down Expand Up @@ -1434,11 +1436,13 @@ void LoaderAllocator::Terminate()
m_pStubHeap = NULL;
}

#ifdef HAS_FIXUP_PRECODE
if (m_pFixupPrecodeHeap != NULL)
{
m_pFixupPrecodeHeap->~InterleavedLoaderHeap();
m_pFixupPrecodeHeap = NULL;
}
#endif // HAS_FIXUP_PRECODE

#ifdef FEATURE_READYTORUN
#ifdef FEATURE_STUBPRECODE_DYNAMIC_HELPERS
Expand All @@ -1459,11 +1463,13 @@ void LoaderAllocator::Terminate()
#endif // FEATURE_STUBPRECODE_DYNAMIC_HELPERS
#endif

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
if (m_pNewStubPrecodeHeap != NULL)
{
m_pNewStubPrecodeHeap->~InterleavedLoaderHeap();
m_pNewStubPrecodeHeap = NULL;
}
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

if (m_pFuncPtrStubs != NULL)
{
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/vm/loaderallocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ class LoaderAllocator
BYTE m_LowFreqHeapInstance[sizeof(LoaderHeap)];
BYTE m_HighFreqHeapInstance[sizeof(LoaderHeap)];
BYTE m_StubHeapInstance[sizeof(LoaderHeap)];
#ifdef HAS_FIXUP_PRECODE
BYTE m_FixupPrecodeHeapInstance[sizeof(InterleavedLoaderHeap)];
#endif // HAS_FIXUP_PRECODE
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
BYTE m_NewStubPrecodeHeapInstance[sizeof(InterleavedLoaderHeap)];
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
BYTE m_StaticsHeapInstance[sizeof(LoaderHeap)];
#ifdef FEATURE_READYTORUN
#ifdef FEATURE_STUBPRECODE_DYNAMIC_HELPERS
Expand All @@ -330,8 +334,15 @@ class LoaderAllocator
PTR_CodeFragmentHeap m_pDynamicHelpersHeap;
#endif // !FEATURE_STUBPRECODE_DYNAMIC_HELPERS
#endif // FEATURE_READYTORUN

#ifdef HAS_FIXUP_PRECODE
PTR_InterleavedLoaderHeap m_pFixupPrecodeHeap;
#endif // HAS_FIXUP_PRECODE

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
PTR_InterleavedLoaderHeap m_pNewStubPrecodeHeap;
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

//****************************************************************************************
OBJECTHANDLE m_hLoaderAllocatorObjectHandle;
FuncPtrStubs * m_pFuncPtrStubs; // for GetMultiCallableAddrOfCode()
Expand Down Expand Up @@ -626,11 +637,13 @@ class LoaderAllocator
return m_pStubHeap;
}

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
PTR_InterleavedLoaderHeap GetNewStubPrecodeHeap()
{
LIMITED_METHOD_CONTRACT;
return m_pNewStubPrecodeHeap;
}
#endif // !FEATURE_PORTABLE_ENTRYPOINTS

#if defined(FEATURE_READYTORUN) && defined(FEATURE_STUBPRECODE_DYNAMIC_HELPERS)
PTR_InterleavedLoaderHeap GetDynamicHelpersStubHeap()
Expand All @@ -648,11 +661,13 @@ class LoaderAllocator
return m_pExecutableHeap;
}

#ifdef HAS_FIXUP_PRECODE
PTR_InterleavedLoaderHeap GetFixupPrecodeHeap()
{
LIMITED_METHOD_CONTRACT;
return m_pFixupPrecodeHeap;
}
#endif // HAS_FIXUP_PRECODE

PTR_CodeFragmentHeap GetDynamicHelpersHeap();

Expand Down
Loading