Commit Graph

53 Commits

Author SHA1 Message Date
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
Jens Johansen 41165b47e3 Fix to closure mock.dart
program.uriToLineStarts is now program.uriToSource.

BUG=
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2609183002 .
2017-01-04 12:36: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 440813c67b Check that invocations have well-formed targets in kernel verifier.
This also fixes some issues in the frontend and transformers that
generated calls without the correct number of type arguments.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2533793005 .
2016-11-30 08:24:03 +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 acc8975cab [kernel] Store named parameters in sorted lists instead of using maps.
FunctionType now has a List<NamedType> which must be sorted by name.
Previously, named parameters were stored in a Map<String, DartType>.

FunctionNode still has a List<VariableDeclaration>, but this list must
now be sorted by name.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2502343002 .
2016-11-16 15:16:24 +01:00
Asger Feldthaus 7ca4400f5b [kernel] Fix parent pointer issue in async rewriter.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2502943002 .
2016-11-15 14:27:22 +01:00
Asger Feldthaus e63a33717e [kernel] Fix some strong mode issues.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2464843002 .
2016-11-14 10:23:37 +01:00
Asger Feldthaus 35ffad846d [kernel] Erasure fix: Replace type parameters with dynamic instead of Object.
Using Object causes issues in function types.

This fixes an issue for running delta-blue in AOT strong mode.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2492453002 .
2016-11-14 10:10:49 +01:00
Kevin Millikin 8adc4a6286 [kernel] Fix a bug in the async translation of let expressions.
If the body of a let expression contains an await, the translation could
hoist statements that contain references to the let-bound variable out
of its scope.

Instead split by cases on whether the body contains an await.  If so, we
hoist let-bound variables to the statement level.  If not, we produce a
let expression.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2480743002 .
2016-11-04 14:20:12 +01:00
Asger Feldthaus 652b28f604 [kernel] Do not duplicate constructors for named mixin applications.
BUG=
R=jensj@google.com

Review URL: https://codereview.chromium.org/2473223003 .
2016-11-04 13:45:20 +01:00
Kevin Millikin fb4123b566 [kernel] Kernel: Fix a bug with await in finally.
The translation for async and async* functions translates returns into
two statements, where the second one is a return.  The VM's compilation
strategy is to inline the code for all finally blocks immediately before
a return statement.

This causes future completion/stream cancellation to occur before
finally blocks, instead of after as intended.

The solution here is to translate returns into a break from a labeled
block and put a single async/async* return sequence, outside any finally
blocks, after the labeled block.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2476513003 .
2016-11-03 10:44:24 +01:00
Kevin Millikin 5f93106653 [kernel] Support both older and newer implementations of dart:async.
The VM target's continuation transformer uses a class that was originally
named _StreamIteratorImpl and then renamed to _StreamIterator.  If looking
up the old name fails, try the new name.

BUG=
R=jensj@google.com

Review URL: https://codereview.chromium.org/2465163004 .
2016-11-02 09:32:25 +01:00
Kevin Millikin a6bba9520b [kernel] Remove BlockExpression from the Kernel language.
BlockExpression allowed statements to appear in an expression context.
It is unsafe for its original use case, allowing 'yield' to appear as an
expression, because the VM's yield implementation does not work when
there are live expression intermediate values.

Eliminate it by changing the async ExpressionLifter to return a
transformed expression and emit statements into a given list as a side
effect.  This requires implementing the transformation for all
statements to account for how they may contain a nested expression.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2460373002 .
2016-11-01 14:13:30 +01:00
Asger Feldthaus f764b34682 [kernel] Introduce Substitution class and Supertype class.
Type annotations in the supertype clauses of a class are now Supertypes
instead of InterfaceTypes. In the current version, the two classes
contain the same information, but they are about to diverge in the
following ways:

- An InterfaceType may be nullable, whereas a supertype cannot.

- An InterfaceType may represent the exact class, a subclass, or
  a subtype of the given class.

- The type arguments to an interface type represent bounds, whereas
  the arguments to a supertype are always exact.

We also introduce a class Substitution that represents an operator
that replaces type parameters with types, depending on the variance
of their use site.

A substitution can be applied to a DartType or a Supertype, and can
be generated independently of how it will be applied.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2439043002 .
2016-10-24 16:21:52 +02:00
Vyacheslav Egorov b33181adbd [kernel] New VM libraries renamed _StreamIteratorImpl into _StreamInterator.
R=kmillikin@google.com
BUG=

Review URL: https://chromereviews.googleplex.com/527977013 .
2016-10-24 13:19:03 +02:00
Jens Johansen 871a8ccfcc [kernel] Create call to noSuchMethod when super call is not correct.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/521977014 .
2016-10-14 08:18:25 +02:00
Asger Feldthaus 9b25e445ed [kernel] Follow redirecting factories to their effective targets.
Previously, we would generate a stub for a redirecting factory, but
the default parameter values were not correctly forwarded.

This could have been fixed by copying the default parameter values into
the stub, but this conflicts with modular compilation, since the
element model does not expose default parameter values, and we should
not rely on the AST of libraries not part of the current build unit.

Apart from fixing this bug, this is also more aligned with how all the
backends actually work.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/513577013 .
2016-10-07 13:34:14 +02:00
Asger Feldthaus d3fdc335a3 [kernel] Update erasure pass to erase type parameters in constants.
Strong mode allows constant expressions to reference type parameters.
This requires constants to be canonicalized at runtime, but it is not
yet determined exactly how this feature will work in future versions
of the language.

For now, we work around it by replacing such types with 'dynamic'.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/516477013 .
2016-10-06 12:58:11 +02:00
Kevin Millikin 466c43c8e0 [kernel] Only produce 'top-level' block expressions from async.
Block expressions are expressions and so can be arbitrarily nested.
They can contain statements, including yield statements.  The VM's
implementation of yield assumes that it can only occur when there are no
live intermediate values.  It is not generally safe to allow
yield-containing block expressions to appear as arbitrary
subexpressions.

As a first step toward eliminating block expressions, this change
flattens the ones produced by the async transformation so that they can
only occur as the children of statements.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/517457014 .
2016-10-06 08:15:44 +02:00
Asger Feldthaus 120c8c3998 [kernel] Erase function type parameters to fake strong mode on the VM.
The VM does not support function type parameters at the moment, but we
can erase them at the last minute, to enable testing of other parts of
strong mode.

This also disables error checking in the SDK since the VM's
patch files are not in strong mode.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/518647013 .
2016-10-04 17:28:45 +02:00
Asger Feldthaus 915854ee14 [kernel] Fix parent pointer in async rewriter.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/518607013 .
2016-09-28 11:17:09 +02:00
Asger Feldthaus 4abe5acc14 [kernel] Remove dead code from async rewriter.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/514107013 .
2016-09-27 13:26:52 +02:00
Martin Kustermann 44a70d3534 [kernel] Mixin desugaring: Clone constructors from base classes, rewrite super initializers
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/510377013 .
2016-09-27 12:19:42 +02:00
Kevin Millikin 79743bee75 [kernel] A one-pass version of the await transformation.
By transforming subexpressions from right-to-left, the transformation knows
whether an expression is possibly live across a await when the expression is
translated.

R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/508487014 .
2016-09-27 10:57:49 +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
Martin Kustermann fd809932d3 [kernel] Add new flutter target, add dart:_builtin to vm/flutter targets, adjust _getMainClosure
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/513757013 .
2016-09-22 13:17:38 +02:00
Asger Feldthaus c3bcd19da6 [kernel] Fix crashes in closure conversion.
CoreTypes should not require that dart:_internal::Context exists.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/507407013 .
2016-09-21 12:19:52 +02:00
Peter von der Ahé 4cb8fa6b49 [kernel] Return invalid declaration, not null.
R=karlklose@google.com

Review URL: https://chromereviews.googleplex.com/509807014 .
2016-09-20 11:30:45 +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 1d2bced4e8 [kernel] Allow async transformer to run on already-transformed code.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504977013 .
2016-09-09 14:51:02 +02:00
Asger Feldthaus 1316073b81 [kernel] Apply async transformation when --target=vm.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/504897014 .
2016-09-08 15:25:20 +02:00
Asger Feldthaus 54baf5bb21 [kernel] Also resolve super calls in constructor bodies.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/501087013 .
2016-09-07 16:48:45 +02:00
Asger Feldthaus 4ce54bdb64 [kernel] Decompose method invocations into getters with a call.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504757014 .
2016-09-06 16:22:05 +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 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
Vyacheslav Egorov d512d0b51e [kernel] Async rewriter: check if statements list is empty before trying to access the last statement.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/488077013 .
2016-08-16 20:57:55 +02: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
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
Martin Kustermann 9936f98a16 [kernel] Handle Let expression specially when doing await transformation
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/471207013 .
2016-08-02 12:17:12 +02:00
Martin Kustermann 86e914b8a8 [kernel] Implement support for "await for (...)"
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/463347013 .
2016-08-02 12:17:12 +02:00
Vyacheslav Egorov f26a9269d3 [kernel] Support async exceptions
Transformer lifts try/catch auxiliary variables that need to survive across
yield points into the context.

Drive by fix: we were calling asyncThenWrapper to create an :async_op_error
callback by mistake.

R=kustermann@google.com
BUG=

Review URL: https://chromereviews.googleplex.com/466247013 .
2016-08-02 12:17:07 +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 439447c41a [kernel] Add AsyncMarker.SyncCoroutine
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/464127013 .
2016-08-02 12:14:50 +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