Commit Graph

220 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
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 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
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 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 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 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
Asger Feldthaus 9c464d2149 [kernel] Type check untyped == calls specially.
A comparison of form x == null does not need an interface target, but
should still have a return type of 'bool'.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2466373002 .
2016-11-02 09:59:24 +01:00
Kevin Millikin 5f93106653 [kernel] Support both older and newer implementations of dart:async.
The VM target's continuation transformer uses a class that was originally
named _StreamIteratorImpl and then renamed to _StreamIterator.  If looking
up the old name fails, try the new name.

BUG=
R=jensj@google.com

Review URL: https://codereview.chromium.org/2465163004 .
2016-11-02 09:32:25 +01:00
Asger Feldthaus 37c5809ccc [kernel] Always store the type of a conditional expressions on the node.
Previously, the type of a conditional expression could be omitted if
one of the arms was just a null literal. This was meant to simplify
translation into kernel, but wasn't really worth it in terms of
complexity, and it does not work well for types that carry nullability
information.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org/2465263002 .
2016-11-01 16:04:10 +01:00
Asger Feldthaus ca5bb64dc0 [kernel] Add strong mode type checking pass.
This is a piece of the upcoming strong mode-based type propagation.
The new type propagator will build its inference graph based on the
subtyping constraints found during type checking.

This type checker is not intended to report type errors to end-users.
In its current form, it is quite redundant with the front end's type
checker, but this will not be the case once we augment kernel's type
system.

The internals of "dart:" libraries are not type checked -- they are
simply assumed to satisfy the type annotations on their interfaces.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2465893002 .
2016-11-01 15:43:31 +01:00
Kevin Millikin a6bba9520b [kernel] Remove BlockExpression from the Kernel language.
BlockExpression allowed statements to appear in an expression context.
It is unsafe for its original use case, allowing 'yield' to appear as an
expression, because the VM's yield implementation does not work when
there are live expression intermediate values.

Eliminate it by changing the async ExpressionLifter to return a
transformed expression and emit statements into a given list as a side
effect.  This requires implementing the transformation for all
statements to account for how they may contain a nested expression.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/2460373002 .
2016-11-01 14:13:30 +01:00
Asger Feldthaus 9b3e387f34 [kernel] Add convenience getter to extract the location of an AST node.
TreeNode.location is a getter for use in diagnostics and debugging.

It uses parent pointers to find the enclosing file URI and line ending
table of the node. If the node has no offset stored, it will use that
of the first enclosing parent that has an offset.

BUG=
R=ahe@google.com, jensj@google.com

Review URL: https://codereview.chromium.org/2448873004 .
2016-10-31 11:29:37 +01:00
Asger Feldthaus f764b34682 [kernel] Introduce Substitution class and Supertype class.
Type annotations in the supertype clauses of a class are now Supertypes
instead of InterfaceTypes. In the current version, the two classes
contain the same information, but they are about to diverge in the
following ways:

- An InterfaceType may be nullable, whereas a supertype cannot.

- An InterfaceType may represent the exact class, a subclass, or
  a subtype of the given class.

- The type arguments to an interface type represent bounds, whereas
  the arguments to a supertype are always exact.

We also introduce a class Substitution that represents an operator
that replaces type parameters with types, depending on the variance
of their use site.

A substitution can be applied to a DartType or a Supertype, and can
be generated independently of how it will be applied.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2439043002 .
2016-10-24 16:21:52 +02:00
Vyacheslav Egorov b33181adbd [kernel] New VM libraries renamed _StreamIteratorImpl into _StreamInterator.
R=kmillikin@google.com
BUG=

Review URL: https://chromereviews.googleplex.com/527977013 .
2016-10-24 13:19:03 +02:00
Asger Feldthaus becc43a03c [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .

Committed: https://github.com/dart-lang/kernel/commit/63c241ee69fb41710b66df106626461539ce0187
2016-10-18 12:55:10 +02:00
Asger Feldthaus d90deb1491 [kernel] Revert "Add null initializers to fields that have no initializer."
This reverts commit 63c241ee69fb41710b66df106626461539ce0187.

BUG=

Review URL: https://codereview.chromium.org/2431623002 .
2016-10-18 12:26:08 +02:00
Asger Feldthaus 8f836aef2e [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .
2016-10-18 12:14:33 +02:00