When we perform constant evaluation in the CFE, the async transform
runs after constant evaluation. Thus, it can no longer use const
bool.fromEnvironment("dart.vm.product") to query whether the VM is
in product mode.
Instead, it can read the product mode define directly from the
environment defines given to the CFE and generate different code
depending on the value.
Change-Id: I2aabc4a84b50a940d35d5664ff4ebdf0680ed5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111645
Reviewed-by: Johnni Winther <johnniwinther@google.com>
In the VM-specific async transformation, an index is used to generate
fresh temporary names for values that are live across an await.
Before it was always 0 when translating a statement because there are
no live values on entry or exit to a statement.
When translating statements nested inside block expressions there can
be live values, so the index should not be reset.
Closes https://github.com/dart-lang/sdk/issues/36466
Change-Id: I6103d75c25f312ab1538a7c0f8fee0fea9f01b27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98664
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
TBR=askesc@google.com
Revert "[CFE] Move constant evaluator to Fasta."
This reverts commit 845b5b2df1.
Revert "[CFE] Always call the constant evaluator by the evaluate method."
This reverts commit 91bc4ec2b9.
Revert "[CFE] Use Fasta diagnostics in the constant evaluator."
This reverts commit c7b572aa29.
Revert "[CFE] Check for null in constant evaluation"
This reverts commit e6d2751e9c.
Revert "Rename import after moving file."
This reverts commit a6e2c5eb4c.
Change-Id: Iadfe087c0110f6f331b82d990213f95d3ef4541b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97223
Reviewed-by: William Hesse <whesse@google.com>
This is in preparation for recognizing Fasta-specific nodes in the
constant evaluator, and for using the Fasta diagnostics framework.
Change-Id: I8535fbb68e622f1814a1d577c348d87e573b6b34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96081
Reviewed-by: Kevin Millikin <kmillikin@google.com>
This is a reland of c2b466b09f
Original change's description:
> [CFE] Move constant evaluation number semantics handling to front end.
>
> JavaScript number semantics is currently implemented as the simplistic
> version previously present in DDC. This is a starting point for fully
> detailed JS number semantics.
>
> Change-Id: Id728b3dacec892a5cbf7ece0d9faea51427f5f9b
> Reviewed-on: https://dart-review.googlesource.com/c/94746
> Commit-Queue: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
Change-Id: I1a488ef41bda819d34cb45cd481fd8fd88bfb01e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95460
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
The constant transformer would only transform optional parameters,
since these are the only ones that can contain default values. This
caused it to miss annotations on required positional parameters.
Change-Id: I49bfc84a1a533cec87db557306fdeb3569156947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/93981
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
This reverts commit c2b466b09f.
Reason for revert: Broke precompiled, DDC and others.
Original change's description:
> [CFE] Move constant evaluation number semantics handling to front end.
>
> JavaScript number semantics is currently implemented as the simplistic
> version previously present in DDC. This is a starting point for fully
> detailed JS number semantics.
>
> Change-Id: Id728b3dacec892a5cbf7ece0d9faea51427f5f9b
> Reviewed-on: https://dart-review.googlesource.com/c/94746
> Commit-Queue: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
TBR=sigmund@google.com,askesc@google.com
Change-Id: I732c75b72df0e0f084ad2784349bee346ae5b7ed
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/95027
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
JavaScript number semantics is currently implemented as the simplistic
version previously present in DDC. This is a starting point for fully
detailed JS number semantics.
Change-Id: Id728b3dacec892a5cbf7ece0d9faea51427f5f9b
Reviewed-on: https://dart-review.googlesource.com/c/94746
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Boolean operations are translated into explicit kernel nodes, so they
will not appear as method calls during constant evaluation.
Change-Id: I30a0abfe37989228d5cff4b3fa3ff5407404e747
Reviewed-on: https://dart-review.googlesource.com/c/93980
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
When evaluating a constant expression, first evaluate all children.
If any of these turn out to be unevaluated, produce a partially
evaluated clone of the expression as a new unevaluated constant.
For lazy operators, if the left-hand side turns out unevaluated, the
right-hand side is included unmodified (not partially evaluated) in
the resulting unevaluated constant expression tree.
The implementation is optimized for the typical case of no unevaluated
constants. The intent is that the handling of unevaluated constants
introduces as little overhead as possible in this case.
Change-Id: Ief8d36357fac01c07bc0049aede0888cd3bc7999
Reviewed-on: https://dart-review.googlesource.com/c/93029
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Prototype for `dart:ffi` on Linux/MacOS x64 in JIT mode.
`dart:ffi` is experimental and its API is likely to change in the future.
Progress and design decisions are tracked in https://github.com/dart-lang/sdk/projects/13
issue: https://github.com/dart-lang/sdk/issues/34452
Change-Id: Ifa4566388e42c8757f154741d11e303465ef305d
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try, vm-kernel-mac-debug-x64-try, vm-kernel-asan-linux-release-x64
Reviewed-on: https://dart-review.googlesource.com/c/80124
Reviewed-by: Samir Jindel <sjindel@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
To support separate compilation in DDC, the constant evaluator would
leave instantiations through unavailable constructors unevaluated.
These constructors were identified by being in an external library and
having no initializers. This check erroneously triggered on
"const Object()", breaking the bytecode generator.
Change-Id: I73c10982a36086a431e9fbd54d67cbcde90df68e
Reviewed-on: https://dart-review.googlesource.com/c/92721
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
This achieves consistency with similar getters in the API.
This is technically a breaking change, since it changes a published
part of the Kernel API. Since the constants API is relatively new and
so far only used internally in the AOT compiler, the change is
expected to be unproblematic.
Closes https://github.com/dart-lang/sdk/issues/35696
Change-Id: I3ca30922580d226ccbdb6f77496983c21ef2102b
Reviewed-on: https://dart-review.googlesource.com/c/90220
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
When there is an invalid expression in a constant expression, stop
constant evaluation. The value of that constant expression is the
first invalid subexpression it encountered. This stops us from trying
to constant fold invalid expressions.
Clean up status files for the co19 constant-update-2018 tests to
remove duplication.
Change-Id: Ie6c87f4782ada65fb4d822ad9bf41aedfe0afc45
Reviewed-on: https://dart-review.googlesource.com/c/90040
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Calls to the factory constructor 'new List' can turn into static
invocations of a backend-specific factory function. Signal an error
instead of crashing.
Change-Id: Id0a8a7f0f847c03225b7fa9da2351032d15522e0
Reviewed-on: https://dart-review.googlesource.com/c/90006
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
An invalid constant is (currently) represented by an unevaluated
invalid expression. Using this instead of null fixes 63 out of 125
CFE constant-evaluation crashes with constant-update-2018 and
correctly signals 26 more previously-missed compile-time errors.
Change-Id: I5b4de3995b3a59978dfa08fc542ef0f027572eb6
Reviewed-on: https://dart-review.googlesource.com/c/89506
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Fasta allows some non-const static field access in constant contexts
which leads to the constant evaluator trying to evaluate them. Signal
an error instead of crashing. This will double-report errors for the
cases that Fasta already catches, and we should fix that
double-reporting.
Fix unbounded recursion in printing unevaluated constants (writeNode
called visitUnevaluatedConstant which called defaultConstant which
called writeNode...).
Fix a spurious trailing comma in printing of instance constants.
Change-Id: Idff3169a3a56432ad67c27ff9c267ef355c4c1dc
Reviewed-on: https://dart-review.googlesource.com/c/89514
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Instead of simply printing a message, properly signal a Fasta problem for
constant errors. This causes 68 tests (presumably missing compile-time
errors) to start passing with --enable-experiment=constant-update-2018.
Change-Id: Ia9f1809305bbef7b4652ce49acf6fb9c18408207
Reviewed-on: https://dart-review.googlesource.com/c/89580
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Make the constant evaluator take an explicit error reporter so we have
to opt in to using the "simple" one that reports errors in an ad hoc
way. This is the start of a change to use Fasta-controlled error
messages throughout and eventually get rid of the simple error
handler, and to continue constant evaluation after the first constant
error.
Change-Id: If6b1801edab6063754b642cf4a603abf9d63103a
Reviewed-on: https://dart-review.googlesource.com/c/89501
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
These can arise in erroneous cases which have already been reported,
e.g., in a for-in loop with a const declaration. The constant
evaluator should not assume a non-null initializer in this case.
Change-Id: I2540cb9c659d33e23b6c00d4a8bbf56c404d8c1d
Reviewed-on: https://dart-review.googlesource.com/c/89280
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>