From 966d02e0f6adfc83411e0766a73bb7f93faa4f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gutowski?= Date: Tue, 30 Jul 2019 22:35:27 +0200 Subject: [PATCH] [DOC] Update compiler phases in documentation Documentation was slightly outdated. Hope this update will help someone :) --- docs/docs/internals/overall-structure.md | 31 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/docs/internals/overall-structure.md b/docs/docs/internals/overall-structure.md index 59245f08608f..345ddb53f925 100644 --- a/docs/docs/internals/overall-structure.md +++ b/docs/docs/internals/overall-structure.md @@ -91,15 +91,18 @@ Seen from a temporal perspective, the `dotc` compiler consists of a list of phases. The current list of phases is specified in class [Compiler] as follows: ```scala - def phases: List[List[Phase]] = + def phases: List[List[Phase]] = frontendPhases ::: picklerPhases ::: transformPhases ::: backendPhases /** Phases dealing with the frontend up to trees ready for TASTY pickling */ protected def frontendPhases: List[List[Phase]] = List(new FrontEnd) :: // Compiler frontend: scanner, parser, namer, typer + List(new YCheckPositions) :: // YCheck positions + List(new Staging) :: // Check PCP, heal quoted types and expand macros List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks List(new PostTyper) :: // Additional checks and cleanups after type checking List(new sbt.ExtractAPI) :: // Sends a representation of the API of classes to sbt via callbacks + List(new SetRootTree) :: // Set the `rootTreeOrProvider` on class symbols Nil /** 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: List(new FirstTransform, // Some transformations to put trees into a canonical form new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars new ElimPackagePrefixes, // Eliminate references to package prefixes in Select nodes - new CookComments) :: // Cook the comments: expand variables, doc, etc. + new CookComments, // Cook the comments: expand variables, doc, etc. + new CompleteJavaEnums) :: // Fill in constructors for Java enums List(new CheckStatic, // Check restrictions that apply to @static members new ElimRepeated, // Rewrite vararg parameters and arguments new ExpandSAMs, // Expand single abstract method closures to anonymous classes new ProtectedAccessors, // Add accessors for protected members new ExtensionMethods, // Expand methods of value classes with extension methods + new CacheAliasImplicits, // Cache RHS of parameterless alias implicits new ShortcutImplicits, // Allow implicit functions without creating closures new ByNameClosures, // Expand arguments to by-name parameters to closures - new LiftTry, // Put try expressions that might execute on non-empty stacks into their own methods new HoistSuperArgs, // Hoist complex arguments of supercalls to enclosing scope new ClassOf, // Expand `Predef.classOf` calls. new RefChecks) :: // Various checks mostly related to abstract members and overriding - List(new TryCatchPatterns, // Compile cases in try/catch + List(new ElimOpaque, // Turn opaque into normal aliases + new TryCatchPatterns, // Compile cases in try/catch new PatternMatcher, // Compile pattern matches new ExplicitOuter, // Add accessors to outer classes from nested ones. new ExplicitSelf, // Make references to non-trivial self types explicit as casts new StringInterpolatorOpt, // Optimizes raw and s string interpolators by rewriting them to string concatentations - new CrossCastAnd, // Normalize selections involving intersection types. - new Splitter) :: // Expand selections involving union types into conditionals + new CrossCastAnd) :: // Normalize selections involving intersection types. List(new PruneErasedDefs, // Drop erased definitions from scopes and simplify erased expressions new VCInlineMethods, // Inlines calls to value class methods new SeqLiterals, // Express vararg arguments as arrays @@ -140,13 +144,16 @@ phases. The current list of phases is specified in class [Compiler] as follows: new ElimByName, // Expand by-name parameter references new CollectNullableFields, // Collect fields that can be nulled out after use in lazy initialization new ElimOuterSelect, // Expand outer selections - new AugmentScala2Traits, // Expand traits defined in Scala 2.x to simulate old-style rewritings - new ResolveSuper, // Implement super accessors and add forwarders to trait methods + new AugmentScala2Traits, // Augments Scala2 traits with additional members needed for mixin composition. + new ResolveSuper, // Implement super accessors new FunctionXXLForwarders, // Add forwarders for FunctionXXL apply method + new TupleOptimizations, // Optimize generic operations on tuples new ArrayConstructors) :: // Intercept creation of (non-generic) arrays and intrinsify. List(new Erasure) :: // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements. List(new ElimErasedValueType, // Expand erased value types to their underlying implmementation types new VCElideAllocations, // Peep-hole optimization to eliminate unnecessary value class allocations + new ArrayApply, // Optimize `scala.Array.apply([....])` and `scala.Array.apply(..., [....])` into `[...]` + new ElimPolyFunction, // Rewrite PolyFunction subclasses to FunctionN subclasses new TailRec, // Rewrite tail recursion to loops new Mixin, // Expand trait fields and trait initializers new LazyVals, // Expand lazy vals @@ -156,8 +163,10 @@ phases. The current list of phases is specified in class [Compiler] as follows: List(new Constructors, // Collect initialization code in primary constructors // Note: constructors changes decls in transformTemplate, no InfoTransformers should be added after it new FunctionalInterfaces, // Rewrites closures to implement @specialized types of Functions. - new GetClass) :: // Rewrites getClass calls on primitive types. - List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to their implementations + new Instrumentation, // Count closure allocations under -Yinstrument-closures + new GetClass, // Rewrites getClass calls on primitive types. + new LiftTry) :: // Put try expressions that might execute on non-empty stacks into their own methods their implementations + List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments // Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here 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: new ExpandPrivate, // Widen private definitions accessed from nested classes new RestoreScopes, // Repair scopes rendered invalid by moving definitions in prior phases of the group new SelectStatic, // get rid of selects that would be compiled into GetStatic + new sjs.JUnitBootstrappers, // Generate JUnit-specific bootstrapper classes for Scala.js (not enabled by default) new CollectEntryPoints, // Find classes with main methods new CollectSuperCalls) :: // Find classes that are called with super Nil /** Generate the output of the compilation */ protected def backendPhases: List[List[Phase]] = + List(new sjs.GenSJSIR) :: // Generate .sjsir files for Scala.js (not enabled by default) List(new GenBCode) :: // Generate JVM bytecode Nil ```