diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 42fb1148659daf..78827a157780e6 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -523,7 +523,8 @@ private static mdToken FindGenericMethodArgTypeSpec(EcmaModule module) public static bool ShouldSkipCompilation(InstructionSetSupport instructionSetSupport, MethodDesc methodNeedingCode) { - if (methodNeedingCode.IsAggressiveOptimization) + bool targetAllowsRuntimeCodeGeneration = ((ReadyToRunCompilerContext)methodNeedingCode.Context).TargetAllowsRuntimeCodeGeneration; + if (methodNeedingCode.IsAggressiveOptimization && targetAllowsRuntimeCodeGeneration) { return true; } @@ -532,8 +533,7 @@ public static bool ShouldSkipCompilation(InstructionSetSupport instructionSetSup // On platforms where we cannot JIT, we need to ensure that we have a fallback implementation pre-compiled // so any code that uses hardware intrinsics and is interpreted has an implementation to use. // This allows us to avoid the high cost of manually implementing intrinsics in the interpreter. - if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(methodNeedingCode) - && ((ReadyToRunCompilerContext)methodNeedingCode.Context).TargetAllowsRuntimeCodeGeneration) + if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(methodNeedingCode) && targetAllowsRuntimeCodeGeneration) { return true; }