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>
This CL changes:
* package:kernel/clone.dart: To not clone file offsets if the
file-uri we copy from is unknown.
* package:kernel/binary/ast_to_binary.dart: To not write out file
offsets if the file-uri is not written/indexed (which happens if
the file uri is not in the `Program.uriToSource` map).
* It reverts the file renaming part of 60a2cfa219 which
fixed the name collision problem only partially (it missed to
rename `runtime/lib/double.dart`, which is not possible because
there's already a `double_patch.dart` file).
Instead of renaming, we solve the problem by mangling the names as follows:
.../sdk/lib/core/double.dart -> dart:core/double.dart
.../runtime/lib/double.dart -> dart:core/runtime/lib/double.dart
.../runtime/lib/double_patch.dart -> dart:core/runtime/lib/double_patch.dart
* It changes the test to ignore any negative token positions. The vm
service does not just expose `-1` token positions for places where
there is no source, but also e.g. `-9` (which means TokenPosition::kMethodExtractor),
this was one reason why the appjit test failed.
* It changes the test to try to force-compile everything (unsure if that works).
Issue https://github.com/dart-lang/sdk/issues/32489
Change-Id: Ia9f42ca9d56d987e3041175add549bb7a133f269
Reviewed-on: https://dart-review.googlesource.com/46341
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This simplifies figuring out what went wrong from just
debugging output in some cases.
Change-Id: Ie7a775c57fb691d6bd3ca1c70a04fb6cbe9e0875
Reviewed-on: https://dart-review.googlesource.com/43060
Reviewed-by: Jens Johansen <jensj@google.com>
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>
This reverts commit ef51b33f22.
Reason for revert: Issue from initial land was fixed in 076db33f03.
Original change's description:
> Revert "[kernel] Don't always treat doubles as constants"
>
> This reverts commit 12407c3ea0.
>
> Reason for revert: co19/Language/Expressions/Object_Identity/double_t01 fails in -c dartkp -r dart_precompiled mode.
>
> Original change's description:
> > [kernel] Don't always treat doubles as constants
> >
> > Previously, when the VM parsed a doubles from the dill file it passed
> > control over to the constant evaluator which would then case the
> > value and canonicalize it.
> > That doesn't really seem to make sense when its not used in a const
> > context, nor is it done the same way for integers for instance.
> >
> > This CL changes that and treats doubles the same way as integers.
> >
> > Below timings are statistics run through "ministat" based on 5 runs
> > of each configuration (now and before). The timings is for running
> > the dill file with the VM, i.e. the dill file was precompiled via
> > fasta.
> >
> > Program adding 50,000 doubles to a list and prints the last one:
> >
> > -56.6 +/- 28.2389
> > -10.9988% +/- 5.48753%
> > (~510 ms -> ~460 ms)
> >
> > Program adding 1,000,000 doubles to a list and prints the last one:
> >
> > -3177.2 +/- 263.54
> > -31.4643% +/- 2.60987%
> > (~10 seconds -> ~7 seconds)
> >
> > Hello world program:
> >
> > No difference proven at 95.0% confidence
> >
> > Change-Id: I7dd748e759b3e433bc806b2ef2505d29f0b109b6
> > Reviewed-on: https://dart-review.googlesource.com/42000
> > Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> > Commit-Queue: Jens Johansen <jensj@google.com>
>
> TBR=ahe@google.com,vegorov@google.com,jensj@google.com
>
> Change-Id: If8efa9917c009f2df68a3ef00331ab45bf8bf67b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/41981
> Reviewed-by: Jens Johansen <jensj@google.com>
> Commit-Queue: Jens Johansen <jensj@google.com>
TBR=ahe@google.com,vegorov@google.com,jensj@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I3c20797f585057e8f77e917918926dcfa921df0a
Reviewed-on: https://dart-review.googlesource.com/42720
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Under certain conditions front-end currently generates as{TypeError}
type checks in constant expressions. Support evaluating these type
checks as constant expressions instead of rejecting them.
Change-Id: Id432c4c5062d7bab89c29fef308b42b2cbd64de8
Reviewed-on: https://dart-review.googlesource.com/41761
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This reverts commit 12407c3ea0.
Reason for revert: co19/Language/Expressions/Object_Identity/double_t01 fails in -c dartkp -r dart_precompiled mode.
Original change's description:
> [kernel] Don't always treat doubles as constants
>
> Previously, when the VM parsed a doubles from the dill file it passed
> control over to the constant evaluator which would then case the
> value and canonicalize it.
> That doesn't really seem to make sense when its not used in a const
> context, nor is it done the same way for integers for instance.
>
> This CL changes that and treats doubles the same way as integers.
>
> Below timings are statistics run through "ministat" based on 5 runs
> of each configuration (now and before). The timings is for running
> the dill file with the VM, i.e. the dill file was precompiled via
> fasta.
>
> Program adding 50,000 doubles to a list and prints the last one:
>
> -56.6 +/- 28.2389
> -10.9988% +/- 5.48753%
> (~510 ms -> ~460 ms)
>
> Program adding 1,000,000 doubles to a list and prints the last one:
>
> -3177.2 +/- 263.54
> -31.4643% +/- 2.60987%
> (~10 seconds -> ~7 seconds)
>
> Hello world program:
>
> No difference proven at 95.0% confidence
>
> Change-Id: I7dd748e759b3e433bc806b2ef2505d29f0b109b6
> Reviewed-on: https://dart-review.googlesource.com/42000
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Commit-Queue: Jens Johansen <jensj@google.com>
TBR=ahe@google.com,vegorov@google.com,jensj@google.com
Change-Id: If8efa9917c009f2df68a3ef00331ab45bf8bf67b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/41981
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Previously, when the VM parsed a doubles from the dill file it passed
control over to the constant evaluator which would then case the
value and canonicalize it.
That doesn't really seem to make sense when its not used in a const
context, nor is it done the same way for integers for instance.
This CL changes that and treats doubles the same way as integers.
Below timings are statistics run through "ministat" based on 5 runs
of each configuration (now and before). The timings is for running
the dill file with the VM, i.e. the dill file was precompiled via
fasta.
Program adding 50,000 doubles to a list and prints the last one:
-56.6 +/- 28.2389
-10.9988% +/- 5.48753%
(~510 ms -> ~460 ms)
Program adding 1,000,000 doubles to a list and prints the last one:
-3177.2 +/- 263.54
-31.4643% +/- 2.60987%
(~10 seconds -> ~7 seconds)
Hello world program:
No difference proven at 95.0% confidence
Change-Id: I7dd748e759b3e433bc806b2ef2505d29f0b109b6
Reviewed-on: https://dart-review.googlesource.com/42000
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
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>
This relands 75a9579ea0.
The approach works as follows:
Step 1: Kernel transform. Under the closed world assumption compute the
set of selectors dispatched dynamically, then mark all procedures that don't
match any of those selectors as 'not-dispatched-dynamically'.
Step 2: VM backend. When building IR for a function if this function was
marked as not-dispatched-dynamically then omit type checks for any parameter
that is not marked as generic-covariant-impl, as such arguments are guaranteed
to be checked on the caller side (by front-end).
+------------------------+------------+----------+-----------+--------------+
| benchmark | baseline | current | with opt | improved by |
+------------------------+------------+----------+-----------+--------------+
| stock_layout_iteration | 2366.3786 | 2724.3 | 2562.75 | -5.93% |
| stock_build_iteration | 3824.3 | 4914.8 | 4681 | -4.76% |
+------------------------+------------+----------+-----------+--------------+
* Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
Baseline is at 6196496 bytes.
Alternatively to annotating individual procedures, I considered annotating Program node
with a set of dynamically dispatched selectors. Decoding and passing this information
around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
approach where all individual procedures are annotated.
Bug: https://github.com/dart-lang/sdk/issues/3179
Change-Id: I2f32a609e3872c74d5ae7bbd97555453aaedf15f
Reviewed-on: https://dart-review.googlesource.com/38125
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
This reverts commit 75a9579ea0.
Reason for revert: function_subtype_bound_closure7_test fails in darkp
Original change's description:
> [vm/kernel/aot] Skip unnecessary type checks on parameters of instance methods.
>
> The approach works as follows:
>
> Step 1: Kernel transform. Under the closed world assumption compute the
> set of selectors dispatched dynamically, then mark all procedures that don't
> match any of those selectors as 'not-dispatched-dynamically'.
>
> Step 2: VM backend. When building IR for a function if this function was
> marked as not-dispatched-dynamically then omit type checks for any parameter
> that is not marked as generic-covariant-impl, as such arguments are guaranteed
> to be checked on the caller side (by front-end).
>
> # Performance Impact
>
> +------------------------+------------+----------+-----------+--------------+
> | benchmark | baseline | current | with opt | improved by |
> +------------------------+------------+----------+-----------+--------------+
> | stock_layout_iteration | 2366.3786 | 2724.3 | 2562.75 | -5.93% |
> | stock_build_iteration | 3824.3 | 4914.8 | 4681 | -4.76% |
> +------------------------+------------+----------+-----------+--------------+
>
> * Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
> Baseline is at 6196496 bytes.
>
> # Alternative Implementations
>
> Alternatively to annotating individual procedures, I considered annotating Program node
> with a set of dynamically dispatched selectors. Decoding and passing this information
> around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
> approach where all individual procedures are annotated.
>
> Change-Id: I363db6d5dd1138fe25917646313c16d0b213c3b4
> Reviewed-on: https://dart-review.googlesource.com/37822
> Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>
TBR=vegorov@google.com,alexmarkov@google.com,sjindel@google.com
Change-Id: I0fd6bf3e6edfc3e605da2b996f9a0da6c409d01c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/37802
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
The approach works as follows:
Step 1: Kernel transform. Under the closed world assumption compute the
set of selectors dispatched dynamically, then mark all procedures that don't
match any of those selectors as 'not-dispatched-dynamically'.
Step 2: VM backend. When building IR for a function if this function was
marked as not-dispatched-dynamically then omit type checks for any parameter
that is not marked as generic-covariant-impl, as such arguments are guaranteed
to be checked on the caller side (by front-end).
# Performance Impact
+------------------------+------------+----------+-----------+--------------+
| benchmark | baseline | current | with opt | improved by |
+------------------------+------------+----------+-----------+--------------+
| stock_layout_iteration | 2366.3786 | 2724.3 | 2562.75 | -5.93% |
| stock_build_iteration | 3824.3 | 4914.8 | 4681 | -4.76% |
+------------------------+------------+----------+-----------+--------------+
* Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
Baseline is at 6196496 bytes.
# Alternative Implementations
Alternatively to annotating individual procedures, I considered annotating Program node
with a set of dynamically dispatched selectors. Decoding and passing this information
around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
approach where all individual procedures are annotated.
Change-Id: I363db6d5dd1138fe25917646313c16d0b213c3b4
Reviewed-on: https://dart-review.googlesource.com/37822
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
This reverts commit 12759870a4.
Reason for revert: Broke many bots.
Original change's description:
> [VM] Use IR for code in [CatchEntryInstr]s to populate captured exception/stacktrace variables
>
> This fixes an issue when a program got loaded via dill, a function
> with a try-catch got optimized and the exception/stacktrace variables
> got captured.
>
> Change-Id: Ia6b62f2a0986c78b90afe7fae25025ca4e5b09db
> Reviewed-on: https://dart-review.googlesource.com/35182
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
TBR=vegorov@google.com,kustermann@google.com
Change-Id: I2ec7b4bea401e6d5665f6e789eb8e241b99db7b3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/36200
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This fixes an issue when a program got loaded via dill, a function
with a try-catch got optimized and the exception/stacktrace variables
got captured.
Change-Id: Ia6b62f2a0986c78b90afe7fae25025ca4e5b09db
Reviewed-on: https://dart-review.googlesource.com/35182
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
The original change is available in patchset 1.
The changes since then are just status file updates.
Change-Id: I0c45c4b09a187bdd60c6a38bf23f6b7a0cf80c97
Reviewed-on: https://dart-review.googlesource.com/34400
Reviewed-by: Jens Johansen <jensj@google.com>
A new Expression was added in bc2560069a
but C++ wasn't updated to handle it.
The crash reported in 31868 is caused by trying to skip past such an
expression, which is now possible.
Actually using that expression is still unhandled though, although thats
a separate issue.
Fixes#31868.
Bug: 31868
Change-Id: Ife0aadb97cee398ee1925fb52f91127225253768
Reviewed-on: https://dart-review.googlesource.com/34361
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
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>
E.g.
```
main() {
new Foo();
}
class Foo {
Foo() {
print("hello from foo");
}
}
```
debugging with --pause_isolates_on_start, the constructor (or anything else
in class Foo) would not be breakable from the Observatory interface.
This CL fixes that by collecting token positions from unfinalized classes.
Bug:
Change-Id: I93a20f3322b0a343a619625c71236b59c885cb7e
Reviewed-on: https://dart-review.googlesource.com/30441
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
* Fixes kernel flow graph builder to use instantiated type argumenst
for CreateArray
* Fixes prologue builder to mask the positon of named arguments in the
arguments descriptor array
* Add a SmiBitAndTOS instruction to DBC
* Implement missing AssertSubtype DBC instruction
* Ensure we don't use field guards in DBC mode
* Remove incorrect assertions in LoadIndexedUnsafe/StoreIndexedUnsafe
* Save argdesc_ in DBC simulator when calling the runtime to optimize
a function (which can call re-entrant to Simulator via const
evalulation)
Issue https://dart-review.googlesource.com/c/sdk/+/29581
Change-Id: Ia14b657db66f90643822b6986ec7f75f746ab0d8
Reviewed-on: https://dart-review.googlesource.com/30340
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>