Commit Graph

47 Commits

Author SHA1 Message Date
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 709c1e0b75 Store library paths relative to a given application root folder.
In kernel, library import URIs now support an "app" scheme as an
alternative to the "file" scheme, representing a path relative to
the application root.

dartk takes an --app-root flag giving the application root. If none
is given, file URIs are used instead.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/60adb852ad706ecf9424c77d47fa05583d543def

Review URL: https://codereview.chromium.org/2532053005 .

Reverted: https://github.com/dart-lang/sdk/commit/bb540416f27c39d75ee7f243899939fc37a2cd03
2016-11-30 10:39:48 +01:00
Asger Feldthaus bb540416f2 Revert "Store library paths relative to a given application root folder."
This reverts commit 60adb852ad.

BUG=

Review URL: https://codereview.chromium.org/2539783002 .
2016-11-29 14:55:57 +01:00
Asger Feldthaus 60adb852ad Store library paths relative to a given application root folder.
In kernel, library import URIs now have the "app" scheme instead of
the "file" scheme, representing a path relative to the application root.

dartk takes an --app-root flag giving the application root. This
defaults to the current working directory.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2532053005 .
2016-11-29 12:40:17 +01:00
Asger Feldthaus 8f12489839 Add --verify-ir flag to dartk and test.py.
This replaces the old --sanity-check flag from dartk. Some files have
been renamed to avoid the wording "sanity check".

Compared to --sanity-check, the following checks have been added:
- variables are not referenced out of scope
- variables are not redeclared
- class type parameters are not referenced from static context

A unit test has been added to check that the verifier rejects certain
invalid ASTs.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2531873002 .
2016-11-28 12:21:19 +01:00
Asger Feldthaus 084bd8add2 Speed up kernel sanity checks.
Sanity checks now run in a single pass rather than two, and
instead of building a set consisting of all members, it uses
a bit from the transformer flags to remember which members are
not orphaned.

As an additional check, it now checks that members are not
declared more than once.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2529973002 .
2016-11-25 12:02:05 +01:00
Asger Feldthaus d056236180 Enable strong-mode for pkg/kernel and fix some strong-mode warnings.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2523673005 .
2016-11-23 16:16:37 +01:00
Asger Feldthaus 5d310431bd Remove closure_conversion.dart from pkg/kernel.
This file is not strong-mode clean, but since a more recent version
of closure conversion still exists in a branch on the kernel github
repo, there is not much point in fixing this version of it.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2526793002 .
2016-11-23 15:34:35 +01:00
Asger Feldthaus f28c1276ee [kernel] Bump kernel's pubspec version to 0.2.0
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2515273002 .
2016-11-21 13:08:17 +01:00
Asger Feldthaus f8b0846bc5 [kernel] Do not compile patched SDK in strong mode when using VM target.
The VM patch files are not strong mode clean, so we're using a hybrid
approach where the SDK is internally unchecked, and is trusted to
satisfy the types on its interface.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/516487014 .
2016-10-07 15:40:46 +02: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 77b7770af4 [kernel] Add sanity checks for dangling or out-of-scope references.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/509427013 .
2016-09-27 13:01:09 +02:00
Asger Feldthaus 38a3e37492 [kernel] Tree shaking transformation.
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/508267013 .
2016-09-23 18:21:35 +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 e5423f6251 [kernel] Read in -D defines and pass them on to the frontend.
This also enables configuration-specific imports when using a newer
version of the analyzer (not currently on pub).

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515727013 .
2016-09-23 12:28:33 +02:00
Asger Feldthaus 492e65b68e [kernel] Support .packages file.
BUG=https://github.com/dart-lang/kernel/issues/27
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/508267014 .
2016-09-22 14:18:18 +02:00
Martin Kustermann 99b1be4d09 [kernel] Add support for passing --url-mapping=<scheme>:<name>::<url> to dartk
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/507527013 .
2016-09-22 13:16:08 +02:00
Kevin Millikin 4e5e312534 [kernel] Context allocation, variable get, and variable set (non-loop contexts).
Allocate contexts to hold captured variables.  Rewrite captured variable
access to context access.  Outside of a local function, this is a single
indirection through a named context.  Inside a local function it requires
traversing (a statically known number of) parent links.

R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/507717013 .
2016-09-20 09:07:22 +02:00
Asger Feldthaus b02cdaccf7 [kernel] Report more errors.
Include up to 100 errors in the output, and print the number
of errors that were truncated.

Also report errors from the SDK and package files.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/506077014 .
2016-09-13 13:16:05 +02:00
Asger Feldthaus 6ed778c06c [kernel] Pass an object with flags to the target.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/501227015 .
2016-09-09 17:49:34 +02:00
Asger Feldthaus a68bf99eaa [kernel] Fix a bug in the command-line tool
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/506597013 .
2016-09-07 16:54:20 +02:00
Asger Feldthaus 0613969032 [kernel] Ensure analysis options are also set on the SDK context.
The analyzer keeps a separate AnalysisContext for the SDK, and the
options we set on our own context did not match those on the SDK,
mainly causing issues for strong mode.

Also, the BatchModeState is now used to share the Dart SDK, instead of
using a single instance held in a static variable.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504827013 .
2016-09-07 13:15:58 +02:00
Kevin Millikin a70332a6c0 [kernel] Add a target-specific list of extra libraries.
Some backend targets require extra libraries that are not used
explicitly by a program (e.g., the Dart VM requires its bootstrap
libraries).  Add a target-specific list of these libraries and ensure
that they are loaded when loading a program from Dart sources.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/495497014 .
2016-09-01 13:13:41 +02:00
Asger Feldthaus 544b9254b7 [kernel] Ignore --target if not compiling whole program.
Now that --target defaults to vm, this check does not make sense.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/497147013 .
2016-08-30 14:03:11 +02:00
Asger Feldthaus ca2aaa47b2 [kernel] Make --target default to vm.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/498687013 .
2016-08-30 11:26:05 +02:00
Asger Feldthaus 7389397bce [kernel] Disable shared batch mode state.
Sharing the AnalysisContext causes test flakiness when two test cases
share the same 'part' file.

The performance impact is actually surprisingly small.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/500717013 .
2016-08-30 11:15:52 +02:00
Asger Feldthaus 760baa3b55 [kernel] Make mixin and super resolution a transformation.
This makes super calls name-based (no target) and add direct calls with
both receiver and explicit target.

Super call resolution translates the name-based super calls into direct
calls after they have been cloned into the mixin application.

For JS backends, it should suffice to clone mixed-in methods that
contain super calls, but that transformation is not part of this CL.

This also adds a --target option to dartk designating the target to
which the kernel IR should be specialized.  The new transformation
is run when --target=vm.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/486537013 .
2016-08-24 16:46:50 +02:00
Harry Terkelsen a74bb4e438 [kernel] Some small fixes, typos, etc.
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/493937013 .
2016-08-22 09:56:05 -07:00
Martin Kustermann 4c06130804 [kernel] Add [InferredValueAttacher] transformer which will annotate fields/parameters/return values
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/488597013 .
2016-08-10 12:03:32 +02:00
Martin Kustermann 8b591e0cc5 [kernel] Ensure we wait until binary was written
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/478537014 .
2016-08-08 14:25:40 +02:00
Martin Kustermann 467352bd9a [kernel] Add batch running support for transform.dart
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/481417013 .
2016-08-08 13:49:34 +02:00
Martin Kustermann de1a935bef [kernel] Use Platform.resolvedExecutable to determine location of dart-sdk to use
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/484957013 .
2016-08-05 13:27:22 +02:00
Martin Kustermann b3f0da0f5b [kernel] Do not print transformed main library by default
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/481297013 .
2016-08-05 13:14:05 +02:00
Vyacheslav Egorov 01f1fe8252 [kernel] Various fixes to make async/await work on the VM.
- Rewrite all expressions in functions, not only expression-statements.
- Inject :await_ctx_var and :await_jump_var into the wrapper.
- Don't use transformed expression directly as part of completer.complete call.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/468717014 .
2016-08-02 12:15:21 +02:00
Martin Kustermann 55fb22d91a [kernel] Implement proof-of-concept for async/async*/sync* rewriting
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/461327013 .
2016-08-02 12:14:50 +02:00
Vyacheslav Egorov 6fc00fe8cf [kernel] Add the first version of async transformer.
This transformer is responsible for lifting subexpression into temporary variables preserved across yield points.

To maintain AST validity I introduced an expression that can contain a block of statements inside called BlockExpression.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/458577014 .
2016-08-02 12:14:50 +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 455d92f76a [kernel] Use allowTrailingOptions flag in dartk.
There was a flag for this in the args package that I somehow missed the
first time around.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/474927013 .
2016-07-20 14:57:59 +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
Martin Kustermann 1d0f534832 [kernel] Revert "Implement binary format implementation for BlockExpression"
This accidentally landed on master branch.
2016-07-08 09:22:36 +02:00
Martin Kustermann 4acb4446fd [kernel] Implement binary format implementation for BlockExpression
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/462427014 .
2016-07-08 09:18:01 +02:00
Asger Feldthaus d61e67d85a [kernel] Fix a broken parent pointer and add option in dartk to check them.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/460807013 .
2016-06-28 11:15:48 +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