From 8861275a96399219f0239b4f9793b11ba4f37ae0 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Wed, 22 Jan 2020 12:48:33 -0800 Subject: [PATCH] Don't do STRESS_PROFILER_CALLBACKS when pre-JITing (#2016) This leads us to generate an illegal relocation fixup. Fixes #1789 --- src/coreclr/src/jit/compiler.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/jit/compiler.cpp b/src/coreclr/src/jit/compiler.cpp index 0029094..a3b8c9c 100644 --- a/src/coreclr/src/jit/compiler.cpp +++ b/src/coreclr/src/jit/compiler.cpp @@ -3092,10 +3092,16 @@ void Compiler::compInitOptions(JitFlags* jitFlags) // Honour COMPlus_JitELTHookEnabled or STRESS_PROFILER_CALLBACKS stress mode // only if VM has not asked us to generate profiler hooks in the first place. // That is, override VM only if it hasn't asked for a profiler callback for this method. - if (!compProfilerHookNeeded && - ((JitConfig.JitELTHookEnabled() != 0) || compStressCompile(STRESS_PROFILER_CALLBACKS, 5))) + // Don't run this stress mode when pre-JITing, as we would need to emit a relocation + // for the call to the fake ELT hook, which wouldn't make sense, as we can't store that + // in the pre-JIT image. + if (!compProfilerHookNeeded) { - opts.compJitELTHookEnabled = true; + if ((JitConfig.JitELTHookEnabled() != 0) || + (!jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) && compStressCompile(STRESS_PROFILER_CALLBACKS, 5))) + { + opts.compJitELTHookEnabled = true; + } } // TBD: Exclude PInvoke stubs -- 2.7.4