Skip to content

Commit 966d02e

Browse files
[DOC] Update compiler phases in documentation
Documentation was slightly outdated. Hope this update will help someone :)
1 parent 929d4be commit 966d02e

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

docs/docs/internals/overall-structure.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ Seen from a temporal perspective, the `dotc` compiler consists of a list of
9191
phases. The current list of phases is specified in class [Compiler] as follows:
9292

9393
```scala
94-
def phases: List[List[Phase]] =
94+
def phases: List[List[Phase]] =
9595
frontendPhases ::: picklerPhases ::: transformPhases ::: backendPhases
9696

9797
/** Phases dealing with the frontend up to trees ready for TASTY pickling */
9898
protected def frontendPhases: List[List[Phase]] =
9999
List(new FrontEnd) :: // Compiler frontend: scanner, parser, namer, typer
100+
List(new YCheckPositions) :: // YCheck positions
101+
List(new Staging) :: // Check PCP, heal quoted types and expand macros
100102
List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks
101103
List(new PostTyper) :: // Additional checks and cleanups after type checking
102104
List(new sbt.ExtractAPI) :: // Sends a representation of the API of classes to sbt via callbacks
105+
List(new SetRootTree) :: // Set the `rootTreeOrProvider` on class symbols
103106
Nil
104107

105108
/** Phases dealing with TASTY tree pickling and unpickling */
@@ -113,25 +116,26 @@ phases. The current list of phases is specified in class [Compiler] as follows:
113116
List(new FirstTransform, // Some transformations to put trees into a canonical form
114117
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
115118
new ElimPackagePrefixes, // Eliminate references to package prefixes in Select nodes
116-
new CookComments) :: // Cook the comments: expand variables, doc, etc.
119+
new CookComments, // Cook the comments: expand variables, doc, etc.
120+
new CompleteJavaEnums) :: // Fill in constructors for Java enums
117121
List(new CheckStatic, // Check restrictions that apply to @static members
118122
new ElimRepeated, // Rewrite vararg parameters and arguments
119123
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
120124
new ProtectedAccessors, // Add accessors for protected members
121125
new ExtensionMethods, // Expand methods of value classes with extension methods
126+
new CacheAliasImplicits, // Cache RHS of parameterless alias implicits
122127
new ShortcutImplicits, // Allow implicit functions without creating closures
123128
new ByNameClosures, // Expand arguments to by-name parameters to closures
124-
new LiftTry, // Put try expressions that might execute on non-empty stacks into their own methods
125129
new HoistSuperArgs, // Hoist complex arguments of supercalls to enclosing scope
126130
new ClassOf, // Expand `Predef.classOf` calls.
127131
new RefChecks) :: // Various checks mostly related to abstract members and overriding
128-
List(new TryCatchPatterns, // Compile cases in try/catch
132+
List(new ElimOpaque, // Turn opaque into normal aliases
133+
new TryCatchPatterns, // Compile cases in try/catch
129134
new PatternMatcher, // Compile pattern matches
130135
new ExplicitOuter, // Add accessors to outer classes from nested ones.
131136
new ExplicitSelf, // Make references to non-trivial self types explicit as casts
132137
new StringInterpolatorOpt, // Optimizes raw and s string interpolators by rewriting them to string concatentations
133-
new CrossCastAnd, // Normalize selections involving intersection types.
134-
new Splitter) :: // Expand selections involving union types into conditionals
138+
new CrossCastAnd) :: // Normalize selections involving intersection types.
135139
List(new PruneErasedDefs, // Drop erased definitions from scopes and simplify erased expressions
136140
new VCInlineMethods, // Inlines calls to value class methods
137141
new SeqLiterals, // Express vararg arguments as arrays
@@ -140,13 +144,16 @@ phases. The current list of phases is specified in class [Compiler] as follows:
140144
new ElimByName, // Expand by-name parameter references
141145
new CollectNullableFields, // Collect fields that can be nulled out after use in lazy initialization
142146
new ElimOuterSelect, // Expand outer selections
143-
new AugmentScala2Traits, // Expand traits defined in Scala 2.x to simulate old-style rewritings
144-
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
147+
new AugmentScala2Traits, // Augments Scala2 traits with additional members needed for mixin composition.
148+
new ResolveSuper, // Implement super accessors
145149
new FunctionXXLForwarders, // Add forwarders for FunctionXXL apply method
150+
new TupleOptimizations, // Optimize generic operations on tuples
146151
new ArrayConstructors) :: // Intercept creation of (non-generic) arrays and intrinsify.
147152
List(new Erasure) :: // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements.
148153
List(new ElimErasedValueType, // Expand erased value types to their underlying implmementation types
149154
new VCElideAllocations, // Peep-hole optimization to eliminate unnecessary value class allocations
155+
new ArrayApply, // Optimize `scala.Array.apply([....])` and `scala.Array.apply(..., [....])` into `[...]`
156+
new ElimPolyFunction, // Rewrite PolyFunction subclasses to FunctionN subclasses
150157
new TailRec, // Rewrite tail recursion to loops
151158
new Mixin, // Expand trait fields and trait initializers
152159
new LazyVals, // Expand lazy vals
@@ -156,8 +163,10 @@ phases. The current list of phases is specified in class [Compiler] as follows:
156163
List(new Constructors, // Collect initialization code in primary constructors
157164
// Note: constructors changes decls in transformTemplate, no InfoTransformers should be added after it
158165
new FunctionalInterfaces, // Rewrites closures to implement @specialized types of Functions.
159-
new GetClass) :: // Rewrites getClass calls on primitive types.
160-
List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to their implementations
166+
new Instrumentation, // Count closure allocations under -Yinstrument-closures
167+
new GetClass, // Rewrites getClass calls on primitive types.
168+
new LiftTry) :: // Put try expressions that might execute on non-empty stacks into their own methods their implementations
169+
List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to
161170
new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments
162171
// Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
163172
new ElimStaticThis) :: // Replace `this` references to static objects by global identifiers
@@ -168,12 +177,14 @@ phases. The current list of phases is specified in class [Compiler] as follows:
168177
new ExpandPrivate, // Widen private definitions accessed from nested classes
169178
new RestoreScopes, // Repair scopes rendered invalid by moving definitions in prior phases of the group
170179
new SelectStatic, // get rid of selects that would be compiled into GetStatic
180+
new sjs.JUnitBootstrappers, // Generate JUnit-specific bootstrapper classes for Scala.js (not enabled by default)
171181
new CollectEntryPoints, // Find classes with main methods
172182
new CollectSuperCalls) :: // Find classes that are called with super
173183
Nil
174184

175185
/** Generate the output of the compilation */
176186
protected def backendPhases: List[List[Phase]] =
187+
List(new sjs.GenSJSIR) :: // Generate .sjsir files for Scala.js (not enabled by default)
177188
List(new GenBCode) :: // Generate JVM bytecode
178189
Nil
179190
```

0 commit comments

Comments
 (0)