Commit graph

1134 commits

Author SHA1 Message Date
Daco Harkes
e1c12b3ab2 [cfe/ffi] Fix Finalizable non-nullable variables
TEST=pkg/vm/test/transformations/ffi_test.dart
TEST=pkg/vm/testcases/transformations/ffi/regress_52596.dart
Contains
`throw "Attempt to execute code removed by Dart AOT compiler (TFA)";`
without the fix.

Closes:https://github.com/dart-lang/sdk/issues/52596
Change-Id: I5de819afcf6f70be037b60432ea016bc281b742e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312909
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-07-11 07:53:47 +00:00
Tess Strickland
ac2533e705 [pkg/vm] Instantiate the ffi Pointer class to bounds when needed.
Previously, the FFI transformer could produce is checks where the
type to check against was Pointer<dynamic>. However, given that
the Pointer class is defined as:

abstract class Pointer<X extends NativeType> ...

the instantiated to bounds version of its type is Pointer<NativeType>.
Pointer<dynamic> is not a subtype of Pointer<NativeType>, and thus is an
invalid instantiation, but the only place this type could occur was as
the right hand side of an is check.

Before 7cc005ea1, Class::RareType() returned the class instantiated with
the null (all-dynamic) type arguments vector. Among other things, this
"rare" type was compared to the right-hand side of is checks and, if it
matched, performed a simple (cid-only) check of the instance type
arguments in unoptimized code.

Afterwards, Class::RareType() returns the class instantiated with a type
arguments vector where each type parameter is instantiated to bounds, so
now the "rare" type check fails and it falls back to the full check of
the instance type arguments, which causes a ~25% regression in some
unoptimized benchmarks.

This CL fixes the generation of those is checks in the FFI transformer
to use the instantiated to bounds version of the Pointer type instead.

TEST=pkg/front_end/test

Issue: https://github.com/dart-lang/sdk/issues/52843
Issue: https://github.com/dart-lang/sdk/issues/52848
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-debug-x64-try,vm-linux-debug-x64-try
Change-Id: Ic9ac6d75ba2743e233065444fad13ab098094349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312400
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-07-05 14:24:56 +00:00
Liam Appelbe
13ec07415b [vm] Async FFI callbacks
More details about the design:
https://docs.google.com/document/d/1QDjyY_6wOTOgURwpeYMKU9qEz0gKxx2MUrdruC6Kp6c/edit?usp=sharing

Change-Id: Ie3985d86dca7f5010044ca46c33ca177588c0f69
Bug: #37022
CoreLibraryReviewExempt: Reviewed by vm and api groups. web and wasm groups not affected because FFI isn't on those platforms.
TEST=async_void_function_callbacks_test.dart, ffi_callback_metadata_test.cc, other front end tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305900
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-28 01:00:18 +00:00
Alexander Markov
57863dc64b [vm/aot/tfa] Tree-shake unused libraries
On a large app (which apparently has too many unused dependencies),
size of the AOT kernel file:
before: 464 MB
after: 108 MB

TEST=pkg/vm/testcases/transformations/type_flow/transformer/libraries.dart
Bug: b/287638965
Change-Id: I79a26305c00741babb6a69a18919983b398109e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310772
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-23 20:14:08 +00:00
Martin Kustermann
ddc236ba64 [vm] Add @pragma('vm:keep-name') annotation
This allows us to keep symbol names for classes/methods/fields - even if
obfuscation is enabled, but has no other effect on tree shaker / ...

For go/dart-ama

TEST=vm/dart/keep_name_pragma_test

Change-Id: I66c0fc32217d9180f821658bae463f2c1d7fb1af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2023-06-16 10:22:23 +00:00
Johnni Winther
7226c7245e [kernel] Remove RedirectingFactory node
Closes #28421
Closes #29169

TEST=existing

Change-Id: Iee7d84fadc10981648cb327589fd7aa15b9b3e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308140
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 06:38:32 +00:00
Johnni Winther
90d5a99c15 [cfe] Remove redirecting factory field
TEST=existing

Change-Id: Ic9f51693d0cc75cbe745dcaa0f4feb26d7005a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307941
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-13 09:24:28 +00:00
Alexander Markov
4a222e0924 [vm/aot/tfa] Cache types
Hide constructors of types objects and avoid creating extra instances of
types, caching them as necessary.

TEST=existing

Change-Id: I2897888649dd1c4338d6e4000ab0c481d9da3c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308242
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-09 14:15:48 +00:00
Johnni Winther
82e3a751a9 [cfe] Remove unnecessary_null_comparison code
The frontend is now run with sound null safety so these are no longer needed.

TEST=existing

Change-Id: I6c1776845854695ff34e310a3bb5bc9d86715f06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307901
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-08 08:46:47 +00:00
Alexander Markov
5b6512f54e [vm/aot] Disable signature shaking for 'this' of inline class members
Specification of inline classes has the following rule for
closurization (tear-off creation) of inline class members:

> The operator == of the closurization returns true if and only if
> the operand is the same object.

This means that each time tear-off is taken, a new closure should be
created which compares equal only to itself. This is true iff that
closure has a non-empty context which captures 'this'.

Signature shaking can remove 'this' parameter if it is not used
and this affects equality of the tear-offs of inline class members.
This change prevents that by marking 'this' parameter of inline
class members as checked.

TEST=co19/LanguageFeatures/Inline-classes/dynamic_semantics_member_invocation_A02_t03
TEST=co19/LanguageFeatures/Inline-classes/dynamic_semantics_member_invocation_A03_t03

Issue: https://github.com/dart-lang/sdk/issues/49737
Change-Id: I4cf4f5afdb6c83a1b1eccf587cafcf9a9ca5178a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307665
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-07 16:02:13 +00:00
Alexander Markov
c82672780a [vm/aot/tfa] Tree-shaking of inline classes
TEST=pkg/vm/testcases/transformations/type_flow/transformer/inline_class.dart

Issue: https://github.com/dart-lang/sdk/issues/49737
Change-Id: I48faba0767994d254590b311380245718895173e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307661
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-07 15:31:34 +00:00
Alexander Markov
808b4d5bf6 [vm/aot/tfa] Cleanup _FallthroughDetector
Control-flow dependent condition can be used to track statically
unreachable code and so separate AST visitor _FallthroughDetector
is no longer needed.

TEST=ci

Change-Id: I9cec56e0f0a7ec6c451ac1143f3048d2de12f053
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306060
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-02 18:03:38 +00:00
Alexander Markov
486b3b380e [vm/aot/tfa] Fix building of data flow summary in case of break from try/finally
In case of a non-local jump (via 'break' or 'continue') which crosses
try/finally block, 'finally' block is executed, so outgoing state of
the 'finally' block should be used at the target of the jump,
instead of the state at break/continue.

In addition to fixing this bug, this change also slightly improves
precision when merging states in try/catch and try/finally based on
the conditions.

TEST=pkg/vm/testcases/transformations/type_flow/summary_collector/control_flow.dart

Change-Id: Id0aa9fa43e73afe2b7eee217837c11dc586b6008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306663
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-02 17:05:10 +00:00
Alexander Markov
8b8d063679 [vm/aot/tfa] Fix handling of 'assert' statement
With conditional data flow TFA should model control flow in
'assert' statements more precisely: message expression is not always
executed; variable values and condition should not be propagated down
from message expression.

TEST=language/assert/message_test
Fixes https://github.com/dart-lang/sdk/issues/52503

Change-Id: Iea3b0bae38ab328bd1ad92cacc6b4c3c99f9753f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305342
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-05-25 14:37:48 +00:00
Chloe Stefantsova
3da16e93a9 [cfe] Ensure mixed in class of the mixin has been transformed
Closes https://github.com/dart-lang/sdk/issues/52302

TEST=covered by existing tests

Change-Id: I8f4a1d5b35c5fa3b9d18aa7473d62c5ff7d6aed2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305320
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-25 07:48:52 +00:00
Ryan Macnak
c747a25d66 [vm] Add arch-specific bits for Android RISCV64.
TEST=local AOSP build
Bug: https://github.com/flutter/flutter/issues/117973
CoreLibraryReviewExempt: VM-only
Change-Id: I9417e86f025bebee359d8ba50ee6b5c8589c2744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303011
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-05-22 16:43:04 +00:00
Alexander Markov
6d466bcb41 [vm/aot/tfa] Conditional data flow
This change improves type flow analysis by adding conditional data
flow. Now each statement in the data flow summary can have an optional
condition. If a condition is present, then the statement is applied
only if its condition is not a 'false' constant. The condition may
become false as a result of whole-program type and constant
propagation (constant value is an optional property of a concrete
type).

Conditions in the data flow summary are populated from conditions in
the 'if' statements and conditional expressions. Conditions are
propagated down the control flow while building the summary.
For example:

  if (x) { return foo(); }
  bar();

Call 'foo()' is guarded by condition 'x' and 'bar()' is guarded by
condition '!x'.

Also, a bunch of unary and binary operations are added in order to
represent logical expressions, comparisons with null, 'is' tests and
conditional moves.

This change makes TFA much more sensitive to the control flow.

In order to offset increase in the compilation time due to the
additional condition and operations in the data flow summary,
the following is done:
* Types corresponding to bool constants are canonicalized; condition
  checking and logical operations are performed using fast identical
  checks.
* Fast identical checks are also added to union and intersection of
  types.
* Added more sophisticated simplifications of Join statements.

Along with reduced analysis due to skipped data flow statements with
false conditions, these improvements result in the slightly reduced
compilation time.

AOT compilation time on large Flutter apps (only AOT step 2 / TFA):
App 1: Before: 65.448s After: 62.893s (-3.9%)
App 2: Before: 55.067s After: 52.192s (-5.2%)

AOT snapshot size of large Flutter apps (Flutter release mode, arm64):
App 1: Before: 32910316 After: 32599936 (-0.9%)
App 2: Before: 34464544 After: 34092907 (-1.0%)
Flutter gallery: -1.9%

Performance on micro-benchmark from https://github.com/dart-lang/sdk/issues/51630 in AOT mode:
Before: 0.405839
After: 0.172886 (2.3x faster than before, still slower than JIT)

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47509.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_51630.dart

Issue: https://github.com/dart-lang/sdk/issues/51630
Fixes https://github.com/dart-lang/sdk/issues/48154
Fixes https://github.com/dart-lang/sdk/issues/47509

Change-Id: I29baf2933972adf83fd58be5ec25be8c30665c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-05-22 16:20:47 +00:00
Ömer Sinan Ağacan
c74387a3a2 [dart2wasm] New async implementation
This CL re-implements the async function compilation without using JSPI
or any other platform features.

This implementation is faster than the JSPI-based one in all benchmarks,
in some cases up to 200x (benchmark results at the end). So we remove
the JSPI-based implementation as there's no point in maintaining a much
slower implementation and supporting two implementations at the same
time (which is tricky because these implementations need different
libraries, all scripts need to support two modes etc.) that also
requires experimental platform features.

# Main changes

- A new pass `AwaitTransformer` transforms `await` expressions to
  top-level statements in form `var <fresh variable> = await <simple
  expr>`, where `<simple expr>` is an expression without `await`.

  After this pass all `await` expressions have the simple continuation
  of "assign the value of the awaited future to this variable and
  continue with the next statement". This simplifies `await`
  compilation.

- A new code generator `AsyncCodeGenerator` (inherits from
  `CodeGenerator`) compiles `async` functions. The `_YieldFinder` class
  is copied from `sync*` code generator but modified to handle `async`
  expressions.

- Mentions to the V8 flag `--experimental-wasm-stack-switching` is
  removed from all scripts and documents.

# Future work

- Control flow handling in `AsyncCodeGenerator` needs to be implemented
  in a similar way in `SyncStarCodeGenerator`. Doing this without
  duplicating a lot of code will require some refactoring.

# New passing tests

- co19/Language/Statements/Yield_and_Yield_Each/Yield/execution_async_A05_t01
- co19/Language/Statements/For/Asynchronous_For_in/execution_A02_t02
- language/regress/regress23996_test
- language/sync_star/dcall_type_test

# Benchmarks

Current implementation:

```
AsyncLiveVars.LiveObj1(RunTime): 1586000.0 us.
AsyncLiveVars.LiveObj2(RunTime): 2114000.0 us.
AsyncLiveVars.LiveObj4(RunTime): 1972500.0 us.
AsyncLiveVars.LiveObj8(RunTime): 2212000.0 us.
AsyncLiveVars.LiveObj16(RunTime): 2238000.0 us.
AsyncLiveVars.LiveInt1(RunTime): 2362000.0 us.
AsyncLiveVars.LiveInt4(RunTime): 2470000.0 us.
AsyncLiveVars.LiveObj2Int2(RunTime): 2575000.0 us.
AsyncLiveVars.LiveObj4Int4(RunTime): 2820000.0 us.
Calls.AwaitAsyncCall(RunTimeRaw): 35676.15658362989 ns.
Calls.AwaitAsyncCallClosureTargetPolymorphic(RunTimeRaw): 38934.108527131786 ns.
Calls.AwaitAsyncCallInstanceTargetPolymorphic(RunTimeRaw): 42617.02127659575 ns.
Calls.AwaitFutureCall(RunTimeRaw): 2832.058906825262 ns.
Calls.AwaitFutureCallClosureTargetPolymorphic(RunTimeRaw): 3665.8125915080527 ns.
Calls.AwaitFutureCallInstanceTargetPolymorphic(RunTimeRaw): 4420.449537241076 ns.
Calls.AwaitFutureOrCall(RunTimeRaw): 3692.7621861152143 ns.
Calls.AwaitFutureOrCallClosureTargetPolymorphic(RunTimeRaw): 4625.346901017576 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphic(RunTimeRaw): 4514.6726862302485 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits(RunTimeRaw): 345172.4137931034 ns.
Calls.AwaitForAsyncStarStreamPolymorphic(RunTimeRaw): 697000.0 ns.
Calls.AwaitForAsyncStarStreamPolymorphicManyYields(RunTimeRaw): 704666.6666666666 ns.
Calls.AwaitForManualStreamPolymorphic(RunTimeRaw): 11010.989010989011 ns.
Calls.SyncCall(RunTimeRaw): 0.40275240996973316 ns.
Calls.SyncCallClosureTarget(RunTimeRaw): 0.3989591156672242 ns.
Calls.SyncCallInstanceTargetPolymorphic(RunTimeRaw): 3.2632549336335526 ns.
Calls.IterableSyncStarIterablePolymorphic(RunTimeRaw): 353.3980582524272 ns.
Calls.IterableManualIterablePolymorphic(RunTimeRaw): 332.1161825726141 ns.
Calls.IterableManualIterablePolymorphicManyYields(RunTimeRaw): 354.28067078552516 ns.
```

New implementation:

```
AsyncLiveVars.LiveObj1(RunTime): 11327.683615819209 us.
AsyncLiveVars.LiveObj2(RunTime): 10923.91304347826 us.
AsyncLiveVars.LiveObj4(RunTime): 10956.284153005465 us.
AsyncLiveVars.LiveObj8(RunTime): 11286.516853932584 us.
AsyncLiveVars.LiveObj16(RunTime): 11445.714285714286 us.
AsyncLiveVars.LiveInt1(RunTime): 11016.483516483517 us.
AsyncLiveVars.LiveInt4(RunTime): 11327.683615819209 us.
AsyncLiveVars.LiveObj2Int2(RunTime): 10918.478260869566 us.
AsyncLiveVars.LiveObj4Int4(RunTime): 10737.967914438503 us.
Calls.AwaitAsyncCall(RunTimeRaw): 1082.2510822510822 ns.
Calls.AwaitAsyncCallClosureTargetPolymorphic(RunTimeRaw): 1056.4124234100993 ns.
Calls.AwaitAsyncCallInstanceTargetPolymorphic(RunTimeRaw): 1134.1726210729273 ns.
Calls.AwaitFutureCall(RunTimeRaw): 865.6509695290858 ns.
Calls.AwaitFutureCallClosureTargetPolymorphic(RunTimeRaw): 841.3967185527977 ns.
Calls.AwaitFutureCallInstanceTargetPolymorphic(RunTimeRaw): 839.066957543212 ns.
Calls.AwaitFutureOrCall(RunTimeRaw): 397.9941096871766 ns.
Calls.AwaitFutureOrCallClosureTargetPolymorphic(RunTimeRaw): 406.17384240454913 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphic(RunTimeRaw): 393.7472929873607 ns.
Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits(RunTimeRaw): 1095.0503723171266 ns.
Calls.AwaitForAsyncStarStreamPolymorphic(RunTimeRaw): 6643.426294820717 ns.
Calls.AwaitForAsyncStarStreamPolymorphicManyYields(RunTimeRaw): 7178.750897343863 ns.
Calls.AwaitForManualStreamPolymorphic(RunTimeRaw): 1456.23998835008 ns.
Calls.SyncCall(RunTimeRaw): 0.3919935321067202 ns.
Calls.SyncCallClosureTarget(RunTimeRaw): 0.3906669661780074 ns.
Calls.SyncCallInstanceTargetPolymorphic(RunTimeRaw): 3.1676143112814583 ns.
Calls.IterableSyncStarIterablePolymorphic(RunTimeRaw): 104.4932079414838 ns.
Calls.IterableManualIterablePolymorphic(RunTimeRaw): 104.57516339869281 ns.
Calls.IterableManualIterablePolymorphicManyYields(RunTimeRaw): 116.92487576731949 ns.
```

TEST=ci
CoreLibraryReviewExempt: Added entry-point pragmas.
Change-Id: I02fbd08141f51c00fb37b6fa0304dc25d6afdb71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301020
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-05-22 08:32:12 +00:00
Nate Bosch
17c626f8b3 Remove some getters for final fields
These were original getters without any fields. After adding fields
to cache the values instead of rereading them on each access the
forwarding public getters became redundant but were not removed.

Make the fields public, remove the getters, and move the docs from the
getters to the fields.

Change-Id: Ie078f5b85cf85f8f86642ac6fe8d36f4107602ee
CoreLibraryReviewExempt: Only impacts VM platform.
Tested:No behavior changes expected. Confirmed updated fields can be read on VM.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304324
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-05-19 00:52:57 +00:00
Johnni Winther
009cbfbeac [kernel] Merge front_end and kernel verifiers
This merges the front_end and kernel verifiers into one Target based
kernel verifier. The RedirectingFactoryBody work-around is moved to
package:kernel to support its verification.

TEST=existing

Change-Id: I0adf4d2c22c4009cf439b3b23fa14192253a2846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-26 14:14:36 +00:00
Stephen Adams
45efccb5e0 Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900

The `List` constructor is removed in Dart 3.0.
Some of the `@patch` implementations were not removed.

This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor  to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper.
The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs.

(It used to be that patches couldn't add public members, that security seems to have been removed.)

Also removes code which tries to detect "the unnamed List constructor",
which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12.

TEST=ci

Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-22 00:38:28 +00:00
Daco Harkes
fa3a72fa7e [cfe/ffi] Error on compound constructors
TEST=co19/LibTest/ffi/Struct/Struct_A02_t01
TEST=co19/LibTest/ffi/Union/Union_A03_t01
TEST=co19/LibTest/ffi/Union/Union_A03_t02
TEST=co19/LibTest/ffi/Union/Union_A03_t03
TEST=co19/LibTest/ffi/Union/Union_A04_t01

Closes: https://github.com/dart-lang/sdk/issues/46813
Change-Id: I2a057613a62eccc0de81083a6f63f8ba68430fc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293684
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-17 11:03:57 +00:00
Jens Johansen
cc40e17fd9 [CFE][ffi] Support FFI Finalizable transformation of redirecting factories
A redirecting factory is normally encoded as something like

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar
    return new self::Foo::•(bar: bar);
```

which the CFE also expects to recreate its internal state when loading
a dill file.

The Finalizable transformation from FFI can change that to something
like:

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar {
    return block {
      final synthesized self::Foo :expressionValueWrappedFinalizable = new self::Foo::•(bar: bar);
      _in::reachabilityFence(bar);
    } =>:expressionValueWrappedFinalizable;
  }
```

though, which the CFE doesn't understand and subsequently crashes as
in https://github.com/flutter/flutter/issues/124369

This CL makes the CFE understand this transformed version,
fixing the crash.

TEST=Existing tests; added incremental compiler test.

Change-Id: I5e7a5fc6201e4419e9ec1ca69d5522d5190f1f83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294761
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-13 07:50:38 +00:00
Daco Harkes
2d61150905 [cfe/ffi] Fix missing type argument on @Native
TEST=tests/ffi/regress_51913_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51913
Change-Id: I79746f3b3852f34d7e31b32260ce5abcb2d6801a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-04-05 16:24:30 +00:00
Daco Harkes
4b5401bfb2 [cfe/ffi] Fix compiler crash on invalid Array type
And report error on invalid type nested in `Array`.

TEST=co19/LibTest/ffi/Array/Array.multi_A03_t02
TEST=co19/LibTest/ffi/Array/Array.multi_A03_t04
TEST=co19/LibTest/ffi/Array/Array_A03_t02
TEST=co19/LibTest/ffi/Array/Array_A03_t04

Bug: https://github.com/dart-lang/sdk/issues/51958
Change-Id: Ida650f2c7c93ebce8c93a1dc5a5b4b222166438b
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-05 16:00:54 +00:00
Daco Harkes
8765f93404 [cfe/ffi] Error on 0-size array
TEST=co19/LibTest/ffi/Array/Array.multi_A02_t01

Bug: https://github.com/dart-lang/sdk/issues/51958
Closes: https://github.com/dart-lang/sdk/issues/45540
Change-Id: I33f84b829968f7f8496710c6facaa489b741b2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-04-05 09:17:58 +00:00
Daco Harkes
7a90dd0c4f [cfe/ffi] Remove custom FFI checks covered by class modifiers
Tests are in the following files 3.0 and pre-3.0 respectively.
TEST=tests/ffi/vmspecific_static_checks_test.dart
TEST=tests/ffi_2/vmspecific_static_checks_test.dart

Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: Ib0b27590748ef788c5475929fde585c790f64e63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291064
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-27 12:15:22 +00:00
Daco Harkes
92e5746494 Reland "[vm/ffi] Add class modifiers"
This is a reland of commit 1755f89092

Can land after (or with) the Flutter PR:
https://github.com/flutter/engine/pull/40434

Original change's description:
> [vm/ffi] Add class modifiers
>
> Adds class modifiers to `dart:ffi`.
>
> Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
> and `AbiSpecificInteger` to be `final class`es.
>
> Does not remove the manual error checking, so some errors will show up
> twice now in language version 3.0. In language version <3.0, only the
> FFI-specific error will show up.
>
> In a follow-up CL, we will try to make the language-errors to show up
> also <3.0 so that we can remove the FFI-specific errors.
>
> Examples of duplicated errors:
> pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart
>
> TEST=pkg/analyzer/test/ (for the analyzer)
> TEST=pkg/front_end/testcases/ (for the CFE)
> TEST=test/ffi/ (for the VM)
>
> CoreLibraryReviewExempt: No need for dart2js to review.
> Bug: https://github.com/dart-lang/sdk/issues/51683
> Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
> Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Jackson Gardner <jacksongardner@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TEST=pkg/analyzer/test/ (for the analyzer)
TEST=pkg/front_end/testcases/ (for the CFE)
TEST=test/ffi/ (for the VM)
CoreLibraryReviewExempt: No need for dart2js to review.
Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: I2ee3f0ac31d4162068a2346a06320029b2263ee2
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289781
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-03-21 15:25:10 +00:00
Ryan Macnak
2cc96bfa0b [vm] Add an ABI for Fuchsia RISC-V.
https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0211_fuchsia_on_risc-v

TEST=./tools/build.py -mrelease -asimriscv64 gen_snapshot_fuchsia gen_snapshot_product_fuchsia
CoreLibraryReviewExempt: VM-only
Change-Id: Ie62addda6c15a5b44e814c49b543319aef4fc5e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281869
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-20 20:46:27 +00:00
Zach Anderson
7471994270 Revert "[vm/ffi] Add class modifiers"
This reverts commit 1755f89092.

Reason for revert: This is a breaking change and is blocking the Dart -> Flutter roll. See https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20Unopt/26896/overview.

Original change's description:
> [vm/ffi] Add class modifiers
>
> Adds class modifiers to `dart:ffi`.
>
> Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
> and `AbiSpecificInteger` to be `final class`es.
>
> Does not remove the manual error checking, so some errors will show up
> twice now in language version 3.0. In language version <3.0, only the
> FFI-specific error will show up.
>
> In a follow-up CL, we will try to make the language-errors to show up
> also <3.0 so that we can remove the FFI-specific errors.
>
> Examples of duplicated errors:
> pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart
>
> TEST=pkg/analyzer/test/ (for the analyzer)
> TEST=pkg/front_end/testcases/ (for the CFE)
> TEST=test/ffi/ (for the VM)
>
> CoreLibraryReviewExempt: No need for dart2js to review.
> Bug: https://github.com/dart-lang/sdk/issues/51683
> Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
> Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Jackson Gardner <jacksongardner@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: Ie5b8a08aea6d64b1991ace4814322b21ffb670c7
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289640
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-03-20 11:15:59 +00:00
Daco Harkes
1755f89092 [vm/ffi] Add class modifiers
Adds class modifiers to `dart:ffi`.

Migrates all user-defined subclasses of `Struct`, `Union`, `Opaque`,
and `AbiSpecificInteger` to be `final class`es.

Does not remove the manual error checking, so some errors will show up
twice now in language version 3.0. In language version <3.0, only the
FFI-specific error will show up.

In a follow-up CL, we will try to make the language-errors to show up
also <3.0 so that we can remove the FFI-specific errors.

Examples of duplicated errors:
pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart

TEST=pkg/analyzer/test/ (for the analyzer)
TEST=pkg/front_end/testcases/ (for the CFE)
TEST=test/ffi/ (for the VM)

CoreLibraryReviewExempt: No need for dart2js to review.
Bug: https://github.com/dart-lang/sdk/issues/51683
Change-Id: I2964ceccb7db59fbdaf6be5319f5e4ec2dabe0f3
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-win-release-try,pkg-mac-release-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-reload-rollback-linux-debug-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289223
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-17 19:29:41 +00:00
Alexander Markov
295e210975 [vm/aot] Unbox records using inferred record shapes
Unboxing of records in return values is switched to use inferred record
shape instead of a static type. This is more accurate, as
static return type 'Object', 'dynamic' or a type parameter would
not prevent record unboxing.

TEST=runtime/tests/vm/dart/records_return_value_unboxing_il_test.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/unboxed_records.dart

Issue: https://github.com/dart-lang/sdk/issues/49719
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I56528e114bc2de94c4a1ec09c48eb5b9ed3c3d3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288824
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-15 17:34:37 +00:00
Johnni Winther
04e6f4c282 [kernel] Add VariableDeclaration.isSynthesized
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.

The name of a variable can only be `null` if it is synthesized.

Partially in response to
https://github.com/dart-lang/sdk/issues/51554

TEST=existing

Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-10 11:13:36 +00:00
Daco Harkes
11929b6f68 [vm/ffi] Change late Finalizable implementation #2
https://dart-review.googlesource.com/c/sdk/+/286782 omitted to treat
captured variables.

We should treat captured variables the same as other variables. We
might decide to inline the body of a closure, in which case we should
not eagerly execute initializer statements for fences.

TEST=pkg/vm/testcases/transformations/ffi/finalizable_late_initializer.dart

Closes: https://github.com/dart-lang/sdk/issues/51511
Change-Id: I80744d347926087f467c561d76eca17d3a108983
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287460
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-03-08 15:40:52 +00:00
Alexander Markov
55ddbe534a [vm/aot/tfa] Avoid using null as an initial value of non-nullable and late variables without initializer
TEST=pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: Ie6b3bdf7069e7d6389e3a729f23b9e1912a4eed2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285061
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-03-07 20:31:14 +00:00
Alexander Markov
110b0f0eba [tfa,dart2wasm] Create separate class for each record shape in TFA
This allows us to better track all kinds of accesses to record
implementation classes in dart2wasm, which generates separate
record implementation class per record shape.

This change also allows us to remove mutable dispatch targets
which were used to implement dynamic accesses to record fields,
and make tracking of record field types more accurate
(record fields are now versioned per shape).

This is also a step towards inferring actual record types.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/records.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/records_dart2wasm.dart
TEST=language/records/simple/dynamic_field_access_test

Issue https://github.com/dart-lang/sdk/issues/49719
Fixes https://github.com/dart-lang/sdk/issues/51363

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: Icba62a7ca8cfd8ddbc7f2b7c38aeabbef5caec4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286950
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-03-07 18:06:42 +00:00
Daco Harkes
7cfbfc6a25 [vm/ffi] Change late Finalizable implementation
This CL replaces `late Finalizable` variables with the original and
a nullable non-late variable. Every assignment is done first to the
late variable, and the immediately to the nullable non-late shadow
variable. The reachability fences are then inserted only for the
nullable non-late shadow variable.

The advantage of this is that the semantics are fully valid and none
of the further compiler pipeline has to know about late Finalizables.
(1) We remove the special casing in the VM.
(2) The TFA logic with finalizables is no longer blocked.

The downside of this approach is that we use more memory, we need
two fields at runtime, one storing a null and the other storing a
sentinel on initiazation. Moreover, we get some extra store
instructions.

TEST=pkg/vm/testcases/transformations/ffi/finalizable_late.dart
TEST=pkg/vm/testcases/transformations/ffi/finalizable_late_2.dart
TEST=tests/language/vm/regress_49005_test.dart

Closes: https://github.com/dart-lang/sdk/issues/51511
Change-Id: Ifedd3387a368233a2d01e1bcaa9f5e3eceb76856
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286782
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-07 10:10:25 +00:00
Alexander Markov
e27923a5a0 [dart2js] Static weak references to method tearoffs
TEST=language/static_weak_reference_test
TEST=language/static_weak_reference_error_test

Bug: b/269223463

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I760476a7c81751f6c302f21251b525cb5c916c02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284489
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-02 20:04:19 +00:00
Daco Harkes
8218ee0840 [cfe/ffi] Fix Finalizable in for( in ) loops
The `Finalizable` visitor was visiting for-in loops in AST order:
(1) variable, (2) iterable, (3) body. This caused the `variable` to be
fenced in the `iterable` expression. The `variable` should only be
fenced in the `body`.

TEST=tests/ffi/regress_51538_test.dart
TEST=pkg/vm/test/transformations/ffi_test.dart
     with pkg/vm/testcases/transformations/ffi/regress_51538.dart

Closes: https://github.com/dart-lang/sdk/issues/51538
Change-Id: Idacf87b6de3ee0d2d5c6c5046060c55135593fed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286182
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-03-02 09:05:19 +00:00
Daco Harkes
cb1b6905ac [vm/ffi] Fix @Natives with VarArgs
This CL fixes the processing of `@Native` annotations to take into
account the native types nested in `VarArgs`.

TEST=tests/ffi/regress_51504_test.dart
TEST=tests/ffi/function_varargs_generated_native_leaf_test.dart
TEST=tests/ffi/function_varargs_generated_native_test.dart

Closes: https://github.com/dart-lang/sdk/issues/51504
Change-Id: Ifb0a08e1e52c9b51cb5143e7ac487a91da4a0e0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285623
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-01 09:08:31 +00:00
Alexander Markov
143e4e9dc8 [vm/aot/tfa] Static weak references to method tearoffs
TEST=pkg/vm/testcases/transformations/type_flow/transformer/weak.dart
TEST=language/vm/static_weak_reference_test
TEST=language/vm/static_weak_reference_error_test

Bug: b/269223463
Change-Id: I23c8229c39217aa1c3f9fb576d8eefa5ceb1d8ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283421
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-02-22 01:01:29 +00:00
Daco Harkes
40787d84fc [frontend_server] Add support for @Native assets
The VM can read native asset mappings from kernel.

Previous CLs already added support to embed native asset mappings for
one-shot compilation.
This CL adds support for adding native assets mappings to kernel files
created by the frontend_server with the incremental compiler.

The frontend_server accepts a `--native-assets=<uri>` at startup and
accepts a `native-assets <uri>` message on stdin as compilation
command.

The frontend_server caches the compiled native assets library.

When a `reset` command is sent to request a full dill from the
incremental compiler, the native assets mapping is taken from the
cache and added to the final dill file.

Split of DartSDK & flutter_tools prototype to land separately.

TEST=pkg/frontend_server/test/native_assets_test.dart

Bug: https://github.com/dart-lang/sdk/issues/49803
Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: I6e15f177564b8a962e81261815e951e7c9525513
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282101
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-21 07:29:29 +00:00
Ömer Ağacan
7c6423cb32 Revert "[kernel] Remove unused RecursiveVisitor type parameter"
This reverts commit a329e05684.

Reason for revert: Broke internal projects

Original change's description:
> [kernel] Remove unused RecursiveVisitor type parameter
>
> TEST=ci
>
> Change-Id: I523282e933b955389c950c1942253d2d66a51f3f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283821
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

TBR=johnniwinther@google.com,omersa@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Iad30e34ce0a491711b0daa1991c69de1796f8846
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284023
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-02-18 10:52:39 +00:00
Ömer Sinan Ağacan
a329e05684 [kernel] Remove unused RecursiveVisitor type parameter
TEST=ci

Change-Id: I523282e933b955389c950c1942253d2d66a51f3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283821
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-02-18 07:31:18 +00:00
Daco Harkes
dc45e67c5e Reland "[vm/ffi] Disallow nullable struct fields"
This is a reland of commit 4e7d71b593

Flutter's dependencies have been rolled.
g3 has also been rolled.

TEST=tests/ffi/regress_51041_test.dart

Original change's description:
> [vm/ffi] Disallow nullable struct fields
>
> TEST=tests/ffi/regress_51041_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/51041
> Change-Id: I44d82c5f378c5d001bfb7526be87c179b8160be1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279511
> Commit-Queue: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I66580ad7c2f032c17cc708ce875e8dba942ae44b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-16 11:26:38 +00:00
Daco Harkes
3a1ac23ea2 [cleanup] Remove stale todo
TEST=only removes a comment

Change-Id: I8562f97f2422484090accd27e595811db1c70ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283185
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-15 14:33:40 +00:00
Daco Harkes
dc2c739a6c [vm/ffi] Fix Struct use in @Natives
The FfiNative transform was trying to access the generated struct
constructor which is added to the AST in the FFI definitions transform.

The FFI definitions transform has to run _before_ the FFI native
transform.

TEST=tests/ffi/regress_51321_test.dart

Closes: https://github.com/dart-lang/sdk/issues/51321
Change-Id: I6b5caf6e5851455cece6aec13ef73d85cc201ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282103
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-02-13 09:40:24 +00:00
Tess Strickland
2c0484c720 [pkg/vm] Initial work on constant operating system fields and getters.
* Add an `targetOS` argument to `pkg/vm`'s `compileToKernel`,
  that contains the target operating system's name.

* Add a new `--target-os` command line argument for all binaries
  that use `compileToKernel` for clients to provide the target
  operating system, if known.

* Add a new`"vm:platform:const"` annotation to certain field and
  getters in the Platform class.

  This annotation is used to annotate static getters and fields with
  initializers where the getter body or field initializer must evaluate
  to a constant value if the target operating system is known. This
  annotation may be used outside the Platform class and in user code.

  For example, this annotation can be used on a static `String` field
  that is initialized with one value if `Platform.isWindows` is true
  and to a different value if `Platform.isWindows` is false.

  Note: If the const functions experimental flag is disabled, then
  any annotated static methods can only contain a single expression
  whose value is returned. If it is enabled, then the static method
  is evaluated as if it is a const function with the special
  handling of annotated static fields and getters above.

* Create a VM constant evaluator that evaluates uses of static getters
  and fields marked with the above annotations when a target operating
  system is provided.

* Use the new VM constant evaluator in the unreachable code elimination
  transformer.

TEST=pkg/vm/test/transformations/platform_use_transformer
     pkg/vm/test/transformations/unreachable_code_elimination

Change-Id: Ie381de70486a767fd7b1d515fd9e6bb58c6bf090
Bug: https://github.com/dart-lang/sdk/issues/31969
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try
CoreLibraryReviewExempt: Just adding vm-specific annotations.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274386
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-02-10 16:29:50 +00:00
Alexander Markov
b9f145259a [dart2wasm/tfa] Fix artificial record class in TFA
If Target doesn't provide a single concrete record
implementation class, then TFA introduces an artificial one.
This class should override all Object public instance
members so calls to Object methods from records are not
monomorphic and not devirtualized incorrectly.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/records_dart2wasm.dart

Change-Id: Id880d70c0ca82b88ebad3a86d9c08546f28f655c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281541
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-02-09 18:07:40 +00:00
Alexander Markov
d7e4ad02d7 [kernel] Cleanup Target.enableSuperMixins flag
This flag is no longer used by the front-end and can be removed.

TEST=ci

Change-Id: Ia19e9927d48d4ae486ee7ffa110abb9960a0840d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281461
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-02-09 16:17:11 +00:00