-
Notifications
You must be signed in to change notification settings - Fork 1.2k
High level overview of a compilation job
For each compilation, an instance of Compiler is created. The compiler class contains several compile
methods, and they all end up calling compileInternal
.
The CommandLineRunner takes the command-line arguments and creates an instance of CompilerOptions. The compiler uses the options object to determine which passes will be run (some checks and some optimizations). This happens in DefaultPassConfig. The two important methods in this class are getChecks
and getOptimizations
.
Before running the checks, the compiler parses the code and creates an abstract-syntax tree (AST). The structure of the AST is described in Node.java and Token.java.
PhaseOptimizer takes the list of passes created in the pass config, and runs them. Running the checks is simple, we just go through the list of checks and run each check once. Some optimization passes run once, and others run in a loop until they can no longer make changes. During an optimization loop, the compiler tries to avoid running passes that are no longer making changes.