Commit Graph

782 Commits

Author SHA1 Message Date
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
Zhivka Gucevska 1b82e0c3a0 Initial implementation of interpreter for Kernel
Basic framework, evaluation of BasicLiterals and dummy evaluation
of print.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2722283003 .
2017-03-02 13:19:27 +01:00
Jens Johansen 89b68e905b Set dartAsyncMarker the same as asyncMarker unless explicitly set
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2728683005 .
2017-03-02 11:13:38 +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
Asger Feldthaus 2f331ecd1b Fix two issues with modular compilation in dartk.
- The interface for a factory constructor in an external library would
  reference the class type parameters instead of its own.

- When a class from an external library gets promoted to mixin level,
  the rest of the library should not be considered "being loaded".
  This would cause members to not get added to the AST.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2710783004 .
2017-02-23 12:38:20 +01:00
Jens Johansen 48d057bdc3 Fix ast_to_text output to pass tests.
Previous commit (86d788e699) broke kernel tests.

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2701313006 .
2017-02-22 12:51:29 +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
Peter von der Ahé d32f47b293 Implement line and column numbers.
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2704753002 .
2017-02-20 10:04:12 +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 fd6018d2ab Add IR nodes needed for deferred loading.
BUG=
R=sra@google.com

Review-Url: https://codereview.chromium.org/2659343002 .
2017-02-13 14:31:24 +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
Peter von der Ahé ee7a3e1e24 Ensure locations are always provided, but don't store them yet.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2691523002 .
2017-02-13 12:30:21 +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
Asger Feldthaus 14c6b27533 Put tree-shaking behind a flag in dartk.
BUG=
R=jensj@google.com

Review-Url: https://codereview.chromium.org/2669783002 .
2017-02-02 15:10:10 +01:00
Asger Feldthaus a2cad3f500 Change type interface target of SuperMethodInvocation to Procedure
BUG=
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2650823005 .
2017-02-02 13:40:29 +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
Martin Kustermann e2eef7bfce Kernel: Do not try to use return value of []=
Fixes #28302

R=ahe@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2668893003 .
2017-02-01 17:47:16 +01:00
Peter von der Ahé 1be77216f1 Report problems through a method.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2620133004 .
2017-01-31 11:07:13 +01: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é bd9d33736d Restore verifier flags after failed verification.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2614143003 .
2017-01-31 11:07:13 +01:00
Peter von der Ahé 3d4ae561f8 Print <Null> instead of crashing.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2617973002 .
2017-01-31 11:07:13 +01:00
Peter von der Ahé 54062a9210 Preserve isConst when cloning.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2616703006 .
2017-01-31 11:07:13 +01:00
Peter von der Ahé eecf30e48d Make DirectMethodInvocation a subclass of InvocationExpression.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2615193003 .
2017-01-31 11:07:12 +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
Peter von der Ahé caa67601ba Print 'await' when for is async.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2527253002 .
2017-01-31 11:07:12 +01:00
Peter von der Ahé f1a306f331 Option to include redirecting factories.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2617963002 .
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
Peter von der Ahé 750d77d96b Only tree-shake if there's a main program.
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2664033003 .
2017-01-31 10:34:26 +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 76442f9394 Fix language/bad_constructor_test in dartk and analyzer.
The test was incorrect because it did not declare that a static warning
was to be expected due to an unresolved reference to 'q'. The unresolved
reference has been removed as it has nothing to do with what it is
supposed to test.

The analyzer was incorrect in that a setter was reported to clash with
a constructor of the same name, but this failure was hidden by the
above issue. This has been fixed.

dartk inherited the issue (and its fix) from the analyzer, but some
additional error handling was needed in dartk to avoid crashing.

Closes https://github.com/dart-lang/sdk/issues/11576

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

Review-Url: https://codereview.chromium.org/2643693002 .
2017-01-19 13:10:32 +01:00
Asger Feldthaus d4dfb3088e Fix some crashes in dartk.
Dartk should no longer crash in these cases:
- main method is provided through an export
- main method is missing
- initializing formal parameter is unresolved
- the loadLibrary function is torn off

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

Committed: https://github.com/dart-lang/sdk/commit/d01bd88152b2d30d6a06d1379e41e1280d094dab
Committed: https://github.com/dart-lang/sdk/commit/979072821d1113248e285f7926663eb00d8a8206
Review-Url: https://codereview.chromium.org/2641523002 .
2017-01-19 12:12:36 +01:00
Asger Feldthaus be9088060d Revert "Fix some crashes in dartk."
This reverts 979072821d

BUG=

Review-Url: https://codereview.chromium.org/2638353003 .
2017-01-18 20:52:13 +01:00
Asger Feldthaus 979072821d Fix some crashes in dartk.
Dartk should no longer crash in these cases:
- main method is provided through an export
- main method is missing
- initializing formal parameter is unresolved
- the loadLibrary function is torn off

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

Committed: https://github.com/dart-lang/sdk/commit/d01bd88152b2d30d6a06d1379e41e1280d094dab
Review-Url: https://codereview.chromium.org/2641523002 .
2017-01-18 16:44:45 +01:00
Asger Feldthaus 6272e23d35 Revert "Fix some crashes in dartk."
This reverts commit d01bd88152.

Some status file updates were missing for precompiled mode.

BUG=

Review-Url: https://codereview.chromium.org/2644513002 .
2017-01-18 12:21:43 +01:00
Martin Kustermann e97bcc5475 VM: [Kernel] Partial support for metadata annotations
The CL adds metadata support for Fields/Classes/Functions/Constructors. There
are other places where annotations can be put in the Dart language but the
Kernel IR currently does not store it in the AST.

Whenever a element (e.g. a function) gets annotated, the VM will make a [Field] for this
element whos value is an array of evaluated constant metadata annotations.

This CL attaches to these [Fields] a `kernel_function` which is then used to do the constant
evaluation.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2632253002 .
2017-01-18 10:51:24 +01:00
Asger Feldthaus d01bd88152 Fix some crashes in dartk.
Dartk should no longer crash in these cases:
- main method is provided through an export
- main method is missing
- initializing formal parameter is unresolved
- the loadLibrary function is torn off

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

Review-Url: https://codereview.chromium.org/2641523002 .
2017-01-18 10:39:10 +01:00