Commit Graph

22802 Commits

Author SHA1 Message Date
Nate Biggs 3d2d6492c1 Add 'external-effect' pragma support to all the backends.
Call sites targeting a procedure annotated with `external-effect` will
not produce any code, including the argument which will not be
evaluated.

However, the single parameter will be treated as 'live' for the purposes
of any global analysis the backends do. This is useful for things like
protobuf shaking where a user may want to retain certain protobuf
messages without actually emitting the code that retains those messages.

Today this functionality is available internally in the vm and wasm SDK
libraries. dart2js has similar functionality represented via the
opaqueTrue and opaqueFalse booleans (which will cause conditional
branches to get shaken after analysis). This will replace dart2js's
opaque(True/False).

This also adds validation to the frontend to ensure a method annotated
with 'external-effect' is well-formed.

Change-Id: If1c4096673e655c58fe7638840a16125003e7809
Tested: Backend tests for codegen were added. A frontend test was added for the validation. A language test was added to confirm the behavior.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-27 09:42:38 -07:00
Sigmund Cherem 8c9f9af9e3 [vm] Make IsRedirectingFactory a JIT-only state bit
To support checking for dynamically-callable targets in dart dynamic
modules, we need to use a bit in the Function header in AOT. Currently
all 32 bits of `kind_tags_` are in use. To make space for that new bit,
we need to evict one of the current properties that is not needed by AOT.

Among them, `IsRedirectingFactory` made the top of the list. It has only
one use in non-AOT logic.

TEST=existing
Bug: b/448095881

Change-Id: I3112d8865523696ed8e906a6c59f53c23db3090a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498281
Auto-Submit: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-27 08:53:18 -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
Ryan Macnak e1d540f0d2 [vm] Fix missing deep immutability bit on strings written as ROData.
TEST=vm-isolate or core snapshots with code
Change-Id: Ic247ff6946556df953828fa60d189e6abdd90014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497340
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-22 10:30:04 -07:00
Ryan Macnak 87faabac13 [vm] Fix alignment for snapshots linked into the main binary.
TEST=ci
Change-Id: I819d035846191aeac441a574302b65674261cc9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497105
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-22 08:26:13 -07:00
Modestas Valauskas b74add4813 [vm/compiler] Specialize Int32x4 operators in AOT.
The five binary operators on Int32x4 (+, -, |, &, ^) were never added
to the recognized-method list as graph intrinsics, so calls to them
were left as runtime calls through external-name bodies. In JIT the
call specializer picked kInt32x4Cid from IC feedback and emitted a
native SimdOpInstr, but AOT has no IC feedback and therefore fell back
to boxed calls, making Int32x4List inner loops 10-70x slower than both
the JIT version and a hand-written scalar equivalent.

This CL wires the same specialization paths that already exist for
Float32x4.+,-,*,/:
  - recognize the five operators as graph intrinsics and mark them
    with `@pragma("vm:recognized", "graph-intrinsic")` plus an
    exact-result-type pragma;
  - add Build_Int32x4{Add,Sub,BitAnd,BitOr,BitXor} helpers that
    delegate to the existing BuildSimdOp;
  - extend SimdOpInstr::KindForOperator and CreateFromCall;
  - extend CallSpecializer::InlineSimdOp and TryInlineRecognizedMethod
    so the non-speculative null-check path used for Float32x4 operators
    in AOT also applies here.

Measured on macOS arm64 (M-series), `dart compile exe`:

  Issue 63217 orSimd      : 12.58 -> 0.32 us/iter  (39x)
  Issue 63217 andNotSimd  : 23.51 -> 0.34 us/iter  (69x)
  Issue 53662 mandelbrot  : 4038.5 -> 55.5 ms       (72x)

A new benchmark benchmarks/SimdInt32x4 exercises all five operators
with a scalar and a SIMD variant so the specialization stays covered
by the benchmark bots; it is registered in Omnibus and OmnibusDeferred.

Existing tests/lib/typed_data/simd_*_test.dart still pass in JIT and
AOT.

TEST=tests/lib/typed_data/int32x4_arithmetic_test; benchmarks/SimdInt32x4
Bug: https://github.com/dart-lang/sdk/issues/53662
Bug: https://github.com/dart-lang/sdk/issues/63217
Change-Id: I9b76ab4fff228ff1a5e3d3c86f4bfc059e66a49a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497000
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-22 00:01:52 -07:00
Ryan Macnak f4d7f070a4 [vm] Remove irregular canonical bits.
Some objects have their canonical bit set but don't have the deeply immutable bit set. It's simpler if they have this bit clear so there is only cluster need, and these objects are instances of VM-internal classes that don't really do canonicalization.

Also give the oddballs their header hash while doing the rest of their initialization. This makes it easier to use the as snapshot base objects when there is no finalize VM isolate step.

TEST=ci
Change-Id: I7bdf7dc59b04ae30f49c5c67c0dc4f69c2d2524f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497121
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-21 15:05:16 -07:00
Ryan Macnak cd26f5e1cc [vm] Add missing serialization clusters for VM isolate objects.
TEST=ci
Change-Id: I738cf1a189accd2e449728bb599b6b92b5797924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496800
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-21 10:13:04 -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
Slava Egorov 5ae14a808c Revert "[vm] Enable misc-include-cleaner in runtime/.clang-tidy"
This reverts commit 8664b0f98b.

Reason for revert: this was enabled without fixing existing violations in the code base.

Original change's description:
> [vm] Enable misc-include-cleaner in runtime/.clang-tidy
>
> Closes https://github.com/dart-lang/sdk/pull/63188
>
> GitOrigin-RevId: 66c5321fc38ae18fd7d7a340e6e162abf330bed1
> Change-Id: I2a8849a3887fc8677a82c9434fe581159a848c7a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496160
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Liam Appelbe <liama@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I9d6e6cdfc084bc78341676c5d08f9d103783a200
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496900
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-04-21 03:02:18 -07:00
randomizedcoder 8664b0f98b [vm] Enable misc-include-cleaner in runtime/.clang-tidy
Closes https://github.com/dart-lang/sdk/pull/63188

GitOrigin-RevId: 66c5321fc38ae18fd7d7a340e6e162abf330bed1
Change-Id: I2a8849a3887fc8677a82c9434fe581159a848c7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496160
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2026-04-20 19:26:12 -07:00
randomizedcoder 1f198e7596 [vm] Remove unused assert.h, add direct stdint.h includes in runtime/include/
Closes https://github.com/dart-lang/sdk/pull/63187

GitOrigin-RevId: 217908e166dfd4eea959e9c81b81ef9dadb0556c
Change-Id: I1ea2f133cede7d9bd6baf077882e41b86546ea9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496180
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-04-20 18:48:31 -07:00
Ryan Macnak af43c1a3d4 [vm] Switch FAR_TMP to X7 for compatibility with Zicfilp.
When enabled, indirect calls and jumps must set X7 to a label value that matches the label in a so-called landing pad at the call target. This check does not apply if the indirect call is made through X1/RA, X5/RA2 or X7/T2, with the expectation that the compiler will limit use of these registers for logically direct calls like an AUPIC+JALR pair, or for software guarded branches like a bounds-checked jump table. We use FAR_TMP for logically direct jumps that exceed J-type range, and blocking it from register allocation limits the availablity of gadgets that set X7.

Compare x64's IBT and arm64's BTI.

TEST=ci
Change-Id: Ic00195eb3c04cc10379f9965e05ef84052e02933
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494861
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-20 17:46:32 -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
Slava Egorov 53ac68e2dd [vm_service] Deprecate Stack.messages
Make VM always return empty array in the response.

Current implementation for this field comes with a bunch of complexity
because it locks message handler and then invokes Dart code which
makes it difficult to reason about various invariants. This code is 
furthermore demonstrated to cause deadlocks. Given that nobody uses 
it - it is simpler to remove this code altogether.

Fixes https://github.com/flutter/flutter/issues/185156

TEST=ci

Change-Id: I497210e0f1542860caa0d765d634f8ec6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-20 10:28:01 -07:00
Tess Strickland 4c89523e4f [vm] Rework printing of EXPECT_STREQ failures.
Currently, the failure message for EXPECT_STREQ just prints the
(escaped) expected and actual strings on failure, but if the
expected and actual strings are mostly the same, it can be difficult
to determine what the difference actually is.

Instead, do a bit of work to find the common prefix and suffix of
the expected and actual strings, so that the actual difference is
more apparent. If the lengths of the common prefix and suffix
combined is considered too short to separately print them, then
the output is the same as before.

TEST=ci (failure output change only, so tested with
         vm/cc/SourceReport_Coverage output on vm-dyn-linux-debug-x64)

Change-Id: Iecaacde6ebf6628643bdf1440c6d77d4ff6599af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495980
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-04-17 04:47:53 -07:00
Alexander Markov 1d901d209d [vm] Add more details to the assertion in ObjectSlots::ObjectSlots
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/63180
Change-Id: I8dc86589827b31ce5838ecb2b4b0d80d5111871a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495942
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-16 14:47:59 -07:00
Alexander Markov d778eb84ac [vm] Fix TSAN data race between concurrent marker and ObjectCopyBase
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/63181

Change-Id: Ia350a73de17f7090e344102f831187368dfedbc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496040
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-04-16 10:07:23 -07:00
Tess Strickland 0e89c5e496 [vm,dyn_modules] Fix Rectangle/MutableRectangle on vm-dyn-aot.
Also allows the --print-classes flag to be used in the AOT runtime if
dynamic modules are enabled and crashes with an appropriate error
message if class finalization fails when loading a member from bytecode.

TEST=co19/LibTest/math/Rectangle co19/LibTest/math/MutableRectangle

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: I1921aa0189eb587cd4658c592a779be190af092e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495724
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-04-16 04:25:37 -07:00
Ryan Macnak 3e05df3856 [vm] Fix more cases of the profiler failing to identify the entry frame.
TEST=dart-fuzz
Bug: https://github.com/dart-lang/sdk/issues/63105
Change-Id: I081a719a1d91c0e003a45ce1249e7856aa46a530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495784
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-15 15:23:51 -07:00
Nourhan 734e12ac96 [vm/service]: Add VM memory mappings for Windows
Implement AddVMMappings for Windows using VirtualQuery and
GetMappedFileNameA, matching the existing Linux/Android implementation.

TEST=tested manually on Windows by opening some tool and looking at
values

Fixes: https://github.com/dart-lang/sdk/issues/46166
Change-Id: I2ad9229c1cc39ffedca7a2c0fc50d5e3da36953d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493020
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-04-15 09:44:59 -07:00
Ryan Macnak b9222a8b7d [vm] Fix MSVC build.
TEST=ci
Change-Id: I13a1485b792e8115e6fbae1064cc60c81959dc7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495780
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-15 09:37:41 -07:00
Ryan Macnak 1c023e852d [vm] Fix dynamic modules build.
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-ffi-dyn-mac-release-simarm64_arm64-try
Change-Id: I565f12d85f3f6be10c2bfdb32a23344fc5e36ed9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495620
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-14 21:05:29 -07:00
Ryan Macnak d4d46a4b83 [vm] Avoid confusing which FP to use for the 3 kinds of profiler stack walks.
We can do a "native" stack walk starting from the interrupt context, a Dart stack walk starting from the exit frame, or a Dart stack walk starting from the interrupt context / simulator state / interpreter state.

Decide which kind of stack walk to do once instead both inside and outside CollectSample. Remove CollectSample, as we should not need SEH guards now that we have accurate stack bounds.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63105
Change-Id: I8f46f2ab860220e0be373f02aa882ac096bb2fb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493969
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-14 17:22:31 -07:00
Ryan Macnak df5cae97dc Revert "[vm, ffi] Remove special case for Fuchsia FFI callback thunks."
This reverts commit 61f45d66b2.
This reverts commit a0ab33ac52.
This reverts commit 68e2512ace.
This reverts commit fb732a570d.

TEST=ci
Bug: b/501539846
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-mac-release-simarm64_arm64-try
Change-Id: I7f27bb15bf1fcb26fe8793a043b7530ed99a02a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495480
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-14 12:22:48 -07:00
Ivan Inozemtsev 97685b7dbb Add missing smi tag shifts
TEST=ci

Bug: b/502506240
Change-Id: Icb81c2c0653ed7793194c2454aa3fc283e797323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495380
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2026-04-14 09:43:24 -07:00
Tess Strickland f9160e5c0b [vm,dyn_modules] Fix dynamic calls from dynamic modules in the AOT runtime.
Dynamic modules may make dynamic calls to compiled methods that had no
dynamic calls in the original whole world compilation. If this happens,
then dynamically create an interpreted dynamic invocation forwarder that
then appropiately checks and delegates to the compiled function.

TEST=co19/LibTest

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: I283ca501f50118606650cf434b8debe30a43f676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-04-14 04:26:01 -07:00
Ryan Macnak 813afcee43 [vm] Simulator support for Zicfilp.
TEST=ci
Change-Id: Ibf9adb39da37ebb350097e3830202940e138c7d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-13 14:00:21 -07:00
Slava Egorov fff4f2324d [vm] Remove _HashFieldBase
This class is structurally equivalent to _HashVMBase and the only reason
for it to exist for inability of normal Dart classes to extend
_HashVMBase - but this can worked around by properly configuring
_HashVMBase class in bootstrapping.

TEST=ci

Change-Id: I5ca401e274920d2b4739424c6b6595306a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494140
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-13 10:10:42 -07:00
Alexander Markov c3589b02b4 [vm] Verify there is no padding between last field and variable-length payload in the VM objects
The implicit padding would not be initialized but would
be scanned by GC.

TEST=Manually tested with implicit padding.

Change-Id: Ia3556d3e42a97fbb2d8f67541d2e7de9b7650077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494566
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-04-13 08:52:24 -07:00
Ben Konyi ae1b83869a [ Service ] Add support for DDS to package:dart_runtime_service_vm
The DartRuntimeService based VM service implementation now has support
for launching DDS instances and responding to _yieldControlToDDS RPC
invocations from DDS instances.

package:vm_service test suite is ~97% passing with this change.

TEST=Local testing.
Change-Id: I2f2f1b0926845134578f08d073ed7606f1fc4173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490320
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-04-10 12:04:28 -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
Tess Strickland 432adf747e [vm,dyn_modules] Fix PrintStackFrames for entry frames, add more info.
The handling of entry frame in PrintStackFrames was broken, now it's
fixed.

In addition, the stack printer now print various info about the static
slots in stack frames, as well as printing out the objects in slots.

Now that entry frames are handled properly, printing with no limit
prints _all_ stack frames on the interpreter stack, noting call
boundaries as they are passed, instead of stopping at the closest
entry frame.

Move the separator between frame from the stack pointer for a frame
to the frame pointer for a frame, meaning that the metadata before
the frame pointer is printed as part of the previous frame, not the
current one.

TEST=ci (manual testing while debugging)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: Ia2ad07c832b791f0c2ce2bbdfbfc32d5d8968476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493402
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-04-10 04:49:32 -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
Alexander Markov 56186c7e96 [vm,dyn_modules] Fix dynamic calls from host app to a dynamic module
Fix the following cases of incorrect optimizations:

* In TFA, when anlyzing a dynamic call with unknown receiver type,
  do not assume that all possible targets can be computed at compile
  time (if there can be dynamically loaded classes).

* In the AOT, disable optimizations for dynamic calls with unique
  selectors (if there can be dynamically loaded classes).

TEST=pkg/dynamic_modules/test/data/dyn_call_from_host

Change-Id: I39d620aae3c116de03d4a2a3fd61864d88c48c8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493960
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-09 09:22:14 -07:00
Alexander Markov 61f45d66b2 [vm] Fix msvc x64/arm64 cross-build
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/493921.

TEST=ci

Change-Id: I136845bc6b2ae0582100b8acadd9be0015d7694c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494022
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-04-09 08:47:40 -07:00
Ryan Macnak a0ab33ac52 [vm, ffi] Fix Fuchsia ARM64 build.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52579
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
Change-Id: I3e3377d0c973614b83664bfd704d5efe532d329f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493968
Commit-Queue: Liam Appelbe <liama@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2026-04-08 20:29:40 -07:00
Ryan Macnak 68e2512ace [vm, ffi] Remove special case for simulator FFI callback thunks.
TEST=ci
Bug: https://dartbug.com/52579
Change-Id: I488af082d5d9db39da38c9ff1e8ac984454bff54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493921
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2026-04-08 16:43:09 -07:00
Ryan Macnak fb732a570d [vm, ffi] Remove special case for Fuchsia FFI callback thunks.
TEST=ci
Bug: https://dartbug.com/52579
Change-Id: I2c1ca144253bc0dbeda53321aa6fe462698095b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493502
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-08 16:43:02 -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
Ryan Macnak ed2bca33a3 Roll Clang from 637e9bc0f763 to 26697f4d07eb
TEST=ci
Change-Id: I3087eac61590edd0aa79e940146345d6370ff39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493840
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-08 14:31:16 -07:00
Daeho Ro c53bdf2dab mach_o: support two level namespace
Closes https://github.com/dart-lang/sdk/pull/63116

GitOrigin-RevId: 8eb01fcda0586e02ec659285b357412e044b823c
Change-Id: I85a2baaa046d207fe1b928043e1e479d3a74a3d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-08 14:17:21 -07:00
Ryan Macnak db173bf585 [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: I6fa47b2c04b0abaae74210c86f9fdf17ec932db7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493222
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-08 10:38:35 -07:00
Alexander Aprelev 8999b65531 [vm/cleanup] Remove unused start_callback, enable_vm_service, paused_for_messages.
TEST=ci

Change-Id: I101a355de9b0c2b36c8977c3af962a3e283a72d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493862
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-04-08 10:05:40 -07:00
Alexander Markov 384f76e596 [vm] Cleanup dead code
TEST=ci

Change-Id: I0ba2ec4a46b81f4efcbf3e516a70a3c2b40bb74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493861
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-08 09:52:39 -07:00
Tess Strickland 9bedae1b84 [vm,dyn_modules] Fix Bytecode ToCString functions.
Instead of using the Function String-creating methods, use the
Function CString-creating methods which avoids allocation that
causes issues when called from within the interpreter (especially
in debug mode, where asserts are triggered).

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ic43a831a6ec1ee4327e1fdf4dfc64bd09af5c04a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493801
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2026-04-08 09:02:00 -07:00
Ryan Macnak 1dc1b015eb [dart:io, win] Don't delete the process list mutex during shutdown.
The exit callback might fire during or after dart:io shutdown.

TEST=ci (flaky)
Bug: https://github.com/dart-lang/sdk/issues/60499
Change-Id: I950ef4a6ba1d99a8eafb55cb051a60f0cb097e71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493485
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-08 08:33:32 -07:00
Alexander Markov 5653511163 [modular_aot] Serialization of type parameter types in the modular snapshots
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I1d0de6222681741acd6a25b06c0b4b3f12ca8534
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493101
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-08 07:44:03 -07:00
Ryan Macnak 9f929d1fcf [vm] Get SP without using VM generated stubs.
TEST=ci
Change-Id: Ie976408ff3cf5691a59081b7b405abe43d7adcc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493165
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-07 08:06:43 -07:00