Commit Graph

2147 Commits

Author SHA1 Message Date
Tony 08139af589 Add compact AOT patching support and related APIs
- Introduced Dart_SetObfuscationMap to restore obfuscation maps before AOT precompilation.
- Added Dart_AotPatchInstallOptions structure for AOT patch installation options.
- Implemented Dart_AotPatchingEnabled to check if compact AOT patching is supported.
- Created Dart_SetAotPatchKeyCallback for AES key resolution during AOT patch installation.
- Developed Dart_InstallAotPatch for validating and installing encrypted AOT patches.
- Added Dart_FreeAotPatchPayload to free memory allocated for patch payloads.
- Updated runtime_args.gni to include dart_enable_aot_patching flag.
- Added tests for AOT patching functionality and ensured exported symbols include new APIs.
- Refactored existing code to accommodate new AOT patching features and improve error handling.
2026-06-24 03:00:14 +08:00
Nourhan Hasan bd5ccf95d1 [vm/service]: Add OS::SafeReadMemory for macOS using mach_vm_read_overwrite
TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/try:vm-asan-mac-release-arm64-try,vm-dyn-mac-debug-arm64-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-mac-release-arm64-try
Change-Id: I1be990f3debb7e0b7102f54e8c5bec25252756d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507040
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-06-11 11:30:22 -07:00
Nourhan Hasan db905b9711 [vm/service]: Add OS::SafeReadMemory for Windows using ReadProcessMemory
TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/try:vm-asan-linux-release-x64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-arm64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-simarm-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-win-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try
Change-Id: I7afabe66211657139981e18d8b1a14c2081d3f5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506640
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-06-10 10:58:15 -07:00
Ryan Macnak 9b8d908379 Speed up RISCV QEMU testing.
- Skip/delete some large tests.
 - Reduce some large tests.
 - Explicitly choose the CPU features, which seems to be disabling something expensive.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63465
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try
Change-Id: Ifa591d6600da3e20c9de4d123906a7747029df7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509200
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-08 13:27:27 -07:00
Alexander Markov 6b9aecbe5f [vm,aot] Fix parameter type checks in the implicit setters of covariant-by-class fields
Implicit setters of covariant fields (both covariant by declaration and
covariant by class aka generic-covariant-impl) need to perform a type
check of their argument.

It means that inferred type of the field cannot be used as inferred
type of parameter of such setter. This change removes such uses of
an inferred type of the field, which restores parameter type check
which was previously incorrectly optimized out.

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

Change-Id: Ie313dbaab51dff15d60ce4390e7e41bdc66ad59d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-06-03 11:32:28 -07:00
Nourhan Hasan 80f770eb57 [vm/service]: Add _readNativeMemory RPC and OS::SafeReadMemory for safe native memory inspection
- Declare OS::SafeReadMemory in os.h
- Implement using pread64(/proc/self/mem) on Linux and Android
- Add _readNativeMemory VM Service RPC with pre-checks for null
  and address overflow

TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/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-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-arm64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-simarm-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try
Change-Id: Id15a82bf478bc4822c08d7fdf0a5c8bfd71a1fe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505781
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-06-02 23:09:24 -07:00
Ryan Macnak 546bf07f7d [vm] Remove transitions for removing VM isolate.
TEST=ci
Change-Id: I65c315e9efc3cd7b8b47d2c167681986278644da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-02 10:28:10 -07:00
Tess Strickland 4b0a4e0a75 [vm,dyn_modules] Fix vm/cc/Profiler tests for dynamic modules.
The only actual change required to the profiler service is appropriately
retrieving the source position for interpreted frames during processing.

Otherwise, most of the tests just need small changes to account for the
slightly different stack trace generated by interpreted code when
walking the stack as code instead of functions:

* Interpreted code calls the runtime entry DRT_AllocateObject directly
  for slow-path allocation instead of via the AllocateObjectSlow stub.

* The current name for bytecode frames when walked as code starts with
  "[Bytecode]" instead of "[Unoptimized]".

The test vm/cc/Profiler_GetSourceReport is skipped since:

* It tests compiled code-specific features like classifying source
  positions.

* Inserting fake samples for interpreted functions is messier since
  many PC offsets may map to the same source position.

The other skipped tests are specific to inlining and/or optimized
compiled code, so there's no point in running them on interpreted code.

TEST=vm/cc/Profiler

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: I3e73f42b2562eb6e3e73fe8d5c3f14389039ee04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507082
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-06-02 04:50:53 -07:00
Ryan Macnak 201abb5cd1 Reduce sanitizer build set.
Change-Id: Idd5df6ff7c5b4f6bc3ccb0a335df0d332556d6ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508420
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-01 16:57:43 -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
Martin Kustermann 2198d25b1e [vm/testing] Make vm/dart/gc/scavenger_abort_2_test more robust
The test tries to keep fields alive by my making a

  toString() => field1 + field2 + ...

Though some field values don't have a `+` operator (e.g. instances of `class C`).

Improving TFA precision can infer that some of these `+` operations will throw,
which then makes other `+` operations unreachable, which removes usages
of those other fields, which will tree shake those other fields, which
will make the test not test anymore what it's intended to.

=> Make the test more robust by using string concatenation instead.

Change-Id: I80788af516083ea3d78ad910eb394e4b7e122384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507000
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-28 03:49:20 -07:00
Alexander Markov 92b3333613 [gardening] Remove standalone/io/http_client_connect_test from isolate stress-testing
This test has been failing with the following errors on
iso-stress-linux-x64 bot:

[tests/standalone/io/http_client_connect_test.dart] error: [HttpException: Connection reset by peer, uri = http://127.0.0.1:36755/, ]
[tests/standalone/io/http_client_connect_test.dart] error: [HttpException: Connection reset by peer, uri = http://127.0.0.1:46789/, ]
[tests/standalone/io/http_client_connect_test.dart] error: [HttpException: Connection reset by peer, uri = http://127.0.0.1:37003/, ]
[tests/standalone/io/http_client_connect_test.dart] error: [HttpException: Connection reset by peer, uri = http://127.0.0.1:42069/, ]

TEST=ci
Change-Id: Ibebd6fe681ae06a098109557051bc0e8d73e74c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505360
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-21 08:24:43 -07:00
Martin Kustermann f3407a2ce4 [gardening] Skip vm/dart/hash_map_probes_limit_test in reload/rollback mode
Change-Id: I3380328271f458a173a352f3b9df3988b56943fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505240
Reviewed-by: Tess Strickland <sstrickl@google.com>
2026-05-21 05:15:21 -07:00
Slava Egorov bc16ca4d51 [vm] Preserve ThreadLocal value if dart::Thread is reclaimed
dart::Thread object representing Isolate's mutator can be reclaimed when
thread is suspended, so we need to preserve thread_locals on Isolate
itself.

TEST=vm/dart/thread_local_test

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

Change-Id: I7502b9bc67a07fb2e82479d3052740516a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504921
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-20 06:21:29 -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 Markov 4c9d7e54cb [vm,compiler] Fix inlining of generic functions with optional parameters
When checking number of arguments passed by the caller against
number of parameters in the callee, inliner was not taking
"type arguments" argument into account which resulted in
the rejected inline if all optional parameters are passed.

TEST=runtime/tests/vm/dart/inline_generic_functions_il_test.dart

Change-Id: I38d1fd2a1a4aadfb0196e5a472d224e3da3a1562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502800
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-12 06:03:11 -07:00
Alexander Markov da1f06f239 [vm,compiler] Fix loop computation in case of try blocks
If catch block is included into the loop, we should also include
the whole try body as there are implicit control flow edges between
each block in a try body and corresponding catch block.

If try body is not included, analysis of loop invariant loads
could miss conflicting stores and may conclude that certain loads are
loop invariant although they are not.

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

Change-Id: I9d6b73e24554ee3bfbcc722fa59634ea90b00abb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501560
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-08 06:37:30 -07:00
Slava Egorov d2903a568c [vm/io] Range check Filter_Process arguments
Add a check both in the native implementation and on the Dart side (to
avoid throwing uncatchable ApiError).

Simplify native implementation: Dart_ListGetAsBytes has fast path for
byte sized typed data lists, so there is no reason to inline the 
same fast path into the caller.

Reported by Kyounghwan Kim (@drg2533)

TEST=runtime/tests/vm/dart/regress_b508627933_test.dart

Bug: b/508627933
Change-Id: I14c0f5270f143ed2386200241b13313f6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-07 04:18:06 -07:00
Ryan Macnak 5bb366bb9f [gardening] Remove lib/async/future_test from isolate stress test.
Bug: https://github.com/dart-lang/sdk/issues/63333
Cq-Include-Trybots: luci.dart.try:iso-stress-linux-arm64-try,iso-stress-linux-x64-try
Change-Id: I9521563be52a902db0720b98c345d7502324d8b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501200
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-06 13:13:46 -07:00
Alexander Markov 69b84908a5 [vm,arm] Fix for crash in Subtype6TestCache on 32-bit arm
On 32-bit arm, when generating subtype test cache stub,
[delayed_type_args_reg] could be the same as [TypeTestABI::kInstanceReg]
(due to lack of registers).

As a result, when loading delayed type arguments from an instantiated
generic closure, [TypeTestABI::kInstanceReg] is eagerly overwritten,
which results in garbage delayed type arguments.

With the linear probe cache this would cause repeated cache misses.
With the hash-based cache this would cause a crash.

Bug: b/507666702
Change-Id: I1093f9277d874154a121ef644ecd7aa76320f789
TEST=runtime/tests/vm/dart/regress_b_507666702_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500842
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-06 06:41:04 -07:00
Alexander Markov 8363860ee7 [vm,compiler] Fix handling of the argument of _simpleInstanceOf
The 2nd argument of _simpleInstanceOf call is always a
Constant (type). However, a Redefinition can be inserted in the middle.

So, instead of ArgumentAt(1)->AsConstant()->value() it is
more safe to use ArgumentValueAt(1)->BoundConstant() as
BindsToConstant/BoundConstant unwraps Redefinition(s) via
OriginalDefinition().

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

Change-Id: Ie4a473ebe2deee8562e6634a792f02b0dcefc918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497761
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-04-27 07:38:24 -07:00
Slava Egorov 488f97eb76 [vm] Update ObjectSlots to handle _LinkedHashBase
Generalize code which computes slots map to handle class hierarchies
which include base classes with VM-described layout like
_LinkedHashBase.

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

TEST=vm/dart/heap_snapshot_regress_63180

Change-Id: I32ab0e258e735f745d45f25813177d0f6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-21 04:02:25 -07:00
Ryan Macnak e860a9b0fa [vm, ffi] Emit the FFI callback stub as a raw blob and place it in the Fuchsia package.
Any blob in the package can be loaded as an executable VMO.

TEST=child CL
Bug: https://dartbug.com/52579
Change-Id: I61f7a84453da4da4733c5a70d4d19f0a6652581b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496661
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-20 11:31:19 -07:00
Alexander Markov 51d1c8923a Reland "[vm,dart2bytecode,modular_aot] Variable-length closure objects"
This is a reland of commit 88496ba1c3

Fixes on top of the original change:

* Closure layout is changed to avoid gap between fixed fields and
  variable-length elements on compressed pointers architecture.
  This gap was causing crashes in the GC when scanning closure
  objects.

* pkg/vm_snapshot_analysis/test/instruction_sizes_test is fixed
  on arm64 by decreasing threshold for detecting size changes.

Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
>  - delayed type arguments;
>  - instantiator type arguments;
>  - function type arguments;
>  - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635

Change-Id: I8685e632e2d0832766ecdc470f3cf9a6b880de48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494243
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-10 06:15:22 -07:00
Alexander Markov 0dfaa16dc7 Revert "[vm,dart2bytecode,modular_aot] Variable-length closure objects"
This reverts commit 88496ba1c3.

Reason for revert: crashes on arm64c

Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
>  - delayed type arguments;
>  - instantiator type arguments;
>  - function type arguments;
>  - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/61572
> Issue: https://github.com/dart-lang/sdk/issues/61635
>
> Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I94c88f8922f6ea49251e942ba791fee714911e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494261
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-04-09 14:12:09 -07:00
Alexander Markov 88496ba1c3 [vm,dart2bytecode,modular_aot] Variable-length closure objects
Extend closure objects with variable number of elements to capture.
This is needed to support capturing multiple independent contexts
after capturing is computed in the front-end.

The following fixed Closure fields are moved into variable-length
elements:
 - delayed type arguments;
 - instantiator type arguments;
 - function type arguments;
 - context.

Number of elements and presence/indices of various type arguments
are encoded into the new length_and_flags field in the Closure.

Most closure objects don't need any of the type arguments so this
change will reduce average Closure object size.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635

Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2026-04-09 12:22:21 -07:00
Ryan Macnak e98e6a1198 [vm] Per isolate group roots accessed via TLS.
Remove special case for null in message snapshots; snapshots are sometimes read or written with no current isolate group.

Currently still all copies pointing into the VM isolate.

TEST=ci
Change-Id: I4d2e35a01880885d4e92e1c623c0f39a35e06065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493866
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-08 15:26:06 -07:00
Tess Strickland 0bbb2ae821 [vm,dyn_modules] Fix/skip vm/cc tests that crash for dynamic modules.
Skip IR or snapshot-related tests when running from bytecode.

TEST=vm/cc/DartAPI_DeepStackTraceInfo
     vm/cc/DartAPI_HeapSampling_UserDefinedClass
     vm/cc/DartAPI_StackTraceInfo
     vm/cc/DartAPI_StackOverflowStackTraceInfoArrowFunction
     vm/cc/DartAPI_StackOverflowStackTraceInfoBraceFunction1
     vm/cc/DartAPI_StackOverflowStackTraceInfoBraceFunction2
     vm/cc/FrameLookup
     vm/cc/Service_LocalVarDescriptors

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: I396a4e8ddacdbb88b3844e4113dc5c4ff6287e30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490083
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-03-26 08:21:00 -07:00
Alexander Markov 17e6648fe0 [vm] Simplify closure instantiation
When instantiating a closure, allocate a new closure object in
the same boostrap native method as checking bounds.

This simplifies code generation and prepares for variable-length
closure objects by removing the only place where closure of unknown
length was allocated in the generated code.

TEST=ci

Change-Id: I9ac51c862081612bca2160699ebe24526d4fc915
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-25 06:59:41 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
Alexander Aprelev 6967e81fb1 [gardening] Reduce test thread concurrency to make sure it passes under tsan.
With new semispace max size set to 4, active mutators count is limited to 2(from standard 16), which puts significantly less stress on sanitizer infrastructure. Reducing isolates count from 20 to 4 still exercises isolate/thread management in the vm.

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

Change-Id: Ibec809625719d5f7ab6525b6b0fa29df4c521b3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487887
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-13 12:16:00 -07:00
Alexander Markov e1db52ab83 [gardening] Skip vm/dart/stream_timeline_to_test on product and reload bots
TEST=ci
Closes https://github.com/dart-lang/sdk/issues/62551

Change-Id: I621c992cd5ed5f0ed7602731b219398a1f48e151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487461
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-12 08:32:01 -07:00
Alexander Markov b979a9086e [gardening] Mark vm/dart/heap_snapshot_regress_49711_test as Slow on reload bots
TEST=ci
Closes https://github.com/dart-lang/sdk/issues/62846

Change-Id: I0eb799f9f08350937e1dab0cd7b1f09776d04e81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487440
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-12 07:57:22 -07:00
Alexander Aprelev 54c5090a65 [gardening] Update stress testing list.
Follow-up to dde4b2475d to fix broken iso-stress-linux bots https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/iso-stress-linux-x64/1876/overview

TEST=iso-linux-stress

Change-Id: Iea60de60fee22ade2d3ec6e95ca08d223e1a7115
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486900
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-10 15:09:21 -07:00
Ryan Macnak b52575161d [vm] Adjust MSAN compile flags to match google3 to reproduce MSAN error in the regexp interpreter.
TEST=msan
Bug: b/489355669
Change-Id: I3ade526a67e5e7d95c8d8862eb92924337057d94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485240
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-04 13:45:22 -08:00
Nate Biggs 159f427938 [vm] Update option for windows priority test.
Use a slightly higher priority than lowest to avoid flaky timeouts.

We avoid using higher priorities than the default because these require
extra permissions and setup.

Change-Id: I69ca93f270697d3e39ef9c0f49184ffb3de32610
Fixes: https://github.com/dart-lang/sdk/issues/62722
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483980
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-27 09:48:51 -08:00
Alexander Aprelev cdf7bf9c78 [vm/shared] Allow const maps in deeply immutable classes.
This relies on runtime check of Map-typed variable initialization.
TEST=kernel_binary_flowgraph_test

Change-Id: Ia9be2644208883739f5896a223dcbe2b59c98114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482021
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-27 07:43:14 -08:00
Slava Egorov d7fa1ced6a [vm] Speedup profile data streaming in AOT
Current implementation of profile data streaming inherited its 
approach to symbolization from the implementation of vm-service's
get{,Perfetto}CpuSamples methods. These methods rather expensive
as they rely on CodeLookupTable to symbolize collected samples, and
constructing CodeLookupTable requires bringing all threads to safepoint
and iterating over old-space to collect code objects. This can take
significant amount of time - especially when old-space is large (e.g.
consider 1Gb+ heaps of Dart Analysis Server).

This CL rewrites profile data streaming to use a completely different
approach in AOT mode where Dart frames are not symbolized eagerly 
and instead stored in the timeline in their raw form: a pair of
an isolate group specific Mapping and a PC value relative to the start
of that mapping. At the end of streaming (or when isolate group
exits) an additional ModuleSymbols packet is emitted which provides
symbolization information for all collected frames. ModuleSymbols
mappings can be cheaply constructed from collected PCs using 
ReversePc lookup tables.

TEST=expanded existing tests

Change-Id: I56ef1dd4c9a17fb0d2e9c24e51f2e4656a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482782
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-25 04:48:51 -08:00
Ryan Macnak e443b89f23 [vm] Update Irregexp to V8 commit 254cc758346f10be2a7e22e55d90d4defe9cad74.
Includes support for modifier spans and duplicate named capture groups.

Drops the flow graph implementation to ease maintenance.

TEST=corelib/regexp
Bug: https://github.com/dart-lang/sdk/issues/56573
Bug: https://github.com/dart-lang/sdk/issues/61337
Bug: https://github.com/dart-lang/sdk/issues/62349
Bug: https://github.com/dart-lang/sdk/issues/62708
Change-Id: I05640ba945a4fa5476e7ad463738f4f39d842c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 09:54:47 -08:00
Lasse R.H. Nielsen 0a88f4ef73 Remove var or final from parameters.
Removed from `benchmarks/`, `runtime/`, `sdk/`, `tools/` and `utils/`.
(Leaving `tests/`, `pkg/` and `third_party/`.)

CoreLibraryReviewExempt: No real change.
Tested: No test changes for no real code changes.
Change-Id: Ieb42441457ca3d0ea4443dd153ee902ea33b28de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480241
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2026-02-13 03:35:34 -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
Slava Egorov 4ec7f9c25d [vm] Fix timeline track metadata handling
AddTrackMetadataBasedOnThread was looking at FLAG_timeline_recorder
to determine if it can skip recording metadata. However the flag
value is not necessary in sync with the current recorder because
NativeRuntime.streamTimelineTo can reconfigure recorder itself
without changing flag value.

It seems strange to be checking the flag instead of using proper OOP
anyway - the function is already virtual. This CL removes code
which was checking the FLAG and instead overrides the method in
subclasses which don't care about track metadata.

TEST=existing tests were updated to cover this case

Change-Id: I2a2859ab5ef28d8d6d2358259cc9ed8d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476400
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-29 02:55:30 -08:00
Ryan Macnak f2e1df1997 [vm] Avoid deadlock in Isolate.debugName.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62237
Change-Id: I57bfcc341e34aa9e873092e0f7ebf44bc2f95cfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476143
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-28 11:10:42 -08:00
Ryan Macnak 47d300538b [test] Avoid slow initialization in large_constant_index_test on simulators.
Bug: https://github.com/dart-lang/sdk/issues/62512
Change-Id: If183af259a41549c17615949fad03c16dfce5bae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475901
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-27 14:11:14 -08:00
Ryan Macnak 1d91605c25 [vm, compiler] Handle 32-bit constant indices for Load/StoreIndexedInstr on ARM64 and RISC-V.
This extends the set of indices that are not processed by the register allocator to match X64. This avoids slowness in the register allocator for large list literals. For some cases, it also reduces code size.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62411
Change-Id: Iab71a6dea2f2f75b06c51e4b23626bc991e1a20f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475720
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-26 14:37:58 -08:00
Tess Strickland 8cbf864289 [vm] Add LC_ENCRYPTION_INFO(_64) load command to iOS snapshots.
When uploading to the App Store, the program must contain an
LC_ENCRYPTION_INFO segment in the Mach-O header so the App Store
can appropriately modify it for its purposes without changing the
header size and/or offsets/addresses in the rest of the shared object.

By default, the load command is only added to iOS snapshots, but
it can be added to any Mach-O snapshot using the --macho-encryptable
command line option.

TEST=vm/dart/use_macho_options_test

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-debug-x64-try,vm-aot-mac-debug-arm64-try,vm-aot-linux-debug-x64-try
Change-Id: I4e79fd9cfb9ba9d49707ec209eca3fee1cefc28c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475040
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-26 06:34:51 -08:00
Alexander Aprelev af7c390044 [vm/shared] Skip runtime deep-immutability check for statically known types.
Fixes https://github.com/dart-lang/sdk/issues/61078
TEST=StreamingFlowGraphBuilder_DeeplyImmutableTypeCheck*

Change-Id: I4116d5f51f3247d50d4e7fc0f87e04238a6e3151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474563
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-22 12:53:50 -08:00
Alexander Markov 0970fb57fe [tests] Update stress_test_list.json after tests were moved
TEST=ci

Change-Id: I4730bdd58e18051d6f07f2af1b70560434bde790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475121
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-22 08:40:07 -08:00
Tess Strickland e283e135ef [gardening] Adjust status file info for moved tests.
Tests from language/vm were moved to vm/dart/language, so move the
related lines from the status files.

Also fix the list of tests for the stress test trybot.

TEST=ci on vm-aot-dwarf-linux-product-x64
           vm-aot-obfuscate-linux-release-x64
           vm-appjit-linux-debug-x64
           vm-appjit-linux-product-x64
           vm-appjit-linux-release-x64

Cq-Include-Trybots: luci.dart.try:vm-appjit-linux-release-x64-try,vm-appjit-linux-product-x64-try,vm-appjit-linux-debug-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-obfuscate-linux-release-x64-try
Change-Id: I48eb25207551c0a9ba637023d36497f184c4a4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474700
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-21 04:58:13 -08:00
Ryan Macnak 97a00247f8 [test] Disable TSAN thread leak detection for more tests that call exit.
Cf. cee7000c1a.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/62405
Change-Id: I03d6bd34e57c249f0e62ae87179614b9871e0436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-20 14:47:53 -08:00