Skip to content

Commit 8dda9b5

Browse files
authored
JIT: Update overview document and rename a few methods (#119762)
- Update list of phases in the overview to include some more phases - Rename one of the `compCompile` overloads to `compCompileAfterInit`. Keep `compCompile` as the method that runs the phases. - Rename local morph to actually be called local morph - Leave a note in the ryujit tutorial that the phase information and details are out of date, and point into the overview instead
1 parent cf42117 commit 8dda9b5

File tree

7 files changed

+134
-100
lines changed

7 files changed

+134
-100
lines changed

docs/design/coreclr/jit/ryujit-overview.md

Lines changed: 109 additions & 79 deletions
Large diffs are not rendered by default.

docs/design/coreclr/jit/ryujit-tutorial.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ Finally, while the original JIT was quite x86-oriented, we now have a broader se
5555
- Inherits from ICorDynamicInfo (corinfo.h)
5656

5757
#### Notes
58-
In this talk and elsewhere, you will see the .NET runtime often referred to as the VM, for virtual machine, the EE, for execution engine, or the CLR, for common language runtime. They are largely used interchangeably, though some might argue the terms have subtle differences.
59-
.NET is somewhat unique in that it currently has a single-tier JIT – no interpreter, and no re-optimizing JIT. While an interpreter exists, and experimentation has been done on re-jitting, the current model remains single-tier.
58+
In this document and elsewhere, you will see the .NET runtime often referred to as the VM, for virtual machine, the EE, for execution engine, or the CLR, for common language runtime. They are largely used interchangeably, though some might argue the terms have subtle differences.
6059

6160
The JIT and the VM each implement an interface that abstracts the dependencies they share. The VM invokes methods on the ICorJitCompiler interface to compile methods, and the JIT calls back on the ICorJitInfo interface to get information about types and methods.
6261

@@ -68,6 +67,10 @@ The JIT and the VM each implement an interface that abstracts the dependencies t
6867
This is the 10,000 foot view of RyuJIT. It takes in MSIL (aka CIL) in the form of byte codes, and the Importer phase transforms these to the intermediate representation used in the JIT. The IR operations are called "GenTrees", as in "trees for code generation". This format is preserved across the bulk of the JIT, with some changes in form and invariants along the way. Eventually, the code generator produces a low-level intermediate called InstrDescs, which simply capture the instruction encodings while the final mappings are done to produce the actual native code and associated tables.
6968

7069
### RyuJIT Phases
70+
71+
Note: Various details in what follows are outdated and should be mostly taken to be of historical interest.
72+
For more up-to-date information about the phases and their details, please see [the overview document](ryujit-overview.md).
73+
7174
![RyuJIT Phases](images/ryujit-phase-diagram.png)
7275

7376
#### Notes

src/coreclr/jit/compiler.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,9 +4502,9 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
45024502
fgNodeThreading = NodeThreading::AllLocals;
45034503
}
45044504

4505-
// Figure out what locals are address-taken.
4505+
// Simplify local accesses and analyze address exposure.
45064506
//
4507-
DoPhase(this, PHASE_STR_ADRLCL, &Compiler::fgMarkAddressExposedLocals);
4507+
DoPhase(this, PHASE_LOCAL_MORPH, &Compiler::fgLocalMorph);
45084508

45094509
// Optimize away conversions to/from masks in local variables.
45104510
//
@@ -5870,10 +5870,10 @@ bool Compiler::skipMethod()
58705870

58715871
/*****************************************************************************/
58725872

5873-
int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
5874-
void** methodCodePtr,
5875-
uint32_t* methodCodeSize,
5876-
JitFlags* compileFlags)
5873+
int Compiler::compCompileAfterInit(CORINFO_MODULE_HANDLE classPtr,
5874+
void** methodCodePtr,
5875+
uint32_t* methodCodeSize,
5876+
JitFlags* compileFlags)
58775877
{
58785878
// compInit should have set these already.
58795879
noway_assert(info.compMethodInfo != nullptr);
@@ -7730,7 +7730,7 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,
77307730

77317731
// Now generate the code
77327732
pParam->result =
7733-
pParam->pComp->compCompile(pParam->classPtr, pParam->methodCodePtr, pParam->methodCodeSize, pParam->compileFlags);
7733+
pParam->pComp->compCompileAfterInit(pParam->classPtr, pParam->methodCodePtr, pParam->methodCodeSize, pParam->compileFlags);
77347734
}
77357735
finallyErrorTrap()
77367736
{

src/coreclr/jit/compiler.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ struct NaturalLoopIterInfo
19301930
// loop can reach every other block of the loop.
19311931
//
19321932
// * All loop blocks are dominated by the header block, i.e. the header block
1933-
// is guaranteed to be entered on every iteration. Note that in the prescence
1933+
// is guaranteed to be entered on every iteration. Note that in the presence
19341934
// of exceptional flow the header might not fully execute on every iteration.
19351935
//
19361936
// * From the above it follows that the loop can only be entered at the header
@@ -6858,7 +6858,7 @@ class Compiler
68586858
// Clear up annotations for any struct promotion temps created for implicit byrefs.
68596859
void fgMarkDemotedImplicitByRefArgs();
68606860

6861-
PhaseStatus fgMarkAddressExposedLocals();
6861+
PhaseStatus fgLocalMorph();
68626862
bool fgExposeUnpropagatedLocals(bool propagatedAny, class LocalEqualsLocalAddrAssertions* assertions);
68636863
void fgExposeLocalsInBitVec(BitVec_ValArg_T bitVec);
68646864

@@ -10909,10 +10909,10 @@ class Compiler
1090910909
void compDoComponentUnitTestsOnce();
1091010910
#endif // DEBUG
1091110911

10912-
int compCompile(CORINFO_MODULE_HANDLE classPtr,
10913-
void** methodCodePtr,
10914-
uint32_t* methodCodeSize,
10915-
JitFlags* compileFlags);
10912+
int compCompileAfterInit(CORINFO_MODULE_HANDLE classPtr,
10913+
void** methodCodePtr,
10914+
uint32_t* methodCodeSize,
10915+
JitFlags* compileFlags);
1091610916
void compCompileFinish();
1091710917
int compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
1091810918
COMP_HANDLE compHnd,

src/coreclr/jit/compphases.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ CompPhaseNameMacro(PHASE_EARLY_UPDATE_FLOW_GRAPH, "Update flow graph early pa
4848
CompPhaseNameMacro(PHASE_DFS_BLOCKS1, "DFS blocks and remove dead code 1",false, -1, false)
4949
CompPhaseNameMacro(PHASE_DFS_BLOCKS2, "DFS blocks and remove dead code 2",false, -1, false)
5050
CompPhaseNameMacro(PHASE_DFS_BLOCKS3, "DFS blocks and remove dead code 3",false, -1, false)
51-
CompPhaseNameMacro(PHASE_STR_ADRLCL, "Morph - Structs/AddrExp", false, -1, false)
51+
CompPhaseNameMacro(PHASE_LOCAL_MORPH, "Local morph", false, -1, false)
5252
CompPhaseNameMacro(PHASE_OPTIMIZE_MASK_CONVERSIONS, "Optimize mask conversions", false, -1, false)
5353
CompPhaseNameMacro(PHASE_EARLY_LIVENESS, "Early liveness", false, -1, false)
5454
CompPhaseNameMacro(PHASE_PHYSICAL_PROMOTION, "Physical promotion", false, -1, false)

src/coreclr/jit/ee_il_dll.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void JitTls::SetCompiler(Compiler* compiler)
273273
#endif // !defined(DEBUG)
274274

275275
//****************************************************************************
276-
// The main JIT function for the 32 bit JIT. See code:ICorJitCompiler#EEToJitInterface for more on the EE-JIT
276+
// The main JIT function for the JIT. See code:ICorJitCompiler#EEToJitInterface for more on the EE-JIT
277277
// interface. Things really don't get going inside the JIT until the code:Compiler::compCompile#Phases
278278
// method. Usually that is where you want to go.
279279

@@ -323,7 +323,7 @@ void CILJit::ProcessShutdownWork(ICorStaticInfo* statInfo)
323323
void CILJit::getVersionIdentifier(GUID* versionIdentifier)
324324
{
325325
assert(versionIdentifier != nullptr);
326-
memcpy(versionIdentifier, &JITEEVersionIdentifier, sizeof(GUID));
326+
*versionIdentifier = JITEEVersionIdentifier;
327327
}
328328

329329
#ifdef TARGET_OS_RUNTIMEDETERMINED

src/coreclr/jit/lclmorph.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,8 +2356,9 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
23562356
};
23572357

23582358
//------------------------------------------------------------------------
2359-
// fgMarkAddressExposedLocals: Traverses the entire method and marks address
2360-
// exposed locals.
2359+
// fgLocalMorph:
2360+
// Traverses the entire method and simplifies local accesses.
2361+
// Also marks locals that are address exposed.
23612362
//
23622363
// Returns:
23632364
// Suitable phase status
@@ -2367,7 +2368,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
23672368
// to just LCL_VAR, do not result in the involved local being marked
23682369
// address exposed.
23692370
//
2370-
PhaseStatus Compiler::fgMarkAddressExposedLocals()
2371+
PhaseStatus Compiler::fgLocalMorph()
23712372
{
23722373
bool madeChanges = false;
23732374

0 commit comments

Comments
 (0)