Commit Graph

1042 Commits

Author SHA1 Message Date
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
Martin Kustermann 43116be5c5 [kernel] Implement binary format implementation for BlockExpression
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/462427014 .
2016-08-02 12:14:50 +02:00
Vyacheslav Egorov 6fc00fe8cf [kernel] Add the first version of async transformer.
This transformer is responsible for lifting subexpression into temporary variables preserved across yield points.

To maintain AST validity I introduced an expression that can contain a block of statements inside called BlockExpression.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/458577014 .
2016-08-02 12:14:50 +02:00
Asger Feldthaus f5093e39b7 [kernel] Include labels in the textual representation.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/475297014 .
2016-07-25 15:18:53 +02:00
Asger Feldthaus c97036648a [kernel] Correctly translate PropertyAccess of a static class member.
This handles the case of null-aware static member access `C?.foo`, as
well as fully qualified static member access `h.C.foo`.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/476957013 .
2016-07-25 15:18:21 +02:00
Asger Feldthaus 2432655e48 [kernel] Add support for batch mode in dartk.
Also forwards errors reported by the analyzer for use
in testing.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/476727013 .
2016-07-22 17:42:32 +02:00
Asger Feldthaus 0228e8c29e [kernel] Fix deserialization of labels in nested functions.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/472867013 .
2016-07-20 14:12:07 +02:00
Asger Feldthaus 241a79e11b [kernel] Preserve leading BOMs during deserialization.
BUG=#21
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/467567013 .
2016-07-20 14:10:22 +02:00
Asger Feldthaus 10d54d7a61 [kernel] Change the default binary file extension to .dill
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/475637013 .
2016-07-19 17:52:33 +02:00
Martin Kustermann 1d0f534832 [kernel] Revert "Implement binary format implementation for BlockExpression"
This accidentally landed on master branch.
2016-07-08 09:22:36 +02:00
Martin Kustermann 4acb4446fd [kernel] Implement binary format implementation for BlockExpression
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/462427014 .
2016-07-08 09:18:01 +02:00
Martin Kustermann 77001a5494 [kernel] Fix moving super initializer to the end
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/462167013 .
2016-07-05 11:53:03 +02:00
Peter von der Ahé 7eef2bb9a2 [kernel] Null aware assignment is when lvalue is null.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/462137013 .
2016-07-01 13:21:45 +02:00
Asger Feldthaus 1d86616fd5 [kernel] Enable Accessor subclasses to provide error handling.
BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/462807013 .
2016-07-01 11:39:21 +02:00