In https://dartbug.com/55357 a crash is reported happening after a hot restart (not reload!) with a compilation error. This causes a "reject" call, which means we create a new incremental compiler, initializing it from the component of the previous good world. World 1: Initial state. World 2: The library is new, but (most) references are reused because of advanced invaidation. References of unnamed extensions are not reused. Instead the canonical names are unbound (so they can successfully be bound to the new reference). We now have: * ref1 (from world1) pointing to no canonical name. * ref2 (from world2) pointing to the canonical name. * The canonical name pointing to ref2. This world is rejected. World 3: We start from the world 1 state, but because world 2 *did* happen and that only most references (i.e. not references for unnamed extensions) were reused, when about to unbind the unnamed extenesion we are looking at ref1 and have nothing to unbind. Compiling creates ref3 (from world 3). Upon attempt to serialize we try to bind the canonical name to "ref3", but it is already bound to "ref2" and we crash. The main problem here is that not only `Reference`s are reused, but because `Reference`s point to `CanonicalName`s these are reused too. This CL clears the canonical name in the references in the libraries that are reused, meaning that a whole new canonical name tree for those libraries will be created. This is more in line with what the non-advanced-invalidation does (by it not reusing references and naturally getting a whole new canonical name tree). In my opinion it even makes more sense --- and the fact that the canonical names were reused was probably more me not thinking about it, than it was a deliberate design decision. Fixes https://github.com/dart-lang/sdk/issues/55357 Change-Id: I90bd579984f4aefad78243e8366ac0ab91a905bf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363563 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
Dart Kernel
Dart Kernel is a small high-level language derived from Dart. It is designed for use as an intermediate format for whole-program analysis and transformations, and to be consumed by codegen and execution backends.
The kernel language has an in-memory representation in Dart and can be serialized as binary or text.
Both the kernel language and its implementations are unstable and are under development.
This package contains the Dart part of the implementation and contains:
- A transformable IR for the kernel language
- Serialization of kernel code
Note: The APIs in this package are in an early state; developers should be careful about depending on this package. In particular, there is no semver contract for release versions of this package. Please depend directly on individual versions.
See ast.dart for the in-memory IR, or binary.md for a description of the binary format. For now, the textual format is very ad-hoc and cannot be parsed back in.