Commit Graph

259 Commits

Author SHA1 Message Date
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
Asger Feldthaus ac21874a21 Disable kernel unit tests.
They are causing issues on dartium and dart2js_jsshell.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2528623002 .
2016-11-23 14:12:54 +01:00
Asger Feldthaus 2eb09d26e3 [kernel] Update and disable some kernel unit tests.
This is in preparation of merging into the SDK repository.
2016-11-23 12:14:59 +01:00
Asger Feldthaus f28c1276ee [kernel] Bump kernel's pubspec version to 0.2.0
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2515273002 .
2016-11-21 13:08:17 +01:00
Asger Feldthaus c62d774c2f [kernel] Upgrade analyzer version to 0.29.0
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2517113002 .
2016-11-21 10:24:29 +01:00
Asger Feldthaus 58019fa42a [kernel] Fix some issues after introducing NamedType.
Some code in type_checker.dart had not been updated and there
was an unused method left in type_algebra.dart.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2504313002 .
2016-11-16 17:09:48 +01:00
Asger Feldthaus acc8975cab [kernel] Store named parameters in sorted lists instead of using maps.
FunctionType now has a List<NamedType> which must be sorted by name.
Previously, named parameters were stored in a Map<String, DartType>.

FunctionNode still has a List<VariableDeclaration>, but this list must
now be sorted by name.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2502343002 .
2016-11-16 15:16:24 +01:00
Asger Feldthaus df36c0b63e [kernel] Remove unnecessary indexing passes from serialization.
Computing the index for variables, labels, and switch cases is now
done on-the-fly instead of as separate passes.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2507723002 .
2016-11-16 15:13:27 +01:00
Asger Feldthaus 7ca4400f5b [kernel] Fix parent pointer issue in async rewriter.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2502943002 .
2016-11-15 14:27:22 +01:00
Asger Feldthaus e63a33717e [kernel] Fix some strong mode issues.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2464843002 .
2016-11-14 10:23:37 +01:00
Asger Feldthaus 35ffad846d [kernel] Erasure fix: Replace type parameters with dynamic instead of Object.
Using Object causes issues in function types.

This fixes an issue for running delta-blue in AOT strong mode.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2492453002 .
2016-11-14 10:10:49 +01:00
Asger Feldthaus f6c3ebe4ee [kernel] Fix a bug in printing of string literals with escape sequences.
BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2500453002 .
2016-11-11 12:22:29 +01:00
Jens Johansen 18baf4394c [kernel] Fixed crash when compiling without linking.
Since offsets and uris was added to the dill file, compiling to dill
without linking hasn't worked because of external libraries.

The external libraries doesn't add to the line starts table and thus
the uris from libraries, classes and so on isn't recorded.

When trying to write an unrecorded uri to the dill file it fails.

The simple solution applied here is to fall-back to the empty
string when the uri hasn't been recorded.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2483243002 .
2016-11-08 14:54:15 +01:00
Kevin Millikin 8adc4a6286 [kernel] Fix a bug in the async translation of let expressions.
If the body of a let expression contains an await, the translation could
hoist statements that contain references to the let-bound variable out
of its scope.

Instead split by cases on whether the body contains an await.  If so, we
hoist let-bound variables to the statement level.  If not, we produce a
let expression.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2480743002 .
2016-11-04 14:20:12 +01:00
Asger Feldthaus 652b28f604 [kernel] Do not duplicate constructors for named mixin applications.
BUG=
R=jensj@google.com

Review URL: https://codereview.chromium.org/2473223003 .
2016-11-04 13:45:20 +01:00
Asger Feldthaus 7607618633 [kernel] Ensure the substitution map in the CloneVisitor is mutable.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2477873002 .
2016-11-04 10:44:37 +01:00
Asger Feldthaus 50d99ee64c [kernel] Fix expected return type in async functions.
Also add support for yield* in the type checker.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2473523004 .
2016-11-03 15:08:57 +01:00
Kevin Millikin fb4123b566 [kernel] Kernel: Fix a bug with await in finally.
The translation for async and async* functions translates returns into
two statements, where the second one is a return.  The VM's compilation
strategy is to inline the code for all finally blocks immediately before
a return statement.

This causes future completion/stream cancellation to occur before
finally blocks, instead of after as intended.

The solution here is to translate returns into a break from a labeled
block and put a single async/async* return sequence, outside any finally
blocks, after the labeled block.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2476513003 .
2016-11-03 10:44:24 +01:00