Commit Graph

102 Commits

Author SHA1 Message Date
Jacob Richman 997b4e62af Run formatter on a few frontend and kernel files that hadn't been formatted.
BUG=
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2820323005 .
2017-04-20 09:25:13 -07:00
Martin Kustermann d8e291cb89 [kernel] vm: Fix a few issues in the kernel flow graph builder, update status file for checked-mode
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2792033002 .
2017-04-03 19:47:01 +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
Kevin Millikin 4de94b2d7b Await cancellation in the Kernel await transformer
When an an async for loop's StreamIterator is canceled the returned
Future should be awaited.  Closes issue 29192.

BUG=https://github.com/dart-lang/sdk/issues/29192
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2782053003 .
2017-03-29 15:20:23 +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
Asger Feldthaus a3402df15c [Kernel] Remove code from the old type propagation.
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2780513004 .
2017-03-28 12:43:22 +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
Peter von der Ahé 02573b3caa Remove Fasta's copy of accessors.dart.
R=asgerf@google.com, jensj@google.com

Review-Url: https://codereview.chromium.org/2777883002 .
2017-03-27 14:04:43 +02:00
Jens Johansen a6ea038643 [kernel] offsets on direct property get/set
BUG=
R=ahe@google.com, kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/7577f6aaa052c9a1c309f13bf338b92bf4fb9fd0
Review-Url: https://codereview.chromium.org/2748333002 .
2017-03-21 14:43:45 +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
Peter von der Ahé 0d83d61601 Remove unnecessary casts.
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2752823003 .
2017-03-16 10:49:47 +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 9fa510ea38 Revert "[kernel] offsets on direct property get/set"
This commit wanted stuff from anther CL that haven't landed yet.

This reverts commit 7577f6aaa0.

BUG=

Review-Url: https://codereview.chromium.org/2751083002 .
2017-03-15 13:54:03 +01:00
Jens Johansen 7577f6aaa0 [kernel] offsets on direct property get/set
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2748333002 .
2017-03-15 13:26:45 +01:00
Dmitry Stefantsov 5526d5eeca Don't create a closure class if it already exists
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2743363007 .
2017-03-15 10:04:05 +01:00
Jens Johansen 4c38b85cb5 [kernel] set dartAsyncMarker to Sync for continuations
After 89b68e905b debugging of async
functions via kernel haven't worked.
Prior to this the dartAsyncMarker for e.g. a rewritte async function
would have been Sync, after it was Yielding.
This changes it back in the continuations rewriting cases.
An alternative fix would be to change
  function.set_is_debuggable(
      kernel_procedure->function()->dart_async_marker() == FunctionNode::kSync);

to something like
  function.set_is_debuggable(
      kernel_procedure->function()->dart_async_marker() == FunctionNode::kSync ||
      kernel_procedure->function()->dart_async_marker() == FunctionNode::kYielding);

in the C++ code.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2743283002 .
2017-03-13 14:37:03 +01:00
Jens Johansen a58fe4898d [Fasta] include source code in dill
At least for now, only when passing --include-source

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2729913005 .
2017-03-07 15:48:25 +01:00
Jens Johansen 9837563cd1 Kernel debugging; service tests
- Offsets on more stuff
- Status file for kernel
 -> Testing with (before fasta)
    ```
    python tools/test.py -mrelease -cdartk --no-tree-shake --no-dfe service
    ```
    now shows everything as passing.
    Reload stuff, and evaluation stuff (e.g.) has been disabled though.
- Lots of new service tests that tests what positions we stop at when
  saying next.

As fasta has now landed debugging does not currently work, but this is still needed in order to both test better and allow for proper kernel debugging support.

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

Review-Url: https://codereview.chromium.org/2680303002 .
2017-03-07 09:43:59 +01:00
Asger Feldthaus af10678cb3 Add source information to the covariance checks inserted for strong mode
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2718363003 .
2017-03-01 09:51:10 +01:00
Kevin Millikin f31b6d5e2c Reland "Track the 'awaiter return' call stack..."
Original CL: https://codereview.chromium.org/2692803006/

Original commit message:
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2725623003 .
2017-02-28 16:13:41 +01:00
Asger Feldthaus ccaff30f00 Fix a type error in reify/transformation/builder.dart.
A call to toList was missing after .map().

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2725623002 .
2017-02-28 13:38:10 +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
Asger Feldthaus a2e55c953d Add LibraryIndex class for finding classes and members by name.
The new class becomes a superclass of CoreTypes, which now gets its
functionality from that class, but also exposes commonly used built-in
members as fields.

This replaces a couple of ad-hoc linear searches spread throughout
the code.

The canonical names are not a convenient interface for transformers, so
the idea is that they can use LibraryIndex to address their own runtime
libraries.

To avoid name clashes and still have a somewhat convenient interface,
getters and setters are prefixed by 'get:' and 'set:' in the lookup
table (and only in the lookup table), and top-level members can be
accessed using '::' as the class name. This is the same convention
used by the VM, although it is currently not required to be the same.

R=dmitryas@google.com, karlklose@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2706243011 .
2017-02-24 14:49:12 +01: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 86d788e699 [Kernel] replace function debuggable originalAsyncMarker
Previously a functions debuggable field was set to false in the async transformation (and because it wasn't done yet, not in async* and sync* transformation, though it should have been). Now instead, set the original async status and set debuggable on the c++ side equivalently.

Also, on the c++ side, set a functions modifier to async etc if they were originally async etc.

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

Review-Url: https://codereview.chromium.org/2697193008 .
2017-02-22 12:12:54 +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
pq ce8dd9cabb Revert "Enable causal stacktrace in kernel"
This reverts commit b29829660b.

(In quest for build greenness.)

BUG=
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2697083002 .
2017-02-15 11:11:30 -08:00
Jens Johansen 0f711a9c54 [kernel] Rewrite method calls transformation
Bring in old CL (https://chromereviews.googleplex.com/485307013/)

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2688513004 .
2017-02-15 14:18:33 +01:00
Jens Johansen b29829660b Enable causal stacktrace in kernel
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2690873005 .
2017-02-15 14:17:29 +01:00
Peter von der Ahé fcb43a1fbf Use kernel transformation and VmTarget.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2691273002 .
2017-02-14 17:21:53 +01:00
Asger Feldthaus ac3e8cb7b3 Support for modular mixin resolution.
When a class from a different build unit is mixed in, the instance
members of the mixed-in class are retained in the external library
definition, so the mixin resolution pass can clone them.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2669303002 .
2017-02-13 14:20:04 +01:00
Martin Kustermann 2e4849856a VM: [Kernel] Add --embedder-entry-points-manifest to dartk/transform and pass it to the treeshaker
The VM's gen_snapshot already accepts an --embedder-entry-points-manifest option.

This CL makes dartk/transform.dart accept the same option and pass the
roots on to the treeshaker.

In addition to what gen_snapshot accepts, we also accept
"*external-instantiation*" instead of a specific constructor/factory name)

BUG=https://github.com/dart-lang/sdk/issues/28559
R=asgerf@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2668893004 .
2017-02-03 12:14:32 +01:00
Kevin Millikin 3057283f0c Split the Kernel transformations into modular and global ones
Target-specific modular transformations have to be able to cope with
external libraries.  Target-specific global transformations should be
optimizations, and not required for correctness, since a simple linker
may choose not to perform them.

Make mixin resolution modular by making it fail when a mixed-in class
comes from an external library.  (We cannot mix in such a class because
we do not necessarily have all class members.)

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2671653003 .
2017-02-02 13:08:27 +01:00
Paul Berry 7ea43baad1 Fix error "Couldn't infer type parameter" in kernel.
R=jensj@google.com

Review-Url: https://codereview.chromium.org/2666043003 .
2017-02-01 09:13:15 -08:00
Peter von der Ahé 1bafcd061f Set isSuper on accessors in no-such-method.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2532573002 .
2017-01-31 11:07:13 +01:00
Peter von der Ahé 5ff19ad4ff Allow main to be null for modular tranformation.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2612873005 .
2017-01-31 11:07:12 +01:00
Martin Kustermann 56e84a40be VM: [Kernel] Fix checked mode issues with await/async transformer
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2659393002 .
2017-01-31 11:03:10 +01:00
Asger Feldthaus e6793f76ee Improvements to the kernel tree shaker.
- Use strong-mode types for more precise tree shaking.
- Bail out nicely if dart:mirrors is used.
- Run the tree shaker in the VM target.

The initial tree-shaking pass could be combined with the type checking
pass (inserting implicit down casts) but for now they remain separate.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/71efbad90c07bece4010162b77d3b51e79b0a34d
Review-Url: https://codereview.chromium.org/2627723003 .
2017-01-20 10:52:27 +01:00
Asger Feldthaus deedd39f04 Revert "Improvements to the kernel tree shaker."
This reverts commit 71efbad90c.

BUG=

Review-Url: https://codereview.chromium.org/2644543004 .
2017-01-19 16:02:48 +01:00
Asger Feldthaus 71efbad90c Improvements to the kernel tree shaker.
- Use strong-mode types for more precise tree shaking.
- Bail out nicely if dart:mirrors is used.
- Run the tree shaker in the VM target.

The initial tree-shaking pass could be combined with the type checking
pass (inserting implicit down casts) but for now they remain separate.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2627723003 .
2017-01-19 14:00:31 +01:00
Karl Klose e88a478a7c Handle constructor bodies
Also rewrites untransformed closures (for example those in initializers) to throw an exception.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2639253003 .
2017-01-19 13:32:18 +01:00
Asger Feldthaus a0b35a6c15 Do not emit InvalidStatement in sanitize_for_vm pass
Closes 28424

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

Review-Url: https://codereview.chromium.org/2638303002 .
2017-01-18 10:31:39 +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 2fc333c93d Fix dispatch name of covariance-checked calls.
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2623333005 .
2017-01-16 12:43:38 +01:00
Martin Kustermann 673eb56471 VM: [Kernel] Fix remaining issues with kernel-based async/await implementation
This CL brings us on-par with the VM implementation in terms of tests.

  * Ensure we have saved-try-ctx/exception/stacktrace variables hoisted out for
    try-catch **and** try-finally.

  * Instead of closing the stream controller for 'async*' functions on return we
    do it inside an try-finally block so we get there in terms of normal and
    exceptional exit.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2627873002 .
2017-01-11 19:35:02 +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
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