Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # The dart2js compiler | |
| 2 | |
| 3 Welcome to the sources of the dart2js compiler! | |
| 4 | |
| 5 ## Architecture | |
| 6 | |
| 7 The compiler is currently undergoing a long refactoring process. As you navigate | |
| 8 this code you may find it helpful to understand how the compiler used to be, | |
| 9 where it is going, and where it is today. | |
| 10 | |
| 11 ### The near future architecture | |
| 12 | |
| 13 The compiler will operate in these general phases: | |
| 14 | |
| 15 1. **load kernel**: Load all the code as kernel | |
| 16 * Collect dart sources transtively | |
| 17 * Convert to kernel AST | |
| 18 (this is will handled by invoking the front-end package) | |
| 19 | |
| 20 Alternatively, the compiler can start compilation directly from a kernel | |
| 21 file(s). | |
| 22 | |
| 23 2. **model**: Create a Dart model of the program | |
| 24 * The kernel ASTs could be used as a model, so this might be a noop or just | |
|
Emily Fortuna
2017/03/10 19:31:22
nit: noop -> no-op
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 25 creating a thin wrapper on top of kernel. | |
| 26 | |
| 27 3. **tree-shake and create world**: Build world of reachable code | |
| 28 * For each reachable piece of code: | |
| 29 * Compute impact (i1) from kernel AST | |
| 30 * Build a closed world (w1) | |
| 31 | |
| 32 4. **analyze**: Run a global analysis | |
| 33 * Assume closed world semantics (from w1) | |
| 34 * Produce a global result (g) | |
| 35 * Like today (g) will contain type and nullability information | |
| 36 * After we adopt strong-mode types, we want to explore simplifying this | |
| 37 to only contain native + nullability information. | |
| 38 | |
| 39 5. **codegen model**: Create a JS model of the program | |
| 40 * Model JavaScript specific concepts (like the split of constructor bodies | |
| 41 as separate elements) and provide a mapping to the Dart model | |
| 42 | |
| 43 6. **codegen and tree-shake**: Generate code, as needed | |
| 44 * For each reachable piece of code: | |
| 45 * build ssa graph from kernel ASTs and global results (g) | |
| 46 * optimize ssa | |
| 47 * compute impact (i2) from optimized code | |
| 48 * emit JS ASTs for the code | |
| 49 * Build a codegen closed world (w2) from new impacts (i2) | |
| 50 | |
| 51 7. **emit**: Assemble and minify the program | |
| 52 * Build program structure from the compiled pieces (w2) | |
| 53 * Use frequency namer to minify names. | |
| 54 * Emit js and source map files. | |
| 55 | |
| 56 ### The old architecture | |
| 57 | |
| 58 The compiler used to operate as follows: | |
| 59 | |
| 60 1. **load dart**: Load all source files | |
| 61 * Collect dart sources transtively | |
| 62 * Scan enough tokens to build import dependencies. | |
| 63 | |
| 64 2. **model**: Create a Dart model (aka. Element Model) of the program | |
| 65 * Do a diet-parse of the program to create the high-level element model | |
| 66 | |
| 67 3. **resolve and tree-shake**: Resolve and build world of reachable code (the | |
| 68 resolution enqueuer) | |
| 69 * For each reachable piece of code: | |
| 70 * Parse the full body of the function | |
| 71 * Resolve it and enqueue other pieces that are reachable | |
| 72 | |
| 73 4. **type check**: Type check every reachable member | |
|
Johnni Winther
2017/03/10 13:42:57
This is a substep of 3 (for each reachable...).
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 74 | |
| 75 5. **analyze**: Run a global analysis | |
| 76 * Assume closed world semantics (from everything enqueued by the resolver) | |
| 77 * Produce a global result about type and nullability information of method | |
| 78 arguments, return values, and receivers of dynamic sends. | |
| 79 | |
| 80 6. **codegen and tree-shake**: Generate code, as needed (via the codegen | |
| 81 enqueuer) | |
| 82 * For each reachable piece of code: | |
| 83 * build ssa graph from resolved source ASTs global results (g) | |
| 84 * optimize ssa | |
| 85 * enqueue visible dependencies | |
| 86 * emit js asts for the code | |
| 87 | |
| 88 7. **emit**: Assemble and minify the program | |
| 89 * Build program structure from the compiled pieces | |
| 90 * Use frequency namer to minify names. | |
| 91 * Emit js and source map files. | |
| 92 | |
| 93 ### The architecture today (which might be changing while you read this!) | |
| 94 | |
| 95 When using the `--use-kernel` flag, you can test the latest state of the | |
| 96 compiler as we are migrating to the new architecture. Currently it works as | |
| 97 follows: | |
| 98 | |
| 99 1. **load dart**: (same as old compiler) | |
| 100 | |
| 101 2. **model**: (same element model as old compiler) | |
| 102 | |
| 103 3. **resolve, tree-shake and build world**: Build world of reachable code | |
| 104 * For each reachable piece of code: | |
| 105 * Parse full body of the function | |
| 106 * Resolve it from the parsed source ASTs | |
| 107 * Compute impact (i1) from resolved source ASTs (no kernel) | |
| 108 * Build a closed world (w1) | |
| 109 | |
| 110 4. **type check**: (same as old compiler) | |
|
Johnni Winther
2017/03/10 13:42:57
Put this after `Resolve it....`
Siggi Cherem (dart-lang)
2017/03/14 21:36:09
Done.
| |
| 111 | |
| 112 6. **kernelize**: Create kernel ASTs | |
| 113 * For all resolved elements in w1, compute their kernel representation using | |
| 114 the `rasta` visitor. | |
| 115 | |
| 116 5. **analyze**: (almost same as old compiler) | |
| 117 | |
| 118 6. **codegen and tree-shake**: Generate code, as needed | |
| 119 * For each reachable piece of code: | |
| 120 * build ssa graph from kernel ASTs (uses global results g) | |
| 121 * optimize ssa | |
| 122 * compute impact (i2) from optimized code | |
| 123 * emit js asts for the code | |
| 124 * Build a codegen closed world (w2) from new impacts (i2) | |
| 125 | |
| 126 7. **emit**: (same as old compiler) | |
| 127 | |
| 128 Some additional details worth highlighting: | |
| 129 | |
| 130 * tree-shaking is close to working as we want: the notion of a world and world | |
| 131 impacts are computed explicitly: | |
| 132 | |
| 133 * In the old compiler, the resolver and code generator directly | |
| 134 enqueued items to be processed, there was no knowledge of what had | |
| 135 to be done other than in the algorithm itself. | |
| 136 | |
| 137 * Now the information is computed explicitly in two ways: | |
| 138 | |
| 139 * The dependencies of a single element are computed as an "impact" | |
| 140 object, these are derived from the structure of the | |
| 141 code (either the resolved code or the generated code). | |
| 142 | |
| 143 * The closed world is now an explicit concept that can be replaced in the | |
| 144 compiler. | |
| 145 | |
| 146 * This allows us to delete the resolver in the future and replace it | |
| 147 with a kernel loader, an impact builder from kernel, and a kernel world. | |
| 148 | |
| 149 * There is an implementation of a kernel impact builder, but it is not yet | |
| 150 in use in the compiler pipeline (gated on replacing the Dart model) | |
| 151 | |
| 152 * We still depend on the Dart model computed by resolution, but progress has | |
| 153 been made introducing an abstraction common to the new and old models. The | |
| 154 old model is the "Element model", the generic abstraction is called the | |
| 155 "Entity model". Some portions of the compiler now refer to the entity model. | |
| 156 | |
| 157 * The ssa graph is built from the kernel ASTs, but it still depends on the old | |
| 158 element model computed from resolution (accessed via a kernel2Ast adapter). | |
| 159 The graph builder implementation covers a large chunk of the language | |
| 160 features, but is not complete (89% of langage & corelib tests are passing). | |
| 161 | |
| 162 * Global analysis is still working on top of the dart2js ASTs. | |
| 163 | |
| 164 ## Code organization and history | |
| 165 | |
| 166 The compiler package was initially intended to be compiler for multiple targets: | |
| 167 Javascript, Dart (dart2dart), and dartino bytecodes. It has now evolved to be a | |
| 168 Javascript only compiler, but some of the abstractions to support multiple | |
| 169 targets still remain. | |
| 170 | |
| 171 ### Possibly confusing terminology | |
| 172 | |
| 173 Some of the terminology in the compiler is confusing without knowing its | |
| 174 history. We are cleaning this up as we are rearchitecting the system, but here | |
| 175 are some of the legacy terminology we have: | |
| 176 | |
| 177 * **target**: the output the compiler is producing. Nowdays it just | |
| 178 JavaScript, but in the past there was also Dart and dartino bytecodes. | |
| 179 | |
| 180 * **backend**: pieces of the compiler that were target-specific. | |
|
Emily Fortuna
2017/03/10 19:31:21
good one. thanks for this explanation.
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
:)
| |
| 181 Note: in the past we've used the term *backend* also for code that is used | |
| 182 in the frontend of the compiler that happens to be target-specific, as well | |
| 183 as and code that is used in the emitter or what traditionally is known | |
| 184 as the backend of the compiler. | |
| 185 | |
| 186 * **frontend**: the parser, resolver, and other early stages of the compiler. | |
| 187 The front-end however makes target-specific choices. For example, to compile | |
| 188 a program with async-await, the dart2js backend needs to include some helper | |
| 189 functions that are used by the expanded async-await code, these helpers need | |
| 190 to be parsed by the frontend and added to the compilation pipeline. | |
| 191 | |
| 192 * **world**: the compiler exploits closed-world assumptions to do | |
| 193 optimizations. The *world* encapsulates some of our knowledge of the | |
| 194 program, like what's reachable from `main`, which classes are instantiated, | |
| 195 etc. | |
| 196 | |
| 197 * **universe**: rather than loading entire programs and removing unreachable | |
| 198 code, the compiler uses a tree-growing approach: it enqueues work based on | |
| 199 what it sees. While this is happening the *world* is considered to be | |
| 200 growing, in the past the term *universe* was used to describe this growing | |
| 201 world. While the term is not completely deleted from the codebase, a lot of | |
| 202 progress has been made to rename *universe* into *world builders*. | |
| 203 | |
| 204 * **model**: there are many models in the compiler: | |
| 205 | |
| 206 * **element model**: this is an abstraction describing the elements seen in | |
| 207 Dart programs, like "libraries", "classes", "methods", etc. | |
| 208 | |
| 209 * **entity model**: also describes elements seen in Dart programs, but it is | |
| 210 meant to be minimalistic and a super-hierarcy above the *element models*. | |
| 211 This is a newer addition, is an added abstraction to make it possible to | |
| 212 refactor our code from our old frontend to the kernel frontend. | |
| 213 | |
| 214 * **Dart vs JS models**: the compiler in the past had a single model to | |
| 215 describe elements in the source and elements that were being compiled. In | |
| 216 the future we plan to have two. Both input model and output models will be | |
| 217 implementations of the *entity model*. The JS model is intended to have | |
| 218 concepts specific about generating code in JS (like constructor-bodies as | |
| 219 a separate entity than the constructor, closure classes, etc). | |
| 220 | |
| 221 * **emitter model**: this is a model just used for dumping out the structure | |
| 222 of the program in a .js text file. It doesn't have enough semantic meaning | |
| 223 to be a JS model for compilation at this moment. | |
| 224 | |
| 225 * **enqueuer**: a work-queue used to achieve tree-shaking (or more precisely | |
| 226 tree-growing): elements are added to the enqueuer as we recognize that they | |
| 227 are needed in a given application. Note that we even track how elements are | |
| 228 used, since some ways of using an element require more code than others. | |
| 229 | |
| 230 ### Code layout | |
| 231 | |
| 232 Here are some details of our current code layout and what's on each file. This | |
| 233 list also includes some action items (labeled AI below), which are mainly | |
| 234 cleanup tasks that we have been discussing for a while: | |
| 235 | |
| 236 **bin folder**: some experimental command-line entrypoints, these need to be | |
| 237 revisited | |
| 238 | |
| 239 * `bin/dart2js.dart`: is a dart2js entry point, not used today other than | |
| 240 locally for development, most of our tools launch dart2js from | |
| 241 `lib/src/dart2js.dart` instead. | |
| 242 | |
| 243 AI: change how we build the SDK to launch dart2js from here, most logic might | |
| 244 remain inside `lib/src/dart2js.dart` for testing purposes. | |
| 245 | |
| 246 * `bin/resolver.dart`: an experiemntal binary we used to run the resolver and | |
| 247 serializer. As we are moving to work on top of kernel this is deprecated and | |
| 248 should be deleted. | |
| 249 | |
| 250 AI: delete this file. | |
| 251 | |
| 252 **lib folder**: API to use dart2js as a library. This is used by our | |
| 253 command-line tool to launch dart2js, but also by pub to invoke dart2js as a | |
| 254 library during `pub-build` and `pub-serve`. | |
| 255 | |
| 256 * `lib/compiler_new.dart`: the current API. This API is used by our command-line | |
| 257 tool to spawn the dart2js compiler. This API (and everything that is | |
| 258 transitively created from it) has no dependencies on `dart:io` so that the | |
| 259 compiler can be used in contexts where `dart:io` is not available (e.g. | |
| 260 running in a browser worker) or where `dart:io` is not used explicitly (e.g. | |
| 261 running as a pub transformer). | |
| 262 | |
| 263 AI: rename to `compiler.dart`. | |
| 264 | |
| 265 * `lib/compiler.dart`: a legacy API that now is implemented by adapting calls to | |
|
Emily Fortuna
2017/03/10 19:31:22
question: does anyone still use this API?
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Yes - `pub build` does for sure, dart-pad might as
| |
| 266 the new API in `compiler_new.dart`. | |
| 267 | |
| 268 AI: migrate users to the new API (pub is one of those users, possibly dart-pad | |
| 269 is another), and delete the legacy API. | |
| 270 | |
| 271 **lib/src folder**: most of the compiler lives here, as very little of its | |
| 272 funtionallity is publicly exposed. | |
|
Emily Fortuna
2017/03/10 19:31:22
funtionallity -> functionality
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 273 | |
| 274 | |
| 275 * `lib/src/dart2js.dart`: the command-line script that runs dart2js. When | |
| 276 building the SDK, the dart2js snapshot is built using the main method on this | |
| 277 script. This file creates the parameters needed to invoke the API defined in | |
| 278 `lib/compiler_new.dart`. All dependencies on `dart:io` come from here. This is | |
| 279 also where we process options (although some of the logic is done in | |
| 280 `options.dart`). | |
| 281 | |
| 282 * `lib/src/compiler.dart`: defines the core `Compiler` object, which contains | |
| 283 all the logic about what the compiler pipeline does and how data is organized | |
| 284 and communicated between different phases. For a long time, `Compiler` was | |
| 285 also used throughout the system as a global dependency-injection object. | |
| 286 We've been slowly disentangling those dependencies, but there are still many | |
| 287 references to `compiler` still in use. | |
| 288 | |
| 289 * `lib/src/apiimpl.dart`: defines `CompilerImpl` a subclass of `Compiler` that | |
| 290 adds support for loading scripts, resolving package URIs and patch files. The | |
| 291 separation here is a bit historical and we should be able to remove it. It was | |
| 292 added to make it easier to create a `MockCompiler` implementation for unit | |
| 293 testing. The `MockCompiler` has been replaced in most unit tests by a regular | |
| 294 `CompilerImpl` that uses a mock of the file-system (see | |
| 295 `tests/compiler/dart2js/memory_compiler.dart`). | |
| 296 | |
| 297 AI: Once all tests are migrated to this memory compiler, we should merge | |
| 298 `Compiler` and `CompilerImpl` and remove this file. | |
| 299 | |
| 300 * `lib/src/old_to_new_api.dart`: helper library used to adapt the public API in | |
| 301 `lib/compiler.dart` to `lib/compiler_new.dart`. | |
| 302 | |
| 303 * `lib/src/closure.dart`: closures are compiled as classes, this file has the | |
| 304 logic to do this kind of conversion in the Dart element model. This includes | |
| 305 computing what needs to be boxed and creating fake element models to represent | |
| 306 closures as classes. We use the fake model approach because the compiler | |
| 307 currently uses the same element model for Dart and JS. Our goal with the | |
| 308 compiler rearchitecture described earlier is to have two models. The | |
| 309 Dart model will be able to encode closures directly, and we'll introduce their | |
| 310 corresponding classes when we create the corresponding JS model, removing the | |
| 311 need of the fake elements. | |
| 312 | |
| 313 * `lib/src/colors.dart`: ANSII support for reporting error messages with colors. | |
| 314 | |
| 315 AI: this file should move under a utilities folder. | |
| 316 | |
| 317 | |
| 318 * Handling of options: as mentioned earlier `lib/src/dart2js.dart` has some | |
| 319 handling of command-line options, the rest is divided into these files: | |
| 320 | |
| 321 * `lib/src/commandline_options.dart`: defines the flags that dart2js accepts. | |
| 322 | |
| 323 * `lib/src/options.dart`: defines first-class objects to represent options of | |
| 324 dart2js. This includes a parse function that can translate flags into their | |
| 325 corresponding objects. This was added recently to simplify how options where | |
|
Emily Fortuna
2017/03/10 19:31:21
where -> were
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done. thanks :)!
| |
| 326 propagated throughout the compiler. | |
| 327 | |
| 328 AI: simplify further how we specify options. Ideally all changes can be done | |
| 329 in a single file (`options.dart`?), and unit-tests can specify options via an | |
| 330 options object rather than command-line flags. | |
| 331 | |
| 332 * `lib/src/common.dart`: convenience file that reexports code used in many | |
| 333 places in the compiler. | |
| 334 | |
| 335 AI: consider deleting this file. | |
| 336 | |
| 337 | |
| 338 * Constants: the compiler has a constant system that delays evaluation of | |
| 339 constants and provides different semantics depending on the embedder, this | |
| 340 abstraction was especially necessary when dart2js was used as a front-end for | |
| 341 non-JS systems like dart2dart and dartino. | |
| 342 | |
| 343 * `lib/src/constants/expressions.dart`: this is how constants are reprensented | |
|
Emily Fortuna
2017/03/10 19:31:22
represented
Siggi Cherem (dart-lang)
2017/03/14 21:36:09
Done.
| |
| 344 after they are parsed but before they are evaluated. It is a target | |
| 345 agnostic representation, all expressions are kept as they appear in the | |
| 346 source, and it doesn't replace _environemnt_ values that are provided on the | |
| 347 command line. In particular, the constant `1 == 1.0` is represented an | |
|
Emily Fortuna
2017/03/10 19:31:22
an -> "as an" ?
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 348 expression that includes this binary expression and `const | |
|
Emily Fortuna
2017/03/10 19:31:22
"this binary expression" being the "==" ?
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
correct, I went ahead and clarified the text.
| |
| 349 String.fromEnvironment("FOO")` is not expanded. | |
| 350 | |
| 351 * `lib/src/constants/value.dart`: this is the represented value of a constant | |
| 352 after it has been evaluated. The resulting value is specific to the target | |
| 353 of the compiler and will no longer have environment placeholders. For | |
| 354 example, when the target is Dart (dart2dart) `1 == 1.0` is evaluated to | |
| 355 `false`, and when the target is JavaScript it is evaluated to `true`. This | |
| 356 specific example is a result of the way dart2js compiles numbers as | |
| 357 JavaScript Numbers. | |
| 358 | |
| 359 * `lib/src/constants/evaluation.dart`: defines the algorithm to turn an | |
| 360 expression into a value. | |
| 361 | |
| 362 * `lib/src/constants/constant_system.dart`: an abstraction that defines how | |
| 363 expressions may be folded. Different implementations of the constant system | |
| 364 are used to target Dart or JavaScript. | |
| 365 | |
| 366 * `lib/src/compile_time_constants.dart`: defines how constant expresions are | |
| 367 created from a parsed AST. | |
| 368 | |
| 369 * `lib/src/constant_system_dart.dart`: defines an implementation of a constant | |
| 370 system with the Dart semantics (where `1 == 1.0` is true). | |
| 371 | |
| 372 * `lib/src/js_backend/constant_system_javascript.dart`: defines an | |
| 373 implementation of a constant system with the JavaScript semantics (where | |
| 374 `1 == 1.0` is false). | |
| 375 | |
| 376 * `lib/src/constants/constructors.dart` and | |
| 377 `lib/src/constants/constant_constructors.dart`: used to define expressions | |
| 378 containing constant constructors. They depend on the resolver to figure out | |
| 379 what is the meaning of an initializer or a field on a constructed constant | |
| 380 created this way. | |
| 381 | |
| 382 AI: consider deleting `constant_system_dart.dart` now that it is no longer | |
| 383 used, or move under testing, if it might be used for unittests of the constant | |
| 384 expressions. | |
| 385 | |
| 386 * Common elements: the compiler often refers to certain elements during | |
| 387 compilation either because they are first-class in the language or because | |
| 388 they are implicitly used to implement some features. These include: | |
| 389 | |
| 390 * `lib/src/core_types.dart`: provides an interface to lookup basic elements | |
|
Johnni Winther
2017/03/10 13:42:56
Now common_elements.dart
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 391 like the class of `Object`, `int`, `List`, and their corresponding interface | |
| 392 types, constructors for symbols, annotations such as `@MirrorsUsed`, the | |
| 393 `identical` function, etc. These are normally restricted to elements that | |
| 394 are understood directly in Dart. | |
| 395 | |
| 396 * `lib/src/js_backend/backend_helpers.dart`: provides a way to lookup internal | |
| 397 elements of the Javascript backend, like our internal | |
| 398 representation of JSInt31, JSArray, and other implementation-specific | |
| 399 elements. | |
| 400 | |
| 401 * `lib/src/dart2js_resolver.dart`: a script to run the compiler up to resolution | |
| 402 and to generate a serialized json representation of the element model. | |
| 403 | |
| 404 AI: delete. | |
| 405 | |
| 406 * `lib/src/deferred_load.dart`: general analysis for deferred loading. This is | |
| 407 where we compute how to split the code in different JS chunks or fragments. | |
| 408 This is run at a time when no code is generated yet, so the decisions made | |
|
Johnni Winther
2017/03/10 13:42:57
This is run after resolution.
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Thanks, Made this clearer.
| |
| 409 here are used later on by the emitter to dump code into different files. | |
| 410 | |
| 411 * `lib/src/dump_info.dart`: a special phase used to create a .info.json file. | |
| 412 This file contains lots of information computed by dart2js including decisions | |
| 413 about deferred loading, results of the global type-inference, and the actual | |
| 414 code generated for each function. The output is used by tools provided in the | |
| 415 `dart2js_info` package to analyze a program and better understand why | |
| 416 something wasn't optimized as you'd expect. | |
| 417 | |
| 418 * Tree-shaking: The compiler does two phases of reducing the program size by | |
| 419 throwing away unreachable code. The first phase is done while resolving the | |
| 420 program (reachablity is basically based on dependencies that appear in the | |
| 421 code), the second phase is done as functions are optimized (which in turn can | |
| 422 delete branches of the code and make more code unreachable). Externally | |
| 423 we refer to it as tree-shaking, but it behaves more like a tree-growing | |
| 424 algorithm: elements are added as they are discovered or as they are used. | |
| 425 On some large apps we've seen 50% of code tree-shaken: 20% from the first | |
| 426 phase, and an additional 30% from the second phase. | |
| 427 | |
| 428 * `lib/src/enqueue.dart`: this is the basic algorithm that adds thigs as they | |
|
Johnni Winther
2017/03/10 13:42:57
thigs -> things
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 429 are discovered during resolution. | |
| 430 | |
| 431 * `lib/src/js_backend/enqueuer.dart`: this is the enqueuer used during code | |
| 432 generation. | |
| 433 | |
| 434 * `lib/src/environment.dart`: simple interface for collecting environment values | |
| 435 (these are values passed via -D flags on the command line). | |
| 436 | |
| 437 * `lib/src/filenames.dart`: basic support for converting between native and Uri | |
| 438 paths. | |
| 439 | |
| 440 AI: move to utils | |
| 441 | |
| 442 * `lib/src/id_generator.dart`: simple id generator | |
| 443 | |
| 444 AI: move to utils | |
| 445 | |
| 446 * `lib/src/library_loader.dart`: the loader of the dart2js frontend. Asks the | |
| 447 compiler to read and scan files, produce enough metadata to understand | |
| 448 import, export, and part directives and keep crawling. It also triggers the | |
| 449 patch parser to load patch files. | |
| 450 | |
| 451 * `lib/src/mirrors_used.dart`: task that analyzes `@MirrorsUsed` annotations, | |
| 452 which let the compiler continue to do tree-shaking even when code is used via | |
| 453 `dart:mirrors`. | |
| 454 | |
| 455 * Input/output: the compiler is designed to avoid all dependencies on dart:io. | |
| 456 Most data is consumed and emitted via provider APIs. | |
| 457 | |
| 458 * `lib/src/compiler_new.dart`: defines the interface of these providers (see | |
| 459 `CompilerInput` and `CompilerOutput`). | |
| 460 | |
| 461 * `lib/src/null_compiler_output.dart`: an `CompilerOutput` that discards all | |
| 462 data written to it (name derives from /dev/null). | |
| 463 | |
| 464 * `lib/src/source_file_provider.dart`: _TODO: add details_. | |
| 465 | |
| 466 * Parsing: most of the parsing logic is now in the `front_end` package, | |
| 467 currently under `pkg/front_end/lib/src/fasta/scanner` and | |
| 468 `pkg/front_end/lib/src/fasta/parser`. The `front_end` parser is AST agnostic | |
| 469 and uses listeners to create on the side what they want as the result of | |
| 470 parsing. The logic to create dart2js' ASTs is defined in listeners within the | |
| 471 compiler package: | |
| 472 | |
| 473 * `lib/src/parser/element_listener.dart`: listener used to create the first | |
| 474 skeleton of the element model (used by the diet parser) | |
| 475 | |
| 476 * `lib/src/parser/partial_elements.dart`: representation of elements in the | |
|
Emily Fortuna
2017/03/10 19:31:22
ah HA! I had wondered about this.
Siggi Cherem (dart-lang)
2017/03/14 21:36:09
:)
| |
| 477 element model whose body is not parsed yet (e.g. a diet-parsed member). | |
| 478 | |
| 479 * `lib/src/parser/node_listener.dart`: listener used to create the body of | |
| 480 methods. | |
| 481 | |
| 482 * `lib/src/parser/member_listener.dart`: listener used to attach method bodies | |
| 483 to class members. | |
| 484 | |
| 485 * `lib/src/parser/parser_task.dart`: Task to execute the full parser. | |
| 486 | |
| 487 * `lib/src/parser/diet_parser_task.dart`: Task to execute diet parsing. | |
| 488 | |
| 489 * `lib/src/patch_parser.dart`: additional support for parsing patch files. We | |
| 490 expect this will also move under `front_end` in the future. | |
| 491 | |
| 492 | |
| 493 * URI resolution: the compiler needs special logic to resolve `dart:*` URIs and | |
| 494 `package:*` URIs. These are specified in three parts: | |
| 495 | |
| 496 * sdk library files are specified in a .platform file. This file has a special | |
| 497 .ini format which is parsed with `lib/src/platform_configuration.dart`. | |
| 498 | |
| 499 * sdk patch files are hardcoded in the codebase in | |
| 500 `lib/src/js_backend/backend.dart` (see `_patchLocations`). | |
| 501 | |
| 502 * package resolution is specified with a `.packages` file, which is parsed | |
| 503 using the `package_config` package. | |
| 504 | |
| 505 * `lib/src/resolved_uri_translator.dart`: has the logic to translate all these | |
| 506 URIs when they are encountered by the library loader. | |
| 507 | |
| 508 AI: consider changing the .platform file format to yaml. | |
| 509 | |
| 510 | |
| 511 * `lib/src/typechecker.dart`: the type checker (spec mode semantics, no support | |
| 512 for strong mode here). | |
| 513 | |
| 514 * World: _TODO: add details_ | |
| 515 | |
| 516 * `lib/src/world.dart` | |
| 517 * `lib/src/universe/call_structure.dart` | |
| 518 * `lib/src/universe/use.dart` | |
| 519 * `lib/src/universe/feature.dart` | |
| 520 * `lib/src/universe/world_impact.dart` | |
| 521 * `lib/src/universe/selector.dart` | |
| 522 * `lib/src/universe/side_effects.dart` | |
| 523 * `lib/src/universe/class_set.dart` | |
| 524 * `lib/src/universe/world_builder.dart` | |
| 525 * `lib/src/universe/function_set.dart` | |
| 526 | |
| 527 | |
| 528 * Testing, debugging, and what not: _TODO: add details_ | |
| 529 * `lib/src/tracer.dart` | |
| 530 * `lib/src/use_unused_api.dart` | |
| 531 | |
| 532 | |
| 533 * SSA (`lib/src/ssa`): internal IR used to optimize functions before emitting | |
| 534 JavaScript. _TODO: add details_. | |
| 535 * `ssa.dart` | |
| 536 * `kernel_string_builder.dart` | |
| 537 * `codegen.dart` | |
| 538 * `variable_allocator.dart` | |
| 539 * `type_builder.dart` | |
| 540 * `value_set.dart` | |
| 541 * `types.dart` | |
| 542 * `jump_handler.dart` | |
| 543 * `codegen_helpers.dart` | |
| 544 * `switch_continue_analysis.dart` | |
| 545 * `types_propagation.dart` | |
| 546 * `nodes.dart` | |
| 547 * `kernel_ast_adapter.dart` | |
| 548 * `graph_builder.dart` | |
| 549 * `validate.dart` | |
| 550 * `builder.dart.rej` | |
| 551 * `interceptor_simplifier.dart` | |
| 552 * `builder_kernel.dart` | |
| 553 * `locals_handler.dart` | |
| 554 * `optimize.dart` | |
| 555 * `kernel_impact.dart` | |
| 556 * `invoke_dynamic_specializers.dart` | |
| 557 * `builder.dart` | |
| 558 * `ssa_branch_builder.dart` | |
| 559 * `value_range_analyzer.dart` | |
| 560 * `ssa_tracer.dart` | |
| 561 * `loop_handler.dart` | |
| 562 | |
| 563 * `tool`: some helper scripts, some of these could be deleted | |
| 564 | |
| 565 * `tool/perf.dart`: used by our benchmark runners to measure performance of so me | |
|
Johnni Winther
2017/03/10 13:42:57
Long lines, here and below.
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 566 frontend pieces of dart2js. We shuld be able to deleted it in the near futur e | |
|
Emily Fortuna
2017/03/10 19:31:21
deleted -> delete
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 567 once the front end code is moved into `fasta`. | |
| 568 | |
| 569 * `tool/perf_test.dart`: small test to ensure we don't break `perf.dart`. | |
| 570 | |
| 571 * `tool/track_memory.dart`: a helper script to see memory usage of dart2js whi le | |
| 572 it's running. Used in the past to profile the global analysis phases when ru n | |
| 573 on very large apps. | |
| 574 | |
| 575 * `tool/dart2js_stress.dart` and `tool/dart2js_profile_many.dart`: other helpe r | |
| 576 wrappers to make it easier to profile dart2js with Observatory. | |
| 577 | |
| 578 * Source map tracking (`lib/src/io`): helpers used to track source information | |
| 579 and to build source map files. _TODO: add details_. | |
| 580 * `lib/src/io/code_output.dart` | |
| 581 * `lib/src/io/source_map_builder.dart` | |
| 582 * `lib/src/io/start_end_information.dart` | |
| 583 * `lib/src/io/position_information.dart` | |
| 584 * `lib/src/io/source_information.dart` | |
| 585 * `lib/src/io/source_file.dart` | |
| 586 * `lib/src/io/line_column_provider.dart` | |
| 587 | |
| 588 * Kernel conversion (`lib/src/kernel`): temporary code to create kernel within | |
| 589 dart2js (previously known as `rasta`). Most of this code will be gone when we | |
| 590 are in the final architecture. _TODO: add details_. | |
| 591 * `lib/src/kernel/task.dart` | |
| 592 * `lib/src/kernel/kernel_visitor.dart` | |
| 593 * `lib/src/kernel/kernel_debug.dart` | |
| 594 * `lib/src/kernel/unresolved.dart` | |
| 595 * `lib/src/kernel/kernel.dart` | |
| 596 * `lib/src/kernel/unavailable.dart` | |
| 597 * `lib/src/kernel/accessors.dart` | |
| 598 * `lib/src/kernel/constant_visitor.dart` | |
| 599 * `lib/src/kernel/error.dart` | |
| 600 | |
| 601 * Global whole-program analysis (a.k.a. type inference): We try to avoid the | |
| 602 term "type inference" to avoid confusion with strong-mode type inference. | |
| 603 However the code still uses the term inference for this global analysis. The | |
| 604 code is contained under `lib/src/inferrer`. _TODO: add details_. | |
| 605 * `lib/src/inferrer/type_graph_dump.dart` | |
| 606 * `lib/src/inferrer/node_tracer.dart` | |
| 607 * `lib/src/inferrer/list_tracer.dart` | |
| 608 * `lib/src/inferrer/closure_tracer.dart` | |
| 609 * `lib/src/inferrer/inferrer_engine.dart` | |
| 610 * `lib/src/inferrer/type_graph_inferrer.dart` | |
| 611 * `lib/src/inferrer/type_graph_nodes.dart` | |
| 612 * `lib/src/inferrer/type_system.dart` | |
| 613 * `lib/src/inferrer/debug.dart` | |
| 614 * `lib/src/inferrer/locals_handler.dart` | |
| 615 * `lib/src/inferrer/map_tracer.dart` | |
| 616 * `lib/src/inferrer/builder.dart` | |
| 617 | |
| 618 * Serialization (`lib/src/serialization/*`: the compiler had support to emit a | |
| 619 serialized form of the element model. This is likely going to be deleted in | |
| 620 the near future (it was created before we had the intent to use kernel as a | |
| 621 serialization format). | |
| 622 | |
| 623 --------- | |
| 624 | |
| 625 _TODO: complete the documentation for the following files_. | |
| 626 | |
| 627 `lib/src/ordered_typeset.dart` | |
| 628 `lib/src/script.dart` | |
| 629 `lib/src/string_validator.dart` | |
| 630 | |
| 631 `lib/src/native` | |
| 632 `lib/src/native/ssa.dart` | |
| 633 `lib/src/native/scanner.dart` | |
| 634 `lib/src/native/js.dart` | |
| 635 `lib/src/native/enqueue.dart` | |
| 636 `lib/src/native/behavior.dart` | |
| 637 `lib/src/native/native.dart` | |
| 638 | |
| 639 `lib/src/js_emitter` | |
| 640 `lib/src/js_emitter/native_emitter.dart` | |
| 641 `lib/src/js_emitter/main_call_stub_generator.dart` | |
| 642 `lib/src/js_emitter/model.dart` | |
| 643 `lib/src/js_emitter/headers.dart` | |
| 644 `lib/src/js_emitter/native_generator.dart` | |
| 645 `lib/src/js_emitter/parameter_stub_generator.dart` | |
| 646 `lib/src/js_emitter/constant_ordering.dart` | |
| 647 `lib/src/js_emitter/program_builder` | |
| 648 `lib/src/js_emitter/program_builder/collector.dart` | |
| 649 `lib/src/js_emitter/program_builder/program_builder.dart` | |
| 650 `lib/src/js_emitter/program_builder/field_visitor.dart` | |
| 651 `lib/src/js_emitter/program_builder/registry.dart` | |
| 652 `lib/src/js_emitter/metadata_collector.dart` | |
| 653 `lib/src/js_emitter/code_emitter_task.dart.rej` | |
| 654 `lib/src/js_emitter/code_emitter_task.dart.orig` | |
| 655 `lib/src/js_emitter/code_emitter_task.dart` | |
| 656 `lib/src/js_emitter/interceptor_stub_generator.dart` | |
| 657 `lib/src/js_emitter/full_emitter` | |
| 658 `lib/src/js_emitter/full_emitter/class_builder.dart` | |
| 659 `lib/src/js_emitter/full_emitter/container_builder.dart` | |
| 660 `lib/src/js_emitter/full_emitter/deferred_output_unit_hash.dart` | |
| 661 `lib/src/js_emitter/full_emitter/class_emitter.dart` | |
| 662 `lib/src/js_emitter/full_emitter/interceptor_emitter.dart` | |
| 663 `lib/src/js_emitter/full_emitter/code_emitter_helper.dart` | |
| 664 `lib/src/js_emitter/full_emitter/emitter.dart` | |
| 665 `lib/src/js_emitter/full_emitter/setup_program_builder.dart` | |
| 666 `lib/src/js_emitter/full_emitter/declarations.dart` | |
| 667 `lib/src/js_emitter/full_emitter/nsm_emitter.dart` | |
| 668 `lib/src/js_emitter/type_test_registry.dart` | |
| 669 `lib/src/js_emitter/js_emitter.dart.rej` | |
| 670 `lib/src/js_emitter/class_stub_generator.dart` | |
| 671 `lib/src/js_emitter/lazy_emitter` | |
| 672 `lib/src/js_emitter/lazy_emitter/model_emitter.dart` | |
| 673 `lib/src/js_emitter/lazy_emitter/emitter.dart` | |
| 674 `lib/src/js_emitter/startup_emitter` | |
| 675 `lib/src/js_emitter/startup_emitter/deferred_fragment_hash.dart` | |
| 676 `lib/src/js_emitter/startup_emitter/model_emitter.dart` | |
| 677 `lib/src/js_emitter/startup_emitter/emitter.dart` | |
| 678 `lib/src/js_emitter/startup_emitter/fragment_emitter.dart` | |
| 679 `lib/src/js_emitter/js_emitter.dart` | |
| 680 `lib/src/js_emitter/helpers.dart` | |
| 681 `lib/src/js_emitter/runtime_type_generator.dart` | |
| 682 `lib/src/js_emitter/js_emitter.dart.orig` | |
| 683 | |
| 684 `lib/src/elements` | |
| 685 `lib/src/elements/modelx.dart` | |
| 686 `lib/src/elements/types.dart` | |
| 687 `lib/src/elements/resolution_types.dart` | |
| 688 `lib/src/elements/entities.dart` | |
| 689 `lib/src/elements/common.dart` | |
| 690 `lib/src/elements/names.dart` | |
| 691 `lib/src/elements/visitor.dart` | |
| 692 `lib/src/elements/elements.dart` | |
| 693 | |
| 694 `lib/src/diagnostics` | |
| 695 `lib/src/diagnostics/invariant.dart` | |
| 696 `lib/src/diagnostics/generated` | |
| 697 `lib/src/diagnostics/generated/shared_messages.dart` | |
| 698 `lib/src/diagnostics/messages.dart` | |
| 699 `lib/src/diagnostics/source_span.dart` | |
| 700 `lib/src/diagnostics/code_location.dart` | |
| 701 `lib/src/diagnostics/diagnostic_listener.dart` | |
| 702 `lib/src/diagnostics/spannable.dart` | |
| 703 | |
| 704 `lib/src/common` | |
| 705 `lib/src/common/codegen.dart` | |
| 706 `lib/src/common/resolution.dart` | |
| 707 `lib/src/common/tasks.dart` | |
| 708 `lib/src/common/work.dart` | |
| 709 `lib/src/common/backend_api.dart` | |
| 710 `lib/src/common/names.dart` | |
| 711 | |
| 712 `lib/src/tokens` | |
|
Johnni Winther
2017/03/10 13:42:56
All but `lib/src/tokens/token_map` is now in fasta
Siggi Cherem (dart-lang)
2017/03/14 21:36:08
Done.
| |
| 713 `lib/src/tokens/token_map.dart` | |
| 714 `lib/src/tokens/precedence.dart` | |
| 715 `lib/src/tokens/precedence_constants.dart` | |
| 716 `lib/src/tokens/token_constants.dart` | |
| 717 `lib/src/tokens/keyword.dart` | |
| 718 `lib/src/tokens/token.dart` | |
| 719 | |
| 720 `lib/src/resolution` | |
| 721 `lib/src/resolution/typedefs.dart` | |
| 722 `lib/src/resolution/registry.dart.orig` | |
| 723 `lib/src/resolution/scope.dart` | |
| 724 `lib/src/resolution/members.dart` | |
| 725 `lib/src/resolution/label_scope.dart` | |
| 726 `lib/src/resolution/registry.dart.rej` | |
| 727 `lib/src/resolution/resolution.dart` | |
| 728 `lib/src/resolution/access_semantics.dart` | |
| 729 `lib/src/resolution/operators.dart` | |
| 730 `lib/src/resolution/member_impl.dart` | |
| 731 `lib/src/resolution/resolution_common.dart` | |
| 732 `lib/src/resolution/semantic_visitor.dart` | |
| 733 `lib/src/resolution/resolution_result.dart` | |
| 734 `lib/src/resolution/send_resolver.dart` | |
| 735 `lib/src/resolution/send_structure.dart` | |
| 736 `lib/src/resolution/variables.dart` | |
| 737 `lib/src/resolution/enum_creator.dart` | |
| 738 `lib/src/resolution/members.dart.orig` | |
| 739 `lib/src/resolution/type_resolver.dart` | |
| 740 `lib/src/resolution/class_members.dart` | |
| 741 `lib/src/resolution/constructors.dart` | |
| 742 `lib/src/resolution/secret_tree_element.dart` | |
| 743 `lib/src/resolution/registry.dart` | |
| 744 `lib/src/resolution/tree_elements.dart` | |
| 745 `lib/src/resolution/semantic_visitor_mixins.dart` | |
| 746 `lib/src/resolution/class_hierarchy.dart` | |
| 747 `lib/src/resolution/signatures.dart` | |
| 748 | |
| 749 `lib/src/scanner` | |
| 750 `lib/src/scanner/scanner_task.dart` | |
| 751 | |
| 752 `lib/src/helpers` | |
| 753 `lib/src/helpers/trace.dart` | |
| 754 `lib/src/helpers/debug_collection.dart` | |
| 755 `lib/src/helpers/expensive_map.dart` | |
| 756 `lib/src/helpers/helpers.dart` | |
| 757 `lib/src/helpers/track_map.dart` | |
| 758 `lib/src/helpers/expensive_set.dart` | |
| 759 `lib/src/helpers/stats.dart` | |
| 760 | |
| 761 `lib/src/js` | |
| 762 `lib/src/js/js.dart` | |
| 763 `lib/src/js/placeholder_safety.dart` | |
| 764 `lib/src/js/js_debug.dart` | |
| 765 `lib/src/js/js_source_mapping.dart` | |
| 766 `lib/src/js/rewrite_async.dart` | |
| 767 | |
| 768 `lib/src/util` | |
| 769 `lib/src/util/uri_extras.dart` | |
| 770 `lib/src/util/indentation.dart` | |
| 771 `lib/src/util/enumset.dart` | |
| 772 `lib/src/util/link.dart` | |
| 773 `lib/src/util/util.dart` | |
| 774 `lib/src/util/maplet.dart` | |
| 775 `lib/src/util/setlet.dart` | |
| 776 `lib/src/util/characters.dart` | |
| 777 `lib/src/util/emptyset.dart` | |
| 778 `lib/src/util/link_implementation.dart` | |
| 779 `lib/src/util/util_implementation.dart` | |
| 780 `lib/src/util/command_line.dart` | |
| 781 | |
| 782 `lib/src/js_backend` | |
| 783 `lib/src/js_backend/frequency_namer.dart` | |
| 784 `lib/src/js_backend/patch_resolver.dart` | |
| 785 `lib/src/js_backend/minify_namer.dart` | |
| 786 `lib/src/js_backend/mirrors_analysis.dart` | |
| 787 `lib/src/js_backend/js_backend.dart` | |
| 788 `lib/src/js_backend/field_naming_mixin.dart` | |
| 789 `lib/src/js_backend/native_data.dart` | |
| 790 `lib/src/js_backend/namer.dart` | |
| 791 `lib/src/js_backend/custom_elements_analysis.dart` | |
| 792 `lib/src/js_backend/type_variable_handler.dart` | |
| 793 `lib/src/js_backend/js_interop_analysis.dart` | |
| 794 `lib/src/js_backend/backend_impact.dart` | |
| 795 `lib/src/js_backend/constant_emitter.dart` | |
| 796 `lib/src/js_backend/lookup_map_analysis.dart` | |
| 797 `lib/src/js_backend/namer_names.dart` | |
| 798 `lib/src/js_backend/runtime_types.dart` | |
| 799 `lib/src/js_backend/no_such_method_registry.dart` | |
| 800 `lib/src/js_backend/constant_system_javascript.dart` | |
| 801 `lib/src/js_backend/backend.dart` | |
| 802 `lib/src/js_backend/backend_serialization.dart` | |
| 803 `lib/src/js_backend/checked_mode_helpers.dart` | |
| 804 `lib/src/js_backend/constant_handler_javascript.dart` | |
| 805 | |
| 806 `lib/src/tree` | |
| 807 `lib/src/tree/prettyprint.dart` | |
| 808 `lib/src/tree/tree.dart` | |
| 809 `lib/src/tree/nodes.dart` | |
| 810 `lib/src/tree/dartstring.dart` | |
| 811 `lib/src/tree/unparser.dart` | |
| 812 | |
| 813 `lib/src/types` | |
| 814 `lib/src/types/abstract_value_domain.dart` | |
| 815 `lib/src/types/types.dart` | |
| 816 `lib/src/types/type_mask.dart` | |
| 817 `lib/src/types/dictionary_type_mask.dart` | |
| 818 `lib/src/types/map_type_mask.dart` | |
| 819 `lib/src/types/forwarding_type_mask.dart` | |
| 820 `lib/src/types/container_type_mask.dart` | |
| 821 `lib/src/types/constants.dart` | |
| 822 `lib/src/types/flat_type_mask.dart` | |
| 823 `lib/src/types/masks.dart` | |
| 824 `lib/src/types/value_type_mask.dart` | |
| 825 `lib/src/types/union_type_mask.dart` | |
| 826 | |
| 827 `lib/src/hash` | |
| 828 `lib/src/hash/sha1.dart` | |
| OLD | NEW |