Commit Graph

200 Commits

Author SHA1 Message Date
Asger Feldthaus bf2df5877e [kernel] Remove obsolete part of readme
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2441603002 .
2016-10-20 13:12:41 +02:00
Asger Feldthaus becc43a03c [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .

Committed: https://github.com/dart-lang/kernel/commit/63c241ee69fb41710b66df106626461539ce0187
2016-10-18 12:55:10 +02:00
Asger Feldthaus d90deb1491 [kernel] Revert "Add null initializers to fields that have no initializer."
This reverts commit 63c241ee69fb41710b66df106626461539ce0187.

BUG=

Review URL: https://codereview.chromium.org/2431623002 .
2016-10-18 12:26:08 +02:00
Asger Feldthaus 8f836aef2e [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .
2016-10-18 12:14:33 +02:00
Peter von der Ahé 8a6629eb5e [kernel] Use public review server.
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2428593002 .
2016-10-18 11:37:37 +02:00
Jens Johansen 1048f55a29 [kernel] Don't emit InvalidExpression on invalid super in binaryexpression
Don't emit invalidexpression on invalid super call --- a correct call will be created later

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/524077013 .
2016-10-14 13:49:51 +02:00
Asger Feldthaus 0b72c538cc [kernel] Update doc comment for TypeParameter.bound.
BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/526987013 .
2016-10-14 13:29:36 +02:00
Peter von der Ahé a61ac3cc41 [kernel] Use Sink<List<int>> instead of IOSink.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/521257013 .
2016-10-14 12:16:13 +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 cb80b352e2 [kernel] Fix a bug in bounded type substitution.
When visiting a generic function type in contravariant context, the
current variance bit would not be propagated to the inner visitor.

For example,

  (<F>(T,F) => F) => int [bottom <: T <: String]

would erroneously map to:

  (<F>(bottom,F) => F) => int

instead of:

  (<F>(String,F) => F) => int

Generic function types cannot occur in contravariant position
using current Dart syntax, but it could possibly occur as an
intermediate type.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/521207013 .
2016-10-13 16:20:33 +02:00
Asger Feldthaus 5f31eff8bd [kernel] Type parameter bounds default to Object instead of dynamic.
This also affects the textual output in most cases, since the bound
is now shown explicitly.

BUG=
R=jensj@google.com

Review URL: https://chromereviews.googleplex.com/526827013 .
2016-10-11 15:21:48 +02:00
Asger Feldthaus b0bfbadbc3 [kernel] Support interface members and overrides with duplicate member names.
When a class inherits two abstract members with the same name from
different supertypes, both members are now present the list returned
by ClassHierarchy.getInterfaceMembers. Previously, only one of the
member would be present.

This ensures that all override pairs can be detected, which in turn
is necessary for inserting covariance checks in strong mode.

Another change in this CL is that interface members are built
eagerly instead of on-demand. This makes the ClassHierarchy more
reliable when used for transformation, and easier to benchmark.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/520907013 .
2016-10-10 11:15:56 +02: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 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 49d4e3a789 [kernel] Update baselines according to change in text printer.
BUG=

Review URL: https://chromereviews.googleplex.com/518067013 .
2016-10-06 15:47:24 +02:00
Asger Feldthaus ad049ce479 [kernel] Ignore fields inserted through error recovery.
Fields without names often arise when the analyzer fails to parse a
union type in a type argument inside a comment. For example:
  Future/*<Foo|Bar>*/ future;

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/519077015 .
2016-10-06 12:59:52 +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 ea2ddd0882 [kernel] Fix canonicalization of mixin classes.
A mixin application C<T1 ... Tm> with D<T1 ... Tn> is canonicalized if
the Ts are distinct, unbound type variables. In all other cases, a new
class is created per mixin application.

Previously, all mixin applications were canonicalized in an overly
general way, causing type checking issues, and excessive duplication of
type parameters.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/511567015 .
2016-10-04 17:45:24 +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 b56d061411 [kernel] Fix the comment on Library.isExternal.
The comment was the result of a bad merge.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/517957015 .
2016-10-04 17:26:10 +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 91febfc627 [kernel] Insert break or throw at the end of a switch case that may fall through.
BUG=https://github.com/dart-lang/kernel/issues/12
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/510567013 .
2016-09-30 12:25:07 +02:00
Jens Johansen 43b8443f0d [kernel] Dill source file and source position inclusion
For now the focus is on getting stacktraces to look right.
What that basically means is to include source positions for throws,
calls (in many forms).

Includes source file uri for libraries, field, classes and methods.
Methods and fields for instance needs it because of top-level
procedures that might be included via 'parts'.

Corresponding kernel-sdk change in review at
https://chromereviews.googleplex.com/516617014

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

Review URL: https://chromereviews.googleplex.com/509247013 .
2016-09-29 11:26:40 +02:00
Asger Feldthaus fe5a26f264 [kernel] Treat an arrow body in a void method as void context.
BUG=https://github.com/dart-lang/kernel/issues/31
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/511307014 .
2016-09-29 11:08:28 +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
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
Martin Kustermann 3afc1542e6 [kernel] Add dart:vmservice_io to the libraries to include in the VM target
(The flutter target already includes dart:vmservice_sky.)

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/512147013 .
2016-09-27 12:20:16 +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
Asger Feldthaus 5d42d2de01 [kernel] Update analyzer and test dependency.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/512047013 .
2016-09-23 17:56:22 +02:00
Asger Feldthaus 6fec4ee7a5 [kernel] Fix a bug in DartOptions.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515767013 .
2016-09-23 17:51:00 +02:00
Asger Feldthaus cd60bb203f [kernel] Ensure class type parameters are not referenced from static context.
BUG=https://github.com/dart-lang/kernel/issues/16
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/510207013 .
2016-09-23 16:33:12 +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 4edef131a9 [kernel] Add subtyping query.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/515667013 .
2016-09-23 16:05:28 +02:00
Asger Feldthaus a91cae8bb4 [kernel] Remove the ?? operator from the IR and desugar it in the frontend.
Note that this affects the binary format, since a type is no longer
stored on LogicalExpression.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502297014 .
2016-09-23 12:52:00 +02:00
Asger Feldthaus e3dac4b11c [kernel] Support both implicit and explicit getters and setters for fields.
Fields getters and setters should be implicit whenever possible
to ensure JS compilers can easily control how they are generated.

However, it is still useful to be able to take control of the getter
or setter in the IR.  We should just refrain from doing so for common
cases, where it can have significant code size impact in JS.

We can use this to insert checked setters for fields that override
a setter with an incompatible type, or whose type references a type
variable.

There are two changes to facilitate this:

- Fields have two flags indicating if the implicit getter and/or
  setter should be generated.  If not set, there can be an explicit
  getter/setter for it in the same class.

- Interface targets that reference a field now go through one
  level of indirection. This lets us update interface targets in
  the IR, which is necessary for redirecting calls to an explicit
  getter or setter.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504357013 .
2016-09-23 12:34:06 +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 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
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
Martin Kustermann a4a3ad3961 [kernel] Use InvalidInitializer() for initializers with compile-time errors
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/508347013 .
2016-09-22 13:05:16 +02:00
Asger Feldthaus c323d3608a [kernel] Set constructor body to an empty statement if its body was omitted.
BUG=https://github.com/dart-lang/kernel/issues/28
R=johnniwinther@google.com

Review URL: https://chromereviews.googleplex.com/512727013 .
2016-09-22 12:15:42 +02:00
Asger Feldthaus 700db55970 [kernel] Minor fixes to the AST printer.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/514717014 .
2016-09-21 19:03:52 +02:00
Asger Feldthaus 4b860db14b [kernel] Reorganize baseline testing.
A single suite of test files is now shared among these configurations,
each with their own expected outputs:
- spec mode
- strong mode
- spec mode w/ type propagation

Although some tests are going to focus on a specific configuration,
for now it seems easier to maintain a single set of tests.

No additional tests have been added in this CL, but the intention
is to start adding more tests.

The baseline tests no longer contain any checked-in dill files.

To simplify dependencies, these tests do not rely on a patched SDK,
which means the async transformer cannot currently be tested with
this framework.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/507347013 .
2016-09-21 12:23:11 +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
Jens Johansen c6d1d01738 [kernel] Fix of saving expression in function body.
Creating a redirecting factory constructor to an abstract class
creates a throw expression directly in function.body.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/506587013 .
2016-09-21 08:26:35 +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