Commit Graph

28 Commits

Author SHA1 Message Date
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`:

```
msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03)
page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71)
cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16)
instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18)
branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35)
seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01)
seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03)
```

Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`):

```
AstFromBinaryEagerCold: -12.5174% +/- 3.10688%
AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433%
AstFromBinaryEager: -10.3432% +/- 3.68375%
```

I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway.

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Jens Johansen afdb87e2cf [kernel] Delete unused code
Change-Id: I8299a49425188c9864fc47532243cede2cf16b1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353960
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-02-29 17:28:01 +00:00
Lasse R.H. Nielsen 8a883fa54d Change : to = for default values in pkg.
Leaves some in parser test:
 pkg/front_end/parser_testcases/error_recovery/keyword_named_formal_parameter_prime.dart

TEST=Refactoring, covered by existing tests.

Change-Id: I7a83ef95df3cbd283878b3685b5c747bd89a1b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256125
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-08-24 15:57:16 +00:00
Johnni Winther be7ff1daf6 [cfe] Add MacroSerializer
This adds a [MacroSerializer] interface to abstract how URIs are
created for precompiled macro components.

Two strategies are added. The existing solution using a temporary
directory in TempDirMacroSerializer and a new solution using the
recently added (experimental) Isolate.createUriForKernelBlob feature
in IsolateSerializer.

Change-Id: Id7117cc518f09e9b3762d6ca924c788c81fd9ac0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234282
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-25 10:40:04 +00:00
Johnni Winther 9e23810b77 [kernel] Migrate more libraries in package:kernel
Change-Id: I249c9fa9f2727544f940b3d954ce49bf38ee4918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191402
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-18 11:06:18 +00:00
Johnni Winther 34fb48bb8a [kernel,front_end] Migrate first wave of pkg/kernel and pkg/front_end
Migrates libraries dependent only on already migrated libraries.

Change-Id: I0e85ee8dbc2afce031b92e0009e71c206a55af28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179502
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-18 15:40:21 +00:00
Johnni Winther 42f09a71ba [vm] Re-resolve stub targets on mixin deduplication
This ensures that stub targets are re-resolved when performing
mixin deduplication. In particular member signatures, whose stub
target point the member signature origin, need to be re-resolved
since the origin is serialized together with the interface target
in PropertyGet, PropertySet and MethodInvocation, and if not
re-resolved, might point to removed members.

TEST=pkg/vm/test/modular_kernel_plus_ast_test.dart

Closes #44560

Change-Id: Ib2dd923fbf736a9defe2df38bbc71d442f80b7bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177127
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-12-29 15:01:35 +00:00
Johnni Winther b38821f39d [kernel] Enforce lints in pkg/kernel
Change-Id: I954f7632f22b552febed2a3140f81245277cb050
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171581
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-11 12:51:28 +00:00
Mike Fairhurst 316128d6cd [kernel] Remove unused dart:async import
Since Dart 2.1, Future and Stream have been exported from dart:core

Change-Id: Ib452692ea2ce02bcc84fa50ffb054410114de56f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164100
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-09-25 09:21:44 +00:00
Jens Johansen 1c3468a646 [kernel] Remove Library.isExternal
Change-Id: I6638b915c1189838e7081069a0075e4ecd9ee9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-12-02 09:24:42 +00:00
Jens Johansen e491bc5d86 Allow to specify what dill file to initialize from
This CL updates the frontend_server to allow specifying what dill
file to initialize from.

Normally, it tries to initialize from the same dill file as is the
output. This is fine in many cases (e.g. flutter run always says it
should output to build/app.dill): The first time it compiles
everything, subsequent times (across restarts) it only recompiles
what's needed.

When running tests, however, the output is in a temporary directory,
so it doesn't work across restarts. The startup time for tests is
always rather high, because it always has to recompile everything.

This CL updates the frontend_server to allow specifying what dill
file to initialize from. Flutter can thus save the compiled test
file in a centralized location (e.g. build/test.dill) and load from
that across restarts.

Plumbing this into flutter yields the following result, when running
a single test (the one automatically created when creating a new
flutter project):

Before: ~5.5 seconds
Now, first run: ~5.5 second (unchanged)
Now, subsequent runs: ~3.4 seconds

Approximate breakdown:

Startup cost (e.g. if there's no test directory):        ~ 800 ms
Starting up the actual frontend server: ~150 ms
Reading source from old dill, loading all relevant files
and invalidating source:                                 ~ 300 ms
Compiling everything (or, rather, nothing as it's all
from the dill at this point):                            ~ 650 ms
Serializing:                                             ~ 250 ms
Copying files:                                           ~  50 ms
Running the actual test:                                 ~1100 ms

Total:                                                   ~3300 ms

`time flutter test --local-engine=host_debug --preview-dart-2`
says ~3.4 seconds...

To compare, --no-preview-dart-2 takes ~2.2 seconds,
so dart2 still has a (significantly) higher startup cost.

Moves the needle on https://github.com/flutter/flutter/issues/15767.

Change-Id: I36a2d05bc76e0193d369df42eb3b9f08416dd78f
Reviewed-on: https://dart-review.googlesource.com/51820
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-17 06:49:41 +00:00
Peter von der Ahé 4f2bdff90b Rename Program to Component
Change-Id: I1a3cc03fba9783807fa637a9d42fdbad68ee7686
Reviewed-on: https://dart-review.googlesource.com/31040
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-03-15 12:22:23 +00:00
Alexander Markov c812f6ab33 [vm, kernel] Tool for dumping kernel files with VM-specific metadata
Change-Id: I7f7b3cd797e30283821741583983dbe939e5132e
Reviewed-on: https://dart-review.googlesource.com/30960
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-01-03 17:40:04 +00:00
Konstantin Shcheglov 8751b91062 Rework DillLoader to allow adding multiple dills.
This allows us to compose a consistent bundle with SDK and the transitive
closure of required libraries for a libarary, and then compile it
separately (or as a part of its own library cycle).

There is still more data public than I'd like, but I will leave this
clean up fo later.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2872903005 .
2017-05-11 08:56:36 -07:00
Emily Fortuna 6b398ef91c Allow dartk to print out binary Kernel IR results to stdout if requested.
BUG=
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2784303003 .
2017-03-31 10:48:09 -07:00
Asger Feldthaus 8bfc4b47c0 Implement canonical name scheme in kernel.
This adds a class CanonicalName that can represent a library, class,
or member.  All references now go through a Reference object, which is
linked to both the AST node and its CanonicalName, so either can be
created first.

dartk now accepts multiple input files:
- If multiple dart files are given, they are all compiled.
- If multiple binaries are given, they are linked together.
Mixed dart and binary input is not supported by dartk.

dartk now has a flag --include-sdk which includes the entire SDK in
the output.  This is so the SDK can be compiled alone and then linked.

Example of compiling separately and then linking:
  dartk foo.dart -o foo.dill
  dartk main.dart -o main.dill
  dartk --include-sdk -o sdk.dill
  dartk main.dill foo.dill sdk.dill --target=vm --link -o program.dill

dartk still has incredibly slow cold start due to the analyzer loading
the dart sdk, so this does not actually speed things up at the moment.

BUG=
R=ahe@google.com, kmillikin@google.com, kustermann@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2665723002 .
2017-02-23 14:12:10 +01:00
Jens Johansen 3f55b8e2b7 Non-format-changing kernel offset changes
Updates to kernel that sets more offsets (and introduces end offests
and 'debuggability') - but doesn't necessarily persist them,
i.e. the format doesn't change and no C++ changes are neccessary yet.

This is step #1 in introducing these things, next step(s) will be
persisting the new stuff and using it on the C++ side.

R=asgerf@google.com, kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/5edca8c4d3733f319ab2d328aa28ceb286a30904

Reopening as I reverted the change as it broke package:compiler.

Review-Url: https://codereview.chromium.org/2610133002 .
2017-01-10 09:16:19 +01:00
Jens Johansen 5215ec6ef2 Revert "Non-format-changing kernel offset changes"
The commit breaks package:compiler.

This reverts commit 5edca8c4d3.

BUG=

Review-Url: https://codereview.chromium.org/2614663007 .
2017-01-05 14:19:23 +01:00
Jens Johansen 5edca8c4d3 Non-format-changing kernel offset changes
Updates to kernel that sets more offsets (and introduces end offests
and 'debuggability') - but doesn't necessarily persist them,
i.e. the format doesn't change and no C++ changes are neccessary yet.

This is step #1 in introducing these things, next step(s) will be
persisting the new stuff and using it on the C++ side.

R=asgerf@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2610133002 .
2017-01-05 13:25:46 +01:00
Karl Klose ff99a0ce59 Merge kernel closure conversion into the Dart SDK
This is the result of:
- taking the diff of the branch closure_conversion to master in the kernel
repository
- updating the file paths
- applying the diff to the Dart SDK
- fixing conflicts between the changes to pkg/kernel in the Dart SDK and the master branch in the kernel repository

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2561723003 .
2016-12-15 10:16:22 +01:00
Asger Feldthaus 564970c10e [kernel] Refactor frontend to allow modular compilation.
The concept of a binary library file no longer exists.

A kernel file can contain any number of libraries, and some of these
libraries can be "external".  To reference a class or member from
another build, the class or member must be declared in an external
library.

Members in an external library contain all their type information,
but have no body.

Classes in an external library have their hierarchy information
present, but are not guaranteed to contain all their actual members.

The idea is that references themselves don't really cross module
boundaries, but rather refer to a local definition whose body is
contributed from elsewhere, much like 'external' members in Dart.

A modular backend such as DDC should be able to compile from one of
these kernel files without needing to load auxiliary information from
summaries or other kernel files.

For whole program transformations or backends, a linking step, which
is not yet implemented, must merge classes and members in external
libraries based on their name.

External libraries share the same IR and binary format as ordinary
libraries.  Transformations that affect the interface for a member
or class should transform the external libraries alongside with the
internal ones, ideally without needing to treat them any different.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/516847013 .
2016-10-04 13:30:46 +02:00
Asger Feldthaus 795ce44ec7 [kernel] Refactor the frontend classes.
dartk and other command-line tools no longer rely on analyzer classes
like AnalysisContext or DartSdk, and instead use only the interface
defined in loader.dart.

The class AnalyzerLoader has been renamed to DartLoader.

The sharing of state in batch mode is now owned by loader.dart, so
dartk.dart does not deal with DartSdk and package_config.

Repository no longer has a package or SDK path. These concepts are
now specific to the Dart frontend. Consequently, loading a binary
file no longer relies on URI resolution.

The Repository class is now more clearly focused on linking symbolic
names to their IR objects, which for the time being is only
URI-to-library bindings, but should be extended to support linking
class and member references across different files and different
loaders.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/512907013 .
2016-09-23 16:11:41 +02:00
Asger Feldthaus 062cb17ec4 [kernel] Strong mode: add interface targets and resynthesis of expression types.
The interface target can now be stored on PropertyGet, PropertySet, and
MethodInvocation  If set, we know the concrete target overrides or
implements that member.

All expressions have a method getStaticType for computing its type,
which relies on interface targets for the expressions that have one.

Expressions whose type is a least upper bound have the type stored
explicitly, so the definition of least upper bounds is contained only
in the frontend.

This is a work in progress towards strong mode support, it is still
not complete.

Still missing in the frontend:
- checks from implicit downcasts
- parameter checks from covariant override or covariant generics

Implemented but not part of this CL:
- subtype tests
- IR type checker (for debugging)

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/496717014 .
2016-09-06 11:40:13 +02:00
Asger Feldthaus f3b8057f9e [kernel] Fix analyzer warnings and remove unused code.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/483967014 .
2016-08-05 11:33:58 +02:00
Asger Feldthaus 2432655e48 [kernel] Add support for batch mode in dartk.
Also forwards errors reported by the analyzer for use
in testing.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/476727013 .
2016-07-22 17:42:32 +02:00
Asger Feldthaus 10d54d7a61 [kernel] Change the default binary file extension to .dill
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/475637013 .
2016-07-19 17:52:33 +02:00
Peter von der Ahé 0e36559dd4 [kernel] Reduce dependencies on analyzer.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/445507013 .
2016-06-17 11:41:26 +02:00
Asger Feldthaus 811a47d430 [kernel] Initial implementation of Dart Kernel.
Contains:
- Command-line tool
- Kernel AST
- Binary serialization
- Printing as text
- Frontend based on analyzer
- Class hierarchy and type algebra
2016-04-26 10:39:15 +02:00