Commit Graph

1555 Commits

Author SHA1 Message Date
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 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 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 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
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 43e846dc68 [kernel] Ensure all allocated values come with a non-zero bitmask.
Allocation of a value and bitmask input are two different constraints
in the constraint system.  However, for all values other than 'null',
there should be exactly one bitmask input and one allocation constraint.

The bitmask input was omitted in some cases in the handling of
externals, which is fixed in this CL.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/481187013 .
2016-08-05 11:36:24 +02:00
Asger Feldthaus f3b8057f9e [kernel] Fix analyzer warnings and remove unused code.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/483967014 .
2016-08-05 11:33:58 +02:00
Asger Feldthaus d5c43b7050 [kernel] Do not use default 'null' value for fields initialized by constructor.
BUG=
R=kustermann@google.com, vegorov@google.com

Review URL: https://chromereviews.googleplex.com/480257013 .
2016-08-04 15:31:31 +02:00
Asger Feldthaus 8ca58e848e [kernel] Handle null being returned when falling over the end of a method.
BUG=
R=kasperl@google.com, kustermann@google.com

Review URL: https://chromereviews.googleplex.com/484727013 .
2016-08-04 15:24:53 +02:00
Asger Feldthaus 6af9572777 [kernel] Handle default parameter values in type propagation.
BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/480247013 .
2016-08-04 15:04:57 +02:00
Asger Feldthaus d3361263a1 [kernel] Properly handle arity ranges in more cases.
The constraint fields that model parameters encode the arity of the
call, in order to weed out dataflow from calls with arity mismatch.
But not all the code had been written do follow this strategy.

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

Review URL: https://chromereviews.googleplex.com/479107013 .
2016-08-04 14:52:57 +02:00
Asger Feldthaus 9885189b09 [kernel] Nullability tracking and API for type propagation.
This adds a notion of bitmasks to the constraint system,
which will be propagated by the solver, and joined using
bitwise OR.  The solver does not care what the bits mean.

These bits propagate nullability and other values that we
care to preserve when a good base class could not be found.

This also adds an interface in front of type propagation
that exposes the inferred types in an accessible manner.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/483887013 .
2016-08-04 13:32:45 +02:00
Asger Feldthaus 2295ad8c35 [kernel] Type propagation: Class hierarchy specialization and more.
Instance members are now cloned for every class that inherits it.

The constraint system now explicitly requires all values to be
created using `newValue()`.

There is now a notion of "unions" for representing sets of values.
For class values, unions correspond to types.  For function values,
unions are based on overriding and method names.

The solver's internal map of type (Value,Field) -> Value denoting
the value of a given field has been removed.

The builder must instead register store and load locations for
every valid (Value,Field) pair.  Dynamic stores assign into the
store location, and dynamic loads take the value from the load
location.
Final fields have no store location, so they cannot be polluted
by dynamic stores.

R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/455987013 .
2016-08-02 18:22:54 +02:00
Martin Kustermann 9936f98a16 [kernel] Handle Let expression specially when doing await transformation
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/471207013 .
2016-08-02 12:17:12 +02:00
Martin Kustermann 86e914b8a8 [kernel] Implement support for "await for (...)"
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/463347013 .
2016-08-02 12:17:12 +02:00
Vyacheslav Egorov f26a9269d3 [kernel] Support async exceptions
Transformer lifts try/catch auxiliary variables that need to survive across
yield points into the context.

Drive by fix: we were calling asyncThenWrapper to create an :async_op_error
callback by mistake.

R=kustermann@google.com
BUG=

Review URL: https://chromereviews.googleplex.com/466247013 .
2016-08-02 12:17:07 +02:00
Vyacheslav Egorov 01f1fe8252 [kernel] Various fixes to make async/await work on the VM.
- Rewrite all expressions in functions, not only expression-statements.
- Inject :await_ctx_var and :await_jump_var into the wrapper.
- Don't use transformed expression directly as part of completer.complete call.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/468717014 .
2016-08-02 12:15:21 +02:00
Martin Kustermann 439447c41a [kernel] Add AsyncMarker.SyncCoroutine
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/464127013 .
2016-08-02 12:14:50 +02:00
Martin Kustermann 55fb22d91a [kernel] Implement proof-of-concept for async/async*/sync* rewriting
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/461327013 .
2016-08-02 12:14:50 +02:00
Martin Kustermann 6afbf59b56 [kernel] Attempt to make printing of [BlockExpression]s nicer
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/458577016 .
2016-08-02 12:14:50 +02:00