Commit Graph

1307 Commits

Author SHA1 Message Date
Ömer Ağacan 95e7793b68 Revert "[dart2wasm] Make int, double, bool box fields immutable"
This reverts commit af2bea8162.

Reason for revert: Caused unexpected performance regressions.

Original change's description:
> [dart2wasm] Make int, double, bool box fields immutable
>
> Make the `value` fields of `BoxedInt`, `BoxedDouble` and `BoxedBool`
> `final`, to generate immutable Wasm fields for them.
>
> Immutable fields can potentially generate better code, as loads from the
> same object will always generate the same value.
>
> To allow making the `value` fields `final`, add a constructor.
>
> To allow adding a constructor, "implement` base classes instead of
> extending them. With `extends` the front-end wants us to call the
> superclass constructors, even though they don't have any constructors.
>
> Implementing `bool` (instead of extending) causes issues in TFA as it
> currently assumes bool literals are compiled as the `bool` class. Update
> TFA to treat bool literals the same way as `int` and `double` literals.
>
> Tested: existing tests
> Change-Id: I3282e188d784fa7a22421edc79ed47f9d85faf19
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393320
> Commit-Queue: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I8bb49bcc4bd9cd01f3e8a692d7ba1bef889ab555
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393840
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Ömer Ağacan <omersa@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-11-06 09:30:00 +00:00
Ömer Sinan Ağacan af2bea8162 [dart2wasm] Make int, double, bool box fields immutable
Make the `value` fields of `BoxedInt`, `BoxedDouble` and `BoxedBool`
`final`, to generate immutable Wasm fields for them.

Immutable fields can potentially generate better code, as loads from the
same object will always generate the same value.

To allow making the `value` fields `final`, add a constructor.

To allow adding a constructor, "implement` base classes instead of
extending them. With `extends` the front-end wants us to call the
superclass constructors, even though they don't have any constructors.

Implementing `bool` (instead of extending) causes issues in TFA as it
currently assumes bool literals are compiled as the `bool` class. Update
TFA to treat bool literals the same way as `int` and `double` literals.

Tested: existing tests
Change-Id: I3282e188d784fa7a22421edc79ed47f9d85faf19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393320
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-11-05 12:09:10 +00:00
Moritz bc3a760f2b Record instances which are not annotations
There is no need to restrict the recording to annotations.
It also opens up more interesting use cases, for example recording instances of `const StringAsset('id').load()` if the class `StringAsset` has the `RecordUse` annotation.

Also includes a small refactoring in a separate commit.

TESTED=pkg/vm/testcases/transformations/record_use/instance_not_annotation.dart
Change-Id: I262995760a8ba8bc14c9cf01e5eb1b47f1278282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
2024-11-04 15:02:53 +00:00
Alexander Markov c409e77d1e Validation of dynamic modules
TEST=pkg/front_end/testcases/general/dynamic_modules


Change-Id: I591d029ed163961f5ece859233874f828d63c857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388442
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-24 16:51:53 +00:00
Jens Johansen e7d825fb3c [CFE/kernel/vm] Incremental compiler/serializer and metadata
This CL:
* Makes the incremental compiler copy over the metadata just created for
  the libraries compiled into the Component returned.
* Preserves metadata when serializing via the incremental serializer.
* Fixes loading a multi-component with metadata.
* Lets the VM copy all metadata in "_combinePendingDeltas"
  when there is only one component to "combine".

It is generally my view, that to do better, metadata has to be redone
(among other things likely has to live on the Library instead).

https://github.com/dart-lang/sdk/issues/39302

With this CL:

```
rm foo.dill ; tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --no-print-incremental-dependencies --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.dart_tool/package_config.json pkg/compiler/lib/src/dart2js.dart
tools/sdks/dart-sdk/bin/dart pkg/vm/bin/dump_kernel.dart foo.dill foo.dump
grep "@vm.call-site-attributes" foo.dump | wc -l
```

(i.e. a one-shot compile) prints 9500.

```
rm foo.dill ; tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --incremental --no-incremental-serialization --no-print-incremental-dependencies --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.dart_tool/package_config.json pkg/compiler/lib/src/dart2js.dart
tools/sdks/dart-sdk/bin/dart pkg/vm/bin/dump_kernel.dart foo.dill foo.dump
grep "@vm.call-site-attributes" foo.dump | wc -l
```

(i.e. an incremental compile but without incremental serialization) prints 9500.

and

```
rm foo.dill ; tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --incremental --no-print-incremental-dependencies --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.dart_tool/package_config.json pkg/compiler/lib/src/dart2js.dart
tools/sdks/dart-sdk/bin/dart pkg/vm/bin/dump_kernel.dart foo.dill foo.dump
grep "@vm.call-site-attributes" foo.dump | wc -l
```

(i.e. an incremental compile with incremental serialization) prints 9500.

If not deleting the dill file first (which will then initialize from it)
metadata might be different though.
If there are no changes and the incremental serializer was and is used
we should still get `9530` (because the bytes are just copied), but
otherwise we might get different results because it's not really
possible to otherwise pick-and-choose and/or merge the metadata.

TEST=Existing tests that it didn't get worse.

Change-Id: I19d530357e7e2a174d7408dbbf0ed7e0248a5b70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358444
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-10-02 09:37:31 +00:00
Devon Carew 1f8aea0c81 Bump lints to a97011b4b031b1df94765dbacd7d92b0b765c8b9
Changes:
```
> git log --format="%C(auto) %h %s" af68bf0..a97011b
 https://dart.googlesource.com/lints.git/+/a97011b add unintended_html_in_doc_comment; rev to 5.1.0 (211)

```

Diff: https://dart.googlesource.com/lints.git/+/af68bf0cbad88002a2ae19ee8db37b64eb120c32..a97011b4b031b1df94765dbacd7d92b0b765c8b9/
Change-Id: I998d73f5f72e94d5f2922b0751d31620a837555e
Tested: analysis only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387601
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-09-30 21:48:03 +00:00
Jens Johansen 3dce89fbe0 [scanner] Don't give the Utf8 scanner a 0-terminated byte sequence
Not having to do the read-allocate-copy dance for files to add a 0-byte
at the end results in these changes when using the CFE to compile
(a fixed version of) the CFE:

```
msec task-clock:u: -1.7356% +/- 0.2164% (-73.16 +/- 9.12)
page-faults:u: -2.6957% +/- 0.0111% (-2914.83 +/- 12.00)
cycles:u: -1.7128% +/- 0.2223% (-297927979.70 +/- 38660477.01)
instructions:u: -1.6814% +/- 0.0002% (-361315766.86 +/- 36853.71)
branch-misses:u: -3.3289% +/- 0.9669% (-2153126.00 +/- 625370.97)
seconds time elapsed: -1.7372% +/- 0.2154% (-0.07 +/- 0.01)
seconds user: -1.5998% +/- 0.2740% (-0.06 +/- 0.01)
seconds sys: -4.1451% +/- 2.9801% (-0.01 +/- 0.01)
Scavenge(   new space) goes from 62 to 61
```

TEST=Existing test coverage.

Change-Id: I8e182bcee39839f6ed1e658c30c85c40ecf0b259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 08:33:48 +00:00
Moritz 7222c2963d Add recording of constant instances to record_use
TESTED=pkg/vm/test/transformations/record_use_test.dart

Change-Id: I73ee5b7f1478286252664c53397270906ead549b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384280
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
2024-09-13 09:07:02 +00:00
Aravind 8f89bbe1a9 [vm/ffi] Not preventing the transformation for InvalidExpression in ffi
Currently, we just "removed" the actual expression by transforming to
`InvalidExpression('Invalid Type')` if a expression is Invalid. But this  could cascade `.address` position errors (i.e transformer no longer able to walk `.address.abc` if the expression is just replaced with empty expression). So unwrapping actual expression from `InvalidExpression` and trying to transforming that actual expression through a recursive call.

TEST=tests/ffi/static_checks/address_position_cascade_test.dart
Bug: https://github.com/dart-lang/sdk/issues/56613
Change-Id: Ib1ba1d5021797b645c29ac296752d844d0935964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384080
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-13 06:59:39 +00:00
Moritz 81daf8e563 Use package:record_use
- Rename resource identifiers in the VM to usage recordings.
- Use package:record_use for serialization.
- Rename and use the experimental flag for this feature.
- Recognize tear-offs and top-level methods as well.

Next steps:

- Add constant instance recording.
- Expose API in package:native_assets_cli's link callback.

TEST=pkg/vm/test/transformations/record_use_test.dart

Change-Id: I8af3625165f78925ae943711245af93a239d1012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
2024-09-12 08:47:53 +00:00
Alexander Markov ad94d963ed [dart2bytecode] Remove the requirement for dynamic module to have 'main'
TEST=DART_CONFIGURATION=DebugX64 out/DebugX64/dart-sdk/bin/dart pkg/dynamic_modules/test/runner/main.dart -r aot --verbose

Change-Id: I8647822982b051b4846dfe4ed7e51a19ef466cf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384311
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-10 14:37:00 +00:00
Sigmund Cherem 25bc18c3b3 Add support for AOT in dynamic_modules tests
* Introduce steps to execute tests in AOT (using gen-kernel,
  dart2bytecode, and aot compiler)
* Accept using filesystem-scheme to provide dynamic_interfaces.yaml input
* Accept empty dynamic_interfaces.yaml
* Make temporary test changes to get them running:
   * include core types in dynamic_interfaces that we may want to have
     by default
   * rename entrypoint to `main`

Most existing test pass, the two tests that validate that a library
cannot be defined twice fail (expectation is to throw, bytecode ignores
the second definition).

To run locally:
```
./tool/build.py -m release --dart-dynamic-modules create_sdk
DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/dart-sdk/bin/dart pkg/dynamic_modules/test/runner/main.dart -r aot
```

Tested: CL adds additional test coverage, currently ran manually, integrated in CI in child CL
Change-Id: I4868e765855d9951bff160c18b846aa628f5e0b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383928
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-09-10 04:09:21 +00:00
Vyacheslav Egorov af82cadcec [vm] Force inlining of various Struct helpers
Specifically apply prefer-inline to:

* All generated accessors. In general we almost always seem to
select them for inlining through small-accessor heuristic,
but sometimes it does not hit. Marking with pragma ensures
that we are not dependent on specific heuristics to produce
good code.
* Various helpers involved in creating struct instances from
typed data. These we *not* hit by normal heuristics and
consequently not inlined prior to this change. Inlining them
opens possibilities to fully eliminate allocations associated
with `Struct.create(...)` if Struct does not escape.
* Array creation helpers and accessors. They were also not inlined
which meant we were producing unnecessary temporary objects
when reading from inline arrays.

TEST=/vm/dart/ffi_structs_optimizations_il_test

CoreLibraryReviewExempt: no API or behavioral changes
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try
Change-Id: I1650023200446bd5289118777365627ca19d3e5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384261
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-09-09 15:03:09 +00:00
Deepak Aravind 9c906ddfb7 [cfe/ffi]: Removing .address invalid expression in leaf call to prevent errors
Closes https://github.com/dart-lang/sdk/pull/56594

GitOrigin-RevId: e673d9b13aa00a263632bb25b1ae30b143bdc9fe
Change-Id: If7f9dd27846c0cddb19b3e89acd9fb3cd25dc77f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382681
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-08-30 20:15:09 +00:00
Alexander Markov 71efc19cc7 [vm/aot,tfa] Remove support for legacy types from TFA
In addition, with sound null safety there is no difference in subtyping
semantic between 'is' and 'as' type checks, so SubtypeTestKind is also
removed.

TEST=ci

Change-Id: Id75ef6a93b115c44b844ef0a32dc8dca5cc61861
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-30 13:55:34 +00:00
Aravind b5928642ff [vm/ffi] Supporting .address.cast() expression in ffi leaf calls
Closes https://github.com/dart-lang/sdk/pull/56357

GitOrigin-RevId: 605e7d3fa5f4c7ce367539a76402e2e51aa69422
Change-Id: I79524b443326a161afe221d0a2afb6bed5866e59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378221
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-08-28 06:34:09 +00:00
Alexander Markov 365346f4a5 [vm, tfa] Handle all entry point and dynamic module pragmas on a node
Previously, TFA only handled the first pragma on a class/member
and ignored the rest.

TEST=language tests in vm-aot-dyn-linux-debug-x64 configuration

Change-Id: Ib5c7133cef653a7b60799a3205d5a182844ac40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382200
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-08-27 15:57:00 +00:00
Vyacheslav Egorov 196f6c90c2 [vm] Create dart:_compact_hash library.
This opens possibility for other core libraries to access implementation
details of compact hash maps/sets and call special "core-library-only"
methods.

TEST=ci

CoreLibraryReviewExempt: VM only library change
Change-Id: I1d7524932c34e6fbe2428853dd547d58bef2d061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379840
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-08-13 09:20:05 +00:00
Daco Harkes 965234ccbe [vm/ffi] Variable length inline arrays
Adds a new `@Array.variable()` to specify that the last element of
structs is a variable length inline array.

This CL does not add any checks for passing structs with variable
length inline arrays by value or directly calling them with
`AllocatorAlloc.call`. Instead, the implementation defaults to what
C does, allocate as if there are 0 elements in the variable length
inline array.

TEST=tests/ffi/*

CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/55964
Change-Id: I524d8a1d710b1a744b392e05fa884908c3ff1f12
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-06 07:50:49 +00:00
Alexander Markov 4e0b69fbd9 [vm/aot] Improve dynamic interface annotator
Dynamic interface annotator now automatically annotates classes and
members which are used implicitly:

* Targets of redirecting factories.
* Classes and members used in constants.
* Instance fields of classes used in instance constants or
  having a callable const constructor.
* Everything used in the bodies of extendable mixin declarations and
  mixin classes.
* Possible dispatch targets of instance calls
  (overrides/implementations).

Front-end server now also exposes '--dynamic-interface' option,
similar to gen_kernel tool.

Also, this change includes a couple of minor fixes:
* Typo in ast.dart.
* In the front-end server, additional dill file specified with
  '--import-dill' option is not ignored when '--link-platform' is
  also used.

TEST=pkg/vm/testcases/transformations/dynamic_interface_annotator

Change-Id: I705b64efb1834dec6e0bdc5873025607f3472139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377761
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-07-30 16:24:51 +00:00
Stephen Adams 175dc05db3 [dart2js, pkg/vm] Recognize more BuilderInfo methods.
An upcomming change to protobufs adds a few more BuilderInfo methods
that 'define' fields.

TEST=existing

Change-Id: I78be355ea1458a6a0f2619c63e3ff5838b527533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377742
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-07-29 20:54:38 +00:00
Daco Harkes 4730365bde [native_assets] Don't tree-shake vm:ffi:native-assets library
Adds a `pragma('vm:entry-point')` to the synthesized library and makes
the tree-shakers respect that pragma on `library`s.

TEST=tests/ffi/native_assets/asset_relative_test.dart

Bug: Found in g3.
Change-Id: I1bc63b42ab867a5f1d2e7f9da4842de59f3d5c1d
Cq-Include-Trybots: dart/try:vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-msan-linux-release-arm64-try,vm-tsan-linux-release-arm64-try,vm-ubsan-linux-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377442
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-07-29 10:29:29 +00:00
Jason Simmons e6078ad383 Add dart:concurrent to the list of core libraries used by the Fuchsia flutter_runner
See https://github.com/flutter/flutter/issues/151587

TEST=Flutter CI

Bug: https://github.com/flutter/flutter/issues/151587
Change-Id: Id1eb6410ea34ae164badaed6e94fed6147344a1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375440
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2024-07-11 20:43:12 +00:00
Jason Simmons 7042d5aa5e Add dart:concurrent to the Fuchsia Dart runner's list of core libraries
See https://github.com/flutter/flutter/issues/151587

TEST=local builds of Flutter targeting Fuchsia
Change-Id: I712ecb28661496f0e4be5091b1ad97d1e3cd28f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375360
Commit-Queue: Jason Simmons <jsimmons@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-07-11 16:07:40 +00:00
Alexander Aprelev d2bc055651 [vm/shared] Add 'dart:concurrent' core library.
This brings Mutex and ConditionVariable classes to guard access to shared variables.

TEST=shared_test, shared_primitives_test
BUG=https://github.com/dart-lang/sdk/issues/55991
CoreLibraryReviewExempt: dart:concurrent library is experimental, restricted to main/dev channels, vm-only at this point.
Change-Id: I64ca7a0434cbe0079976133ccbf9de2dd4c0d7b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372181
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-07-10 19:45:29 +00:00
Johnni Winther c17e9c116e [cfe] Clean up backend imports
This updates backend imports to use reexports from api_prototype
or api_unstable.

TEST=existing

Change-Id: I8d9d1c76ef72c709c578acac5497064710ee5579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373462
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-07-08 11:32:30 +00:00
Jens Johansen 11e1c32467 [CFE] Make file tracking more explicit; step towards hopefully getting rid of CompilerContext.current
TEST=Existing tests.

Change-Id: Ic403670fd0de954fe8827a54c61f7f02ab08fa85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373742
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-07-08 10:46:13 +00:00
Alexander Markov efab897725 [vm,aot] Fix type check in implicit setter of a covariant field
Inferred type of a covariant field should not be used as
an argument type of an implicit setter, as setter of a covariant
field performs a type check before assigning value to the field.

Correct such uses of covariant field types in unboxing
and AOT type propagation in order to avoid incorrect removal of
a type check in the implicit setter of a covariant field.

TEST=runtime/tests/vm/dart/regress_56051_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56051

Change-Id: I55bfedfd96e918aac9597706c6eab1b81e1202ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372721
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-25 14:34:20 +00:00
Johnni Winther 8df57398c9 [cfe] Move src/fasta/ subfolders to src/
Part of removing uses of 'fasta'.

TEST=existing

Change-Id: Ice027678e11b7da8c1a7e756a1e1c8c8284722bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372623
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-06-25 10:05:21 +00:00
Alexander Markov 6ca015ab20 [vm] Cleanup obsolete pragma vm:non-nullable-result-type
Since sound null safety, 'vm:non-nullable-result-type' pragma is
no longer useful as the same information is conveyed by a non-nullable
return type.

TEST=ci

Change-Id: Ie6a61aca38cfea47cb005b12ca7f0d7631791024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372200
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-20 20:24:44 +00:00
Johnni Winther e40cad30a3 [cfe] Move fasta/codes/ to src/ and rename to cfe_codes*
Part of removing uses of 'fasta'.

TEST=existing

Change-Id: Ibf144a126d8ff4ba15b6cfd2c4fb898e9a499362
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371685
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-06-20 09:36:39 +00:00
Alexander Markov 0c9067c626 [vm,aot] Preliminary support for dynamic interface in AOT
TEST=runtime/tests/vm/dart/dynamic_module_pragmas_il_test.dart

Change-Id: I6efd24f55726db858711d5f77beabf5659e288a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371563
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-18 14:31:24 +00:00
Alexander Markov 6ab01427bd [pkg/vm] Consolidate kernel compilation options to an object
TEST=ci

Change-Id: Ic9a8801bff140b1393decde61917e8c61ab1945d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370721
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-10 22:56:50 +00:00
Alexander Markov 9a3ca8ffd4 [vm,dart2wasm,tfa] Support dynamic interface in TFA
TEST=pkg/vm/testcases/transformations/type_flow/transformer/dynamic_module_extendable.dart

Change-Id: I6ef43053d86b1a12259f1cb4d0b542c9519591f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370143
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 17:28:10 +00:00
Alexander Markov 17e12879fc Dynamic interface yaml file
TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart

Change-Id: Ib620a98b19067c51d913b499274bfed9aaa576f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370065
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 16:09:54 +00:00
Johnni Winther 5d8d7941ac [cfe] Remove unnecessary use of Nullability.legacy
TEST=existing

Change-Id: I53b749c53e5f742d778c07571aafb7aff6325c9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368560
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-30 08:10:29 +00:00
Alexander Markov 345b437179 [vm, dart2wasm, tfa] Do not infer nullable return type when static type is non-nullable
With sound null safety, implicit "return null" at the end of function
should be taken into account only if return type is nullable.

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

Issue: https://github.com/flutter/flutter/issues/148617
Change-Id: I209fc9a3b10639fd4024d4b1807591498349e1f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367980
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-05-23 18:19:40 +00:00
Vyacheslav Egorov 945153584c [dartdev] Add --depfile option to dart compile
I would like to add an option to our BUILD
files to precompile gen_kernel and
compile_platform to speedup iteration cycles
when working on core library changes.

To make this robust I would like to use
depfile to track dependencies and know
when compile_platform should be
recompiled.

TEST=pkg/dartdev/test/commands/compile_test.dart
R=kustermann@google.com

Change-Id: Id674f7353342c8275a8a0c4a70e3f5eaeb7f05d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367023
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-05-23 12:58:29 +00:00
Martin Kustermann d63a5f2a04 [dart2wasm]/[vm] Use inferred return types of methods in dart2wasm
* Make TFA annotate members with inferred return types
  => We introduce new `vm.inferred-return-type.metadata`
* Make dart2wasm use inferred return types for wasm signatures

Issue https://github.com/dart-lang/sdk/issues/55668

TEST=Updated expectation files.

Change-Id: If2478255c2bb2633348f475b157f28581481578f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366540
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-05-17 10:30:31 +00:00
Martin Kustermann 05df51c962 [vm] Use newer language version in package:vm which removes some unnecessary casts
TEST=ci

Change-Id: Ic1218bddf1879054f1d35ac550224a294d03cda8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366664
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-16 08:57:40 +00:00
Johnni Winther ae03b57cbb [cfe] Remove .isNonNullableByDefault from package:kernel
This removes the .isNonNullableByDefault properties and similar from
the AST nodes in package:kernel. NNBD is now always enabled so these
properties are trivial.

TEST=existing

Change-Id: I75ca0551ac4b5910ea63530dd0c9c2e68bd01aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366320
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-05-15 08:31:38 +00:00
Johnni Winther 310775bd43 [cfe] Remove isNonNullableByDefault argument from messages
Legacy libraries are no longer supported so nullabilities are always
shown in messages.

TEST=existing

Change-Id: Ic1a444c3f5d98baff70a60a2ad0d316d487ea250
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365824
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-05-14 09:32:01 +00:00
Vyacheslav Egorov 04cc5098ab [vm] Enable test pattern (a&b == 0) fusion in AOT on X64/ARM64
Previously we would only fuse this pattern for Smi operations
which (almost) never happens in AOT. This CL enables fusion
for Int64 operations as well.

The implementation is limited to X64 and ARM64 for now
because implementing it on 32-bit platforms is somewhat
cumbersome.

Issue https://github.com/dart-lang/sdk/issues/55522

R=alexmarkov@google.com
TEST=vm/cc/IL_TestIntInstr,vm/dart/test_int_pattern_il_test

Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try,vm-aot-linux-debug-simriscv64-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-simriscv64-try,vm-linux-release-ia32-try
Change-Id: I62a482640db45befac6b0b78850f23a8cc624c75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365463
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-05-11 08:53:29 +00:00
Martin Kustermann bb044733cd [vm]/[dart2wasm] Fix list factory specialization code
The list factory specialization code can only know constant values
passed to `growable: <xxx>` if the variables are local and not
parameters.

TEST=corelib/list_factory_specialization_regression_test

Change-Id: I2c425108fd266fea6b443a7adee86c5a2b33a4d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365584
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-05-08 08:59:01 +00:00
Alexander Markov 9ee25d3ce1 Cleanup unsound mode from pkg/vm, frontend_server and dart2native
TEST=ci

Change-Id: Ica8b8b68f69e8f4a8cd5af3375da4a9ff0947c35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-04-29 14:18:01 +00:00
Daco Harkes 94890c86c7 [vm] Resource Identifier fix loading units
The loading units were taken from the definitions instead of the
references.
This CL fixes that and adds test cases.

Add some doc comments and references to TODOs.

TEST=pkg/vm/test/transformations/resource_identifier_test.dart

Change-Id: I59a640344206555ae1b190521ee3e36d52199700
Cq-Include-Trybots: dart/try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-win-release-try,pkg-win-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364103
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Moritz Sümmermann <mosum@google.com>
2024-04-26 14:49:20 +00:00
Alexander Markov 29b4e5bff5 [vm] Unsound mode cleanup: remove legacy types from VM-specific kernel transformations
TEST=ci

Change-Id: I1de94863ed0c66497c9487fb4a9edf6e6d91ea5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364520
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-04-26 13:50:19 +00:00
Daco Harkes 4b66657b98 [vm/ffi] address of operator for FFI leaf calls
During FFI leaf calls, the Dart GC will not run. This means that we
can pass pointers into `TypedData` to FFI calls that take `Pointer`
arguments.

After this CL, we have three types of arguments that can flow into
`Pointer` argument in an FFI call:
* `Pointer`.
* `TypedData`: Any typed data including views.
* `_Compound`: A TypedData/Pointer and an offset in bytes.

The is only possible for `@Native external` functions, `asFunction`
does not support passing in `TypedData`. (See related GitHub issues
for discussion. TLDR: FFIgen should generate bindings without config.)

`.address` expressions on `TypedData` and `Array` elements do _not_
introduce bounds checks, even though `TypedData` and `Array` have
bounds information. E.g. `ffiNative(Uint8List(10)[20].address)` does
not throw.

Implementation details:

The CFE analyzes call-sites to `@Native external` functions. If the
arguments are `.address` expressions, it transforms the call site to
pass the compound or `TypedData`. If an additional offset needs to be
applied, the CFE constructs a new `_Compound` with the correct offset
in bytes.

The CFE then also creates a new `@Native external` function which have
`TypedData`s and `_Compound`s parameters. To avoid name clashes, these
functions are postfixed with `#` and `P`, `T`, or `C` for each Pointer
parameter.

TEST=pkg/vm/testcases/transformations/ffi/address_of_*

In the VM, `TypedData` arguments are passed as tagged values, and the
address is loaded inside the `FfiCallInstr`. `_Compound` arguments
turn into two IL definitions, one for the `TypedDataBase` (tagged),
and one for the offset in bytes (unboxed). The address is then loaded
inside the `FfiCallInstr` and the offset in bytes is applied.

Adding the offset in bytes required an extra temp register for ia32.
Also, it uncovered that the temp register in arm32 was conflicting
with the argument registers. However, TMP should suffice instead.

TEST=tests/ffi/address_of_array_generated_test.dart
TEST=tests/ffi/address_of_struct_generated_test.dart
TEST=tests/ffi/address_of_typeddata_generated_test.dart

Closes: https://github.com/dart-lang/sdk/issues/44589
Closes: https://github.com/dart-lang/sdk/issues/54771

CoreLibraryReviewExempt: VM only, unsupported in dart2wasm
Change-Id: I01fb428cfd6f9096a34689c2819c124a8003cb6b
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360882
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-04-25 10:06:16 +00:00
Alexander Markov 778a413fa6 [tfa] Fix crash when building field guard summary with captured receiver
When building a field guard summary, field initializer is not included
into the body. So field initializer AST should not be visited to
calculate captured variables and field guard summary
should not have a captured reveiver.

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

Issue: https://github.com/flutter/flutter/issues/147239
Change-Id: I717e942c0174294fda68a8c1ce946f73095e7a17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364203
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-04-23 22:01:29 +00:00
Alexander Markov 6d4817b147 Disable --no-sound-null-safety in 'dart compile', front-end server and gen_kernel
Change 'dart compile', front-end server and gen_kernel tools to reject
--no-sound-null-safety option as unsound mode is no longer supported.

TEST=ci

Change-Id: I4f6e87865bf206a27958caee4088272b4e397608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-04-18 13:34:17 +00:00