Commit Graph

309 Commits

Author SHA1 Message Date
Kevin Millikin d562f7ced5 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

BUG=
R=asgerf@google.com, jensj@google.com, vegorov@google.com

Committed: https://github.com/dart-lang/sdk/commit/ed77783cd32d55fdad61bf9bc749030847ba9384
Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-30 09:31:31 +02:00
Zach Anderson a7d1d99389 Revert "Remove definitions from Kernel canonical names."
This reverts commit ed77783cd3.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2782913003 .
2017-03-29 11:25:17 -07:00
Kevin Millikin ed77783cd3 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

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

Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-29 16:03:03 +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
Zhivka Gucevska 1851ca685e Change layout of fields in a object values
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2781453002 .
2017-03-28 11:19:16 +02:00
Zhivka Gucevska 23cc114c2f Implements simple statement executer
This change adds support for executing:
 - BlockStatement
 - ExpressionStatement
 - IfStatement
 - VariableDeclaration

Currently only BlockStatement introduces a new environment and
VariableDeclaration modifies the environment.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2775293002 .
2017-03-28 10:23:15 +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
Zhivka Gucevska 02251a05eb Add support for implicit getters and setters
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2764073002 .
2017-03-24 16:04:02 +01: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
Zhivka Gucevska 80a334512a Add representation for object values
It also adds few operators for the Basic literals for testing purposes.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2764823002 .
2017-03-21 13:17:33 +01:00
Jens Johansen a1a34a1c84 [kernel] Debugging of switch statement
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2750013002 .
2017-03-21 11:36:48 +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
Paul Berry 685045d619 Start unraveling circularities between analyzer and front_end/kernel.
This CL moves many of the files from
pkg/front_end/lib/src/fasta/analyzer/ to pkg/analyzer/lib/src/fasta/.
It also moves two files from pkg/kernel/lib/analyzer/ to
pkg/analyzer/lib/src/kernel/.

This reduces the amount of circularity between analyzer and
front_end/kernel so that there are no files in front_end or kernel
which are both dependend upon by analyzer and depend upon analyzer.  I
will clean up the remaining circularities in future CLs.

There should be no functional change.

R=ahe@google.com, asgerf@google.com, kmillikin@google.com, scheglov@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2756593004 .
2017-03-17 05:56:06 -07:00
Zhivka Gucevska 3f141d638f Implement visitor with 1 argument for Statements
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2740273003 .
2017-03-16 11:11:04 +01: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
Jens Johansen 5e1ba94af4 [kernel] debugging for in statement
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2747813003 .
2017-03-15 13:22:58 +01:00
Zhivka Gucevska bd3cfd6979 Implements support for variables and evaluation of logic expressions
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2740433006 .
2017-03-15 12:50:16 +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
Peter von der Ahé 4f6d58fc50 Implement nested switches and missing switch continue targets.
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2746923002 .
2017-03-13 13:52:39 +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
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