From 4c20c15e44e928c944ea3b6d8365d8ebb6cbcd55 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 25 Jun 2024 10:47:36 +0200 Subject: [PATCH 1/7] JIT: Avoid reporting call-sites in MinOpts on all targets When the call-sites have no interesting GC information we avoid reporting them, but this behavior was enabled only for x86/x64. Enable this on other platforms too. Fix #103917 --- src/coreclr/jit/gcencode.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index 91f2a481a68cef..26923a911aab8e 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -4065,13 +4065,7 @@ void GCInfo::gcMakeRegPtrTable( { GCENCODER_WITH_LOGGING(gcInfoEncoderWithLog, gcInfoEncoder); - // TODO: Decide on whether we should enable this optimization for all - // targets: https://github.com/dotnet/runtime/issues/103917 -#ifdef TARGET_XARCH const bool noTrackedGCSlots = compiler->opts.MinOpts() && !compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT); -#else - const bool noTrackedGCSlots = false; -#endif if (mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS) { From fe57c11431bc8f363b473a982b69bc6ec290775e Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 25 Jun 2024 11:16:01 +0200 Subject: [PATCH 2/7] Run jit-format --- src/coreclr/jit/gcencode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index 26923a911aab8e..ab21243f585c98 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -4065,7 +4065,8 @@ void GCInfo::gcMakeRegPtrTable( { GCENCODER_WITH_LOGGING(gcInfoEncoderWithLog, gcInfoEncoder); - const bool noTrackedGCSlots = compiler->opts.MinOpts() && !compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT); + const bool noTrackedGCSlots = + compiler->opts.MinOpts() && !compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT); if (mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS) { From 6f9c8aa427e6a98b22272f3254f69760618aab43 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 25 Jun 2024 16:02:37 +0200 Subject: [PATCH 3/7] No tracked GC slots even when prejitting MinOpts --- src/coreclr/jit/gcencode.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index ab21243f585c98..1e10f9cc6c7076 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -4065,8 +4065,7 @@ void GCInfo::gcMakeRegPtrTable( { GCENCODER_WITH_LOGGING(gcInfoEncoderWithLog, gcInfoEncoder); - const bool noTrackedGCSlots = - compiler->opts.MinOpts() && !compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT); + const bool noTrackedGCSlots = compiler->opts.MinOpts(); if (mode == MAKE_REG_PTR_MODE_ASSIGN_SLOTS) { From 4390b5cef23d290ea0910b6a88218a3795b60dc8 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 4 Nov 2024 19:14:52 +0100 Subject: [PATCH 4/7] Force MinOpts for NAOT --- src/coreclr/jit/compiler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 6916e931172e2f..4312ea37356887 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -3992,6 +3992,11 @@ void Compiler::compSetOptimizationLevel() "IL Code Size,Instr %4d,%4d, Basic Block count %3d, Local Variable Num,Ref count %3d,%3d for method %s\n", info.compILCodeSize, opts.instrCount, fgBBcount, lvaCount, opts.lvRefCount, info.compFullName)); + if (IsTargetAbi(CORINFO_NATIVEAOT_ABI)) + { + theMinOptsValue = true; + } + _SetMinOpts: // Set the MinOpts value From 83fe9db5da83836efedf88a5b6e13950ab960099 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 11 Nov 2024 17:13:37 +0100 Subject: [PATCH 5/7] IsSafePoint -> CouldBeSafePoint --- src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp b/src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp index 66c775e0e2c05e..fd11d8f4abac3e 100644 --- a/src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp +++ b/src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp @@ -479,7 +479,7 @@ void CoffNativeCodeManager::EnumGcRefs(MethodInfo * pMethodInfo, codeOffset - 1 ); - assert(decoder.IsSafePoint()); + assert(decoder.CouldBeSafePoint()); } } From 0a2738b78766682a27c89ffedff4d8b5a281ce4e Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 11 Nov 2024 17:23:35 +0100 Subject: [PATCH 6/7] Fix in Unix version too --- src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp index 9f982f630bcec7..1098bdcb1edf52 100644 --- a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp @@ -246,7 +246,7 @@ void UnixNativeCodeManager::EnumGcRefs(MethodInfo * pMethodInfo, codeOffset - 1 ); - assert(decoder.IsSafePoint()); + assert(decoder.CouldBeSafePoint()); } } From b7aa263a3b1a100fad525f36e23047ace391ef10 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 8 Jan 2025 13:02:09 +0100 Subject: [PATCH 7/7] Revert "Force MinOpts for NAOT" This reverts commit 4390b5cef23d290ea0910b6a88218a3795b60dc8. --- src/coreclr/jit/compiler.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 9e3633f509293b..901c4039b5dff8 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -3973,11 +3973,6 @@ void Compiler::compSetOptimizationLevel() "IL Code Size,Instr %4d,%4d, Basic Block count %3d, Local Variable Num,Ref count %3d,%3d for method %s\n", info.compILCodeSize, opts.instrCount, fgBBcount, lvaCount, opts.lvRefCount, info.compFullName)); - if (IsTargetAbi(CORINFO_NATIVEAOT_ABI)) - { - theMinOptsValue = true; - } - _SetMinOpts: // Set the MinOpts value