Commit Graph

22874 Commits

Author SHA1 Message Date
Ryan Macnak b0a82e98d5 [build, mac] Sign shared libraries and fix incremental build for changes to signing script or entitlement files.
TEST=ci
Change-Id: Ied90ee7b81a23de266d6f7dc5e642a820dac9248
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506341
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-27 06:34:31 -07:00
Johnni Winther a04691a8a8 [kernel][Contexts] Serialize new local variables
This adds serialization of the new local variables, VariableStatement and VariableDeclaration. This prepares for replacing LegacyVariable with the new variables in all backends.

TEST=existing

Change-Id: I9bbebfbfd372042d6b7027f0fabd24c165699832
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-27 00:41:34 -07:00
Ryan Macnak 84bd4ea759 [build] Remove dead tools.
TEST=ci
Change-Id: I535527098d08b3ecbf1ae731497750a43f478196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-26 14:40:09 -07:00
Ryan Macnak d080a5defd [build] Remove dead configs.
TEST=ci
Change-Id: Ibfff85b97d607fffb8aae49bd56e688ba292ff6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506461
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-05-26 14:38:25 -07:00
Alexander Aprelev 276cace231 [vm/mac] Fix WorkSet name confusion on flutter mac.
On mac with two WorkSet classes, WorkSet destructor from lib/isolate.cc is invoked instead of WorkSet destructor from vm/object.cc. This results in consistent assertion failures on flutter dart-debug builds on mac.

Might help with https://github.com/flutter/flutter/issues/186134

TEST=flutter test with dart-debug build

Change-Id: I9a0a0c9d02ee013da900807b8726df26a3660cc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505661
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-26 11:21:44 -07:00
Ryan Macnak e04d2179a1 [vm] Fix quadratic cost of SNAPSHOT_BACKTRACE.
Observed this taking ~16% of debug gen_snapshot time.
Observed this taking ~52% of debug AppJIT training time.

TEST=ci
Change-Id: I945e4f3a8794e607e1402150a10f0d328fa1e677
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506260
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-05-26 09:40:40 -07:00
Modestas Valauskas c5d547fdb8 [vm/compiler] Preset far_branch_level for huge JIT-optimized functions.
When the unoptimized code of a function exceeds 1 MB, start its
optimized compile with far_branch_level=1 instead of 0. Without this,
the assembler fails on out-of-range conditional branches at level=0,
longjmps out of the optimizing pipeline, and the whole pipeline reruns
at level=1 from scratch.

Measured on a naive 49 KLOC generated lexer with --huge_method_cutoff
gates lifted: JIT compile drops from ~26.6s to ~13.2s (about 50%).

Work towards https://github.com/dart-lang/sdk/issues/63230

TEST=ci

Change-Id: I2608a23ef899603a46b401b71be7322b7a8dd44b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506120
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-26 08:10:15 -07:00
Ryan Macnak 53733077b2 Revert "[standalone] Remove the fallback root certificates."
This reverts commit 039aef728a.

Reason for revert: b/515601247

Original change's description:
> [standalone] Remove the fallback root certificates.
>
> The discovery of the system root certificates is more robust after 2142d8e148.
>
> TEST=ci
> Change-Id: I8215cb92f98e620b82f21261c13e061a2b488b5d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433923
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TEST=ci
Change-Id: Ib07de221ff1160461d930f7165a7cd8179b4e3f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506100
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-26 07:49:52 -07:00
Ryan Macnak 58ea063ca8 [vm, compiler] Fix high hash collision rate in a large run of sequential double values.
TEST=many_double_literals_test
Change-Id: Ieddaa44ddc0cc67eb8913a62daab44b5579123a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506140
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-26 06:42:00 -07:00
Modestas Valauskas 0a2f2ceacf [vm/compiler] Stop ConstantPropagator phi join at NonConstant.
Short-circuit the per-predecessor Join loop in
ConstantPropagator::VisitPhi once the running join has reached top.

Measured on a naive 49 KLOC generated lexer with --huge_method_cutoff
gates lifted: AOT compile drops from ~21s to ~11s (about 47%).

Work towards https://github.com/dart-lang/sdk/issues/63230

TEST=ci

Change-Id: I3103253bdba93252d4b7abcb25819a52f75b2058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505402
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-26 00:56:04 -07:00
Alexander Aprelev 8765d80177 Revert "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable"
This reverts commit 0bef837817.

Reason for revert: simarm, xarm bot failures https://github.com/dart-lang/sdk/issues/63436

Original change's description:
> [vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable
>
> Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
> (commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
> when a hardware fast path is available; otherwise the newly added
> Dart bodies inline at call sites via vm:prefer-inline. The C++
> natives are removed.
>
> Backend codegen
> ---------------
> ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
> ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
>            register pair (ctz).
> x64:       popcntq when TargetCPUFeatures::popcnt_supported();
>            LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
>            on BMI1+, preserves dest on zero otherwise).
> RISC-V 64: cpop / ctz when RV_baseline includes Zbb.
>
> Per-arch availability is encapsulated in
> UnaryInt64OpInstr::IsSupported(Token::Kind).
>
> Apple M-series ARM64, AOT (us/iter, lower is better):
>   cardinality.swar              371
>   cardinality.accelerated       154    (2.4x)
>   forEachSetBit.swar          19031
>   forEachSetBit.accelerated    4988    (3.8x)
>   select.swar                   199
>   select.accelerated             77    (2.6x)
>   complementCardinality.swar    399
>   complementCardinality.accel   152    (2.6x)
>
> Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
> and ctz intrinsification).
>
> Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
> BitSet implementation).
>
> Fixes https://github.com/dart-lang/sdk/issues/52673
> Fixes https://github.com/dart-lang/sdk/issues/38346
> Issue https://github.com/dart-lang/sdk/issues/10212
> Issue https://github.com/dart-lang/sdk/issues/5798
> TEST=tests/corelib/int_bit_count_test
>
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
> Change-Id: I9c2c4225fd63d54e190398a0fb6649366317dd17
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504221
> Commit-Queue: Slava Egorov <vegorov@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I4eaca9e25a919ba494f2e7e9819f1ea7d5a13078
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505941
Auto-Submit: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
2026-05-22 14:22:30 -07:00
Alexander Markov d7d723327f [modular_aot] Serialization of type parameter declarations in module snapshots
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Ia5646ec6e2133a2232ffbbdb4926d94296bcd690
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505522
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-22 10:10:19 -07:00
Modestas Valauskas 0bef837817 [vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable
Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
(commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
when a hardware fast path is available; otherwise the newly added
Dart bodies inline at call sites via vm:prefer-inline. The C++
natives are removed.

Backend codegen
---------------
ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
           register pair (ctz).
x64:       popcntq when TargetCPUFeatures::popcnt_supported();
           LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
           on BMI1+, preserves dest on zero otherwise).
RISC-V 64: cpop / ctz when RV_baseline includes Zbb.

Per-arch availability is encapsulated in
UnaryInt64OpInstr::IsSupported(Token::Kind).

Apple M-series ARM64, AOT (us/iter, lower is better):
  cardinality.swar              371
  cardinality.accelerated       154    (2.4x)
  forEachSetBit.swar          19031
  forEachSetBit.accelerated    4988    (3.8x)
  select.swar                   199
  select.accelerated             77    (2.6x)
  complementCardinality.swar    399
  complementCardinality.accel   152    (2.6x)

Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
and ctz intrinsification).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Fixes https://github.com/dart-lang/sdk/issues/52673
Fixes https://github.com/dart-lang/sdk/issues/38346
Issue https://github.com/dart-lang/sdk/issues/10212
Issue https://github.com/dart-lang/sdk/issues/5798
TEST=tests/corelib/int_bit_count_test

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
Change-Id: I9c2c4225fd63d54e190398a0fb6649366317dd17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504221
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
2026-05-22 05:58:10 -07:00
Modestas Valauskas 1d61eecafa [vm/compiler] Dedup blocks in WBE worklist.
Generalize DefinitionWorklist into a Worklist<T, E> template and use a
new BlockEntryWorklist (keyed by preorder_number) to drive the WBE
dataflow. The bitvector-backed membership set prevents the same block
from being enqueued many times, which is what caused compile time to
blow up on large generated programs.

Measured on a naive 49 KLOC generated lexer with --huge_method_cutoff
gates lifted and with synchronous compilation: AOT compile drops from
~42s to ~19s.

Work towards https://github.com/dart-lang/sdk/issues/63230

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

TEST=ci

Change-Id: I56c5dc40f534e4b28fe6b608a3b7f49e14957ef7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505461
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-22 03:53:47 -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
Ryan Macnak 2f2a523818 Fix gcc 16 build.
TEST=local build
Bug: https://github.com/dart-lang/sdk/issues/63406
Change-Id: I20c2806e569211ef7d32e95961179dbf2aba15a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505181
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-20 19:36:12 -07:00
Alexander Markov c93a1c2bc3 [vm,aot] Restore generation of TTS for type arguments passed to factory constructors
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/501762.

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

Change-Id: I85386738c203a7fb27171bf904723106b764288e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504680
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-20 15:11:47 -07:00
Ryan Macnak 25a757da3e Reland "[build] Generate AOT snapshots in the SDK as dylibs on Mac."
Also apply code signing like we do for C++ binaries.

Cq-Include-Trybots: luci.dart.try:dart-sdk-mac-try,dart-sdk-mac-arm64-try
Change-Id: If2a379c0cde556ad3198cafc5b53a386bd265197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504721
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-20 11:33:39 -07:00
Alexander Aprelev 58047e7d94 [vm/native_api] Ensure isolate is not available for duration of native port operations.
Follow-up to 5a98fe5564.

TEST=ci

Change-Id: I62269b713968f0d0e436d86b7d7b481fc5b52cc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501620
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-20 08:40:17 -07:00
Ryan Macnak b2911c0bf1 Fix GCC build.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63406
Change-Id: I3bb3963fcc182777c5d2c0e062ae4bbf3c5aae75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504800
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-20 08:21:30 -07:00
Tess Strickland 2b9e597980 [vm] Fix CanonicalizeHash for TypedData.
Previously, the loop threw away the calculated hash value, so the
finalized hash was only the combined hash from the length plus last
byte.

Fix this, and also use 32-bit chunks as much as possible to reduce the
number of iterations for larger typed data objects.

TEST=ci

Change-Id: I0c033701232f1a1299356cab0b09079f9f86c026
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504980
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-05-20 06:38:42 -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
Tess Strickland 58e0b77bd6 [vm,dyn_modules] Fix source reports for enhanced enums with bytecode.
Coverage information for enhanced enums should not include initializer
functions for enum elements or the values field, so skip over these when
the enum is defined in bytecode.

TEST=vm/cc/SourceReport_Coverage_IssueCov386_EnhancedEnums

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I1dba3c87fdfcc39762bba5f0c35cfd061ec76371
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504240
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-05-20 06:04:16 -07:00
Ryan Macnak 039aef728a [standalone] Remove the fallback root certificates.
The discovery of the system root certificates is more robust after 2142d8e148.

TEST=ci
Change-Id: I8215cb92f98e620b82f21261c13e061a2b488b5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433923
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-19 11:20:48 -07:00
Ryan Macnak 6a9b9b331c [vm, compiler] Fix calculation to find the beginning of the FFI callback stub on ARM32.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63402
Change-Id: I4aff8d6dca9aa71fd68275fd495b7dba2e119df5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504401
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-05-19 09:06:20 -07:00
Tess Strickland 52cfd29cbb [vm,dynamic_modules] Add RecordCoverage instruction.
The RecordCoverage instruction has an A/E encoding. The A argument
is the type of coverage being recorded, whereas the E argument is
the logical index into the coverage array for updating whether that
source position has been hit.

Also adds new metadata to the bytecode component for the coverage
arrays associated with bytecode containing RecordCoverage instructions
and a new runtime entry for lazily allocate the coverage array for
an interpreted function when needed.

The type of coverage is encoded in the RecordCoverage instruction,
despite being redundant with the information in the coverage array, so that checking whether that type of coverage is currently enabled at
runtime doesn't require either accessing the coverage array (which may
be lazily allocated), forcing allocation of the coverage array just to
discover that type of coverage is currently disabled, or reading the
serialized bytecode component to avoid that forced allocation.

------

Other changes:

Source reporting now treats unexecuted interpreted functions when
not forcing compilation as if they were uncompiled native functions,
so that the source report from running the same code gives the same
result whether using the interpreter or the native compiler.

Bytecode closures are no longer skipped in source reports. Previously
any closure without a context scope was skipped, but bytecode closures
don't have those.

TEST=vm/cc/SourceReport_Coverage

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I7557e5dd4c98331c7ca2f5c867dd5f6d03e9d756
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-05-19 04:27:39 -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 9f3a2222fa [modular_aot] Fix reading nullability of types from module snapshots
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Id2b0504cf4b02ee8a2086e18901f182f2730ba5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503960
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-18 08:19:41 -07:00
Ryan Macnak 350163cc25 [vm] Per-group callback thunks.
With no VM isolate, the lifetime of the template stub will be the lifetime of the group instead of the VM.

TEST=ci
Change-Id: I4ed2f5e5c6e8f4c92c430898dc38355a227d4057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500620
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-05-18 08:11:36 -07:00
Alexander Markov 45503a1a3e [modular_aot] Instance method closurization
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I5e8993936b55c7cb8b581c64fd7ce8a38c9f9ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503682
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-18 08:03:55 -07:00
Alexander Markov ccbcd76265 [modular_aot] Records
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Ie6ba4148ca9193b5b28de3d90efa7bb55427ef53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498660
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-18 08:03:32 -07:00
Nourhan Hasan 046d473d5e [vm/service]: use a map for service ID zones to avoid ID reuse and unbounded growth (#62205)
Replace the growable array with a hash map so that zones are truly
removed on deletion and IDs are never reused.

TEST=Manually tested with test_zones.dart (IDs increase, map size
toggles); existing service tests pass

Fixes: https://github.com/dart-lang/sdk/issues/62205
Change-Id: I0bbec4a0fc0aef9ed8679a3aa5ce832fea9bfde8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489720
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-18 03:57:44 -07:00
James Robinson b5a613c378 [fuchsia] Use zx_port_cancel_key in Fuchsia event handling logic
This updates the IOHandle type in eventhandler_fuchsia to use
zx_port_cancel_key to cancel outstanding asynchronous waits instead of
the (older) zx_port_cancel. The cancel_key operation requires only the
key used to register the initial wait and not the originating handle.
This means that the IOHandle operation no longer has to store the
original handle or worry about its lifetime.

Tested: Patched locally in a test embedder using this logic
Change-Id: Iec0ec632a7dd438a34e482a12b5b298be56ce476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501840
Reviewed-by: Zijie He <zijiehe@google.com>
Auto-Submit: James Robinson <jamesr@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-13 12:47:06 -07:00
Eric Seidel a6a403c0b9 [vm, simarm64] Extract CalleeRegisterVerifier class
Closes https://github.com/dart-lang/sdk/pull/63012

GitOrigin-RevId: 56b29e0480f66e41ddd15e24249a5be75aed13ca
Change-Id: I55ed703a366aefd3b273acd74a6c99c91ed38759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491682
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-13 11:42:35 -07:00
Sigmund Cherem d65783ef59 [dyn modules] add runtime flag for checking under JIT
At this time, this flag is mainly going to be used to enable partial
testing of the JIT runtime when loading applications from kernel
snapshots.

Bug: b/448095881

TEST=none yet, will be added in upcoming CL
Change-Id: I272d43cdab0c9a9c3653cccc9e96961c1122bbd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503460
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2026-05-13 11:42:30 -07:00
Sigmund Cherem cca6298498 [dyn_modules] Check target of dcall from dynamic modules is valid.
Unlike other calls from Dynamic Modules, dynamic calls cannot be
validated entirely at compile time. While we check that the selector
used matches a selector that was allowed (either because a method with
that selector name was exposed as dynamically callable or because the
selector was allowlisted during bytecode compilation), the compiler
doesn't know statically whether the target of the call is exposed.

In prior changes we modified the annotator to add a pragma indicating
whether a member is dynamically-callable or
implicitly-dynamically-callable. Here we use that information to set a
bit on functions and their corresponding dynamic invocation forwarders,
which is verified by the interpreter to make sure the dynamic call is
still allowed.

TEST=none yet - will be added in subsequent CL (see CL chain)

Bug: b/448095881
Change-Id: I27acb4e690a68e08fe1f1ca94e0d77cc7dc4d11e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498300
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2026-05-13 09:40:57 -07:00
Ben Konyi 51050481c9 [Service] Support isolate/root in package:dart_runtime_service
Adds isSystemIsolate in the isolate startup message sent to the
VM service, allowing for the service to identify the first non-system
isolate as the root isolate.

TEST=Existing tests

CoreLibraryReviewExempt: dart:vmservice is internal.
Change-Id: I0a982a1fc06bd0be0426ad9d1401e89375cbed40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500000
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jessy Yameogo <yjessy@google.com>
2026-05-13 09:40:15 -07:00
peeefour 1d80afe498 [vm/io] Range check Socket_SendMessage arguments
Closes https://github.com/dart-lang/sdk/pull/63365

GitOrigin-RevId: 344604dd1a17b73c6665026e7e75693fe0fa7ca7
Change-Id: I8f51d5735a56564f2181bcd1206c9cfdff80f077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502960
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-13 03:40:04 -07:00
Alexander Markov b7125bde65 [vm] Fix OneArgUnoptimizedStaticCallStub on ia32
Fixes https://github.com/dart-lang/sdk/issues/63367
TEST=ci

Change-Id: I70ab32807a8fd03e84878f1ecfc5fb1497928a51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-12 08:43:04 -07:00
Ryan Macnak 94347fdf01 [vm] Don't use ApiError to represent errors during startup.
With the removal of the VM isolate and less bootstrapping being repeated in the AOT runtime, ApiError cannot be instantiated until after snapshot loading succeeds.

TEST=ci
Change-Id: I5be295e87e6d6351ada40d2837825b1f93672ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501262
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-12 08:41:20 -07:00
Alexander Markov 6195ea86bc [vm] Remove irregular type arguments parameter from factories
In the VM, factory constructors always had an extra "type arguments"
parameter, even if class is not generic. Factory constructor bodies
were using class type parameters instead of function type parameters.

This results in extra code when calling non-generic factories
which is slightly inefficient in terms of code size and performance.
Also, it creates an additional complexity throughout the system as
factories should be special cased in many places.

This change removes artificial "type arguments" parameter, treating
factory constructors basically as static methods. This matches
kernel AST representation.

TEST=ci

Change-Id: I957583cb2ce9a3c408699880a04036e06b01dd31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501762
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-12 06:11:15 -07:00
Alexander Markov 66b54232ee [vm] Make vm/cc/Inliner_InlineForceOptimized test less fragile
This test verifies how deoptIds and environments are set
when inlining force-optimized functions.

The problem is that it looks at the chain of inlined calls:

foo() {
  call1 -> Pointer.fromAddress
}

Pointer.fromAddress() {
  call2 -> _fromAddress
}

// force-optimized
_fromAddress() { ... }

During inlining of force-optimized callee, its instructions
should receive deoptId/env from inlined call site.
In this case, the call site is 'call2'.

However, the test has been matching deoptId/env with 'call1'.

It was a mere coincidence that deoptIds of call1 and call2
were the same. Any attempt to make a change which would
affect deoptIds within Pointer.fromAddress breaks this test.

In order to fix this, a simpler setup is now used:

foo() {
  call1 -> newHash()
}

// force-optimized
newHash() { ... }

Also, the check for deoptId of outermost environment is dropped as
in this case there are no multiple environments.

In addition, also remove the duplicate pragma from _fromAddress.

TEST=vm/cc/Inliner_InlineForceOptimized

Change-Id: I1f592a74dfb8b7c2f67f3b0a51e7f7b74bf358eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502801
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-12 06:03:38 -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
Modestas Valauskas 754239b077 [core] Add trailingZeroBitCount and oneBitCount to int
Adds two new getters to int for bit-counting: trailingZeroBitCount
(ctz) and oneBitCount (popcount). On native platforms they operate
on the full 64-bit two's-complement representation; on the web they
operate on the least-significant 32 bits.

Implementations:
- VM: unified C++ natives Integer_trailingZeroBitCount /
  Integer_oneBitCount on _IntegerImplementation, using
  Utils::CountTrailingZeros64 and Utils::CountOneBits64. The receiver
  may be _Smi or _Mint at runtime.
- dart2js / DDC: clz32-based ctz and a SWAR popcount.
- dart2wasm: inlined i64.ctz and i64.popcnt intrinsics.

leadingZeroBitCount (clz) is intentionally excluded from this CL: its
result depends on the platform integer width (e.g. 1.leadingZeroBitCount
is 31 on web, 63 on native), and the same value can be derived from
the existing bitLength getter when needed.

Asm intrinsification on native architectures is intentionally left for
a separate follow-up CL.

Work towards https://github.com/dart-lang/sdk/issues/6486 (this CL
covers popcount and ctz from the bit-twiddling list; clz, rotate,
reverse, and others remain).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Bug: https://github.com/dart-lang/sdk/issues/52673
Bug: https://github.com/dart-lang/sdk/issues/38346
TEST=tests/corelib/int_bit_count_test

Change-Id: I8a5cdb5c91360478f47bbd6b9c84ca1c477aa8c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-05-12 05:49:31 -07:00
Alvin 7bc22cf877 [vm/io] Range check SynchronousSocket_WriteList arguments
Closes https://github.com/dart-lang/sdk/pull/63358

GitOrigin-RevId: 1a5eb0d7e11fca131a721cd0535954f96ac1dfaf
Change-Id: I670ebdd4fadef383872a9d719efa22d6479b812d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502441
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-12 00:32:52 -07:00
Alexander Markov 76ffb5053c [modular_aot] Instantiation of type arguments
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I019ebc77c9e3f8d1748797fe76b17ccce82a0d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501260
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-08 07:22:17 -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
Kevin Moore a77583dd11 [profiling] update generated proto files
Eliminates analysis errors

Change-Id: I8a7508687502b021ead265316825a1d16fb18a65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501706
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-05-07 23:51:32 -07:00
Kevin Moore 8a965f86c1 [dartfuzz] Fix analysis issues
Mostly adding types

Change-Id: I2f161654a8fee33380075a64ebe7968ac1e741e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501704
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2026-05-07 13:16:29 -07:00