Skip to content

Commit ac13edc

Browse files
Change CORJIT_FLAG_READYTORUN and CORJIT_FLAG_PREJIT to CORJIT_FLAG_AOT (#113850)
CORJIT_FLAG_READYTORUN and CORJIT_FLAG_PREJIT were always both set together. Introduce a new name to be more explicit of a concept that includes both ReadyToRun and NativeAOT (AOT == Ahead Of Time). Introduce new JIT helpers `IsAot` (for either NativeAOT or R2R), `IsNativeAot`, and `IsReadyToRun`. Remove the name "ngen" in a bunch of places in the JIT code.
1 parent 551379a commit ac13edc

36 files changed

+173
-188
lines changed

src/coreclr/inc/corjitflags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class CORJIT_FLAGS
4040
CORJIT_FLAG_ALT_JIT = 8, // JIT should consider itself an ALT_JIT
4141
CORJIT_FLAG_FROZEN_ALLOC_ALLOWED = 9, // JIT is allowed to use *_MAYBEFROZEN allocators
4242
// CORJIT_FLAG_UNUSED = 10,
43-
CORJIT_FLAG_READYTORUN = 11, // Use version-resilient code generation
43+
CORJIT_FLAG_AOT = 11, // Do ahead-of-time code generation (ReadyToRun or NativeAOT)
4444
CORJIT_FLAG_PROF_ENTERLEAVE = 12, // Instrument prologues/epilogues
4545
CORJIT_FLAG_PROF_NO_PINVOKE_INLINE = 13, // Disables PInvoke inlining
46-
CORJIT_FLAG_PREJIT = 14, // prejit is the execution engine.
46+
// CORJIT_FLAG_UNUSED = 14,
4747
CORJIT_FLAG_RELOC = 15, // Generate relocatable code
4848
CORJIT_FLAG_IL_STUB = 16, // method is an IL stub
4949
CORJIT_FLAG_PROCSPLIT = 17, // JIT should separate code into hot and cold sections

src/coreclr/inc/jiteeversionguid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737

3838
#include <minipal/guid.h>
3939

40-
constexpr GUID JITEEVersionIdentifier = { /* 27f02512-bc1c-44b7-8d96-cf1a3beadfbe */
41-
0x27f02512,
42-
0xbc1c,
43-
0x44b7,
44-
{0x8d, 0x96, 0xcf, 0x1a, 0x3b, 0xea, 0xdf, 0xbe}
40+
constexpr GUID JITEEVersionIdentifier = { /* 7139df75-63b2-4610-9a53-f9a86f474db8 */
41+
0x7139df75,
42+
0x63b2,
43+
0x4610,
44+
{0x9a, 0x53, 0xf9, 0xa8, 0x6f, 0x47, 0x4d, 0xb8}
4545
};
4646

4747
#endif // JIT_EE_VERSIONING_GUID_H

src/coreclr/jit/assertionprop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
883883
if (curAssertion->op1.kind == O1K_EXACT_TYPE)
884884
{
885885
ssize_t iconVal = curAssertion->op2.u1.iconVal;
886-
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
886+
if (IsAot())
887887
{
888888
printf("Exact Type MT(0x%p)", dspPtr(iconVal));
889889
}
@@ -903,7 +903,7 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
903903
else if (curAssertion->op1.kind == O1K_SUBTYPE)
904904
{
905905
ssize_t iconVal = curAssertion->op2.u1.iconVal;
906-
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI) || opts.IsReadyToRun())
906+
if (IsAot())
907907
{
908908
printf("MT(0x%p)", dspPtr(iconVal));
909909
}

src/coreclr/jit/codegenarmarch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
630630
}
631631
else
632632
{
633-
// Ngen case - GS cookie constant needs to be accessed through an indirection.
633+
// AOT case - GS cookie constant needs to be accessed through an indirection.
634634
instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, regGSConst, (ssize_t)compiler->gsGlobalSecurityCookieAddr,
635635
INS_FLAGS_DONT_CARE DEBUGARG((size_t)THT_GSCookieCheck) DEBUGARG(GTF_EMPTY));
636636
GetEmitter()->emitIns_R_R_I(INS_ldr, EA_PTRSIZE, regGSConst, regGSConst, 0);
@@ -4622,7 +4622,7 @@ void CodeGen::genPushCalleeSavedRegisters()
46224622
// - Generate fully interruptible code for loops that contains calls
46234623
// - Generate fully interruptible code for leaf methods
46244624
//
4625-
// Given the limited benefit from this optimization (<10k for CoreLib NGen image), the extra complexity
4625+
// Given the limited benefit from this optimization (<10k for CoreLib AOT image), the extra complexity
46264626
// is not worth it.
46274627
//
46284628
rsPushRegs |= RBM_LR; // We must save the return address (in the LR register)

src/coreclr/jit/codegencommon.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,9 +1768,9 @@ void CodeGen::genGenerateCode(void** codePtr, uint32_t* nativeSizeOfCode)
17681768
DoPhase(this, PHASE_EMIT_GCEH, &CodeGen::genEmitUnwindDebugGCandEH);
17691769

17701770
#ifdef DEBUG
1771-
// For R2R/NAOT not all these helpers are implemented. So don't ask for them.
1771+
// For AOT not all these helpers are implemented. So don't ask for them.
17721772
//
1773-
if (genWriteBarrierUsed && JitConfig.EnableExtraSuperPmiQueries() && !compiler->opts.IsReadyToRun())
1773+
if (genWriteBarrierUsed && JitConfig.EnableExtraSuperPmiQueries() && !compiler->IsAot())
17741774
{
17751775
void* ignored;
17761776
for (int i = CORINFO_HELP_ASSIGN_REF; i <= CORINFO_HELP_BULK_WRITEBARRIER; i++)
@@ -1944,13 +1944,16 @@ void CodeGen::genGenerateMachineCode()
19441944

19451945
printf("; %s code\n", compiler->compGetTieringName(false));
19461946

1947-
if (compiler->IsTargetAbi(CORINFO_NATIVEAOT_ABI))
1947+
if (compiler->IsAot())
19481948
{
1949-
printf("; NativeAOT compilation\n");
1950-
}
1951-
else if (compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_READYTORUN))
1952-
{
1953-
printf("; ReadyToRun compilation\n");
1949+
if (compiler->IsTargetAbi(CORINFO_NATIVEAOT_ABI))
1950+
{
1951+
printf("; NativeAOT compilation\n");
1952+
}
1953+
else
1954+
{
1955+
printf("; ReadyToRun compilation\n");
1956+
}
19541957
}
19551958

19561959
if (compiler->opts.IsOSR())
@@ -2031,8 +2034,7 @@ void CodeGen::genGenerateMachineCode()
20312034
GetEmitter()->emitBegFN(isFramePointerUsed()
20322035
#if defined(DEBUG)
20332036
,
2034-
(compiler->compCodeOpt() != Compiler::SMALL_CODE) &&
2035-
!compiler->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT)
2037+
(compiler->compCodeOpt() != Compiler::SMALL_CODE) && !compiler->IsAot()
20362038
#endif
20372039
);
20382040

src/coreclr/jit/codegenloongarch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4664,7 +4664,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
46644664
}
46654665
else
46664666
{
4667-
//// Ngen case - GS cookie constant needs to be accessed through an indirection.
4667+
// AOT case - GS cookie constant needs to be accessed through an indirection.
46684668
// instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, regGSConst, (ssize_t)compiler->gsGlobalSecurityCookieAddr);
46694669
// GetEmitter()->emitIns_R_R_I(INS_ld_d, EA_PTRSIZE, regGSConst, regGSConst, 0);
46704670
if (compiler->opts.compReloc)
@@ -7108,7 +7108,7 @@ void CodeGen::genPushCalleeSavedRegisters(regNumber initReg, bool* pInitRegZeroe
71087108
// - Generate fully interruptible code for loops that contains calls
71097109
// - Generate fully interruptible code for leaf methods
71107110
//
7111-
// Given the limited benefit from this optimization (<10k for SPCL NGen image), the extra complexity
7111+
// Given the limited benefit from this optimization (<10k for SPCL AOT image), the extra complexity
71127112
// is not worth it.
71137113
//
71147114

src/coreclr/jit/codegenriscv64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,7 +4669,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
46694669
}
46704670
else
46714671
{
4672-
//// Ngen case - GS cookie constant needs to be accessed through an indirection.
4672+
// AOT case - GS cookie constant needs to be accessed through an indirection.
46734673
// instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, regGSConst, (ssize_t)compiler->gsGlobalSecurityCookieAddr);
46744674
// GetEmitter()->emitIns_R_R_I(INS_ld_d, EA_PTRSIZE, regGSConst, regGSConst, 0);
46754675
if (compiler->opts.compReloc)
@@ -6914,7 +6914,7 @@ void CodeGen::genPushCalleeSavedRegisters(regNumber initReg, bool* pInitRegZeroe
69146914
// - Generate fully interruptible code for loops that contains calls
69156915
// - Generate fully interruptible code for leaf methods
69166916
//
6917-
// Given the limited benefit from this optimization (<10k for SPCL NGen image), the extra complexity
6917+
// Given the limited benefit from this optimization (<10k for SPCL AOT image), the extra complexity
69186918
// is not worth it.
69196919
//
69206920

src/coreclr/jit/codegenxarch.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
156156
}
157157
else
158158
{
159-
// Ngen case - GS cookie value needs to be accessed through an indirection.
159+
// AOT case - GS cookie value needs to be accessed through an indirection.
160160

161161
pushedRegs = genPushRegs(regMaskGSCheck, &byrefPushedRegs, &norefPushedRegs);
162162

@@ -9821,7 +9821,7 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
98219821
// RCX = ProfilerMethHnd
98229822
if (compiler->compProfilerMethHndIndirected)
98239823
{
9824-
// Profiler hooks enabled during Ngen time.
9824+
// Profiler hooks enabled during AOT.
98259825
// Profiler handle needs to be accessed through an indirection of a pointer.
98269826
GetEmitter()->emitIns_R_AI(INS_mov, EA_PTR_DSP_RELOC, REG_ARG_0, (ssize_t)compiler->compProfilerMethHnd);
98279827
}
@@ -9900,7 +9900,7 @@ void CodeGen::genProfilingEnterCallback(regNumber initReg, bool* pInitRegZeroed)
99009900
// R14 = ProfilerMethHnd
99019901
if (compiler->compProfilerMethHndIndirected)
99029902
{
9903-
// Profiler hooks enabled during Ngen time.
9903+
// Profiler hooks enabled during AOT.
99049904
// Profiler handle needs to be accessed through an indirection of a pointer.
99059905
GetEmitter()->emitIns_R_AI(INS_mov, EA_PTR_DSP_RELOC, REG_PROFILER_ENTER_ARG_0,
99069906
(ssize_t)compiler->compProfilerMethHnd);
@@ -9982,7 +9982,7 @@ void CodeGen::genProfilingLeaveCallback(unsigned helper)
99829982
// RCX = ProfilerMethHnd
99839983
if (compiler->compProfilerMethHndIndirected)
99849984
{
9985-
// Profiler hooks enabled during Ngen time.
9985+
// Profiler hooks enabled during AOT.
99869986
// Profiler handle needs to be accessed through an indirection of an address.
99879987
GetEmitter()->emitIns_R_AI(INS_mov, EA_PTR_DSP_RELOC, REG_ARG_0, (ssize_t)compiler->compProfilerMethHnd);
99889988
}
@@ -11718,7 +11718,7 @@ bool CodeGenInterface::genCodeIndirAddrCanBeEncodedAsZeroRelOffset(size_t addr)
1171811718
//
1171911719
bool CodeGenInterface::genCodeIndirAddrNeedsReloc(size_t addr)
1172011720
{
11721-
// If generating relocatable ngen code, then all code addr should go through relocation
11721+
// If generating relocatable AOT code, then all code addr should go through relocation
1172211722
if (compiler->opts.compReloc)
1172311723
{
1172411724
return true;
@@ -11751,7 +11751,7 @@ bool CodeGenInterface::genCodeIndirAddrNeedsReloc(size_t addr)
1175111751
//
1175211752
bool CodeGenInterface::genCodeAddrNeedsReloc(size_t addr)
1175311753
{
11754-
// If generating relocatable ngen code, then all code addr should go through relocation
11754+
// If generating relocatable AOT code, then all code addr should go through relocation
1175511755
if (compiler->opts.compReloc)
1175611756
{
1175711757
return true;

src/coreclr/jit/compiler.cpp

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
22972297
#ifdef DEBUG
22982298

22992299
const JitConfigValues::MethodSet* pfAltJit;
2300-
if (jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
2300+
if (jitFlags->IsSet(JitFlags::JIT_FLAG_AOT))
23012301
{
23022302
pfAltJit = &JitConfig.AltJitNgen();
23032303
}
@@ -2323,7 +2323,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
23232323
#else // !DEBUG
23242324

23252325
const char* altJitVal;
2326-
if (jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
2326+
if (jitFlags->IsSet(JitFlags::JIT_FLAG_AOT))
23272327
{
23282328
altJitVal = JitConfig.AltJitNgen().list();
23292329
}
@@ -2927,13 +2927,13 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
29272927
// Honour DOTNET_JitELTHookEnabled or STRESS_PROFILER_CALLBACKS stress mode
29282928
// only if VM has not asked us to generate profiler hooks in the first place.
29292929
// That is, override VM only if it hasn't asked for a profiler callback for this method.
2930-
// Don't run this stress mode when pre-JITing, as we would need to emit a relocation
2930+
// Don't run this stress mode under AOT, as we would need to emit a relocation
29312931
// for the call to the fake ELT hook, which wouldn't make sense, as we can't store that
2932-
// in the pre-JIT image.
2932+
// in the AOT image.
29332933
if (!compProfilerHookNeeded)
29342934
{
29352935
if ((JitConfig.JitELTHookEnabled() != 0) ||
2936-
(!jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) && compStressCompile(STRESS_PROFILER_CALLBACKS, 5)))
2936+
(!jitFlags->IsSet(JitFlags::JIT_FLAG_AOT) && compStressCompile(STRESS_PROFILER_CALLBACKS, 5)))
29372937
{
29382938
opts.compJitELTHookEnabled = true;
29392939
}
@@ -3049,7 +3049,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
30493049

30503050
if (opts.compProcedureSplitting)
30513051
{
3052-
// Note that opts.compdbgCode is true under ngen for checked assemblies!
3052+
// Note that opts.compDbgCode is true under AOT for checked assemblies!
30533053
opts.compProcedureSplitting = !opts.compDbgCode || enableFakeSplitting;
30543054

30553055
#ifdef DEBUG
@@ -3155,9 +3155,9 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
31553155
printf("OPTIONS: optimizer should use profile data\n");
31563156
}
31573157

3158-
if (jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
3158+
if (jitFlags->IsSet(JitFlags::JIT_FLAG_AOT))
31593159
{
3160-
printf("OPTIONS: Jit invoked for ngen\n");
3160+
printf("OPTIONS: Jit invoked for AOT\n");
31613161
}
31623162
}
31633163
#endif
@@ -3234,15 +3234,15 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
32343234

32353235
bool Compiler::compJitHaltMethod()
32363236
{
3237-
/* This method returns true when we use an INS_BREAKPOINT to allow us to step into the generated native code */
3238-
/* Note that this these two "Jit" environment variables also work for ngen images */
3237+
// This method returns true when we use an INS_BREAKPOINT to allow us to step into the generated native code.
3238+
// Note that these two "Jit" environment variables also work for AOT images.
32393239

32403240
if (JitConfig.JitHalt().contains(info.compMethodHnd, info.compClassHnd, &info.compMethodInfo->args))
32413241
{
32423242
return true;
32433243
}
32443244

3245-
/* Use this Hash variant when there are a lot of method with the same name and different signatures */
3245+
// Use this Hash variant when there are a lot of method with the same name and different signatures.
32463246

32473247
unsigned fJitHashHaltVal = (unsigned)JitConfig.JitHashHalt();
32483248
if ((fJitHashHaltVal != (unsigned)-1) && (fJitHashHaltVal == info.compMethodHash()))
@@ -3721,9 +3721,8 @@ void Compiler::compSetOptimizationLevel()
37213721
{
37223722
theMinOptsValue = true;
37233723
}
3724-
// For PREJIT we never drop down to MinOpts
3725-
// unless unless CLFLG_MINOPT is set
3726-
else if (!opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
3724+
// For AOT we never drop down to MinOpts unless unless CLFLG_MINOPT is set
3725+
else if (!IsAot())
37273726
{
37283727
if ((unsigned)JitConfig.JitMinOptsCodeSize() < info.compILCodeSize)
37293728
{
@@ -3763,10 +3762,9 @@ void Compiler::compSetOptimizationLevel()
37633762
}
37643763
}
37653764
#else // !DEBUG
3766-
// Retail check if we should force Minopts due to the complexity of the method
3767-
// For PREJIT we never drop down to MinOpts
3768-
// unless unless CLFLG_MINOPT is set
3769-
if (!theMinOptsValue && !opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) &&
3765+
// Retail check if we should force Minopts due to the complexity of the method.
3766+
// For AOT we never drop down to MinOpts unless unless CLFLG_MINOPT is set.
3767+
if (!theMinOptsValue && !IsAot() &&
37703768
((DEFAULT_MIN_OPTS_CODE_SIZE < info.compILCodeSize) || (DEFAULT_MIN_OPTS_INSTR_COUNT < opts.instrCount) ||
37713769
(DEFAULT_MIN_OPTS_BB_COUNT < fgBBcount) || (DEFAULT_MIN_OPTS_LV_NUM_COUNT < lvaCount) ||
37723770
(DEFAULT_MIN_OPTS_LV_REF_COUNT < opts.lvRefCount)))
@@ -3835,14 +3833,13 @@ void Compiler::compSetOptimizationLevel()
38353833
codeGen->setFrameRequired(true);
38363834
#endif
38373835

3838-
if (opts.OptimizationDisabled() ||
3839-
(opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) && !IsTargetAbi(CORINFO_NATIVEAOT_ABI)))
3836+
if (opts.OptimizationDisabled() || IsReadyToRun())
38403837
{
3841-
// The JIT doesn't currently support loop alignment for prejitted images outside NativeAOT.
3838+
// The JIT doesn't currently support loop alignment for AOT images outside NativeAOT.
38423839
// (The JIT doesn't know the final address of the code, hence
38433840
// it can't align code based on unknown addresses.)
38443841

3845-
codeGen->SetAlignLoops(false); // loop alignment not supported for prejitted code
3842+
codeGen->SetAlignLoops(false); // loop alignment not supported for AOT code
38463843
}
38473844
else
38483845
{
@@ -6677,11 +6674,11 @@ void Compiler::compCompileFinish()
66776674
}
66786675
#endif // TRACK_ENREG_STATS
66796676

6680-
// Only call _DbgBreakCheck when we are jitting, not when we are ngen-ing
6681-
// For ngen the int3 or breakpoint instruction will be right at the
6682-
// start of the ngen method and we will stop when we execute it.
6677+
// Only call _DbgBreakCheck when we are jitting, not when we are generating AOT code.
6678+
// For AOT the int3 or breakpoint instruction will be right at the
6679+
// start of the AOT method and we will stop when we execute it.
66836680
//
6684-
if (!opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
6681+
if (!IsAot())
66856682
{
66866683
if (compJitHaltMethod())
66876684
{
@@ -6948,9 +6945,9 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
69486945

69496946
const bool forceInline = !!(info.compFlags & CORINFO_FLG_FORCEINLINE);
69506947

6951-
if (!compIsForInlining() && opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
6948+
if (!compIsForInlining() && IsAot())
69526949
{
6953-
// We're prejitting the root method. We also will analyze it as
6950+
// We're AOT compiling the root method. We also will analyze it as
69546951
// a potential inline candidate.
69556952
InlineResult prejitResult(this, info.compMethodHnd, "prejit");
69566953

0 commit comments

Comments
 (0)