Commit Graph

226 Commits

Author SHA1 Message Date
Alexander Aprelev e71bd048e5 [vm, kernel] Fix async stack code traversal in dart2.
With this change debugger requests yield(await) positions from kernel builder so it can confirm which frame handles what exceptions.
This also renames ':completer' to ':async_completer' in constructed kernel, so it is compliant with what VM expects to see(and updates test expectations accordingly).
Further it fixes async stack navigation for sync-async that became default in dart vm since first version went for the review((uses `future` getter, rather than property).
It also makes `future` getter non-debuggable to allow stepping-out of async methods.

Make Handle zone-scoped. Clean up frame counter var name.

Bug: https://github.com/dart-lang/sdk/issues/29056

Change-Id: Ia71f3c851a6b313655b57dad28c296f5dd081eda
Reviewed-on: https://dart-review.googlesource.com/54640
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-05-22 00:27:01 +00:00
Martin Kustermann aafc2a6d43 Reland "[vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)"
The CL was originally committed in 039e8a175 (and reverted in
46ab040e5). The fix for the issue has landed in 9d9ce8d69 .

This time the CL will land in "disabled" form and will be enabled in a separate CL.

Change-Id: I3d5eb952230aee99875e3c58a6595691c5145e25
Reviewed-on: https://dart-review.googlesource.com/55361
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-16 12:48:38 +00:00
Martin Kustermann f2b37ab643 [VM] Add support for conditions in switch-case expressions to "constants" transformation
This seems to be the last remaining case which causes constant
evaluation in the VM in AOT mode.

Change-Id: I37dba2c634afa3bebd918ebe6dd93ff52a7708e7
Reviewed-on: https://dart-review.googlesource.com/55163
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-05-15 12:52:22 +00:00
Jens Johansen 9d05ada522 Renamings and updated comments in class hierarchy #2
Follow-up to https://dart-review.googlesource.com/c/sdk/+/53804.

Change-Id: I8359985f60207ef92c365c9a6e3833be181b49be
Reviewed-on: https://dart-review.googlesource.com/55162
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-15 10:12:32 +00:00
Jens Johansen f08f61e84d Incremental ClassHierarchy
This CL turns the ClassHierarchy incremental and use that in two places:

* When compiling incrementally
* When performing the second ClassHierarchy computation after adding
  forwarding stubs.

Change-Id: I7046d6be9d7673dc0783a98789b5a25183b44799
Reviewed-on: https://dart-review.googlesource.com/53804
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-05-15 07:37:09 +00:00
Peter von der Ahé 02cd63eefd Remove unused closure conversion
Change-Id: I0edbbd29a4cc603e7479023bc0e8869c78ca7bcc
Reviewed-on: https://dart-review.googlesource.com/54225
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-14 14:58:17 +00:00
Peter von der Ahé bc86dc1dd6 Remove unused reify transformation
Change-Id: I4d29e3372b9aaf6bc7f1849e9fc0fb27f63e5c5f
Reviewed-on: https://dart-review.googlesource.com/54223
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
2018-05-14 14:48:57 +00:00
Peter von der Ahé abb861d812 Remove pkg/kernel/lib/frontend directory
Removing this directory as it is mostly unused.
Closure conversion still relies on VariableAccessor, so I moved it
there.

We should consider removing closure conversion. I don't believe we
actually use it.

Change-Id: I885620b310c4d1bf3a9b9b805188921bc242a993
Reviewed-on: https://dart-review.googlesource.com/54221
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-14 14:25:38 +00:00
Jens Johansen 7b3ba3f41f ClassHierarchy refactorings
This CL:
* Removes unused functions in the ClassHierarchy
* Turns the data structures used in the ClassHierarchy upside down
  (nodes have a lists of supers instead of lists of subs)
* Factors some things that needs the original list-of-subs into another
  class that the user can ask the ClassHierarchy to compute if needed.
  It appears that it isn't generally.

This is step #1 in turning the ClassHierarchy into an incremental
ClassHierarchy.

Change-Id: I48c5731c01c1b0e8bf1fcd4ddba7f2bf7ce3b9c9
Reviewed-on: https://dart-review.googlesource.com/53662
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-05-14 11:33:20 +00:00
Zach Anderson 46ab040e58 Revert "[vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)"
This reverts commit 039e8a1755.

Reason for revert:
Blocks the roll into Flutter.
See https://github.com/dart-lang/sdk/issues/33095

Original change's description:
> [vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)
> 
> This CL also uses the newer `onProblem` error reporting mechanism, which supports contexts.
> 
> The errors by the constant evaluator are formatted e.g. like this:
> 
>     .../language_2/compile_time_constant_o_test_01.dart:14:8: Error: Duplicate keys are not allowed in constant maps (found duplicate key "StringConstant(foo)").
>       "foo": 499
>        ^
>     .../language_2/compile_time_constant_o_test_01.dart:32:24: Context: While analyzing:
>       Expect.identical(m1, m3);
> 
> Change-Id: I463416e14686e218b0f08903bd6aa0bca7392260
> Reviewed-on: https://dart-review.googlesource.com/53021
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,alexmarkov@google.com,askesc@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I1af0200dcb0aef03c7bd9ba3b5aead1565f05708
Reviewed-on: https://dart-review.googlesource.com/54720
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Todd Volkert <tvolkert@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-05-11 17:50:46 +00:00
Kevin Millikin 8dbe716085 Remove the unused GenericCovariantInterface bit
None of the back ends are using it and it imposes a cost to have to
compute it and try to preserve it.

Change-Id: I217e1191b535829021fa11f2698cadd8d4baf1c8
Reviewed-on: https://dart-review.googlesource.com/54383
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-09 15:04:43 +00:00
Martin Kustermann 039e8a1755 [vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)
This CL also uses the newer `onProblem` error reporting mechanism, which supports contexts.

The errors by the constant evaluator are formatted e.g. like this:

    .../language_2/compile_time_constant_o_test_01.dart:14:8: Error: Duplicate keys are not allowed in constant maps (found duplicate key "StringConstant(foo)").
      "foo": 499
       ^
    .../language_2/compile_time_constant_o_test_01.dart:32:24: Context: While analyzing:
      Expect.identical(m1, m3);

Change-Id: I463416e14686e218b0f08903bd6aa0bca7392260
Reviewed-on: https://dart-review.googlesource.com/53021
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-09 09:00:02 +00:00
Alexander Aprelev 384a59595c Recognize synthetic catch-clause and unhandled exceptions.
Bug: https://github.com/flutter/flutter/issues/16741
Change-Id: I619c2eb0662cfdd16cc865ae5eae9c7d19bc55c4
Reviewed-on: https://dart-review.googlesource.com/52984
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-02 22:39:56 +00:00
Martin Kustermann a31d24dbd8 [vm/kernel] Add a knob to constant evaluate annotations only conditionally
This "knob" to turn off constant evaluation for annotations is required
because the TFA transformation leaves annotations in a state where they
cannot be evaluated anymore.

Change-Id: I7720a07ef42ff69834e24a856613ea2e846b4f2d
Reviewed-on: https://dart-review.googlesource.com/52803
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-30 13:34:35 +00:00
Martin Kustermann 4697e3c8f6 [vm/kernel] Change "constants" kernel2kernel transformation to be able to recover from errors
Instead of simply throwing an exception when a compile-time error was
discovered during constant evaluation, we report the error and continue
transforming.

This also collects a context, which can be used by error reporters to
show users in which context an error occured.

The reason for using an interface for reporting errors is to be able to
report reasonable nice error messages, keep the transformation inside
package:kernel and allow users of the transformation to possibly report
nicer error message, e.g. by adding quotes of source positions (which
will come in another CL). This makes it slightly verbose.

Change-Id: I965cafc690dddb525b20368d03bb978e18a6ee58
Reviewed-on: https://dart-review.googlesource.com/52447
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-30 11:27:55 +00:00
Martin Kustermann e9ffc02663 Add partial instantiation support for constant evaluator [PartialInstantiationConstant]
Change-Id: Iaa93da60331737aaa6bceb4d2fe1d791dc7e95e9
Reviewed-on: https://dart-review.googlesource.com/52445
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-04-25 09:25:28 +00:00
Samir Jindel db2f3de25d [kernel] Fix handling of function type type parameters in closure conversion.
Change-Id: Ic805d13bff3e1bc09f8483d918a14fe2f1d7f2d9
Reviewed-on: https://dart-review.googlesource.com/51920
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-04-22 23:01:45 +00:00
Dmitry Stefantsov c7cdb72f32 Move CloneWithoutBody to Kernel API
Change-Id: I21be996293af74bbaf96913d6f345cef28975a4c
Reviewed-on: https://dart-review.googlesource.com/47840
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-03-22 14:25:52 +00:00
Peter von der Ahé 4f2bdff90b Rename Program to Component
Change-Id: I1a3cc03fba9783807fa637a9d42fdbad68ee7686
Reviewed-on: https://dart-review.googlesource.com/31040
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-03-15 12:22:23 +00:00
Kevin Millikin 65b19ffa3c Translate asserts in the VM-specific async translation
Translate assert statements in async functions.  The translation of
the condition subexpression can produce a sequence of statements that
have been hoisted out of it.  These need to be guarded so they are
executed only when asserts are enabled.

For this purpose, we introduce an AssertBlock.  The semantics of the
assert block:

assert { s0; ...; sn; }

is the same as:

if (assertsEnabled) { s0; ...; sn; }

where assertsEnabled is a more primitive nullary expression that is
true iff. assertions are enabled.  We chose not to encode this using a
construct like assertsEnabled because (1) we would have to support it
appearing as an arbitrary expression which we don't currently need
and (2) it requires deeper pattern matching to detect and skip the
guarded code when desired.

The translation is more complicated because if there is a message
subexpression in an assert, it is conditionally evaluated only if the
assert's condition is false.

Fixes https://github.com/dart-lang/sdk/issues/28498

Change-Id: I0912a57104ede3160533e49f65b6fb79b76f1500
Reviewed-on: https://dart-review.googlesource.com/46442
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-03-14 19:41:09 +00:00
Samir Jindel 290c576264 Remove inherited setters for mixed-in fields and copy their covariance-bits.
Currently the transformed expectations are not checked.
This will be implemented shortly.

Mixin code from kmillikin@ (https://dart-review.googlesource.com/c/sdk/+/46060).
Test from jensjoha@.

Change-Id: If8abe4950b80bbec993833700bfeeb8be15f9585
Reviewed-on: https://dart-review.googlesource.com/46061
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-03-12 14:25:01 +00:00
Jens Johansen 7b4ad246b7 [kernel] Fix crash in mixin resolution on invalid override
Change-Id: I602fe4aaed1520ead002933a41ca75527e93e4af
Reviewed-on: https://dart-review.googlesource.com/42746
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-27 14:14:08 +00:00
Mike Fairhurst d0be238ca3 Add missing void annotation: refs #32161
Change-Id: Iea314e7a23513eef1823dbfe8690494f45af9185
Reviewed-on: https://dart-review.googlesource.com/42323
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2018-02-22 18:01:32 +00:00
Kevin Millikin ffc5a96074 Reland "Fix a bug in Kernel's mixin elimination"
Reland
https://github.com/dart-lang/sdk/commit/52d1b4e96d0a384b08aafc184785d1c74cb74efc
with a fix to the test so that it does not use super mixins.

Change-Id: Id1283b1066e853baca4c39402c255ceaa90662f4
Reviewed-on: https://dart-review.googlesource.com/43002
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-02-22 11:52:24 +00:00
William Hesse 7bb941a60c Revert "Fix a bug in Kernel's mixin elimination"
This reverts commit 52d1b4e96d.

Reason for revert: Analyzer and DDC do not support the super-mixin fix and flag, so the new test fails on them.  The test needs to either be marked as failing on them, or support needs to be added and work in the test framework.

Original change's description:
> Fix a bug in Kernel's mixin elimination
> 
> Mixin elimination copied factory constructors from the mixin class to
> the mixin application class.  This could be observed as an unbound
> type parameter which led to a crash in the VM.  Fixes
> https://github.com/dart-lang/sdk/issues/32267.
> 
> Change-Id: I87b70a35d11c364739d01e261adf5329d492d8cf
> Reviewed-on: https://dart-review.googlesource.com/42922
> Reviewed-by: Jens Johansen <jensj@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,jensj@google.com,kmillikin@google.com

Change-Id: I4a0bcf0b323c9adef7e5dc7d9019b6aafe40509d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/42960
Reviewed-by: William Hesse <whesse@google.com>
2018-02-22 10:09:09 +00:00
Kevin Millikin 52d1b4e96d Fix a bug in Kernel's mixin elimination
Mixin elimination copied factory constructors from the mixin class to
the mixin application class.  This could be observed as an unbound
type parameter which led to a crash in the VM.  Fixes
https://github.com/dart-lang/sdk/issues/32267.

Change-Id: I87b70a35d11c364739d01e261adf5329d492d8cf
Reviewed-on: https://dart-review.googlesource.com/42922
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-22 08:51:09 +00:00
Vyacheslav Egorov 1796437cce [vm/kernel] Support synchronously completing futures
Slightly alter async/await transformation in such a way that
:await_jump_var/:await_ctx_var are set before _awaitHelper(...) is invoked -
just like in the AST transformer used by the legacy pipeline. This guarantees
that recursive invocations will continue from the right "jump" point (instead of
continuing from the current jump point).

Fixes https://github.com/dart-lang/sdk/issues/32098

Change-Id: I8899669ceefe3f2edba6531897834b2c275efada
Reviewed-on: https://dart-review.googlesource.com/40520
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-02-12 15:01:18 +00:00
Samir Jindel 1edbc43fec [kernel] Expose converting a single procedure from the async transformation.
Change-Id: Ie0e3b14d555b38e26289085732eb3ad5a0ccbb63
Reviewed-on: https://dart-review.googlesource.com/40523
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-02-12 13:38:10 +00:00
Florian Loitsch 3b8e4d41a7 Reapply "Run async functions immediately."
Which was reverted in commit 032be73dbe.
Originally commited in commit 67bac0bce6.
Original review URL: https://dart-review.googlesource.com/5263

Change-Id: Ic7333c29e502a3924dc6aade8ffa46fc8aa5b04a
Reviewed-on: https://dart-review.googlesource.com/38120
Commit-Queue: Florian Loitsch <floitsch@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2018-02-02 15:50:16 +00:00
Florian Loitsch 032be73dbe Revert "Run async functions immediately."
This reverts commit 67bac0bce6.

Reason for revert: broke the bot.

Original change's description:
> Run async functions immediately.
> 
> Migrated from https://codereview.chromium.org/2478703003/
> 
> Change-Id: I1d678c01ba5876490b12c676c500171328361d31
> Reviewed-on: https://dart-review.googlesource.com/5263
> Commit-Queue: Florian Loitsch <floitsch@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Vijay Menon <vsm@google.com>
> Reviewed-by: William Hesse <whesse@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>

TBR=whesse@google.com,rnystrom@google.com,vegorov@google.com,kustermann@google.com,zra@google.com,floitsch@google.com,jmesserly@google.com,vsm@google.com,regis@google.com,sigmund@google.com

Change-Id: I20c948057423c3fa5aa8c72843f8f2a17e086ad5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/37981
Reviewed-by: Florian Loitsch <floitsch@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2018-02-01 15:01:21 +00:00
Jens Johansen c3b992dcd8 [fasta] incremental compiler can initialize from dill
As requested in #31691 the incremental compiler should be able to
initialize its state from a previously generated dill file.

This CL introduces that functionally.
It is tested, but actual usage (e.g. proper invalidation of old files)
should live outside of the front-end (i.e. it's the callers responsibility).
One option would be for the caller to load the dill file and use the
included sources to invalidate changed files.

On my machine a from-scratch compile of dart2js takes ~5 seconds,
one initialized from such an output and with a single file invalidated
(though it actually hasn't changed) it takes ~1 second and the resulting
dill file is bit-perfect compared to the from-scratch compiled one.

Closes #31691.

Change-Id: I07f5efca5f2684d73f6c252f2dbc2ad04e9b5cd0
Reviewed-on: https://dart-review.googlesource.com/37260
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-01 14:57:07 +00:00
Florian Loitsch 67bac0bce6 Run async functions immediately.
Migrated from https://codereview.chromium.org/2478703003/

Change-Id: I1d678c01ba5876490b12c676c500171328361d31
Reviewed-on: https://dart-review.googlesource.com/5263
Commit-Queue: Florian Loitsch <floitsch@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-02-01 14:08:57 +00:00
Alexander Markov 450765c64e [kernel] Support external procedures without @ExternalName in treeshaker/findNativeName
Dart allows 'external' functions which are not connected to their body.
Calling such functions produces runtime error, but they should be accepted
at compile time. Test language_2/external_test verifies this behavior.

This CL fixes treeshaker/findNativeName to return 'null' instead of throwing
an error for 'external' functions without @ExternalName annotation (which
is used to specify native name).

Change-Id: I04ec892af29ffe064ece8fddd6f67c7acdca1139
Reviewed-on: https://dart-review.googlesource.com/37122
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-01-31 19:52:25 +00:00
Jens Johansen 6fe7b74e47 [kernel] Mark synthetic constructors as such
Fixes #31143

Change-Id: I2c844e48c955234de1b03de08c12729f72db4f3a
Reviewed-on: https://dart-review.googlesource.com/35921
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-01-19 12:29:56 +00:00
Peter von der Ahé 4d1adf42d3 Deprecate IncrementalClassHierarchy
See https://github.com/dart-lang/sdk/issues/31842

Change-Id: I019909831a91a4e06138dc3a6bf32f766bca1ae6
Reviewed-on: https://dart-review.googlesource.com/34880
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-01-17 13:30:17 +00:00
Vyacheslav Egorov ff008ca37a [vm/kernel/async] Use proper type argument when createing async* controller.
Change-Id: I40e5d2d933b83a24c9d8177437fb6df1f21b5cc1
Reviewed-on: https://dart-review.googlesource.com/34741
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-01-15 22:06:30 +00:00
Martin Kustermann 0fb2d0bfed Finish the kernel2kernel "constants" transformation by fixing a whole bunch of issues
Change-Id: I24e2ff06db1a7555f5091d0c27060ed79d6787ee
Reviewed-on: https://dart-review.googlesource.com/31980
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-01-08 19:56:24 +00:00
Kevin Millikin 6fa813d818 Change handling of Kernel static errors
Before: Kernel static errors were represented by throwing a distinguished
error or else by calling a distinguished library const constructor.

Now: Kernel static errors are represented by InvalidExpression.  To support
error reporting, InvalidExpression has an optional message and a file
offset.  A back end can choose to signal these errors at any time; for
example, when deserializing the binary, or when compiling the procedure
containing the static error, or when the erroneous expression is evaluated
at run time.

InvalidStatement is removed because it can be encoded as ExpressionStatement
of InvalidExpression.

Future work:

* supporting static errors where an expression cannot appear in the AST
* allowing InvalidExpression to contain an Expression for error recovery
* adding a top-level list of static errors and warnings to the binary

Bug: https://github.com/dart-lang/sdk/issues/29840
Change-Id: Ifdfe9a76cee6cefed28061bf245be70531d2f413
Reviewed-on: https://dart-review.googlesource.com/31320
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-01-04 11:00:25 +00:00
Vyacheslav Egorov 3fc72c50d9 [kernel] Fix strong mode typing in async transformer.
Fill in interfaceTarget for :for-iterator._subscription.

Bug:
Change-Id: I29bd44ca4649f3530c0b74f8372349704c99d443
Reviewed-on: https://dart-review.googlesource.com/26700
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-12-06 23:19:13 +00:00
Alexander Markov da61c326ed [VM/Kernel] Move devirtualization to pkg/vm, cleanup target-options
* The package:kernel/transformations/precompiler.dart is moved to
  package:vm and split into 2 libraries: metadata/direct_call and
  transformations/cha_devrtualization.

* Fasta 'target-options' command line argument and
  package:kernel/target/implementation_option.dart are cleaned up
  as they are no longer used.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I21a7b6bc62a036a9694e62a5dae890f6120d79ab
Reviewed-on: https://dart-review.googlesource.com/26360
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-06 18:49:33 +00:00
Peter von der Ahé e14726a3f4 Use absolute URIs instead of relative paths
We change the type of FileUriNode.fileUri from String to Uri, which in principle
doesn't change the binary format. However, we did notice that LibraryParts
weren't serialized as specified in binary.md, so we also fixed that.

Since fileUris are stored as strings in a separate table, Uri.parse is only called
once per unique URI.

Fasta only uses relativizeUri when printing diagnostics, and URIs stored in
expectation files (golden files) are relativized using String.replaceAll.

Change-Id: Ib2dc1b80c03a0cdaf84e48b8b3ba73b16bdf8a40
Reviewed-on: https://dart-review.googlesource.com/25421
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-12-04 11:34:24 +00:00
Alexander Markov f6334d583f [Kernel/AOT] Check if call is legal before doing devirtualization
This change makes devirtualization more robust until front-end fully
implements override checks.

Change-Id: I96f666cca034984a10bd1a90078c4a5e53ddd27d
Reviewed-on: https://dart-review.googlesource.com/21786
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-27 17:59:12 +00:00
Martin Kustermann c7bbaaf9f5 [Kernel] Add treeshaker support for constants
Change-Id: I9546147dbcb76a3112785fd99dbd0cca4463bd70
Reviewed-on: https://dart-review.googlesource.com/21641
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-11-20 14:33:47 +00:00
Martin Kustermann abaaee069a [kernel] Fix various issues in the kernel treeshaker
The changes in this CL include:

   * handle interface targets also on this dispatch (which happens due
     to mixins)
   * preserve class members if interface targets refer to them
   * remove references to shaken elements in `Library.additionalExports`
   * support handling of typedefs

Change-Id: Id8df6fbf5c3428ae9c9f8b11ee9bf80c35a7a091
Reviewed-on: https://dart-review.googlesource.com/21640
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2017-11-20 13:23:27 +00:00
Martin Kustermann d354a28cb2 [kernel] Add kernel2kernel constant evaluation, binary format as well as vm support
The introduced "constants" transformation can evaluate constant expressions.  The
original use-sites of constant expressions are replaced by a new [ConstantExpression]
node, which points to a subclass of a new [Constant] class hierarchy.  Constant
[Field]s and [VariableDeclarations]s will be removed, since all use-sites are
re-written.

The [Constant] class hierarchy is, similarly to the [DartType] class hierarchy, not
part of the AST tree (also has no parent pointer).  The constants form a
DAG (directed acyclic graph).

There is no canonicalization requirement of the [Constant] objects referenced by the
AST (via [ConstantExpression]).  Although it is beneficial to canonicalize them during
construction, since it reduces time spent in operator==/hashCode.

This CL furthermore adds support for a constant table in the binary format.  Similarly
to [String]s, we canonicalize the constants before writing the table to the binary.
The constant table entries in the binary are written in a post-order way, to ensure
easy construction on the backend side.

The text format will be augmented with a "constants { ... }" section at the end,
which lists the constants in the same order as in the binary format.

The transformation can be used by those backends who choose to do so.  It is not
enabled by default atm.  It should therefore not affect analyzer, fasta or other
components.

Change-Id: I57cd9624fedcf537ab6870db76246149647bed21
Reviewed-on: https://dart-review.googlesource.com/14382
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-11-16 11:08:02 +00:00
Vyacheslav Egorov c847cbd5e4 [VM, Kernel] Use T as a Completer type argument in async transformation.
Previously we used FutureOr<T> by mistake.

This causes the code construct a much more meaningful type Future<T> not

Fixes https://github.com/dart-lang/sdk/issues/31324

Bug:
Change-Id: I38d4e4101b81bb33d53a87385ebcf60302f6764f
Reviewed-on: https://dart-review.googlesource.com/21081
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-11-15 14:05:32 +00:00
Alexander Aprelev 1a45ad96ca Move super resolution from kernel transformation to VM flow graph construction.
Super resolution kernel transformation updates kernel graph with
resolved static calls in place, which breaks incremental modular nature
of transformations.

Bug: dartbug.com/31043
Change-Id: I7ec52d29ea03652cae1403dd89552b30686a5749
Reviewed-on: https://dart-review.googlesource.com/18320
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-11-08 20:17:51 +00:00
Samir Jindel 7b6b716071 [kernel] Don't cancel completed streams in the Async transformation.
Bug:
Change-Id: I40742b13f1b47f2817c480bfc257deaf6f1028ca
Reviewed-on: https://dart-review.googlesource.com/17820
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-03 17:03:01 +00:00
Paul Berry cc3f95b41d Check procedure kind when matching up forwarding stubs during mixin resolution.
Otherwise we might match up a getter to a setter and crash.

The test cases indirectly verify that mixin resolution does the right
thing by checking the semantics of the generated code.  These tests do
not pass yet, because covariance checks are not yet implemented in the
VM.

Change-Id: Ibe6d8b7479f86151c515c45c20ed7c880bf2ad43
Reviewed-on: https://dart-review.googlesource.com/16686
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-26 12:54:08 +00:00
Karl Klose 51089b53cd Remove strong mode type check insertion transformations
Change-Id: I7f4bb08b32b0ecf5af4d60af0a5b5b3a2e41c49a
Reviewed-on: https://dart-review.googlesource.com/16482
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Karl Klose <karlklose@google.com>
2017-10-26 07:32:00 +00:00