Skip to content

Commit a3b607a

Browse files
[wasm coreclr] Minor nits (#119369)
* Disable finalizer calls on WASM * Disable InterleavedLoaderHeap when FEATURE_PORTABLE_ENTRYPOINTS is set.
1 parent 203b67e commit a3b607a

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

src/coreclr/vm/ceemain.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void EEStartupHelper()
865865
// the completion of its initialization part that initializes COM as that has to be done
866866
// before the first Thread is attached. Thus we want to give the thread a bit more time.
867867
FinalizerThread::FinalizerThreadCreate();
868-
#endif
868+
#endif // TARGET_WINDOWS
869869

870870
InitPreStubManager();
871871

@@ -926,17 +926,18 @@ void EEStartupHelper()
926926
}
927927
#endif
928928

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

941942
#ifdef FEATURE_PERFTRACING
942943
// Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup.

src/coreclr/vm/dllimportcallback.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ UMEntryThunkData* UMEntryThunkData::CreateUMEntryThunk()
287287
AllocMemTracker *pamTracker = &amTracker;
288288

289289
pData = (UMEntryThunkData *)pamTracker->Track(pLoaderAllocator->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(UMEntryThunkData))));
290-
UMEntryThunk* pThunk = (UMEntryThunk*)pamTracker->Track(pLoaderAllocator->GetNewStubPrecodeHeap()->AllocStub());
290+
UMEntryThunk* pThunk;
291+
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
292+
PORTABILITY_ASSERT("WASMTODO: Marshalled delegates are not supported with wasm.");
293+
pThunk = NULL;
294+
#else // !FEATURE_PORTABLE_ENTRYPOINTS
295+
pThunk = (UMEntryThunk*)pamTracker->Track(pLoaderAllocator->GetNewStubPrecodeHeap()->AllocStub());
296+
#endif // FEATURE_PORTABLE_ENTRYPOINTS
291297
#ifdef FEATURE_PERFMAP
292298
PerfMap::LogStubs(__FUNCTION__, "UMEntryThunk", (PCODE)pThunk, sizeof(UMEntryThunk), PerfMapStubType::IndividualWithinBlock);
293299
#endif

src/coreclr/vm/finalizerthread.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ void FinalizerThread::EnableFinalization()
4343
{
4444
WRAPPER_NO_CONTRACT;
4545

46+
#ifndef TARGET_WASM
4647
hEventFinalizer->Set();
48+
#endif // !TARGET_WASM
4749
}
4850

4951
namespace

src/coreclr/vm/loaderallocator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,12 @@ void LoaderAllocator::Init(BYTE *pExecutableHeapMemory)
12351235

12361236
initReservedMem += dwStubHeapReserveSize;
12371237

1238+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
12381239
m_pNewStubPrecodeHeap = new (&m_NewStubPrecodeHeapInstance) InterleavedLoaderHeap(
12391240
&m_stubPrecodeRangeList,
12401241
false /* fUnlocked */,
12411242
&s_stubPrecodeHeapConfig);
1243+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
12421244

12431245
#if defined(FEATURE_STUBPRECODE_DYNAMIC_HELPERS) && defined(FEATURE_READYTORUN)
12441246
if (IsCollectible())
@@ -1434,11 +1436,13 @@ void LoaderAllocator::Terminate()
14341436
m_pStubHeap = NULL;
14351437
}
14361438

1439+
#ifdef HAS_FIXUP_PRECODE
14371440
if (m_pFixupPrecodeHeap != NULL)
14381441
{
14391442
m_pFixupPrecodeHeap->~InterleavedLoaderHeap();
14401443
m_pFixupPrecodeHeap = NULL;
14411444
}
1445+
#endif // HAS_FIXUP_PRECODE
14421446

14431447
#ifdef FEATURE_READYTORUN
14441448
#ifdef FEATURE_STUBPRECODE_DYNAMIC_HELPERS
@@ -1459,11 +1463,13 @@ void LoaderAllocator::Terminate()
14591463
#endif // FEATURE_STUBPRECODE_DYNAMIC_HELPERS
14601464
#endif
14611465

1466+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
14621467
if (m_pNewStubPrecodeHeap != NULL)
14631468
{
14641469
m_pNewStubPrecodeHeap->~InterleavedLoaderHeap();
14651470
m_pNewStubPrecodeHeap = NULL;
14661471
}
1472+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
14671473

14681474
if (m_pFuncPtrStubs != NULL)
14691475
{

src/coreclr/vm/loaderallocator.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ class LoaderAllocator
310310
BYTE m_LowFreqHeapInstance[sizeof(LoaderHeap)];
311311
BYTE m_HighFreqHeapInstance[sizeof(LoaderHeap)];
312312
BYTE m_StubHeapInstance[sizeof(LoaderHeap)];
313+
#ifdef HAS_FIXUP_PRECODE
313314
BYTE m_FixupPrecodeHeapInstance[sizeof(InterleavedLoaderHeap)];
315+
#endif // HAS_FIXUP_PRECODE
316+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
314317
BYTE m_NewStubPrecodeHeapInstance[sizeof(InterleavedLoaderHeap)];
318+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
315319
BYTE m_StaticsHeapInstance[sizeof(LoaderHeap)];
316320
#ifdef FEATURE_READYTORUN
317321
#ifdef FEATURE_STUBPRECODE_DYNAMIC_HELPERS
@@ -330,8 +334,15 @@ class LoaderAllocator
330334
PTR_CodeFragmentHeap m_pDynamicHelpersHeap;
331335
#endif // !FEATURE_STUBPRECODE_DYNAMIC_HELPERS
332336
#endif // FEATURE_READYTORUN
337+
338+
#ifdef HAS_FIXUP_PRECODE
333339
PTR_InterleavedLoaderHeap m_pFixupPrecodeHeap;
340+
#endif // HAS_FIXUP_PRECODE
341+
342+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
334343
PTR_InterleavedLoaderHeap m_pNewStubPrecodeHeap;
344+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
345+
335346
//****************************************************************************************
336347
OBJECTHANDLE m_hLoaderAllocatorObjectHandle;
337348
FuncPtrStubs * m_pFuncPtrStubs; // for GetMultiCallableAddrOfCode()
@@ -626,11 +637,13 @@ class LoaderAllocator
626637
return m_pStubHeap;
627638
}
628639

640+
#ifndef FEATURE_PORTABLE_ENTRYPOINTS
629641
PTR_InterleavedLoaderHeap GetNewStubPrecodeHeap()
630642
{
631643
LIMITED_METHOD_CONTRACT;
632644
return m_pNewStubPrecodeHeap;
633645
}
646+
#endif // !FEATURE_PORTABLE_ENTRYPOINTS
634647

635648
#if defined(FEATURE_READYTORUN) && defined(FEATURE_STUBPRECODE_DYNAMIC_HELPERS)
636649
PTR_InterleavedLoaderHeap GetDynamicHelpersStubHeap()
@@ -648,11 +661,13 @@ class LoaderAllocator
648661
return m_pExecutableHeap;
649662
}
650663

664+
#ifdef HAS_FIXUP_PRECODE
651665
PTR_InterleavedLoaderHeap GetFixupPrecodeHeap()
652666
{
653667
LIMITED_METHOD_CONTRACT;
654668
return m_pFixupPrecodeHeap;
655669
}
670+
#endif // HAS_FIXUP_PRECODE
656671

657672
PTR_CodeFragmentHeap GetDynamicHelpersHeap();
658673

0 commit comments

Comments
 (0)