This CL does two things: * "Reenable" the skipping of the dart:ffi transformation entirely when the application does not use dart:ffi. This was originally added inad596359a6but was logically disabled in4558112105when dart:core started depending on it. Here we now ignore (real) dart:* libraries when looking for dependencies of dart:ffi. * Find the subset of the just compiled libraries that transitively depend on dart:ffi and just run the dart:ffi transformation on those libraries. For dart2js that doesn't use dart:ffi at all we go from: ``` $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:09.003428: Transformed ffi natives in 51ms. 0:00:09.203442: Transformed ffi annotations in 199ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:09.098175: Transformed ffi natives in 52ms. 0:00:09.296847: Transformed ffi annotations in 198ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:08.854341: Transformed ffi natives in 57ms. 0:00:09.061804: Transformed ffi annotations in 207ms. ``` to ``` $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:09.138651: Skipped ffi transformation in 1ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:09.242590: Skipped ffi transformation in 1ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi" 0:00:09.163885: Skipped ffi transformation in 1ms. ``` When compiling the flutter gallery app that does depend on dart:ffi we go from: ``` $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:16.344955: Transformed ffi natives in 78ms. 0:00:16.777218: Transformed ffi annotations in 432ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:15.994674: Transformed ffi natives in 80ms. 0:00:16.472779: Transformed ffi annotations in 478ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:16.027488: Transformed ffi natives in 81ms. 0:00:16.491362: Transformed ffi annotations in 463ms. ``` to ``` $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:15.991628: Transformed ffi natives in 30ms. 0:00:16.226564: Transformed ffi annotations in 234ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:16.184984: Transformed ffi natives in 29ms. 0:00:16.404439: Transformed ffi annotations in 219ms. $ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi" 0:00:15.933513: Transformed ffi natives in 27ms. 0:00:16.145640: Transformed ffi annotations in 212ms. ``` TEST=Assuming tests already exists. Change-Id: Ie13be1924d3439cb710c782af81e1e42cda2a838 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228001 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Jens Johansen <jensj@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.