diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 3515db9792064a..fb59a8eb5903f6 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -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(); @@ -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. diff --git a/src/coreclr/vm/dllimportcallback.cpp b/src/coreclr/vm/dllimportcallback.cpp index 2224e189fdac1f..3947a139990a70 100644 --- a/src/coreclr/vm/dllimportcallback.cpp +++ b/src/coreclr/vm/dllimportcallback.cpp @@ -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 diff --git a/src/coreclr/vm/finalizerthread.cpp b/src/coreclr/vm/finalizerthread.cpp index ef5949ec055404..9be9ead073bfc5 100644 --- a/src/coreclr/vm/finalizerthread.cpp +++ b/src/coreclr/vm/finalizerthread.cpp @@ -43,7 +43,9 @@ void FinalizerThread::EnableFinalization() { WRAPPER_NO_CONTRACT; +#ifndef TARGET_WASM hEventFinalizer->Set(); +#endif // !TARGET_WASM } namespace diff --git a/src/coreclr/vm/loaderallocator.cpp b/src/coreclr/vm/loaderallocator.cpp index c6cb894b008458..e6a113c62b6334 100644 --- a/src/coreclr/vm/loaderallocator.cpp +++ b/src/coreclr/vm/loaderallocator.cpp @@ -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()) @@ -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 @@ -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) { diff --git a/src/coreclr/vm/loaderallocator.hpp b/src/coreclr/vm/loaderallocator.hpp index 6c876fde167574..74c4b0c9bfc64b 100644 --- a/src/coreclr/vm/loaderallocator.hpp +++ b/src/coreclr/vm/loaderallocator.hpp @@ -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 @@ -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() @@ -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() @@ -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();