Commit Graph

16353 Commits

Author SHA1 Message Date
Ben Konyi 6ea62c02fe [ Service ] Run the service's main() via _runMainIsolate
Prior to this change, the VM service isolate was configured to execute
`main` directly. This resulted in unexpected behavior around exceptions
thrown after the first asynchronous gap, which were unhandled but caused
the service isolate to exit silently with no error.

This change updates how the service isolate starts execution by
invoking `main` via `dart:isolate`'s `_runMainIsolate` method, similar
to how user isolates and the DartDev isolate start execution. This
results in the message handler being triggered, meaning the microtask
queue will be processed correctly and unhandled exceptions in
asynchronous contexts being reported.

TEST=Local testing with exceptions explicitly thrown from within the VM
service

Change-Id: I69475a86d923489fa216bc8e939a2726cf3ff2e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-03-24 11:57:40 -07:00
Ryan Macnak 0a30a91dd7 [vm] Update ApiNativeScope to C11 thread locals.
TEST=ci
Change-Id: Iec314b13981c0cd11f6dd28c2e881281c3a10a8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490300
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-24 11:26:23 -07:00
Nourhan Hasan 596e0b0849 [vm/service]: expose Pointer<T> address in VM Service Protocol
Pointer<T> instances were previously serialized as PlainInstance
with no address, making them opaque to all debugger clients.

TEST=pkg/vm_service/test/get_object_rpc_test.dart

Fixes: https://github.com/dart-lang/sdk/issues/62853
Change-Id: Ia44eb0fa0851332409680d8d593141fe25505114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486460
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-03-24 10:23:38 -07:00
Slava Egorov 618d608c81 [perf_witness] Fix -o behavior with relative path
Target process and the recorder might be running in different working
directories so request to start recording should always use absolute
path.

This also cleans up how file recorders are created: it does not make
sense to create the recorder and the check if we can open the file
(in fact: creating recorder and failing to open file will cause
deadlocks). Thus this CL changes the code to first open the file
and only if we succeeded creates the recorder.

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

TEST=extended existing tests to cover this

Change-Id: Ib9d88ce23d93bcc5d6335ba1daebad2e6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490160
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-24 06:46:47 -07:00
Lasse R.H. Nielsen cdd8311b14 Make VM run microtasks after an event handler throws.
Tested: Test added for fix.
Change-Id: Ifbefb01ef0caf9de80e44c44e5de4cc51bb129cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-24 06:36:04 -07:00
Alexander Markov efce7c1cb0 [vm,dyn_modules] Fix single-target cid range dispatch for dynamically loaded classes
In AOT mode, when call site is transitioned from monomorphic state
(with receiver cid1) to polymorphic (with receiver cid2),
there is an optimization which checks if all _allocated_ classes
in the class id range cid1..cid2 have the same dispatch target.
If so, a specialized SingleTargetCall stub is used.

The problem is that 'allocated' bit is only set during precompilation,
and dynamically loaded classes were not considered as valid receiver
classes by this optimization.

As a result, the following situation could happen:
cid1 < cid3 < cid2,
cid1 dispatches to target1
cid2 dispatches to target1
cid3 should dispatch to target2, but it is still in range cid1..cid2 and
SingleTargetCall stub would incorrectly dispatch it to target1.

The fix is to treat all dynamically loaded classes as allocated when
checking for single target optimization.

TEST=pkg/dynamic_modules/test/data/single_target_cid_range_dispatch
Fixes b/493677699

Change-Id: I42e407385a5d9b0a4a1017f713b47587c3c6a818
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488920
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2026-03-19 06:12:41 -07:00
Alexander Markov d611d205e3 [modular_aot] Initial code generation for TypeCast, TypeTest
Also:
* Revise code generation for cycles in parallel moves using temporary
  register.
* Support splitting of live intervals both at even and odd positions.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I900edc275b59daf93604668eada1421dd125b217
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487982
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-18 14:53:09 -07:00
Ryan Macnak a0faceddd7 [vm] Reduce symbol roots.
TEST=ci
Change-Id: I09b1015cff6ae36c9d76a95e969bd9dd684c25fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488582
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-18 10:45:00 -07:00
Ryan Macnak ec77e28f26 [vm] Shrink the FFI callback stub.
Instead of switching over each of the different callback types and duplicating the call-dart-spill-call-runtime-restore in the stub, have the initial runtime call return a function pointer for the runtime call to end that kind of callback. A separate case for tail calls is still needed.

TEST=ci
Change-Id: I691487ca12337ddef1adaeec4c163c56e2feb09e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488261
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-18 10:18:06 -07:00
Ryan Macnak 28f94515fe [vm] Fix warning on newer GCC.
TEST=local build
Change-Id: Ic54b6bd6ae53cd4b5ef6dfa3d57ce05d8dff1755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488522
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-17 12:28:30 -07:00
Ryan Macnak b76efb098b [vm, gc] Also apply back pressure during concurrent sweep.
When running without concurrent marking, the growth policy sets an allocation limit that triggers a blocking GC. When running with concurrent marking, the growth policy sets an allocation limit that triggers the start of concurrent marking, but the mutator will continue to allocate until marking completes. By itself, this would allow the heap to grow far beyond its working set size, so back pressure is applied to the mutator by making it do some incremental marking work in proportion to the amount it allocates. A similar race between mutator and GC exists for concurrent sweep, so make the mutator do some incremental sweeping too.

Cf. 305c3e30c6.

TEST=golem
Bug: https://github.com/dart-lang/sdk/issues/62762
Change-Id: I6f882e6893e1cd3b3591db8cd03b61eb06bfa02f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486828
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-16 10:24:42 -07:00
Ryan Macnak 1e3a9469d7 [vm, compiler] Fix kNativeCallbackSharedStubSize for debug MSAN.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62835
Change-Id: I2b8d0fd63144df5ed7255ef9d44944af39d618a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487280
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-16 09:58:48 -07:00
Tess Strickland 32b8c8f12f [vm,dyn_modules] Fix the interpreter case in GenerateResumeStub.
Previously, it would always call the ResumeInterpreter runtime entry
passing null as the value to return to the resumed code. Instead,
appropriately retrieve the to-be-returned value from the stack.

Also fixes IL printing to print constants in non-SSA flow graphs and
adds Interpreter::TraceStackFrames, which prints the top frames of the
current stack, so calls to it can be added for easier debugging in the
future.

TEST=pkg/vm_service/test/async_star_step_out_test.dart
     (still fails, but the failure changes due to no longer spuriously
      calling get:current after the generator finishes)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ibb3524d32c8c4e1320f4f9dfd35947eda7d6ca68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488181
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-03-16 09:35:38 -07:00
Sigmund Cherem 354b0f8606 [dyn_modules] Support types in a dynamic interface.
This CL adds a new `can-be-used-as-type` section in the dynamic
interface to expose the type of a class or extension type, without
making them callable or exposing their members.

Details:
* add the new section to the documentation
* add support in the TFA transformation to annotate kernel nodes
* add support to the validator to check for proper usage from dynamic modules
* add CFE, transformation, and end2end tests.

The CL ignores DDC and Dart2wasm at the moment and we intend to approve
any failures. It's possible that DDC works due to its modular nature.

BUG=b/488343137
TEST=cfe, annotator, and e2e tests

Change-Id: I900b22b85950f8ac379eabaa2ef58f075e18519c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486340
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-12 09:46:50 -07:00
Ben Konyi a8aba7fab8 [ Service ] Add support for isolate-based RPCs to dart_runtime_service_vm
This change adds initial support for working with isolates in the Dart
Runtime Service and its backends.

The new `IsolateManager` base class tracks the set of active isolates
and their lifecycle events. The `VmIsolateManager` extends this class,
adding support specific to interacting with isolates within the Dart VM.

TEST=vm/cc/DartAPI_InvokeVMServiceMethod*_Exp

Change-Id: I3dfa298722c40dbdfdd58105cc78f31d058dd7a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486560
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jessy Yameogo <yjessy@google.com>
2026-03-12 09:08:14 -07:00
Alexander Markov 72042aedb9 [vm] Fix TSAN data race between Profiler::IsolateGroupShutdown and Profiler::SetConfig
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/62837

Change-Id: Iee456945f3c09bc02e5449a476c56fa445b4ca7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-12 08:41:30 -07:00
Alexander Markov 09cd42db1c [vm] Expose object tags and max new-space object size via runtime offsets
Also, cleanup duplicate constant kTagBitsSizeTagPos.

TEST=ci

Change-Id: I83465af0cc8e93880ddae7d161151b397f8ec8c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487101
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-03-11 14:05:49 -07:00
Alexander Markov bcbc47d99c [vm] Expose predefined class ids via runtime offsets
TEST=ci

Change-Id: Ie0627c6c1ef32e1c21ee04aba84b05534f1f752b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486862
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-11 13:24:40 -07:00
Alexander Aprelev 46cf07fe35 [vm/shared] Ensure scratch register is requested as temp for LoadStaticFieldInstr.
TEST=tests/ffi/many_listener_callbacks_test/5 on vm-ffi-qemu-linux-release-arm

Change-Id: I6a60220bce6dbc760e3a027b1b023c59dff36ba7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-11 13:11:32 -07:00
Ryan Macnak 616ee51f99 Fix Fuchsia build.
TEST=ci
Change-Id: Ib13283c0d4d107c813d8aa1684caef68c356dddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486826
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-10 16:44:26 -07:00
Ryan Macnak 38743dd774 [vm] Remove unused dependency on ICU i18n.
TEST=ci
Change-Id: I6a09ef8af516495d479b5969aa89c9b2ceb9dc6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486824
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-10 12:36:30 -07:00
Alexander Markov 6746db1f31 [modular_aot] Fix live ranges of non-fixed temps, fix serialization of two-byte strings
* Live ranges of non-fixed register temporaries should interfere both
  with live ranges of inputs and outputs.

* When serializing a two-byte (non-Latin1) strings, ensure that
  characters in the data section are aligned by 2.
  However, already written data in the serialization buffer
  may be misaligned (as we're writing to a series of buffers), so
  write each code unit as separate bytes instead of writing them as
  Uint16List.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Ia9919218e473979529c8af48480a09adc1659b1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486540
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-03-09 13:02:03 -07:00
Alexander Markov d97566551b [vm,modular_aot] Boxing/unboxing of int and double values
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I9fe47364bf772ccedf21f95aa5b16b92b0215b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486240
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-09 11:34:09 -07:00
Tess Strickland db8563d4d6 [vm,dyn_modules] Recognize the vm:invisible pragma.
Adds a new isInvisible flag for both FunctionDeclarations and
ClosureDeclarations and sets it if the function or closure declaration
is annotated with @pragma('vm:invisible'). This way, function visibility
is appropriately recorded even if options.emitAnnotations is false.

The bytecode reader checks for the isInvisible flag when reading
FunctionDeclarations and ClosureDeclarations and appropriately
sets the is_visible flag for the Function object accordingly.

TEST=pkg/dart2bytecode/test/bytecode_generator_test
     vm/dart/invisible_function_pragma_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: If435afbe5e74adc022ce064784b6b3e5e8a88164
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486381
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-09 10:16:02 -07:00
Johnni Winther 988cd0f9b7 [cfe][PrimaryConstructors] Add isRedirecting/SuperInitializer flags to InvalidInitializer
This adds isRedirectingInitializer and isSuperInitializer to the Initializer hierarchy and adds flags to InvalidInitializer to signal when the InvalidInitializer should be taking as a redirecting or super initializer. This allows us to avoid miscatergorizing such declarations when they are erroneous.

Part of #61700

TEST=existing

Change-Id: If0fabbda10b72304999a5380fce74f9e8fa91ca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-09 03:36:55 -07:00
Alexander Aprelev 3c24bf2413 [gardening] Assert Record FieldNames contents.
Fixes https://github.com/dart-lang/sdk/issues/62850
TEST=ci

Change-Id: I8e81dc7cb0e17b6ee43bfaaba1553ae932d74f44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486261
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-06 13:38:53 -08:00
Alexander Markov fd18bbb4a3 [vm,modular_aot] Dynamic calls
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I13eaccbefae4917500ee3aeb6a09d71f480a4c94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485560
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-05 15:51:29 -08:00
Ryan Macnak da0ba8eb5c [vm] Unpoison return value from FFI callbacks.
Also fix XMM1/FA1/D1/D2/D3 getting clobbered for isolate-group bound callbacks and sync-ownership callbacks.

TEST=msan
Bug: https://github.com/dart-lang/sdk/issues/62816
Change-Id: Id721825fdec1984189051ea1c5cc73791bad53be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485300
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-04 17:15:55 -08:00
Ryan Macnak ee5371268c [vm, windows] Get DSO offsets without needing SymInitialize.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60499
Change-Id: Ie9d45072e5a74522c22a99a18277ccbed53636b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485581
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-04 16:07:20 -08: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
Ryan Macnak 4bb6609724 [vm] C++20 updates.
- std::atomic_ref
  - std::bit_cast
  - std::rotl,rotr
  - designated initializers

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/42074
Change-Id: I7be17147723db6f7620a147e75d38ebe46393f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484700
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-04 12:40:19 -08:00
Slava Egorov a1fcb5e863 [vm] Zero initialize registers in the regexp interpreter
RegExp compiler produces bytecode which might issue PushRegister
before SetRegister - which leads to a use of uninitialized value
under MSAN if these registers are not initialized.

TEST=ci

Change-Id: I011545cf05de62490d71503ea5a60a656a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485000
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-03 07:04:06 -08:00
Tess Strickland 7ad5ee3dae [vm,dyn_modules] Print line and column for synthetic token positions.
When using the --dump-kernel-bytecode flag, also print the line and
number of the source position encoded by a synthetic token position.

Also use the decoded value for a synthetic token position when
converting it as a C string for printing, which also makes it easier to
correlate real and synthetic token positions encoding the same source
position.

Also change the long outdated comment about synthetic token positions
not encoding a real source offset, as most if not all uses of them
do actually encode a real source offset.

TEST=manual use during debugging

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ic16e320e9a10d8343e8a37c8270c7076bb7052c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484943
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-03 06:58:35 -08:00
Alexander Aprelev f3bc347448 [core/shared] Allow for BigInt to work in isolategroup-bound callbacks.
Introduce runtime checks for BigInt to allow it being used as deeply immutable class.

TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Bug: https://github.com/dart-lang/sdk/issues/62601
Change-Id: I343862bdf5603be571d3bf937261dd61aca9ca0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-02 13:52:34 -08:00
Alexander Markov 9657cf7a02 [vm,modular_aot] Support serialization of local function references in modular snapshots
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I5b5c9b0cc66d44b25691d72df34efb8071c1564b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484221
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 08:13:26 -08:00
Alexander Markov ffa7e990f0 [vm,dart2bytecode] Use local function IDs to register and find functions
TEST=ci

Change-Id: I275a7f9e81a8fa69a004518b150c7dfcf1fe7bd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483844
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 07:55:38 -08:00
Alexander Markov 99929813b0 [vm,kernel] Add unique IDs for local functions in kernel AST
The unique IDs are assigned during VM-specific lowering transformation
and recomputed during TFA tree shaking.

The IDs are not assigned when local function AST nodes are created
as it makes certain AST transformations very fragile (e.g. moving
a sub-tree to another parent, cloning a tree to insert into another
member).

The IDs will be used to identify local functions within a member by
the VM and different compilers (dart2bytecode, modular AOT).

TEST=ci

Change-Id: Ifa5dc007322a0137776961d364bbf8565137b318
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 06:55:31 -08:00
Tess Strickland b1005044db [gardening] Fix TRACE_TYPE_CHECKS on MSVC.
Add __VA_OPT__ to guard the trailing comma, since we use
the /Zc:preprocessor flag.

Remove the conditional guard, since __VA_OPT__ is the
portable way of doing this in C++20, and we target that
version of the language standard when compiling.

TEST=build on vm-msvc-win-x64,vm-msvc-win-arm64

Cq-Include-Trybots: luci.dart.try:vm-msvc-win-arm64-try,vm-msvc-win-x64-try
Change-Id: I5b718858300d72679e9c8bced5f1419e206a2e94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484621
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-03-02 05:47:34 -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 c3bd038008 [vm] Fix profile streaming in debug mode.
Simplify isolate group enter-exit logic in EmitModuleSymbolsFor: always
call it without an active isolate group. Make sure that we 
destroy StackZone before trying to exit the isolate.

Skip unit test with deferred units on Mac OS: as we don't support
deferred units when writing out Mach-O files currently.

TEST=ci

Change-Id: I8a8615f045781f263c92c45eecf955366a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-26 03:28:56 -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 d5e2f31993 [vm] Fix race compiling regexp.
TEST=iso-stress
Change-Id: I013d7d91d37b62ed60d7f067a62c6f419c0d0a7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483362
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-02-24 15:23:18 -08:00
Ryan Macnak c87555403c [vm] Avoid heap walk for AOT profiler.
TEST=pkg/vm_service
Change-Id: I6d5d6cc5d6f879f8a0e128c7862d0ff031552211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482963
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-24 10:24:31 -08:00
Ryan Macnak 5e173fa736 [vm] Mark natives as unreachable in gen_snapshot.
This allows a great deal of linker GC resulting in a much smaller binary. The benefit multiplies for Flutter development because the Flutter tool downloads many variant copies of gen_snapshot.

out/ReleaseX64/exe.stripped/gen_snapshot -1.55M (-23.4%)

TEST=ci
Change-Id: I9f6e650f78ea52c9c6953320a669b71019403236
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482965
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-02-24 10:08:30 -08:00
Alexander Markov 0ec57dd561 [vm,modular_aot] Initial code generation for static field loads and stores
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I07aa7cabf8fe78c0f98c17b98ae85bdc903b99c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482920
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-24 08:54:39 -08:00
Slava Egorov 33c0d4bf70 [vm/profiler] Don't give up when FP is invalid
If we have Dart stack frame information don't give up on profiler
sample if C frame is malformed due to invalid FP. We are not 
going to use C frame information anyway.

TEST=ci

Change-Id: I8da05d1397f805543b7721fa9d861a996a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-24 01:32:27 -08:00
Ryan Macnak 60fe67bb4b [vm] Let the C++ compiler know it can assume the low bit of a Smi is clear.
TEST=ci
Change-Id: I89f60532a6fe7923a5d4d7bbcd624228ab899854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481300
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 13:01:19 -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
Alexander Markov 7eb7da6890 [vm,modular_aot] Initial code generation for interface calls
Also:
* Support arguments descriptors.
* Fix order of ClosureCall inputs in local function invocations.
* Fix order of passing arguments in all Dart calls.
* Fix handling of fields in InstanceSerializationCluster.
* Do not compile abstract methods and fields.
* Do not generate initializer functions for fields with trivial
  initializers.
* Initialize Code::code_source_map to an empty CodeSourceMap
  (in order to avoid failed assertions).

TEST=tools/test.py -n vm-modaot-mac-debug-arm64 language

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I40ff1b8234c32c41e08f3288a23e4abc173efcfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-23 08:03:48 -08:00
Alexander Markov 39c5a61f89 [vm] Check covariance of type parameters of a forwarding stub instead of its target
A forwarding stub can have a covariant type parameter while the same
type parameter in its forwarding stub target is non-covariant.

We should still check bounds of such type parameters
(the bound to check is taken from the forwarding stub target).

TEST=tests/language/regress/regress62664_test.dart
Fixes https://github.com/dart-lang/sdk/issues/62664

Change-Id: I86eeb9f8a537c22fb473388f9b17f55084af6366
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-23 07:27:56 -08:00