Commit Graph

21991 Commits

Author SHA1 Message Date
Ben Konyi 11ab2dfe2f Revert "[SDK] Switch dds and dtd to use an AOT snapshot"
This reverts commit 6450d76f1f.

Reason for revert: Breaking Flutter G3 roll

Original change's description:
> [SDK] Switch dds and dtd to use an AOT snapshot
>
> TEST=ci
>
> Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I9985919063cacfc8673b3e2946eaa163e90c9cc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411200
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-02-20 15:17:16 -08:00
Ryan Macnak 398bd838d5 [vm, reload] Use the right field table when checking if the values in shared fields still conform to the static type.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60098
Change-Id: I00d680485312027fe6bdbdf95f48a4bd3be8ec68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410743
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-02-19 11:01:21 -08:00
Ryan Macnak cb59df7acf [vm, ffi] Better handle errors that are not unhandled exceptions during FFI callbacks.
Before this change, an error reaching an FFI callback would attempt to execute the normal invocation stub from the beginning in the FFI callback's frame, which quickly crashes. After this change, the runtime recognizes this marker use of the invocation stub and returns to the FFI callback function instead.

TEST=ffi/unwind
Bug: https://github.com/dart-lang/sdk/issues/39487
Change-Id: I477cfcfc236e6cf518ebfe52860ba49e466ebf8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409562
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-02-19 09:40:34 -08:00
Lasse R.H. Nielsen aab7621900 Remove some multitest runtime-tests.
Change-Id: I8fb69fecbe67236a4cbad9c1eb899a31a26a1ba3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410002
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-02-19 04:21:42 -08:00
Ryan Macnak 12be1f79d2 [vm] Test active mutator stealing works with dart:concurrent locks.
- Add Monitor.notifyAll.
 - Refactor Mutex.runLocked to unlock if interrupted by unwind error.
 - Fix skipped DLRT_ExitHandleScope during an unwind error.

TEST=vm/dart/isolates/many_isolates_blocked_at_monitor_test
Bug: https://github.com/dart-lang/sdk/issues/55991
CoreLibraryReviewExempt: VM-only experimental library
Change-Id: I7a37544436e22158e45ee44567600fcf7ff7d7b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409561
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-02-18 10:33:14 -08:00
Michael Goderbauer 539b0e2a1c Refactor regression_44985_test.dart
Change-Id: I0e5788dd5e0636927df1e961cc00b104bc2b21a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409843
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2025-02-13 23:23:30 -08:00
asiva 6450d76f1f [SDK] Switch dds and dtd to use an AOT snapshot
TEST=ci

Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-02-13 09:11:38 -08:00
Martin Kustermann 23cac7c840 [gardening] Make more robust test for mutator bit stealing mechanism
We also disable the test in hotreload mode, because threads that are
stuck in ffi calls don't participate in hot-reload requests.

This is something we may want to look into. Right now it's conservative in
the sense that if an embedder did a `Dart_LookupClass()` in such a ffi call
and then a reload happened, such a handle would possibly hold pointer to
an old class object and weird things may happen.

This fixes test failures in hot reload / rollback mode of

  `vm/dart/isolates/many_isolates_blocked_at_ffi_test`

and also make it more robust.

TEST=tests/ffi/dl_api_exit_enter_isolate_test

Change-Id: I823d07a6ab04e62e051e4d22ec80cbc3649762a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409100
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-02-13 01:19:14 -08:00
Alexander Markov f37db8487f [vm] Double check if thread interrupts are enabled after thread is interrupted
Thread interrupts can be disabled after thread interrupter decided to
interrupt a thread but before thread actually receives and handles
a signal.

This may cause a data race accessing a Sample between profiler which
initializes and adds a Sample and the main thread using
Profiler::sample_block_buffer() in the profiler unit tests.

This is a possible fix for the following benign TSAN error:

WARNING: ThreadSanitizer: data race (pid=5824)
  Write of size 4 at 0x7f53e8e53a98 by thread T6:
    #0 dart::Sample::set_thread_task(dart::Thread::TaskKind) out/ReleaseTSANX64/../../runtime/vm/profiler.h:325:12 (run_vm_tests+0x292cab2)
    #1 dart::SetupSample(dart::Thread*, bool, unsigned long) out/ReleaseTSANX64/../../runtime/vm/profiler.cc:1226:11 (run_vm_tests+0x292cab2)
    #2 dart::Profiler::SampleThread(dart::Thread*, dart::InterruptedThreadState const&) out/ReleaseTSANX64/../../runtime/vm/profiler.cc:1381:7 (run_vm_tests+0x292cab2)
    #3 dart::ThreadInterrupterLinux::ThreadInterruptSignalHandler(int, siginfo_t*, void*) out/ReleaseTSANX64/../../runtime/vm/thread_interrupter_linux.cc:44:5 (run_vm_tests+0x2a064b0)
    #4 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*) ../staging/llvm_build/tools/clang/stage2-bins/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:2122:5 (run_vm_tests+0x1fc057f)
    #5 dart::Mutex::Unlock() out/ReleaseTSANX64/../../runtime/vm/os_thread_linux.cc:367:16 (run_vm_tests+0x2924b89)

  Previous read of size 4 at 0x7f53e8e53a98 by main thread:
    #0 dart::Sample::head_sample() const out/ReleaseTSANX64/../../runtime/vm/profiler.h:350:59 (run_vm_tests+0x22c70e7)
    #1 dart::SampleBuffer::VisitSamples(dart::SampleVisitor*) out/ReleaseTSANX64/../../runtime/vm/profiler.h:589:20 (run_vm_tests+0x22c70e7)
    #2 dart::SampleBlockBuffer::VisitSamples(dart::SampleVisitor*) out/ReleaseTSANX64/../../runtime/vm/profiler.h:752:18 (run_vm_tests+0x22c70e7)
    #3 dart::Dart_TestHelperProfiler_GetSourceReport(dart::Thread*) out/ReleaseTSANX64/../../runtime/vm/profiler_test.cc:2241:26 (run_vm_tests+0x22c70e7)
    #4 dart::Dart_TestProfiler_GetSourceReport() out/ReleaseTSANX64/../../runtime/vm/profiler_test.cc:2206:1 (run_vm_tests+0x22c70e7)
    #5 dart::TestCase::Run() out/ReleaseTSANX64/../../runtime/bin/run_vm_tests.cc:53:3 (run_vm_tests+0x203fe6c)

--- Re-run this test:
python3 tools/test.py -n vm-tsan-linux-release-x64 vm/cc/Profiler_GetSourceReport

Also, this change is a possible fix for https://github.com/dart-lang/sdk/issues/44089.

TEST=ci

Change-Id: I8ad87c340580325cbd6e22b5f068e1e33b0a7d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409460
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-12 14:48:28 -08:00
Ivan Inozemtsev 51ea42537a Add support for flushing microtasks in dart_engine.h
Also add a sample for calling Dart functions which return/accept futures.

Change-Id: I932d0577709f4e068ccd3212797751ecb347c4f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408281
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-02-12 11:10:25 -08:00
Alexander Markov 223c3a1c60 [vm, dynamic_modules] Inherit IsDynamicallyOverridden when creating method extractor
A method extractor (implementing get:foo for a method foo()) can be
used as an interface target. If original method can be overridden in
a dynamic module, then method extractor can be overridden too.
So IsDynamicallyOverridden flag should be copied when creating
a method extractor.

TEST=dynamic_modules_suite/tearoff_no_concrete_impl
Fixes https://github.com/dart-lang/sdk/issues/60116

Change-Id: I54439426645b3daf308d18da6e0d06602b9ec30f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-12 10:38:48 -08:00
Vyacheslav Egorov 10741eddf7 [vm/compiler] Let ResolveControlFlow handle spill slot moves
There is no need to manually add a move on entry to the try.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-product-arm64-try,vm-aot-mac-release-arm64-try
Change-Id: I3720b1dd5b089b22d68d87274f1e3a7814bbd0e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409141
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-02-12 08:03:12 -08:00
Robert Nystrom 3f0dc30379 Remove deleted language test from VM stress test list.
Change-Id: I45b5c58cc040fa0624de4c3643ccafe2d4b26071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409183
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-02-11 20:27:02 -08:00
Liam Appelbe cb02b8726a [vm] Isolate ownership API
go/dart-isolate-ownership-api

Change-Id: Ia778a916de3fecec9f0aa1a5c8bc9fd7dd421267
Bug: https://github.com/dart-lang/native/issues/1908
TEST=runtime/vm/dart_api_impl_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-02-11 20:09:11 -08:00
asiva b1e10bff4f [gardening] Remove deleted test from stress test configuration.
TEST=vm/dart/isolates/concurrency_stress_sanity_test

Change-Id: I3648e58dd301578b44f2dfd5981e892dd377985b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409184
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-02-11 17:25:36 -08:00
Alexander Aprelev 413d9e9be4 [vm] Fix liveness calculation to correctly account for try-catch flow.
Ensure that liveness analysis as part of register allocation takes into account try-catch implicit data flow.

Fixes https://github.com/dart-lang/sdk/issues/60017
TEST=nested_try_throw_environment_test

Change-Id: I6013942f8f4b78655938765e11859008c28cb9e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408421
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-02-11 12:23:19 -08:00
Martin Kustermann e072cdb204 [vm] Add test to ensure class hierarchy is present in output of analyze_snapshot
go/dart-ama

Change-Id: I533ca49d0e27a59f2f2763cc14c69485a470c281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408561
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-02-11 11:40:24 -08:00
Alexander Markov ce600d0f50 [vm] Fix TSAN data race when accessing Thread::top_
This is a possible fix for the following benign TSAN error:

WARNING: ThreadSanitizer: data race (pid=40436)
  Read of size 8 at 0x7b7c000bfa48 by thread T6 (mutexes: write M0):
    #0 dart::Page::object_end() const out/ReleaseTSANX64/../../runtime/vm/heap/page.h (dart+0x25ade83)
    #1 dart::Page::used() const out/ReleaseTSANX64/../../runtime/vm/heap/page.h:107:34 (dart+0x25ade83)
    #2 dart::SemiSpace::used_in_words() const out/ReleaseTSANX64/../../runtime/vm/heap/scavenger.h:46:18 (dart+0x25ade83)
    #3 dart::Scavenger::UsedInWords() const out/ReleaseTSANX64/../../runtime/vm/heap/scavenger.h:157:17 (dart+0x25ade83)
    #4 dart::GetProcessMemoryUsageHelper(dart::JSONStream*)::$_0::operator()(dart::IsolateGroup*) const out/ReleaseTSANX64/../../runtime/vm/service.cc:4729:50 (dart+0x25ade83)

  Previous write of size 8 at 0x7b7c000bfa48 by thread T9:
    #0 dart::Thread::set_top(unsigned long) out/ReleaseTSANX64/../../runtime/vm/thread.h:698:34 (dart+0x2622071)
    #1 dart::Scavenger::TryAllocateFromTLAB(dart::Thread*, long) out/ReleaseTSANX64/../../runtime/vm/heap/scavenger.h:256:13 (dart+0x2622071)
    #2 dart::Scavenger::TryAllocate(dart::Thread*, long) out/ReleaseTSANX64/../../runtime/vm/heap/scavenger.h:139:12 (dart+0x2622071)
    #3 dart::Heap::AllocateNew(dart::Thread*, long) out/ReleaseTSANX64/../../runtime/vm/heap/heap.cc:84:27 (dart+0x2622071)
    #4 dart::Heap::Allocate(dart::Thread*, long, dart::Heap::Space) out/ReleaseTSANX64/../../runtime/vm/heap/heap.h:87:16 (dart+0x2416cab)

TEST=ci

Change-Id: Id9077cff2c1143adf999b2b26c941701d63cd844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409180
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-11 09:39:20 -08:00
Ryan Macnak 9e8a21bf52 [vm] Improve the hash for function type parameters.
AOT compiling the isolate stress test spends the majority of its time canonicalizing function types.

In release mode, 2:45 -> 1:43 (-38%)

TEST=ci
Change-Id: I58ef0157612930d582784c7bea7de177c1219a0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408941
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-02-10 16:02:30 -08:00
Ryan Macnak 4cf27cc968 [vm, compiler] Fix assert assembling add/subs with extended register.
This is not symmetric with add/sub, accepting ZR instead of CSP.

TEST=vm/cc/Assembler_CmpExtReg, dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/60092
Change-Id: Icc24f7883a113eac504fd8fc29c0d6f781cb7657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408901
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-02-10 15:16:50 -08:00
Ryan Macnak d9503428fa [vm, reload] Restore assertion that the reload context is gone before shutdown.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/32796
Change-Id: Idae5f2240af6069bf5bb4f1bb5868b2f39cead3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408202
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-02-10 14:36:31 -08:00
Ryan Macnak 2a08770912 [vm] If waiting for an active mutator slot for too long, steal a slot from a thread at a native safepoint.
The thread whose slot was stolen will take the slow path attempting to exit its safepoint and wait to reacquire an active mutator slot.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54687
Change-Id: I49c4c12b38d38d7afa4df6b346c2a464f75ef6e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406404
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-02-10 09:38:42 -08:00
Ryan Macnak 4617198d58 [vm] Add option for GC at [re]throw.
Add a reduced test for crash / false ConcurrentModificationError observed by the isolate stress test.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60017
Change-Id: I665a7ec48c150d270e751ab13393384613d44674
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408201
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-02-05 14:24:32 -08:00
Alexander Markov f2d70cec04 [vm,arm64] Fix AddImmediate in case of CSP
Use extended register variant of add instruction when Rd or Rn
register is CSP (SP). Also fix assertion which was incorrectly
testing that Rd cannot be CSP if extended register operand is used
(actually it cannot be ZR).

TEST=vm/cc/Assembler_Drop
Fixes https://github.com/dart-lang/sdk/issues/46433

Change-Id: I542dd7bc0661b3195fa466e43cd65998c1c4ac81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408141
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-02-05 12:32:39 -08:00
Alexander Markov 30d6cc9394 [vm,tests] Fix vm/dart/devirtualization_during_inlining_il_test on vm-aot-optimization-level-linux-release-x64
TEST=vm/dart/devirtualization_during_inlining_il_test
Fixes https://github.com/dart-lang/sdk/issues/54940

Change-Id: If867cdcffbed32925ff40094fc112cd6b238ac97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408120
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-05 10:47:00 -08:00
Alexander Markov 430554158e [vm] Support implicit dynamic calls
According to the spec, a call in the form

  e(a0,...,aN)

where static type of 'e' is 'dynamic' should succeed only if
(1) 'e' evaluates to a function, or
(2) runtime type of 'e' has a 'call' *method*.

If runtime type of 'e' has a 'call' getter this invocation should
fail with NSM.

This behavior is different from 'e.call(a0,...,aN)' which accepts
'call' getters.

---

In order to implement this behavior in the VM, a special
'dyn:implicit:call' selector is added. It behaves similarly to
'dyn:call' except when looking for a getter target.

This selector is used when CFE sets FlagImplicitCall on a
DynamicInvocation node.


TEST=co19/Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A04_t01
TEST=co19/Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A04_t02

Fixes https://github.com/dart-lang/sdk/issues/59965
Issue https://github.com/dart-lang/sdk/issues/59952
Issue https://github.com/dart-lang/sdk/issues/51517
Issue https://github.com/dart-lang/language/issues/3482

Change-Id: Ic45f7743ad75571476642dcec9c91e6a77e8e321
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407161
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-02-04 08:13:29 -08:00
Alexander Markov 00e5314d7b [vm,compiler] Do not treat unrelated DynamicInvocation flag as InstanceInvocation.FlagInvariant
StreamingFlowGraphBuilder::BuildMethodInvocation handles both
DynamicInvocation and InstanceInvocation nodes.

BuildMethodInvocation has been reading flags field and testing
kInstanceInvocationFlagInvariant bit without checking if node is
InstanceInvocation, so it has been handling an unrelated
DynamicInvocation flag (FlagImplicitCall) as FlagInvariant.

TEST=ci

Change-Id: I1e2ecbb0023bfdb393fc24c29cc8263e05198277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407081
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-04 07:27:39 -08:00
Daco Harkes 74f2d4b1af [vm/ffi] Error on invoking callback from leaf call
All callbacks flow via the single runtime entry, so we add a check
there.

TEST=tests/ffi/function_callbacks_leaf_test.dart

(The transition verification in
https://dart-review.googlesource.com/c/sdk/+/407021
doesn't catch the error. The callbacks already transitioned before
reaching the generated code in that CL.)

Closes: https://github.com/dart-lang/sdk/issues/60021
Change-Id: Ia6bf8af186c9c8c5a66cffa537d80421467330d4
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407023
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-02-04 03:36:29 -08:00
Daco Harkes 5984cc8c24 [vm] Verify transitions in generated code
The transitions in C++ have asserts which run in debug mode to validate
that the transitions are happening in the right order.

The transitions in the generated code had no equivalent. This CL
introduces the equivalent for the generated code.

The transitions to generated code are misnamed currently. They come
from either VM or Native, not only Native. For example the FFI
callbacks and call return sequence can already transition from native
into the VM when entering the safepoint.

These checks don't catch the invalid FFI callbacks.
Bug: https://github.com/dart-lang/sdk/issues/60021
These are caught when looking up the FFI metadata:
https://dart-review.googlesource.com/c/sdk/+/407023

This CL omits to implement the check in ia32, since ia32 is scheduled
for removal.

The check is only enabled in debug mode. The asserts for the C++ are
also only run in debug mode. And enabling this check in release for
AOT regresses the parent CL benchmark by ~30% on Mac Arm64.

TEST=test/ffi

Change-Id: Ieaf1e43533baae294af37b2e171b68bd314fdbe0
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407021
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-02-04 03:36:29 -08:00
Ben Konyi dacb2a71a7 [ CLI ] Remove implicit entry into DartDev if VM service is enabled
Related issue https://github.com/dart-lang/sdk/issues/59992

TEST=N/A

Change-Id: Id95a8015b479f4b5ed67ccfd14d9593d11b96a66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406640
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-02-03 16:40:40 -08:00
Ryan Macnak fb0cac7375 [vm] Fix uninitialized Code::instructions_ during deferred loading.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/59905
Bug: https://github.com/dart-lang/sdk/issues/60035
Change-Id: I733ee43f4e5e48ffa8eeb357de543233a1887b4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407601
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-02-03 16:02:38 -08:00
Alexander Markov 7fd0d073a9 [vm] Cleanup experimental createUriForKernelBlob API
This API was added in https://dart-review.googlesource.com/c/sdk/+/232682
in order to support one of the strategies for running macros,
but it is no longer needed.

TEST=ci

Change-Id: I8da233932351f27fd5dfd01b66f481195d7ca0e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407540
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-02-03 12:55:53 -08:00
Tess Strickland 8e17d8b841 [gardening] Remove deleted test from stress test configuration.
TEST=vm/dart/isolates/concurrency_stress_sanity_test

Issue: https://github.com/dart-lang/sdk/issues/60031
Cq-Include-Trybots: luci.dart.try:vm-linux-release-x64-try
Change-Id: I10852f8268a8a2ab03049eccf254379324d48565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407380
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-02-03 03:15:07 -08:00
Tess Strickland 23b4b3c254 [tests] Updates for the change in path.
These files were moved from the root directory to lib/ in
https://dart-review.googlesource.com/c/sdk/+/405140, but the tests
that used them weren't updated accordingly.

TEST=service/breakpoint_in_package_parts_class_file_uri_test

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

Change-Id: Ie7eb4666baa7caab95a1aa8469fc890a127f9565
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405762
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-01-29 08:01:39 -08:00
Ivan Inozemtsev 6e33c95463 Dart Engine
Adds shared libraries for embedding Dart VM and new API (runtime/engine/include/dart_engine.h).

TEST=tests/standalone/embedder_samples_test.dart

Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-product-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-aot-win-product-x64-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-appjit-linux-product-x64-try,vm-appjit-linux-release-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-product-arm-try,vm-ffi-android-product-arm64c-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-gcc-linux-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-arm64-try,vm-linux-release-ia32-try,vm-linux-release-simarm-try,vm-linux-release-x64-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-mac-release-arm64-try,vm-mac-release-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-msvc-windows-try,vm-reload-linux-debug-x64-try,vm-reload-linux-release-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-reload-rollback-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try,vm-win-release-x64-try
Change-Id: Ia4e4d1b871ddef515cfb2f4639bdaa9fe3676936
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402860
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-01-28 03:53:40 -08:00
Alexander Markov efee57c5f8 [vm] Replace unreachable 'throw' code with Never/Stop
Change core library '_throwNew' helpers to return Never.

Since https://dart-review.googlesource.com/c/sdk/+/405604 flow graph
builder automatically appends Stop and closes fragment after appending
a call with return type Never. So additional 'throw' after calling
'_throwNew' are no longer needed and can be removed.

Also, cleanup unused FlowGraphBuilder::ThrowTypeError() and
replace 'throw' with shorter Stop at the end of 'case'.

TEST=ci

Change-Id: I0a5109fd693c0463c53e70e5dd261f8080bf1132
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406080
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-01-27 16:05:48 -08:00
Ryan Macnak 82f8a10cdb [vm] Take only a read lock during Field::SetStaticValue.
It is safe for multiple isolates to set their values concurrently. Only growth of the field tables needs to be excluded by the write lock.

A storm of such setters are invoked as part of core library initialization during isolate spawning.

TEST=ci, tsan
Change-Id: I4677e33ee80bb06d261ada2ae9d6b71c94fde611
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-01-27 10:41:28 -08:00
Alexander Markov 6ddd96b45a [vm,compiler] Treat 'Never' return type as unreachable
When building a flow graph, break control flow (close fragment) after
a call with return type 'Never'. Append 'Stop' instruction after
the call to make sure the return address is still within function
code range.

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

Fixes https://github.com/dart-lang/sdk/issues/59941
Issue https://github.com/dart-lang/sdk/issues/56969

Change-Id: I5bbc0b9740a4f7e06b8560589daeb2b44f13d084
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405604
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-01-27 08:16:08 -08:00
Alexander Markov e893d11b3f [vm,compiler] Fix serialization of ranges and arguments descriptors
Convert range boundaries with symbolic references to other instructions
into constant boundaries to avoid serializing extra references.

Specially handle serialization of arguments descriptors which are
cached in the VM isolate.

TEST=ci

Change-Id: Ifab3bb4d9b037aaefd81d38dd93d47cd4b42cf1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405571
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-01-27 06:46:05 -08:00
Sigurd Meldgaard 503437735a Create lib folder for observatory_test_package
This is in preparation for https://dart-review.googlesource.com/c/sdk/+/397164

Pub insists that packages have their code in 'lib/'.

TEST=ci
Change-Id: I416204bec5ef7948bcf93c39f50fb018574b775f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405140
Reviewed-by: Tess Strickland <sstrickl@google.com>
2025-01-24 06:51:02 -08:00
Tess Strickland 1ac77f57dd [vm] Align entry point verification and the precompiler.
For entry-point pragma annotations, most of the time they are
used with either no argument or with an argument that evaluates
to either

* false to denote the annotation should not take effect, or
* null or true to denote the annotation should take effect.

However, the user can also specify that only part of the operations
on a member should be accessed from native code by using a string
argument that is either 'call', 'set', or 'get'.

The entry point verification in Invoke/InvokeGetter/InvokeSetter
assumes that for getters and setters, the only valid string argument
is 'get' or 'set', respectively. This is because those methods are
called via `Dart_GetField`[0] and `Dart_SetField`, respectively, as if
they were the getter or setter of a defined field.

However, the precompiler previously assumed that the string
argument 'call' was the only string argument that meant the link
to a function's code object should be saved. Similarly, it assumed the
string argument 'get' for functions meant that their implicit closure
function should be saved, which ends up including getters. Furthermore,
it did not do anything with setters annotated with the string argument
'set'. This means that the code link would not be saved for getters or
setters that were annotated with the string argument expected by the
entry point verifier.

This CL aligns the precompiler to match the expectations of other
parts of the codebase. It also changes TFA to report an error
if a getter or setter is marked with the string argument 'call'.

[0] `Dart_Invoke` can be called with the name of a getter that
returns a closure, but doing so is semantically equivalent to
calling `Dart_GetField` followed by `Dart_InvokeClosure`.

TEST=vm/dart/entrypoint_verification_test

Fixes: https://github.com/dart-lang/sdk/issues/59920
Change-Id: Ia2768bbaf9058bb14a1cdfb331eb85fa082a0e90
Cq-Include-Trybots: luci.dart.try:vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-product-x64-try,vm-aot-mac-product-arm64-try,vm-aot-obfuscate-linux-release-x64-try,vm-linux-debug-x64-try,vm-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404823
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-01-24 03:21:22 -08:00
Jens Johansen 46c9c29b6f [vm] Fix crash when expression evaluating with extension type with type parameter is available
Fixes https://github.com/dart-lang/sdk/issues/59653

Tested: Manually; added pkg/vm_service/test/issue_59653_test.dart and existing tests / CI.
Change-Id: I0969720c4d7c50e8756406477abe791891877abb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405381
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2025-01-23 23:26:39 -08:00
Alexander Markov ec8f330391 [vm,dynamic_modules] Fix dynamic modules build for arm64 and arm
TEST=tools/build.py -a simarm64 -m debug --dart-dynamic-modules runtime runtime_precompiled
TEST=tools/build.py -a simarm -m debug --dart-dynamic-modules runtime runtime_precompiled
Fixes b/391269628

Change-Id: Ic352b967d887c7753d1664d2cd9b66ebc4205222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405240
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-01-23 07:20:19 -08:00
Vyacheslav Egorov 939cdfbfcd [vm] Move bin/lockers.h to platform/lockers.h
We have to place these classes into a platform namespace to avoid
conflicts with vm/lockers.h.

To avoid changes to files in bin we simply change bin/lockers.h
to introduce bin::{Monitor,Mutex}Locker aliases for
platform::{Monitor,Mutex}Locker.

TEST=ci
R=kustermann@google.com

Change-Id: I975f24a8499ea85d0ba887180a81287fcf4101bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405460
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-01-23 04:19:48 -08:00
asiva fca032461a [VM/Runtime] Turn on isolate group metrics gathering in product mode
dart2js benchmarks use --print-metrics to track heap usage, with the
shift to running dart2js using aproduct mode AOT snapshot these
metrics are not printed resulting in errors from the benchmarks.
The size increase from turning on these isolate group metrics in product
mode is not very significant (about 2k).

TEST=ci

Change-Id: Ie9bbaecd57a2b45c27a158f6eb4988966a41ce67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-01-22 07:48:37 -08:00
Mohamed Abdelaal 9b7bb9df90 Fix "the the" typo
Closes https://github.com/dart-lang/sdk/pull/59926

GitOrigin-RevId: cb37bca473b0c177b876a0f4e75858cd1862e699
Change-Id: I6827241b22e99db455945afcdfbaee0450999ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404923
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-01-21 14:08:20 -08:00
Alexander Markov 4dba853325 [vm,compiler] Count DispatchTableCalls in call site count for inlining heuristics
TEST=ci

Change-Id: I820b2f6ff25bddea4ab27a6c9594e3e0bf9534a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404901
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-01-17 07:13:38 -08:00
asiva 7b25ce88d3 [dartdev] Use VmInteropHandler for invoking sub commands
Use VmInteropHandler for invoking sub commands instead of running them
in an isolate. Running sub commands in an isolate causes an increased footprint.
Changing this to use VmInteropHandler avoids the additional memory footprint.

Commands that need to use an AOT runtime for execution now exec the AOT
runtime and run the command.

TEST=ci

Change-Id: Ic96845b19951170effea3dd3619f798e2c72968a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402781
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-01-16 09:15:01 -08:00
Ivan Inozemtsev 6880ea8495 Remove unused variables in Windows code
Upstreaming internal changes required to enforce `-Wunused-variable`
and `-Wunused-result` on Windows.

Tested: ci
Change-Id: I98d9ba8eeebf4dd8520b4263f4a57039c28020ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404840
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
2025-01-16 07:47:51 -08:00
Alexander Markov 9e8e8e5fca [vm,dynamic_modules] Support members which are overridden implictly (transitively) by a dynamic module
Consider the following situation: member M1 is overridden by another
member M2; M2 is overridden in a dynamic module.

Members which can be overridden in a dynamic module (such as M2)
should be specified as 'can-be-overridden' in the dynamic interface.
Members which are overridden implicitly/transitively (such as M1)
are not required to be mentioned in the dynamic interface.
However, when determining possible targets for a call with
interface target M1, compiler should treat it as potentially
overridden in a dynamic module.

This change adds such handling to the VM/AOT. Dynamic interface
annotator now marks members such as M1 with
'dyn-module:can-be-overridden-implicitly' pragma, and
VM/AOT takes both can-be-overridden and can-be-overridden-implicitly
into account.

This change also simplifies handling of implicitly extenable classes
in the VM/AOT - now VM handles both extendable and implicitly-extendable
pragmas (from dynamic interface annotator) instead of recalculating
implicitly extendable classes on its own.

TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart
TEST=dynamic_modules_suite/implicitly_extendable

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

Change-Id: Id4570cc86303f8e45a061d696e9bca0d0b2b4b81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403951
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-15 08:13:52 -08:00