Commit Graph

294 Commits

Author SHA1 Message Date
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 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
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
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