Commit Graph

561 Commits

Author SHA1 Message Date
Ankit Ranjan 6de2588d56 [vm/ffi] Migrate legacy multi-test files to Process.run
Migrates vmspecific_enable_ffi_test.dart and
abi_specific_int_incomplete_aot_test.dart away from legacy multi-test
markers. Since these tests verify VM/gen_snapshot compile-time errors
(not CFE errors), they cannot use // [cfe] expectations. Instead, they
now spawn a subprocess and verify the expected error is produced.

- vmspecific_enable_ffi_test: Runs helper with --enable-ffi=false, checks for error
- abi_specific_int_incomplete_aot_test: Compiles helper with `dart compile aot-snapshot`, checks for error

Both tests self-spawn AOT tooling (gen_snapshot) or the JIT `dart` CLI,
so they only run on the dartkp host bots and are skipped elsewhere
(ia32, android, fuchsia, qemu) via tests/ffi/ffi.status.

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

Change-Id: Ib2482c3172b20a4366f984da33544fc515b540c4
Cq-Include-Trybots: dart/try:vm-aot-android-debug-arm64c-try,vm-aot-android-debug-arm_x64-try,vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-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-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Ankit Ranjan <ankitranjandev@gmail.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-06-11 07:25:59 -07:00
Alexander Aprelev 8f1a38f07b [vm/isolate_api] Ensure isolate acquisition fails gracefully when target isolate is exiting.
Introduce `is_acquirable` isolate property that tracks whether isolate can be entered, avoid a `pool_` check that does not work correctly as isolate being shutdown.

BUG=https://github.com/dart-lang/sdk/issues/63515
BUG=https://github.com/dart-lang/sdk/issues/63514
TEST=ci

Change-Id: I84577ad082d87ead8cdb9f591fabdf918e2f4bd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509221
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-06-10 09:59:06 -07:00
Shikhar Soni 93ca44b048 [ffi] Add DynamicLibrary.openFromAssetId
Adds a new API `DynamicLibrary.openFromAssetId` to `dart:ffi` that
allows opening dynamically loaded libraries using their native asset IDs
instead of physical file paths.

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

TEST=./tools/test.py -n vm-aot-linux-debug-x64 'ffi/native_assets/asset_*'
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-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-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
R=vegorov@google.com
Change-Id: Ic617cb0906d1688d2d080dae7d1e08ee58b4c8d6

CoreLibraryReviewExempt: VM-only
Change-Id: Ic617cb0906d1688d2d080dae7d1e08ee58b4c8d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507180
Auto-Submit: Shikhar Soni <shikharsoni@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2026-06-10 09:49:30 -07:00
Alexander Aprelev 4f2ee94e20 [vm/isolate_api] Fix thread-starting race in threading_test.
Fixes https://github.com/dart-lang/sdk/issues/63526
TEST=ci

Change-Id: I7e0a52d3c5a7c04c1d853f769544547758c49545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509541
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-06-10 09:37:00 -07:00
Ryan Macnak fc750ac8e0 [build] Remove unsigned executable memory permissions from the AOT runtime on Mac.
Snapshots are now generally signed Mach-O dylibs loaded by dlopen, instead of ELF files mapped executable by the VM's loader.

TEST=ci
Change-Id: Id19877bed0bd0282b320f070904a848b0c076a54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-01 07:21:29 -07:00
Alexander Aprelev 02b30d5275 [vm/shared] Implement Isolate pinToCurrentThread, isPinnedToCurrentThread.
TEST=threading_pinning_test

Change-Id: I9a80543a06dbf51c070fed5c0e64eeba247497de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497126
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-29 07:58:23 -07:00
Alexander Aprelev 527d529493 [vm/shared] Implement Isolate runEventLoopSync.
TEST=ffi/threading_runeventloop_test

Change-Id: I2061d10d14bcdd589a4a9893f122620f8d0a4e7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497100
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-28 11:38:29 -07:00
Alexander Aprelev 52fc4ee1eb [vm/fuchsia] Skip new test on fuchsia.
The test requires experimental shared data flag, which can't be passed to gen_snapshot on fuchsia at the moment.

Fixes https://github.com/dart-lang/sdk/issues/63462
TEST=ci

Change-Id: I96c5847b17625b874027e468d99a1f492fa5d17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506701
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 14:08:42 -07:00
Alexander Aprelev 488ba69e41 [vm/shared] Introduce isolate event loop handling dart api.
Implement api methods to create and shutdown isolates from IsolateGroup-bound callbacks (normally invoked from native code), run dart code on such isolates.
The rest of the api is not implemented yet.

TEST=tests/ffi/threading_test.dart
BUG=https://github.com/dart-lang/sdk/issues/62407
CoreLibraryReviewExempt: vm-only change to isolate library
Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486522
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 11:31:11 -07:00
Martin Kustermann 84704290ab [vm] Change various external FFI declarations from Object to Object?
The C side can return any object, including `null`, we should therefore
change those declarations to return top type / `Object?`.

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

TEST=https://dartbug.com/63411

CoreLibraryReviewExempt: Internal only changes
Change-Id: I6478e39113fba5d422059de62b88fe738ddbfc05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504920
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-20 02:28:18 -07:00
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00
Alexander Aprelev 00cda4d60f [ffi/isolate_group] Move IsolateGroupBound callbacks from isolate to isolate group.
This allows creation of isolategroup-bound callbacks when isolate is not available. For example, to support proposed Isolate::onEvent/Isolate::handleEvent api https://github.com/dart-lang/language/blob/main/working/333%20-%20shared%20memory%20multithreading/shared_native_memory.md#additional-isolate-apis.

BUG=https://github.com/dart-lang/sdk/issues/63291
TEST=isolate_group_bound_callback_test

CoreLibraryReviewExempt: vm ffi-specific comments changes
Change-Id: I9a757a39ba8e152db64f59a66d337ca672103277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499661
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-05 08:37:06 -07:00
Johnni Winther 4cfd3da965 [cfe][PrimaryConstructors] Update reporting for mixin class with initializer/constructor body
This update the position used for reporting a mixin class primary constructor with a primary constructor by declaration with initializers or an explicit body. Since mixin classes can have simple constructors, it makes more sense to report the error on the offending syntax than on the primary constructor itself.

The CL also updates the offset used for field initializers to the field name rather than the `=`. This align the offset with what is used for property sets.

Change-Id: Id5ccd55536b2c3b9d9336d2854772c1bcc5a175a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-04-01 01:17:28 -07:00
Alexander Aprelev 46cf07fe35 [vm/shared] Ensure scratch register is requested as temp for LoadStaticFieldInstr.
TEST=tests/ffi/many_listener_callbacks_test/5 on vm-ffi-qemu-linux-release-arm

Change-Id: I6a60220bce6dbc760e3a027b1b023c59dff36ba7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-11 13:11:32 -07:00
Shanu Kumawat dba9cb988c [analyzer/ffi] Check @Native on extension members
Validate @Native annotations on extension and extension type instance
members by modeling the receiver as the first Dart parameter when
checking the full function type against the FFI signature.

This aligns analyzer diagnostics with CFE behavior for extension-like
members (issue #60250), while preserving the pointer-receiver
restriction diagnostic behavior introduced by #62716.

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

TEST=tests/ffi/static_checks/regress_60250_test.dart
TEST=tests/ffi/static_checks/regress_62716_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

R=davidmorgan@google.com

Change-Id: I688f338f47aa1f6670afce2cb4d4d4f88e3816ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482160
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Shanu Kumawat <shanu.kumawat.dev@gmail.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-03 01:03:36 -08:00
Alexander Aprelev f3bc347448 [core/shared] Allow for BigInt to work in isolategroup-bound callbacks.
Introduce runtime checks for BigInt to allow it being used as deeply immutable class.

TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Bug: https://github.com/dart-lang/sdk/issues/62601
Change-Id: I343862bdf5603be571d3bf937261dd61aca9ca0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-02 13:52:34 -08:00
Alexander Aprelev e9229a0585 [core/shared] Allow http ContentType to work in isolategroup-bound callbacks.
TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: I2262f22f0bca4ef35add27c54cc1a84b3f5bbd76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478221
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-02-27 07:43:14 -08:00
Daco Harkes 8852aa5c19 [analyzer/ffi] Fix analyzer crash
TEST=tests/ffi/static_checks/regress_62716_test.dart

Fixes: https://github.com/dart-lang/sdk/issues/62716
Change-Id: I8abc006cd1e7274089ea618c970aacd0bc2267e4
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,analyzer-win-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,front-end-nnbd-mac-release-x64-try,front-end-nnbd-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483241
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2026-02-24 05:01:40 -08:00
Daco Harkes 86880a4cab [cfe/ffi] Don't transform methods if wrong number of arguments
TEST=tests/ffi/static_checks/regress_62693_test.dart

Closes: https://github.com/dart-lang/sdk/issues/62693
Change-Id: Ifa9228568a4b01f162df727f80cbb923d148d043
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,analyzer-win-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,front-end-nnbd-mac-release-x64-try,front-end-nnbd-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482760
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2026-02-23 03:50:41 -08:00
Shanu Kumawat b6920ec07c [vm/ffi] Migrate 9 static check tests to new format
Converts the old multitest format (using //# markers) to the new format with explicit [analyzer] and [cfe] error expectations for the following tests:

- regress_44986_test.dart
- regress_46085_test.dart
- regress_47673_2_test.dart
- regress_51041_test.dart
- vmspecific_function_callbacks_negative_test.dart
- vmspecific_regress_38993_test.dart
- vmspecific_static_checks_ffinative_test.dart
- vmspecific_static_checks_varargs_test.dart
- vmspecific_variance_function_checks_test.dart

Updates #60212
TEST=tests/ffi/static_checks/
R=omersa@google.com

Change-Id: I92ea8d3e9ad750b17a7c0fa15f249f55936739cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478460
Auto-Submit: Shanu Kumawat <shanu.kumawat.dev@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-11 11:06:39 -08:00
Liam Appelbe 4679c040c6 [vm] Sync ffi callbacks can enter owned target isolate
Adds a new code path for NativeCallable.isolateLocal invocations. If
the current thread is not entered into any isolate, but owns the
target isolate, then it enters the target isolate, invokes, then exits
the isolate.

Fixes: https://github.com/dart-lang/sdk/issues/61623
TEST=tests/ffi/function_callbacks_isolate_ownership_test.dart
Change-Id: I401f185fadf7d2a55190dafd15387e1c418c67c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-02-05 01:29:23 -08:00
Alexander Aprelev 37b14e84f4 [core/shared] Allow for RegExp to work in isolategroup-bound callbacks.
TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: I3c4734464e1902458edb4a03f5a9e9384509356b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-30 11:16:13 -08:00
Alexander Aprelev 27d4f2c79d [core/shared] Mark _CopyingBytesBuilder._emptyList shared
This enables use of BytesBuilder in isolategroup-bound callbacks.

TEST=run_isolate_group_run_test
CoreLibraryReviewExempt: this adds vm-specific pragma
Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: Ic73887af099e6a7636e939d378dbe08a2f0c8f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476601
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-29 14:31:47 -08:00
Alexander Aprelev 9d92474635 [vm/shared] Allow for print to work in isolategroup-bound callbacks.
TEST=ci
CoreLibraryReviewExempt:no-op split of printToZone into getter/setter, with different implementation only for vm.
Change-Id: I915c9330458cb2ba3f0f13ab109af12bacc233d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475926
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-28 08:52:08 -08:00
Alexander Aprelev eb75c53d95 [vm/shared] Perform deeply-immutable initialization runtime check.
When an initial value is assigned into a class tagged as deeply-immutable, perform runtime check of that value. This is needed to support proper initialization of the closures as part of deeply-immutable classes.

BUG=https://github.com/dart-lang/sdk/issues/61962
TEST=run_isolate_group_run_test

Change-Id: I550746c0d22ca06ffb89959e8384cc9e6d28d590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-14 08:42:22 -08:00
Ryan Macnak cee7000c1a [test] Enable TSAN thread leak detection for most tests.
Disable for tests that use dart:io's exit.

Add missing thread joins to cc tests.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/41811
Change-Id: Id4e1a468a986c886fb5ae9e9677b4d8d0281cc79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468880
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-05 10:04:25 -08:00
Daco Harkes b277407152 [ffi][cfe] Support @Native() external Array<Struct> fields
For structs, we were already loading the size of the struct at
runtime for the size of the memcopy. This CL makes that work for
the `Array`s as well.

TEST=pkg/vm/testcases/transformations/ffi/regress_62087.dart
TEST=tests/ffi/native_assets/asset_absolute_test.dart

Closes: https://github.com/dart-lang/sdk/issues/62087
Change-Id: I15a5796d713879a613971e080d18101111704b9b
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-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-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464706
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-01-05 08:01:26 -08:00
Alexander Aprelev a949c74530 [vm/shared] Ensure stores into shared static variables are checked.
Closures going into shared variables in particular have to be confirmed to capture appropriate values.

BUG=https://github.com/dart-lang/sdk/issues/62179
TEST=run_isolate_group_run_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-aot-dyn-linux-debug-x64-try
Change-Id: I27416773fd77077018739ea4dbcc6e4695e67be8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469103
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-22 07:53:44 -08:00
Alexander Markov 9a049d5b2d [gardening] Mark ffi/function_structs_by_value_generated_args_native_test test as slow on simarm64_arm64
Fixes https://github.com/dart-lang/sdk/issues/62230

Change-Id: If4a30a2d115748e6cc3272d71063e62251dc6358
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467660
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-12-11 11:33:32 -08:00
Alexander Aprelev 2c715e92b6 [vm/sdk] Use FinalThreadLocal for Iterable toString.
This allows use of toString in isolategroup-bound callbacks.

BUG=https://github.com/dart-lang/sdk/issues/61030.
TEST=ci
CoreLibraryReviewExempt: effectively vm-only change
Change-Id: Iccdc218716cbbe2346aa85bb6134f4129debe057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451841
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2025-12-11 09:32:41 -08:00
Alexander Aprelev f1a1f6a986 [vm/shared] Maintain visited set when assessing immutability in closures.
Fixes https://github.com/dart-lang/sdk/issues/62178
TEST=run_isolate_group_run_test

Change-Id: Ia722ef6417e5cf2506bbc70d55299ce1ec04d13f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466842
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-12-10 09:19:04 -08:00
Alexander Aprelev 170df25b66 [vm/shared] Prohibit capturing of 'late final' variables by isolategroup-bound closures.
TEST=run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/62181

Change-Id: I50037ede337367020176262b98d2c2fd100b050a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466820
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-10 08:29:57 -08:00
Alexander Aprelev f04ff0410e [vm/shared/bytecode] Support use of vm:shared in bytecode/interpreter.
Fixes https://github.com/dart-lang/sdk/issues/62032
TEST=ci

Change-Id: I80600d81ee73b16338a337f7139bf4e898af6eca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466124
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-05 21:38:41 -08:00
Ryan Macnak 13507d2594 [test] Don't test the profiler in a test with a large number of threads.
TSAN's vector clocks become more expensive as the number of threads that touch a variable increases. The Mac/Windows/Fuchsia profilers will sample threads by suspending it and accessing it from another thread.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/61960
Change-Id: I2bfb7908af8ff864bc52577bacbb89a4778150d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465980
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-03 13:56:31 -08:00
Alexander Aprelev f2475606c6 [vm/shared/test] Add Encoding.getByName test when used in isolategroup-bound context.
Follow-up to https://dart-review.googlesource.com/c/sdk/+/461185/comment/323d39ca_c22b0862/

TEST=ci

Change-Id: Iea9c68c0761a63804e87d9d2f54f1571ff983cd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465962
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-12-03 11:32:00 -08:00
Alexander Aprelev 4bc746a1cb [sdk/vm] Make Encoding._nameToEncoding map const.
This allows use of Encoding class in isolategroup-bound callbacks.

TEST=run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/61541

Change-Id: Iaa545bc2df7ffd98e9fc09381826c566f4b833ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461185
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-12-02 05:51:22 -08:00
Alexander Aprelev c7fc60c78b [sdk/vm] Use FinalThreadLocal to store _Random singleton object.
This allows use of Random in isolategroup-bound callbacks.

BUG=https://github.com/dart-lang/sdk/issues/61541
TEST=run_isolate_group_run_test

Change-Id: Id847e900be05f2866386c025b1796b3f34c1e8df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461940
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-01 11:37:01 -08:00
Alexander Aprelev d793fc0ed5 [sdk/vm] Make Base64._inverseAlphabet shared.
This is so that Base64 decoding is available for isolategroup-bound callbacks.

TEST=run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/61541
CoreLibraryReviewExempt: vm-only pragma
Change-Id: I30b8f0c36b0f980a1f5a13cec3cb07e214324ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461180
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-01 10:20:11 -08:00
Daco Harkes e3882c8a77 [ffi] Address lints in tests
Change-Id: I30b4aa4a6195bac96ebe3f3f8e9c07acdec9b2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464481
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2025-11-25 08:03:02 -08:00
Daco Harkes ef30b3cc99 [vm/ffi] Test and Document NativeFinalizer Dart API limitations
Explicitly allow calling `Dart_DeletePersistentHandle` and
`Dart_DeleteWeakPersistentHandle` from `NativeFinalizers`.

And exercise this behavior in tests.

TEST=tests/ffi/vmspecific_native_finalizer_api_calls_test.dart
TEST=tests/ffi/vmspecific_native_finalizer_isolates_test.dart

Closes: https://github.com/dart-lang/sdk/issues/62076
CoreLibraryReviewExempt: VM-only. Doc-only.
Change-Id: I4915092e4b13cc55d0d48e7977149fb32059b854
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-dyn-linux-debug-x64-try,vm-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-asan-linux-release-x64-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-win-debug-x64-try,vm-reload-linux-debug-x64-try,vm-gcc-linux-x64-try,vm-appjit-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-dyn-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464180
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2025-11-25 02:50:47 -08:00
Alexander Aprelev d6ed8432a2 [sdk/vm] Use FinalThreadLocal for caching double toString values.
This allows use of double.toString in isolategroup-bound callbacks.

BUG=https://github.com/dart-lang/sdk/issues/61541
TEST=run_isolate_group_run_test

Change-Id: I14443221ffda6f2e639cdbaeea4a2e460a6f42a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460960
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-11-19 09:58:43 -08:00
Alexander Aprelev b4e0dc2f09 [gardening] Fix status file entry for many_listener_callbacks_test.
Fixes https://github.com/dart-lang/sdk/issues/61733
TEST=ci

Change-Id: Ib8b4862c467d81c1c389d46c6a56378fc74180b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460482
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-11-07 15:35:07 -08:00
Nate Biggs 4e5f1d719e Mark ffi/many_listener_callbacks_test as ExtraSlow on relevant configs.
Bug: #61733
Change-Id: I22f800cd9c5faddc4044d77b4e52b78113d6a0a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457920
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-10-28 09:51:14 -07:00
Alexander Markov 82144f037b [tests] Reduce number of threads in ffi/many_listener_callbacks_test
Issue: https://github.com/dart-lang/sdk/issues/61733
Change-Id: I3d6ef801f7c7f24d56b129ac4f169a7b2a2c5448
Cq-Include-Trybots: luci.dart.try:vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-mac-release-simarm64_arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455464
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2025-10-16 18:15:14 -07:00
Liam Appelbe e0a8637123 [test] Mark many_listener_callbacks_test as slow
Also remove the hot reload skip for this test. Should have done this in
https://dart-review.googlesource.com/c/sdk/+/449160.

Fixes: https://github.com/dart-lang/sdk/issues/61532
Change-Id: Ic49805c0b93570dad94c8ec55f6ba7411b495a1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452340
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-09-29 22:25:21 -07:00
Liam Appelbe 4df2a9515d [vm] Simplify FfiCallbackMetadata locking
Remove the locks in DLRT_GetFfiCallbackMetadata, and switch from
safepoint locks to ordinary locks in FfiCallbackMetadata. This fixes the
deadlock bugs at the cost of reducing thread safety in error cases. Some
cases that would have failed gracefully will now have undefined
behavior.

Also, FATAL instead of no-op if a dead callback is invoked.

Fixes: https://github.com/dart-lang/sdk/issues/61372
Change-Id: Ie09fca3c629ad61b2ffbdd029269338f2706df4b
TEST=CI, particularly many_listener_callbacks_test on reload bot
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449160
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-09-17 18:16:01 -07:00
Alexander Aprelev acc4ee0b1e Reapply "[vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt."
This reverts commit ce9c2d3dd1 and as patchset 2 applies the fix to crash revealed on mac bots.

TEST=isolate_group_bound_lazy_deopt_test

Change-Id: I8aa05a482954dfbd4599d68637287f8b93716ce2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448641
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-09-05 12:13:14 -07:00
Alexander Aprelev ce9c2d3dd1 Revert "[vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt."
This reverts commit e5f66118aa.

Reason for revert: isolate_group_bound_init_test failures on mac bots: https://dart-ci.appspot.com/log/vm-aot-mac-release-x64/vm-aot-mac-release-x64/4425/ffi/isolate_group_bound_init_test/2

Original change's description:
> [vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt.
>
> Iterating over only isolates ignores isolategroup-bound dart code.
>
> Fixes https://github.com/dart-lang/sdk/issues/61326
> TEST=isolate_group_bound_lazy_deopt_test
>
> Change-Id: Ic27679ab7eb37aa2ca703937355dc83d751e0054
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448254
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Alexander Aprelev <aam@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Ieb04abbf1b4a7fbc7637e5a7c3a3dce2010f2101
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448602
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-09-05 09:25:18 -07:00
Alexander Aprelev e5f66118aa [vm/shared] Ensure to iterate over mutators, rather than only isolates during deopt.
Iterating over only isolates ignores isolategroup-bound dart code.

Fixes https://github.com/dart-lang/sdk/issues/61326
TEST=isolate_group_bound_lazy_deopt_test

Change-Id: Ic27679ab7eb37aa2ca703937355dc83d751e0054
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448254
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-09-05 08:41:36 -07:00
Liam Appelbe 1484ea4740 [test] Skip exceptional_return_const_test on Fuchsia
Change-Id: Idc249e027d64095b1951684501fdd9ff4fd92b2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448340
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-09-03 19:07:12 -07:00