Commit Graph

43 Commits

Author SHA1 Message Date
Peter von der Ahé 2d9956a93d Move kernel baseline tests to front_end.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2825063002 .
2017-04-19 10:57:58 +02:00
Dmitry Stefantsov cd501b2db3 Switch to Fasta in "golden" tests of closure conversion
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2808443002 .
2017-04-07 14:21:04 +02:00
Dmitry Stefantsov 42f82d1d21 Add primitive to create closures and use it for closure conversion
A new AST node 'ClosureCreation' is added. It takes a name of a
top-level function, a context, and a closure function type and creates a
closure of the given type. The effect of this closure invocation is the
same as of the invocation of the given top-level function with the
contexts as the first argument.

In order to use 'ClosureCreation', the closure conversion pass now
transforms closures into top-level functions, not closure classes. These
functions receive the context as the first argument.

The type of the expression represented by 'ClosureCreation' is its third
parameter. It its the responsibility of closure conversion pass to
create the correct types for 'ClosureCreation' nodes based on types of
closures transformed into top-level functions.

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2778223002 .
2017-03-31 14:43:56 +02:00
Asger Feldthaus f396d919ae Remove some additional code that depended on the old type propagation.
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2781473004 .
2017-03-28 13:51:21 +02:00
Dmitry Stefantsov 9ab86da19c Add Vector type to Kernel
There are four operations that work on Vectors: Vector creation, looking
up an item in a Vector, assigning a value to an item in a Vector, and
copying a Vector. The first three operations are allowed to only use
integer literals as number operands (length for Vector creation, index
for item lookup and assignment). Corresponding AST nodes are created for
these operations.

Vectors are used to represent contexts in Closure Conversion. The parent
context is stored as item 0 in its children contexts. The "golden" tests
for this transformation are adjusted accordingly.

The support for Vectors is added to ast-to-text, ast-to-binary, and
binary-to-ast transformations.

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

Review-Url: https://codereview.chromium.org/2767773004 .
2017-03-27 15:52:32 +02:00
Jacob Richman 28c43eaeab Fix kernel test case format error.
BUG=
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2766963002 .
2017-03-22 08:32:36 -07:00
Martin Kustermann ad7d04f76a Regenerate kernel strong-mode baseline files
Review-Url: https://codereview.chromium.org/2769573004 .
2017-03-22 08:58:19 +01:00
Jacob Richman d1fa3c67af Run dartfmt on kernel package
BUG=
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2747113004 .
2017-03-17 08:21:52 -07:00
Dmitry Stefantsov 1ec9c97924 Srong-mode tests for generic methods
(`tests/language_strong/generic_methods_*`) are reused as 'golden' tests
for 'reify' transformation.

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2756693002 .
2017-03-17 12:51:35 +01:00
Dmitry Stefantsov b87a479c2b Pass type arguments as a list in generic methods invocations
All generic methods are equipped with one extra named parameter for
passing type arguments as a list of type values.

Additinally, this change forces strong mode usage for 'dartk' in
'reified_dart'. Strong mode is required for loader to not strip away
type arguments from generic methods. In future, a command line argument
may be implemented for that (e.g. --generic-methods), if generic method
support will land before the strong mode.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2713163002 .
2017-03-16 10:47:11 +01:00
Jens Johansen 067b377a3c Mark new debugging stuff as flaky as it fails on mac/win/whatnot
BUG=

Review-Url: https://codereview.chromium.org/2732973006 .
2017-03-07 10:34:52 +01:00
Martin Kustermann bd59a9724e Regenerate baseline files for kernel/test/baseline_strong_mode_test
Review-Url: https://codereview.chromium.org/2731483002 .
2017-03-02 11:06:43 +01:00
Karl Klose 5df5395559 closure conversion: Do not set Context.parent if the value is null
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2716573002 .
2017-02-28 11:23:00 +01:00
Karl Klose 5a42bf8062 Support closures in initializers
Moved the code to modify the current block with context updates to its own class and added another class for context updates in initializer expressions.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2712473003 .
2017-02-28 11:16:41 +01:00
Karl Klose f12f5bcb15 Add multitest markers to reify test
TBR=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2696283006 .
2017-02-17 14:51:33 +01:00
Dmitry Stefantsov d5e2fcb430 Merge the work on Generic Types Reification from 'dart-lang/reify' repo
This CL adds the work done at https://github.com/dart-lang/reify to SDK.
The commit that is used for the merge is
a2066a68374d49de92ff75f5e1ffc36335fd9451 (Nov 23, 2016). The code is
adjusted to respect the changes of the kernel package in SDK since that
commit.

The reify transformation is run by specifying 'vmreify' target to
'dartk'. The transformation requires its runtime library to present in
the program being transformed. The library is found in its default
location in SDK checkout if 'dartk' is run from its default location in
SDK checkout. To preserve the library in the output, TreeShaker is
disabled in 'vmreify' target.

The "golden" set of tests is also copied from 'dart-lang/reify'
repository, and the appropriate test suite is defined for it.

The bash script 'bin/reified_dart' from 'dart-lang/reify' is rewritten
as Dart script 'pkg/kernel/bin/reified_dart.dart'. It requires path to
'dartk' and path to SDK. Those are taken from their default locations in
SDK if 'reified_dart.dart' is run from its default location in SDK.

The added files were formatted using 'dartfmt' with default settings.
Additionally, the files were checked with 'dartanalyzer --strong'. The
necessary changes were made to fix the error messages. There are some
'hint' and 'error' messages left for some .dart files from the added
test cases, but they reflect intentional errors or conventions in those
files.

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

Review-Url: https://codereview.chromium.org/2697873007 .
2017-02-17 14:19:29 +01:00
Martin Kustermann f99d3c9192 Mark kernel test as slow, regenerate baseline file
Review-Url: https://codereview.chromium.org/2682653002 .
2017-02-07 11:16:24 +01:00
Asger Feldthaus b07ab608e9 Run tree shaking in strong-mode baseline tests.
This test now asserts that the string literal "unused" does not occur
in the output in addition to checking the expected output.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2645733004 .
2017-01-23 10:38:53 +01:00
Karl Klose 8c6a174091 Use List::filled instead of List:: in closure conversion
The redirecting factory List:: is currently removed and replaced with the actual target at the callsites during construction of kernel, but referencing the actual target here would make the transformation platform specific.

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2637083002 .
2017-01-17 15:17:11 +01:00
Asger Feldthaus 70a4d169c0 Insert covariance checks in strong mode.
"Covariance checks" are checks on certain parameters, necessary due to
the unsafe covariant subtyping rule for interface types.

The new pass generates a checked entry point for each method with
covariance checks. This entry point checks the parameters whose type
cannot be trusted, and then calls the actual method implementation.

Every typed call is then redirected to the checked entry point if the
interface taget declares any parameters with unsafe types, unless the
receiver is 'this'.

Dynamic calls and covariant overrides are not addressed by this CL,
these are still unchecked.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2618393002 .
2017-01-11 16:33:04 +01:00
Asger Feldthaus 8dd2b15951 Insert implicit downcasts in kernel strong mode.
This is implemented as a separate pass, although going forward
I would like the new frontend to insert these checks.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2619193003 .
2017-01-11 13:47:40 +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 ddc6af7556 Update kernel testcase baseline.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2541523002 .
2016-11-30 08:18:55 +01:00
Asger Feldthaus 5d26d67342 Revert "Update kernel baseline tests."
This reverts commit b771d61499.

BUG=

Review URL: https://codereview.chromium.org/2540713002 .
2016-11-29 15:01:09 +01:00
Asger Feldthaus b771d61499 Update kernel baseline tests.
These tests are currently disabled on the buildbots, but we should
keep them up-to-date so we can re-enable them soon.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2533773004 .
2016-11-29 12:58:31 +01:00
Asger Feldthaus 963e1ebc55 Do not sort named parameters on FunctionNode.
This was originally done to be consistent with FunctionType,
where the named parameters are sorted, but for FunctionNode
it is not necessary.

It causes issues for natives that expect parameters to be
declared in a certain order. It is also an issue if we
ever want to reuse the kernel format for summaries, where
it is also preferable to present the named parameters in
their original order.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2527933002 .
2016-11-25 11:22:37 +01:00
Asger Feldthaus 58019fa42a [kernel] Fix some issues after introducing NamedType.
Some code in type_checker.dart had not been updated and there
was an unused method left in type_algebra.dart.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2504313002 .
2016-11-16 17:09:48 +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 f6c3ebe4ee [kernel] Fix a bug in printing of string literals with escape sequences.
BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2500453002 .
2016-11-11 12:22:29 +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
Asger Feldthaus 50d99ee64c [kernel] Fix expected return type in async functions.
Also add support for yield* in the type checker.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2473523004 .
2016-11-03 15:08:57 +01:00
Asger Feldthaus 9c464d2149 [kernel] Type check untyped == calls specially.
A comparison of form x == null does not need an interface target, but
should still have a return type of 'bool'.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2466373002 .
2016-11-02 09:59:24 +01:00
Asger Feldthaus 37c5809ccc [kernel] Always store the type of a conditional expressions on the node.
Previously, the type of a conditional expression could be omitted if
one of the arms was just a null literal. This was meant to simplify
translation into kernel, but wasn't really worth it in terms of
complexity, and it does not work well for types that carry nullability
information.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2465263002 .
2016-11-01 16:04:10 +01:00
Asger Feldthaus ca5bb64dc0 [kernel] Add strong mode type checking pass.
This is a piece of the upcoming strong mode-based type propagation.
The new type propagator will build its inference graph based on the
subtyping constraints found during type checking.

This type checker is not intended to report type errors to end-users.
In its current form, it is quite redundant with the front end's type
checker, but this will not be the case once we augment kernel's type
system.

The internals of "dart:" libraries are not type checked -- they are
simply assumed to satisfy the type annotations on their interfaces.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2465893002 .
2016-11-01 15:43:31 +01: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 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 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 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
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 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