Commit Graph

276 Commits

Author SHA1 Message Date
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
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 1628afdcf0 Add VM target with closure conversion to dartk
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2635223002 .
2017-01-17 15:58:11 +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
Paul Berry 05a417034a Initial implementation of front_end hot reload API.
This implementation is based on the existing kernel and analysis
driver logic, using proxy classes to account for interface
incompatibilities between those components.  In future CLs, I
hope we can (a) move the necessary analysis driver logic into
front_end, and (b) reduce or eliminate the number of proxy
classes needed.

This CL represents the very first inklings of functionality; all that
is confirmed to work at this point is compilation of a single source
file containing an empty `main` method.

R=danrubel@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2624193003 .
2017-01-17 06:10:02 -08: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 23cc9cca41 VM: [Kernel] Add toString() support for generated enum classes
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2625053003 .
2017-01-11 19:50:21 +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 414d66dce6 More offsets in kernel
Added offsets to more nodes.
Added end offsets to some nodes.
Added functionnode debuggability flag.

This changes the dill format.
The new offsets et al. are read on the C++ side, but not used
for anything usefull yet.

This is step #2 in introducing these things, next step(s) will be
using it on the C++ side.

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2626613002 .
2017-01-11 09:59:52 +01:00
Jens Johansen 98e96e2a29 Initialize boolean to fix checked mode error.
Vvoid 'boolean expression must not be null' error in checked mode.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2619983002 .
2017-01-10 10:41:08 +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
Jens Johansen 5edca8c4d3 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

Review-Url: https://codereview.chromium.org/2610133002 .
2017-01-05 13:25:46 +01:00
Asger Feldthaus 0546f6b4b7 Support generic method syntax in kernel pipeline.
Closes https://github.com/dart-lang/sdk/issues/28231
Closes https://github.com/dart-lang/sdk/issues/28238

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2613683003 .
2017-01-04 14:25:36 +01:00
Jens Johansen 41165b47e3 Fix to closure mock.dart
program.uriToLineStarts is now program.uriToSource.

BUG=
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2609183002 .
2017-01-04 12:36:46 +01:00
Jens Johansen aecb572d76 Include source in kernel.
- For now include source uncompressed.
- When running from kernel, use token position 0
  (i.e. dummy, but 'real' position) as start and end on functions
  and classes to enable Observatory to run with the dill file.
- Debugging does not work, but one can browse the source in
  Observatory.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2587673004 .
2017-01-03 14:33:16 +01:00
Asger Feldthaus 456f9b50b6 Allocate fewer objects in dartk frontend.
TypeAnnotationBuilder and InterfaceType were being allocated
a bit aggressively.

It makes no measurable difference on runtime, but it rules out
some of these objects as potential culprits.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2581693002 .
2016-12-15 13:44:25 +01:00
Asger Feldthaus 2e718613aa Add 'self_check' runtime for running self-checking unit tests
Some of the kernel unit tests can now be run using:

  tools/test.py -cdartk -rself_check language co19

This will search the pkg/ folder for files matching *_self_check.dart
and run each program with the compiled output as argument. If there is
no compiler, the test case itself is given as argument. These testers
are always run in batch-mode.

This type of test has no expected output, but is intended to check
itself by testing that certain invariants are not violated while
processing the given data set.

The 'self_check' runtime is not specifically tied to kernel,
although only kernel is using it at the moment.

There is also a new option --skip-compilation which skips the
compiler step.  It doesn't interact nicely with the status files,
but can still be useful for a quick offline test.

Current limitations:
- All self-check tests are treated as the same test case. If one fails,
  the remaining self-check testers don't run for that input.
- There is no way to run a subset of the self-check tests, or filter
  them based on what compiler was used.
- Tests that are expected to fail in the compiler show up as
  errors when skipping compilation.

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

Review-Url: https://codereview.chromium.org/2549793002 .
2016-12-15 13:07:03 +01:00
Karl Klose d55e9b1c80 Add file missing from previous commit
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2577013002 .
2016-12-15 10:36:45 +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
Sigmund Cherem 02d557d134 Use sdk summaries in front_end/kernel_generator.
This CL adds support for using sdk summaries when building kernel using the
front_end entrypoint. I didn't expose this functionality in the dartk binary,
I'm hoping we can delay doing so until we integrate dartk and front_end.

I also switched front_end/tool/perf.dart to use kernel_generator directly.

This makes some observable difference for small scripts, but not so much with large apps like dart2js. Makes sense considering that the sdk is about 2Mb, and dart2js is 6Mb of sources.

The most interesting number I got is building the a library kernel file (not the whole program) for a small hello-world script on a warmed up vm:
no summaries: 500ms
with summaries: 30ms

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

Review-Url: https://codereview.chromium.org/2562923002 .
2016-12-09 13:29:41 -08:00
Stephen Adams 71a344438d dart2js-kernel: associate more compound assignment inner nodes
We can now find the inner nodes (reads and binary operations) of
a[i]++, ++a[i], a[i]*=9.

R=efortuna@google.com

Review-Url: https://codereview.chromium.org/2561843002 .
2016-12-08 11:46:48 -08:00
Paul Berry ae6fd961a1 Prepare for decoupling analyzer ASTs from element model.
This CL creates top level accessor functions which may be used to map from AST data structures to their corresponding elements and types, and begins using those accessor functions throughout the SDK.  It also adds empty interfaces ResolutionTarget and ResolutionType, which are implemented by Element and DartType respectively.

In a future CL, I will change the types stored in the AST to ResolutionTarget and ResolutionType, rather than specific element types; this will decouple the ASTs from the element model.  The presence of the accessor functions will allow clients to continue accessing elements and types in a type-safe way.

R=asgerf@google.com, brianwilkerson@google.com, scheglov@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/2551023005 .
2016-12-07 11:08:14 -08:00
Sigmund Cherem f315ae1c00 dartk: remove uses of .computeNode
As a result, this changes the order in which declarations appear in the generated output. The new order is more consistent with the textual order in the original file.

Calling .computeNode() is sort of an anti-pattern for using analyzer. This was
however used very sparsely in dartk. The few places where it was used,
computeNode was practically called immediately after resolving the library
element, so I don't expect this to make almost any difference in performance.

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

Review URL: https://codereview.chromium.org/2553303002 .
2016-12-07 07:42:30 -08:00
Asger Feldthaus bb92055c47 Re-enable kernel unit tests on platforms where they are supported.
Some of them use dart:io and/or bigints so they have been disabled
on browsers and JS command-line tests.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2548833002 .
2016-12-05 11:35:41 +01:00
Asger Feldthaus 47bfb02f36 Fix a bug in kernel class hierarchy.
Abstract members would sometimes be seen at possible dispatch targets.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2542143003 .
2016-12-02 13:32:45 +01:00
Kevin Millikin bda2c1d534 Update kernel/binary.md.
Update a few things that are out of date and consistently use List for
arrays preceded by a UInt length.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2539063002 .
2016-11-30 12:26:03 +01:00
Asger Feldthaus 709c1e0b75 Store library paths relative to a given application root folder.
In kernel, library import URIs now support an "app" scheme as an
alternative to the "file" scheme, representing a path relative to
the application root.

dartk takes an --app-root flag giving the application root. If none
is given, file URIs are used instead.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/60adb852ad706ecf9424c77d47fa05583d543def

Review URL: https://codereview.chromium.org/2532053005 .

Reverted: https://github.com/dart-lang/sdk/commit/bb540416f27c39d75ee7f243899939fc37a2cd03
2016-11-30 10:39:48 +01:00
Asger Feldthaus 440813c67b Check that invocations have well-formed targets in kernel verifier.
This also fixes some issues in the frontend and transformers that
generated calls without the correct number of type arguments.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2533793005 .
2016-11-30 08:24:03 +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 bb540416f2 Revert "Store library paths relative to a given application root folder."
This reverts commit 60adb852ad.

BUG=

Review URL: https://codereview.chromium.org/2539783002 .
2016-11-29 14:55:57 +01:00
Martin Kustermann b5e0a0060b Remove dart:mojo.internal library in FlutterTarget
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2539773002 .
2016-11-29 14:41:40 +01:00
Asger Feldthaus 640061d62e Add more checks to kernel verifier.
We now check that classes and type parameters are not redeclared.

The verify_test also verifies that its test harness has no errors,
as this would make all the other tests useless.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2539743002 .
2016-11-29 13:04:43 +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 60adb852ad Store library paths relative to a given application root folder.
In kernel, library import URIs now have the "app" scheme instead of
the "file" scheme, representing a path relative to the application root.

dartk takes an --app-root flag giving the application root. This
defaults to the current working directory.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2532053005 .
2016-11-29 12:40:17 +01:00
Asger Feldthaus 0ae961f428 Document that setter expressions return their right-hand side.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2530203003 .
2016-11-28 12:27:08 +01:00
Asger Feldthaus 8f12489839 Add --verify-ir flag to dartk and test.py.
This replaces the old --sanity-check flag from dartk. Some files have
been renamed to avoid the wording "sanity check".

Compared to --sanity-check, the following checks have been added:
- variables are not referenced out of scope
- variables are not redeclared
- class type parameters are not referenced from static context

A unit test has been added to check that the verifier rejects certain
invalid ASTs.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2531873002 .
2016-11-28 12:21:19 +01:00
Stephen Adams b20b10a0af dart2js-kernel: Implement Let and PropertySet.
The Accessor builders capture some subexpressions to help map kernel
Nodes to Ast Nodes.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/2526123002 .
2016-11-26 12:42:37 -08:00
Asger Feldthaus 084bd8add2 Speed up kernel sanity checks.
Sanity checks now run in a single pass rather than two, and
instead of building a set consisting of all members, it uses
a bit from the transformer flags to remember which members are
not orphaned.

As an additional check, it now checks that members are not
declared more than once.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2529973002 .
2016-11-25 12:02:05 +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 d056236180 Enable strong-mode for pkg/kernel and fix some strong-mode warnings.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2523673005 .
2016-11-23 16:16:37 +01:00
Asger Feldthaus 5d310431bd Remove closure_conversion.dart from pkg/kernel.
This file is not strong-mode clean, but since a more recent version
of closure conversion still exists in a branch on the kernel github
repo, there is not much point in fixing this version of it.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2526793002 .
2016-11-23 15:34:35 +01:00
Asger Feldthaus f13881ac08 Fix the pubspec and warnings in pkg/kernel.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2530543002 .
2016-11-23 14:36:22 +01:00