Commit Graph

931 Commits

Author SHA1 Message Date
Asger Feldthaus a68bf99eaa [kernel] Fix a bug in the command-line tool
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/506597013 .
2016-09-07 16:54:20 +02:00
Asger Feldthaus 54baf5bb21 [kernel] Also resolve super calls in constructor bodies.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/501087013 .
2016-09-07 16:48:45 +02:00
Kevin Millikin 3e8056d8b9 [kernel] Include the library dart:mirrors for target=vm.
Bootstrapping the VM does require dart:mirrors in some modes, and it
will be ignored in the Kernel binary if it is not required by the VM, so
always include it.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/505697013 .
2016-09-07 16:37:32 +02:00
Asger Feldthaus 60d24a5491 [kernel] Include interface targets in the textual output.
Calls are now printed as follows:

Dynamic calls: receiver.name
Interface calls: receiver.{target}
Direct calls: receiver.{=target}
Dynamic super calls: super.name
Super interfaces calls: super.{target}

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502957013 .
2016-09-07 14:45:34 +02:00
Asger Feldthaus e7a10f9424 [kernel] Put the interface target on implied .call invocations.
Example from js_ast:

  class JsBuilder {
  	Node call(x) => ...
  }
  const JsBuilder js = const JsBuilder();

In codegen:
  js("#.#", ...)

Translated to kernel:
  js.call("#.#", ...) // JsBuilder::call as interface target

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502947013 .
2016-09-07 13:37:25 +02:00
Asger Feldthaus 0613969032 [kernel] Ensure analysis options are also set on the SDK context.
The analyzer keeps a separate AnalysisContext for the SDK, and the
options we set on our own context did not match those on the SDK,
mainly causing issues for strong mode.

Also, the BatchModeState is now used to share the Dart SDK, instead of
using a single instance held in a static variable.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504827013 .
2016-09-07 13:15:58 +02:00
Peter von der Ahé 2aa32c7c54 [kernel] Allow null in super accesses.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/502937013 .
2016-09-07 11:40:20 +02:00
Asger Feldthaus bb6e93480a [kernel] Copy strong-mode fields in clone visitor.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504777014 .
2016-09-06 18:41:31 +02:00
Asger Feldthaus 4ce54bdb64 [kernel] Decompose method invocations into getters with a call.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504757014 .
2016-09-06 16:22:05 +02:00
Asger Feldthaus de323e90bd [kernel] Fix interface target for postfix increment in void context.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/496557013 .
2016-09-06 13:43:28 +02:00
Asger Feldthaus 062cb17ec4 [kernel] Strong mode: add interface targets and resynthesis of expression types.
The interface target can now be stored on PropertyGet, PropertySet, and
MethodInvocation  If set, we know the concrete target overrides or
implements that member.

All expressions have a method getStaticType for computing its type,
which relies on interface targets for the expressions that have one.

Expressions whose type is a least upper bound have the type stored
explicitly, so the definition of least upper bounds is contained only
in the frontend.

This is a work in progress towards strong mode support, it is still
not complete.

Still missing in the frontend:
- checks from implicit downcasts
- parameter checks from covariant override or covariant generics

Implemented but not part of this CL:
- subtype tests
- IR type checker (for debugging)

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/496717014 .
2016-09-06 11:40:13 +02:00
Peter von der Ahé 9b3b4159c9 [kernel] Include 'name' in SuperMethodInvocation.visitChildren.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/503837013 .
2016-09-05 16:25:34 +02:00
Asger Feldthaus f40abb7e56 [kernel] Do not insert type arguments in super initializer calls
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502787013 .
2016-09-05 14:19:21 +02:00
Asger Feldthaus 6ac6e2fa96 [kernel] Emit an error, but don't crash, if a target-specific library is missing.
BUG=

Review URL: https://chromereviews.googleplex.com/503797013 .
2016-09-05 13:36:51 +02:00
Kevin Millikin a70332a6c0 [kernel] Add a target-specific list of extra libraries.
Some backend targets require extra libraries that are not used
explicitly by a program (e.g., the Dart VM requires its bootstrap
libraries).  Add a target-specific list of these libraries and ensure
that they are loaded when loading a program from Dart sources.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/495497014 .
2016-09-01 13:13:41 +02:00
Kevin Millikin f9fffc319f [kernel] Change the annotation Native to ExternalName.
The annotation Native from dart:_internal clashes with a class of the
same name from dart:_js_helper.  Change the one in dart:_internal to
ExternalName instead.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/493567015 .
2016-08-31 15:17:27 +02:00
Asger Feldthaus f1422becf5 [kernel] Canonicalize mixin applications within each library.
For example:
  class A extends Foo<int> with Bar<String> {}
  class B extends Foo<int> with Bar<double> {}

becomes:
  class Foo&Bar<S,T> = Foo<S> with Bar<T>;
  class A extends Foo&Bar<int, String> {}
  class B extends Foo&Bar<int, double> {}

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/493197013 .
2016-08-31 09:42:55 +02:00
Asger Feldthaus 544b9254b7 [kernel] Ignore --target if not compiling whole program.
Now that --target defaults to vm, this check does not make sense.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/497147013 .
2016-08-30 14:03:11 +02:00
Asger Feldthaus ca2aaa47b2 [kernel] Make --target default to vm.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/498687013 .
2016-08-30 11:26:05 +02:00
Asger Feldthaus 49c32fbc55 [kernel] Fix a bug in the clone visitor.
It would fail to clone a field without an initializer.

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

Review URL: https://chromereviews.googleplex.com/497757013 .
2016-08-30 11:25:25 +02:00
Asger Feldthaus 7389397bce [kernel] Disable shared batch mode state.
Sharing the AnalysisContext causes test flakiness when two test cases
share the same 'part' file.

The performance impact is actually surprisingly small.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/500717013 .
2016-08-30 11:15:52 +02:00
Asger Feldthaus 8360857541 [kernel] Fix parent pointer issues in cloner.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/496887013 .
2016-08-26 16:01:54 +02:00
Asger Feldthaus b0f94795b3 [kernel] Add a script for regenerating all checked-in dill files.
Also update the README again.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/494247013 .
2016-08-26 10:16:54 +02:00
Asger Feldthaus 2559837552 [kernel] Update readme.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/492507013 .
2016-08-25 16:16:14 +02:00
Asger Feldthaus 760baa3b55 [kernel] Make mixin and super resolution a transformation.
This makes super calls name-based (no target) and add direct calls with
both receiver and explicit target.

Super call resolution translates the name-based super calls into direct
calls after they have been cloned into the mixin application.

For JS backends, it should suffice to clone mixed-in methods that
contain super calls, but that transformation is not part of this CL.

This also adds a --target option to dartk designating the target to
which the kernel IR should be specialized.  The new transformation
is run when --target=vm.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/486537013 .
2016-08-24 16:46:50 +02:00
Asger Feldthaus 55a08b45a6 [kernel] Fix generation of index field on enums.
Make sure the 'index' field we generate corresponds to the Element
from the analyzer's model.

As it is now, this does not cause any reproducible errors since the
Element for the 'index' field is never referenced, but this will change
as we introduce interface targets in strong mode.

BUG=
R=kasperl@google.com

Review URL: https://chromereviews.googleplex.com/497607013 .
2016-08-23 12:55:12 +02:00
Asger Feldthaus 4ff550edc1 [kernel] Share local variable map between environments.
Fixes an issue with captured variables not being shared between
nested functions.

BUG=https://github.com/dart-lang/kernel/issues/24
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/492317013 .
2016-08-23 10:32:38 +02:00
Asger Feldthaus d1bc33eba9 [kernel] Fix some frontend bugs.
BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/491157013 .
2016-08-23 10:31:05 +02:00
Vyacheslav Egorov 9f6acbb041 [kernel] Document AsyncMarker.SyncYielding and native yields.
BUG=
R=asgerf@google.com, kustermann@google.com

Review URL: https://chromereviews.googleplex.com/481977013 .
2016-08-23 10:27:27 +02:00
Harry Terkelsen a74bb4e438 [kernel] Some small fixes, typos, etc.
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/493937013 .
2016-08-22 09:56:05 -07:00
Asger Feldthaus 551889c3fb [kernel] Remove NormalClass, MixinClass and use just Class.
We need the ability to efficiently transform a mixin application class
into a regular class, and the separation was obstructing it.  It also
simplifies the IR a bit, although it no longer enforces the invariant
that mixin applications cannot contain fields and procedures.

The binary format is unchanged, so the separation still shows up in
there.  This ensures the CL can land without any changes to the SDK.

BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/488407013 .
2016-08-22 12:35:18 +02:00
Asger Feldthaus 64a31ebdad [kernel] Fix a type annotation.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/488427013 .
2016-08-22 10:41:41 +02:00
Paul Berry fe4c8eb032 [kernel] Update pubspec to point to analyzer 0.27.4.
And fix the resulting deprecation warning.

R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/492777014 .
2016-08-17 05:59:29 -07:00
Asger Feldthaus 8f3c6994ef [kernel] More error handling and a bunch of fixes in the frontend.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/485377014 .
2016-08-17 13:51:33 +02:00
Vyacheslav Egorov d512d0b51e [kernel] Async rewriter: check if statements list is empty before trying to access the last statement.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/488077013 .
2016-08-16 20:57:55 +02:00
Paul Berry 9e90f404a1 [kernel] Fix analyzer warnings and hints
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/488937014 .
2016-08-16 07:33:48 -07:00
Asger Feldthaus 95b6cce25a [kernel] Mark native functions as external and annotate with @Native.
This requires a class Native to exist in the dart:_internal library, to
be used as the annotation.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/493667013 .
2016-08-16 13:18:46 +02:00
Martin Kustermann dff517836c [kernel] Make all parameters get inserted into builder.parameters
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/485297014 .
2016-08-10 14:56:37 +02:00
Asger Feldthaus f98e1d5894 [kernel] Track baseclasses in type propagation.
There is a new lattice point for each class, representing the values
that are subclasses of it.

To ensure that subclassing information is valued higher than subtype
information, we exploit that the ordering of lattice points determines
how the join operation chooses between ambiguous upper bounds.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/488627013 .
2016-08-10 12:50:44 +02:00
Martin Kustermann 4c06130804 [kernel] Add [InferredValueAttacher] transformer which will annotate fields/parameters/return values
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/488597013 .
2016-08-10 12:03:32 +02:00
Asger Feldthaus 4c82d6853e [kernel] Support metadata annotations on classes and members.
BUG=
R=jensj@google.com, kustermann@google.com, vegorov@google.com

Review URL: https://chromereviews.googleplex.com/481447014 .
2016-08-09 16:32:23 +02:00
Vyacheslav Egorov cc98203a2f [kernel] Support BlockExpression-s in the type inference constraint builder.
Ignore function bodies for external methods.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/482497013 .
2016-08-09 16:15:54 +02:00
Martin Kustermann c7fa95d117 [kernel] Add new [InferredValue] ast node, annotate return types, variables, fields
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/485197013 .
2016-08-09 12:53:42 +02:00
Asger Feldthaus b77af073b9 [kernel] Handle classes with a 'call' field or getter.
There is a new 'call handler' meta field in the constraint system,
unfolding any number of 'call' properties on the callee until a
function value is found.

Every method invocation must now load this field to ensure the actual
function is invoked.  This adds quite a bit of overhead, but in strong
mode we should be able to avoid the extra load in practice.

BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/485117015 .
2016-08-09 12:34:59 +02:00
Martin Kustermann 8b591e0cc5 [kernel] Ensure we wait until binary was written
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/478537014 .
2016-08-08 14:25:40 +02:00
Martin Kustermann 467352bd9a [kernel] Add batch running support for transform.dart
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/481417013 .
2016-08-08 13:49:34 +02:00
Martin Kustermann de1a935bef [kernel] Use Platform.resolvedExecutable to determine location of dart-sdk to use
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/484957013 .
2016-08-05 13:27:22 +02:00
Martin Kustermann b3f0da0f5b [kernel] Do not print transformed main library by default
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/481297013 .
2016-08-05 13:14:05 +02:00
Jens Johansen 15352e963d [kernel] Fixed visitor example in documentation
R=asgerf@google.com
BUG=

Review URL: https://chromereviews.googleplex.com/479327013 .
2016-08-05 11:57:18 +02:00
Asger Feldthaus a9fd5f8b07 [kernel] Add transformation to dynamically verify results of type propagation.
It currently only checks function parameters, and uses an
imperfect check for exactness and subclassing.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/486697013 .
2016-08-05 11:41:05 +02:00