From a9ca2206bd4f94514608d2ebee3c4733609c5976 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 4 Sep 2025 13:18:41 +0200 Subject: [PATCH 01/15] Fix build when tiered compilation is disabled --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 8 ++++---- src/coreclr/inc/dacvars.h | 2 ++ src/coreclr/inc/vptr_list.h | 2 ++ src/coreclr/vm/amd64/asmconstants.h | 2 ++ src/coreclr/vm/amd64/thunktemplates.S | 6 +++++- src/coreclr/vm/arm/asmconstants.h | 2 ++ src/coreclr/vm/arm64/asmconstants.h | 2 ++ src/coreclr/vm/arm64/asmhelpers.S | 6 +++++- src/coreclr/vm/arm64/thunktemplates.S | 8 ++++++-- src/coreclr/vm/eventtrace.cpp | 6 ++++++ src/coreclr/vm/i386/asmconstants.h | 2 ++ src/coreclr/vm/i386/thunktemplates.S | 2 ++ src/coreclr/vm/loongarch64/asmconstants.h | 2 ++ src/coreclr/vm/loongarch64/asmhelpers.S | 6 +++++- src/coreclr/vm/loongarch64/thunktemplates.S | 2 ++ src/coreclr/vm/riscv64/asmconstants.h | 2 ++ src/coreclr/vm/riscv64/asmhelpers.S | 6 +++++- 17 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 8465c0ec4a1790..64b92a5022e140 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -914,7 +914,7 @@ void DacDbiInterfaceImpl::GetSequencePoints(MethodDesc * pMethodDesc, ULONG32 entryCount; BOOL success = DebugInfoManager::GetBoundariesAndVars(request, - InfoStoreNew, + InfoStoreNew, NULL, // allocator BoundsType::Uninstrumented, &entryCount, &mapCopy, @@ -5515,7 +5515,7 @@ void DacDbiInterfaceImpl::GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContex { UpdateContextFromRegDisp(&tmpRd, &tmpContext); CopyMemory(pContextBuffer, &tmpContext, sizeof(*pContextBuffer)); - pContextBuffer->ContextFlags = DT_CONTEXT_CONTROL + pContextBuffer->ContextFlags = DT_CONTEXT_CONTROL #if defined(TARGET_AMD64) || defined(TARGET_ARM) | DT_CONTEXT_INTEGER // DT_CONTEXT_INTEGER is needed to include the frame register on ARM32 and AMD64 architectures // DT_CONTEXT_CONTROL already includes the frame register for X86 and ARM64 architectures @@ -7196,7 +7196,7 @@ HRESULT DacDbiInterfaceImpl::AreOptimizationsDisabled(VMPTR_Module vmModule, mdM *pOptimizationsDisabled = activeILVersion.IsDeoptimized(); } #else - pOptimizationsDisabled->SetDacTargetPtr(0); + *pOptimizationsDisabled = FALSE; #endif return S_OK; @@ -7339,7 +7339,7 @@ HRESULT DacDbiInterfaceImpl::GetDomainAssemblyFromModule(VMPTR_Module vmModule, pVmDomainAssembly->SetHostPtr(pModule->GetDomainAssembly()); return S_OK; -} +} DacRefWalker::DacRefWalker(ClrDataAccess *dac, BOOL walkStacks, BOOL walkFQ, UINT32 handleMask, BOOL resolvePointers) : mDac(dac), mWalkStacks(walkStacks), mWalkFQ(walkFQ), mHandleMask(handleMask), mStackWalker(NULL), diff --git a/src/coreclr/inc/dacvars.h b/src/coreclr/inc/dacvars.h index 31a618b33d0369..75b4b2e4d56ba4 100644 --- a/src/coreclr/inc/dacvars.h +++ b/src/coreclr/inc/dacvars.h @@ -98,7 +98,9 @@ DEFINE_DACVAR(PTR_StubLinkStubManager, StubLinkStubManager__g_pManager, StubLink DEFINE_DACVAR(PTR_JumpStubStubManager, JumpStubStubManager__g_pManager, JumpStubStubManager::g_pManager) DEFINE_DACVAR(PTR_RangeSectionStubManager, RangeSectionStubManager__g_pManager, RangeSectionStubManager::g_pManager) DEFINE_DACVAR(PTR_VirtualCallStubManagerManager, VirtualCallStubManagerManager__g_pManager, VirtualCallStubManagerManager::g_pManager) +#ifdef FEATURE_TIERED_COMPILATION DEFINE_DACVAR(PTR_CallCountingStubManager, CallCountingStubManager__g_pManager, CallCountingStubManager::g_pManager) +#endif DEFINE_DACVAR(PTR_ThreadStore, ThreadStore__s_pThreadStore, ThreadStore::s_pThreadStore) diff --git a/src/coreclr/inc/vptr_list.h b/src/coreclr/inc/vptr_list.h index 8fade7caa332bf..0959a394e3ca85 100644 --- a/src/coreclr/inc/vptr_list.h +++ b/src/coreclr/inc/vptr_list.h @@ -37,7 +37,9 @@ VPTR_CLASS(InteropDispatchStubManager) #if defined(TARGET_X86) && !defined(UNIX_X86_ABI) VPTR_CLASS(TailCallStubManager) #endif +#ifdef FEATURE_TIERED_COMPILATION VPTR_CLASS(CallCountingStubManager) +#endif VPTR_CLASS(PEImageLayout) VPTR_CLASS(ConvertedImageLayout) diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 1880ecbafdd340..a37c1bbbdd0e0e 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -538,6 +538,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecode #define StubPrecodeData__SecretParam 0x00 ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, SecretParam)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -546,6 +547,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #ifdef FEATURE_CACHED_INTERFACE_DISPATCH #define OFFSETOF__InterfaceDispatchCache__m_rgEntries 0x20 diff --git a/src/coreclr/vm/amd64/thunktemplates.S b/src/coreclr/vm/amd64/thunktemplates.S index 611556da202bb9..cb18e081985a6b 100644 --- a/src/coreclr/vm/amd64/thunktemplates.S +++ b/src/coreclr/vm/amd64/thunktemplates.S @@ -57,7 +57,7 @@ LEAF_END_MARKED StubPrecodeCodeTemplate, _TEXT // FixupPrecode // ---------- -#define FIXUP_PRECODE_CODESIZE 0x18 +#define FIXUP_PRECODE_CODESIZE 0x18 #define FIXUP_PRECODE_DATASIZE 0x18 // 3 qwords .set FIXUP_PRECODE_NUM_THUNKS_PER_MAPPING,(THUNKS_MAP_SIZE / FIXUP_PRECODE_CODESIZE) @@ -101,6 +101,7 @@ LEAF_ENTRY FixupPrecodeCodeTemplate int 3 LEAF_END_MARKED FixupPrecodeCodeTemplate, _TEXT +#ifdef FEATURE_TIERED_COMPILATION // ---------- // CallCountingStub // ---------- @@ -144,6 +145,7 @@ LEAF_ENTRY CallCountingStubCodeTemplate int 3 int 3 LEAF_END_MARKED CallCountingStubCodeTemplate, _TEXT +#endif // FEATURE_TIERED_COMPILATION #endif @@ -168,6 +170,7 @@ PATCH_LABEL FixupPrecodeCode_Fixup jmp [rip + DATA_SLOT(FixupPrecode, PrecodeFixupThunk)] LEAF_END_MARKED FixupPrecodeCode, _TEXT +#ifdef FEATURE_TIERED_COMPILATION LEAF_ENTRY CallCountingStubCode, _TEXT mov rax,QWORD PTR [rip + DATA_SLOT(CallCountingStub, RemainingCallCountCell)] dec WORD PTR [rax] @@ -176,3 +179,4 @@ LEAF_ENTRY CallCountingStubCode, _TEXT LOCAL_LABEL(CountReachedZero): jmp QWORD PTR [rip + DATA_SLOT(CallCountingStub, TargetForThresholdReached)] LEAF_END_MARKED CallCountingStubCode, _TEXT +#endif // FEATURE_TIERED_COMPILATION diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index 0f4840be10697a..7e4197697eb599 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -187,6 +187,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, #define StubPrecodeData__Target 0x04 ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecodeData, Target)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -195,6 +196,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x08 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 0x1 diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index b5b9de92ff4847..e34661fa7b9fff 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -274,6 +274,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecode #define StubPrecodeData__SecretParam 0x00 ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, SecretParam)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -282,6 +283,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #ifdef FEATURE_CACHED_INTERFACE_DISPATCH #define OFFSETOF__InterfaceDispatchCache__m_rgEntries 0x20 diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index 801995254258d7..5b04330cecea0d 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -579,6 +579,10 @@ NESTED_ENTRY OnCallCountThresholdReachedStub, _TEXT, NoHandler EPILOG_BRANCH_REG x9 NESTED_END OnCallCountThresholdReachedStub, _TEXT +#endif // FEATURE_TIERED_COMPILATION + +#ifdef FEATURE_ON_STACK_REPLACEMENT + NESTED_ENTRY JIT_Patchpoint, _TEXT, NoHandler PROLOG_WITH_TRANSITION_BLOCK @@ -595,7 +599,7 @@ LEAF_ENTRY JIT_PatchpointForced, _TEXT b C_FUNC(JIT_Patchpoint) LEAF_END JIT_PatchpointForced, _TEXT -#endif // FEATURE_TIERED_COMPILATION +#endif // FEATURE_ON_STACK_REPLACEMENT LEAF_ENTRY JIT_ValidateIndirectCall, _TEXT ret lr diff --git a/src/coreclr/vm/arm64/thunktemplates.S b/src/coreclr/vm/arm64/thunktemplates.S index 6320513b73e4c3..e8e9e9ba020d46 100644 --- a/src/coreclr/vm/arm64/thunktemplates.S +++ b/src/coreclr/vm/arm64/thunktemplates.S @@ -65,7 +65,7 @@ LEAF_END_MARKED StubPrecodeCodeTemplate, _TEXT dmb ishld ldr x12, DATA_SLOT(FixupPrecode, MethodDesc, FIXUP_PRECODE_CODESIZE, FixupPrecodeCodeTemplate) ldr x11, DATA_SLOT(FixupPrecode, PrecodeFixupThunk, FIXUP_PRECODE_CODESIZE, FixupPrecodeCodeTemplate) - br x11 + br x11 IN_PAGE_INDEX = IN_PAGE_INDEX + 1 .endr @@ -77,6 +77,7 @@ LEAF_ENTRY FixupPrecodeCodeTemplate THUNKS_BLOCK_FIXUP_PRECODE LEAF_END_MARKED FixupPrecodeCodeTemplate, _TEXT +#ifdef FEATURE_TIERED_COMPILATION // ---------- // CallCountingStub // ---------- @@ -110,6 +111,7 @@ LEAF_END_MARKED FixupPrecodeCodeTemplate, _TEXT LEAF_ENTRY CallCountingStubCodeTemplate THUNKS_BLOCK_CALLCOUNTING LEAF_END_MARKED CallCountingStubCodeTemplate, _TEXT +#endif // FEATURE_TIERED_COMPILATION #endif #ifdef DATA_SLOT @@ -134,9 +136,10 @@ LEAF_END_MARKED CallCountingStubCodeTemplate, _TEXT dmb ishld ldr x12, DATA_SLOT(FixupPrecode, MethodDesc) ldr x11, DATA_SLOT(FixupPrecode, PrecodeFixupThunk) - br x11 + br x11 LEAF_END_MARKED FixupPrecodeCode\STUB_PAGE_SIZE +#ifdef FEATURE_TIERED_COMPILATION LEAF_ENTRY CallCountingStubCode\STUB_PAGE_SIZE LOCAL_LABEL(StubStart\STUB_PAGE_SIZE): ldr x9, DATA_SLOT(CallCountingStub, RemainingCallCountCell) @@ -151,5 +154,6 @@ LOCAL_LABEL(CountReachedZero\STUB_PAGE_SIZE): br x10 brk 0xf000 // Stubs need to be aligned in total size LEAF_END_MARKED CallCountingStubCode\STUB_PAGE_SIZE +#endif // FEATURE_TIERED_COMPILATION .endr diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index e1553b5d348611..004d21227c1bf9 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -1925,10 +1925,12 @@ VOID ETW::EnumerationLog::SendOneTimeRundownEvents() // Fire the runtime information event ETW::InfoLog::RuntimeInformation(ETW::InfoLog::InfoStructs::Callback); +#if defined(FEATURE_TIERED_COMPILATION) if (ETW::CompilationLog::TieredCompilation::Rundown::IsEnabled() && g_pConfig->TieredCompilation()) { ETW::CompilationLog::TieredCompilation::Rundown::SendSettings(); } +#endif // FEATURE_TIERED_COMPILATION } @@ -5443,6 +5445,7 @@ VOID ETW::EnumerationLog::EnumerationHelper(Module *moduleFilter, DWORD enumerat } } +#if defined(FEATURE_TIERED_COMPILATION) void ETW::CompilationLog::TieredCompilation::GetSettings(UINT32 *flagsRef) { CONTRACTL { @@ -5484,7 +5487,9 @@ void ETW::CompilationLog::TieredCompilation::GetSettings(UINT32 *flagsRef) #endif *flagsRef = flags; } +#endif // FEATURE_TIERED_COMPILATION +#if defined(FEATURE_TIERED_COMPILATION) void ETW::CompilationLog::TieredCompilation::Runtime::SendSettings() { CONTRACTL { @@ -5556,6 +5561,7 @@ void ETW::CompilationLog::TieredCompilation::Runtime::SendBackgroundJitStop(UINT FireEtwTieredCompilationBackgroundJitStop(GetClrInstanceId(), pendingMethodCount, jittedMethodCount); } +#endif // FEATURE_TIERED_COMPILATION #endif // !FEATURE_NATIVEAOT diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 6f5321582c84dd..336aef331fb612 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -301,6 +301,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecode #define StubPrecodeData__SecretParam 0x00 ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, SecretParam)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -309,6 +310,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x08 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #undef ASMCONSTANTS_C_ASSERT #undef ASMCONSTANTS_RUNTIME_ASSERT diff --git a/src/coreclr/vm/i386/thunktemplates.S b/src/coreclr/vm/i386/thunktemplates.S index d0b8257e32f50e..a9a2c34c157732 100644 --- a/src/coreclr/vm/i386/thunktemplates.S +++ b/src/coreclr/vm/i386/thunktemplates.S @@ -44,6 +44,7 @@ SLOT_ADDRESS_PATCH_LABEL FixupPrecode, MethodDesc SLOT_ADDRESS_PATCH_LABEL FixupPrecode, PrecodeFixupThunk LEAF_END_MARKED FixupPrecodeCode +#ifdef FEATURE_TIERED_COMPILATION LEAF_ENTRY CallCountingStubCode mov eax, dword ptr [DATA_SLOT(CallCountingStub, RemainingCallCountCell)] SLOT_ADDRESS_PATCH_LABEL CallCountingStub, RemainingCallCountCell @@ -55,3 +56,4 @@ LOCAL_LABEL(CountReachedZero): INDJMP DATA_SLOT(CallCountingStub, TargetForThresholdReached) SLOT_ADDRESS_PATCH_LABEL CallCountingStub, TargetForThresholdReached LEAF_END_MARKED CallCountingStubCode +#endif // FEATURE_TIERED_COMPILATION diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index 41589253cb9752..ff2afdd25989c7 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -219,6 +219,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecode #define StubPrecodeData__SecretParam 0x00 ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, SecretParam)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -227,6 +228,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 1 diff --git a/src/coreclr/vm/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index ce5a90fe2d5f8d..cdcaf96184cb27 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -949,6 +949,10 @@ NESTED_ENTRY OnCallCountThresholdReachedStub, _TEXT, NoHandler EPILOG_BRANCH_REG $t4 NESTED_END OnCallCountThresholdReachedStub, _TEXT +#endif // FEATURE_TIERED_COMPILATION + +#ifdef FEATURE_ON_STACK_REPLACEMENT + NESTED_ENTRY JIT_Patchpoint, _TEXT, NoHandler PROLOG_WITH_TRANSITION_BLOCK @@ -965,7 +969,7 @@ LEAF_ENTRY JIT_PatchpointForced, _TEXT b C_FUNC(JIT_Patchpoint) LEAF_END JIT_PatchpointForced, _TEXT -#endif // FEATURE_TIERED_COMPILATION +#endif // FEATURE_ON_STACK_REPLACEMENT // ------------------------------------------------------------------ // size_t GetThreadStaticsVariableOffset() diff --git a/src/coreclr/vm/loongarch64/thunktemplates.S b/src/coreclr/vm/loongarch64/thunktemplates.S index 52be9666d29582..cfdae816bc570c 100644 --- a/src/coreclr/vm/loongarch64/thunktemplates.S +++ b/src/coreclr/vm/loongarch64/thunktemplates.S @@ -24,6 +24,7 @@ LEAF_ENTRY FixupPrecodeCode jirl $r0,$r21,0 LEAF_END_MARKED FixupPrecodeCode +#ifdef FEATURE_TIERED_COMPILATION // NOTE: For LoongArch64 `CallCountingStubData__RemainingCallCountCell` must be zero !!! // Because the stub-identifying token is $t1 within the `OnCallCountThresholdReachedStub`. LEAF_ENTRY CallCountingStubCode @@ -39,3 +40,4 @@ LOCAL_LABEL(CountReachedZero): ld.d $r21, $t2, CallCountingStubData__TargetForThresholdReached jirl $r0,$r21,0 LEAF_END_MARKED CallCountingStubCode +#endif // FEATURE_TIERED_COMPILATION diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index b2260e8a30f26d..d277116584d9bf 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -220,6 +220,7 @@ ASMCONSTANTS_C_ASSERT(StubPrecodeData__Target == offsetof(StubPrecode #define StubPrecodeData__SecretParam 0x00 ASMCONSTANTS_C_ASSERT(StubPrecodeData__SecretParam == offsetof(StubPrecodeData, SecretParam)) +#ifdef FEATURE_TIERED_COMPILATION #define CallCountingStubData__RemainingCallCountCell 0x00 ASMCONSTANTS_C_ASSERT(CallCountingStubData__RemainingCallCountCell == offsetof(CallCountingStubData, RemainingCallCountCell)) @@ -228,6 +229,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) +#endif #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 1 diff --git a/src/coreclr/vm/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index 1c03436880c0cc..7e2db0a99a69f9 100644 --- a/src/coreclr/vm/riscv64/asmhelpers.S +++ b/src/coreclr/vm/riscv64/asmhelpers.S @@ -822,6 +822,10 @@ NESTED_ENTRY OnCallCountThresholdReachedStub, _TEXT, NoHandler EPILOG_BRANCH_REG t4 NESTED_END OnCallCountThresholdReachedStub, _TEXT +#endif // FEATURE_TIERED_COMPILATION + +#ifdef FEATURE_ON_STACK_REPLACEMENT + NESTED_ENTRY JIT_Patchpoint, _TEXT, NoHandler PROLOG_WITH_TRANSITION_BLOCK @@ -838,7 +842,7 @@ LEAF_ENTRY JIT_PatchpointForced, _TEXT j C_FUNC(JIT_Patchpoint) LEAF_END JIT_PatchpointForced, _TEXT -#endif // FEATURE_TIERED_COMPILATION +#endif // FEATURE_ON_STACK_REPLACEMENT // ------------------------------------------------------------------ // size_t GetThreadStaticsVariableOffset() From eb3ad2096715b71665dd7bd095ca502565f9fd60 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 4 Sep 2025 22:14:55 +0200 Subject: [PATCH 02/15] Fix build --- src/coreclr/clrfeatures.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/coreclr/clrfeatures.cmake b/src/coreclr/clrfeatures.cmake index ed8fdbdc577da9..0881965e6c979c 100644 --- a/src/coreclr/clrfeatures.cmake +++ b/src/coreclr/clrfeatures.cmake @@ -1,9 +1,6 @@ -if (NOT CLR_CMAKE_TARGET_ARCH_WASM) +if (NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_MACCATALYST) set(FEATURE_TIERED_COMPILATION 1) set(FEATURE_REJIT 1) -endif() - -if (NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_MACCATALYST) set(FEATURE_JIT 1) endif() From e86025ae9f5aa4fd47ffe9a791f38e4674718650 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 4 Sep 2025 23:59:26 +0200 Subject: [PATCH 03/15] Check for precode in JIT helper indirection --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 9efc29f22370d9..4a3e64eb86bd34 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10884,7 +10884,7 @@ void CEECodeGenInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN } } - if (IndirectionAllowedForJitHelper(ftnNum)) + if (IndirectionAllowedForJitHelper(ftnNum) && helperMD->HasPrecode()) { Precode* pPrecode = helperMD->GetPrecode(); _ASSERTE(pPrecode->GetType() == PRECODE_FIXUP); From ca4e4d6ebac3995f8011faac7c85f520e74e60c0 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:26:35 +0200 Subject: [PATCH 04/15] Update src/coreclr/inc/dacvars.h Co-authored-by: Aaron Robinson --- src/coreclr/inc/dacvars.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/inc/dacvars.h b/src/coreclr/inc/dacvars.h index 75b4b2e4d56ba4..3bfc8e5aa5da81 100644 --- a/src/coreclr/inc/dacvars.h +++ b/src/coreclr/inc/dacvars.h @@ -100,7 +100,7 @@ DEFINE_DACVAR(PTR_RangeSectionStubManager, RangeSectionStubManager__g_pManager, DEFINE_DACVAR(PTR_VirtualCallStubManagerManager, VirtualCallStubManagerManager__g_pManager, VirtualCallStubManagerManager::g_pManager) #ifdef FEATURE_TIERED_COMPILATION DEFINE_DACVAR(PTR_CallCountingStubManager, CallCountingStubManager__g_pManager, CallCountingStubManager::g_pManager) -#endif +#endif // FEATURE_TIERED_COMPILATION DEFINE_DACVAR(PTR_ThreadStore, ThreadStore__s_pThreadStore, ThreadStore::s_pThreadStore) From f8ded3f0343715ef2a32434a6990e6487f75a587 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:26:49 +0200 Subject: [PATCH 05/15] Update src/coreclr/inc/vptr_list.h Co-authored-by: Aaron Robinson --- src/coreclr/inc/vptr_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/inc/vptr_list.h b/src/coreclr/inc/vptr_list.h index 0959a394e3ca85..317c71582ab89e 100644 --- a/src/coreclr/inc/vptr_list.h +++ b/src/coreclr/inc/vptr_list.h @@ -39,7 +39,7 @@ VPTR_CLASS(TailCallStubManager) #endif #ifdef FEATURE_TIERED_COMPILATION VPTR_CLASS(CallCountingStubManager) -#endif +#endif // FEATURE_TIERED_COMPILATION VPTR_CLASS(PEImageLayout) VPTR_CLASS(ConvertedImageLayout) From 51a2896a49924c394c32e653a7e0af6cd5d4c653 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:26:59 +0200 Subject: [PATCH 06/15] Update src/coreclr/vm/amd64/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/amd64/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index a37c1bbbdd0e0e..b37f0285bbeb06 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -547,7 +547,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #ifdef FEATURE_CACHED_INTERFACE_DISPATCH #define OFFSETOF__InterfaceDispatchCache__m_rgEntries 0x20 From 6c0315bc914284101e61eddc2cf6092f7d3c5194 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:27:07 +0200 Subject: [PATCH 07/15] Update src/coreclr/vm/arm/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/arm/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index 7e4197697eb599..e2e52c399fde27 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -196,7 +196,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x08 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 0x1 From dbb63c6628ecbbdfc041cb381bb79dd0647fd976 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:27:14 +0200 Subject: [PATCH 08/15] Update src/coreclr/vm/arm64/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/arm64/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index e34661fa7b9fff..083a32d31ba0e6 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -283,7 +283,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #ifdef FEATURE_CACHED_INTERFACE_DISPATCH #define OFFSETOF__InterfaceDispatchCache__m_rgEntries 0x20 From 304332a2d35ebb8de0f3ace1f8b5415cb31a34ca Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:27:37 +0200 Subject: [PATCH 09/15] Update src/coreclr/vm/eventtrace.cpp Co-authored-by: Aaron Robinson --- src/coreclr/vm/eventtrace.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 004d21227c1bf9..882141ec274582 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -5487,9 +5487,6 @@ void ETW::CompilationLog::TieredCompilation::GetSettings(UINT32 *flagsRef) #endif *flagsRef = flags; } -#endif // FEATURE_TIERED_COMPILATION - -#if defined(FEATURE_TIERED_COMPILATION) void ETW::CompilationLog::TieredCompilation::Runtime::SendSettings() { CONTRACTL { From cab6136457418f9ba025cda73087d82522a5fcfb Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:27:43 +0200 Subject: [PATCH 10/15] Update src/coreclr/vm/i386/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/i386/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 336aef331fb612..209a1e731050b6 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -310,7 +310,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x08 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #undef ASMCONSTANTS_C_ASSERT #undef ASMCONSTANTS_RUNTIME_ASSERT From d7a3784692c561ffecbe101e44bad5395bc3d4ca Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:27:55 +0200 Subject: [PATCH 11/15] Update src/coreclr/vm/loongarch64/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/loongarch64/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index ff2afdd25989c7..77404df969160f 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -228,7 +228,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 1 From 7052a5cda7d9a9581036f551c43f9905b4c8e2ec Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 5 Sep 2025 09:28:04 +0200 Subject: [PATCH 12/15] Update src/coreclr/vm/riscv64/asmconstants.h Co-authored-by: Aaron Robinson --- src/coreclr/vm/riscv64/asmconstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index d277116584d9bf..8db47c768a2f9a 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -229,7 +229,7 @@ ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForMethod == offsetof(CallCoun #define CallCountingStubData__TargetForThresholdReached 0x10 ASMCONSTANTS_C_ASSERT(CallCountingStubData__TargetForThresholdReached == offsetof(CallCountingStubData, TargetForThresholdReached)) -#endif +#endif // FEATURE_TIERED_COMPILATION #ifdef PROFILING_SUPPORTED #define PROFILE_ENTER 1 From 2743a0adda09bda15f5097d17f986a1ee3c9fb8a Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 22 Sep 2025 12:47:11 +0200 Subject: [PATCH 13/15] Revert HasPrecode change --- src/coreclr/vm/jitinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 4a3e64eb86bd34..9efc29f22370d9 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10884,7 +10884,7 @@ void CEECodeGenInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN } } - if (IndirectionAllowedForJitHelper(ftnNum) && helperMD->HasPrecode()) + if (IndirectionAllowedForJitHelper(ftnNum)) { Precode* pPrecode = helperMD->GetPrecode(); _ASSERTE(pPrecode->GetType() == PRECODE_FIXUP); From 99a4ded497ee7568806944cd573dc0d41633cb45 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 23 Sep 2025 11:13:50 +0200 Subject: [PATCH 14/15] Condition FEATURE_ON_STACK_REPLACEMENT tiered compilation --- src/coreclr/inc/switches.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/coreclr/inc/switches.h b/src/coreclr/inc/switches.h index 7915e0944f4175..7baa64668383fe 100644 --- a/src/coreclr/inc/switches.h +++ b/src/coreclr/inc/switches.h @@ -48,7 +48,10 @@ #elif defined(TARGET_64BIT) +#ifdef FEATURE_TIERED_COMPILATION +// FEATURE_ON_STACK_REPLACEMENT is only needed for tiered compilation. #define FEATURE_ON_STACK_REPLACEMENT +#endif #if defined(HOST_UNIX) // In PAL we have a mechanism that reserves memory on start up that is From aed16ca353d9a88a66da3cba34c5b13744e43714 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 23 Sep 2025 11:30:14 +0200 Subject: [PATCH 15/15] Add comment --- src/coreclr/inc/switches.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/inc/switches.h b/src/coreclr/inc/switches.h index 7baa64668383fe..ad9421bb3949ab 100644 --- a/src/coreclr/inc/switches.h +++ b/src/coreclr/inc/switches.h @@ -49,9 +49,9 @@ #elif defined(TARGET_64BIT) #ifdef FEATURE_TIERED_COMPILATION -// FEATURE_ON_STACK_REPLACEMENT is only needed for tiered compilation. -#define FEATURE_ON_STACK_REPLACEMENT -#endif + // FEATURE_ON_STACK_REPLACEMENT is only needed for tiered compilation. + #define FEATURE_ON_STACK_REPLACEMENT +#endif // FEATURE_TIERED_COMPILATION #if defined(HOST_UNIX) // In PAL we have a mechanism that reserves memory on start up that is