Commit Graph

22923 Commits

Author SHA1 Message Date
Ryan Macnak 97a00247f8 [test] Disable TSAN thread leak detection for more tests that call exit.
Cf. cee7000c1a.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/62405
Change-Id: I03d6bd34e57c249f0e62ae87179614b9871e0436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-20 14:47:53 -08:00
Ryan Macnak cd5b99154f [vm] Fix potential upref of null in GenerateAppAOTAsAssembly.
Fixes GCC TSAN build.

TEST=local build
Change-Id: I8e7829835b412a9f5fdf638c793d6acf4a2dc501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472664
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-20 09:49:35 -08:00
Slava Egorov 5cf77e660a [vm] Add an intptr_t cast to fix 32-bit builds
Compilation issue introduced by
commit 0fee95455c.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-ffi-android-release-arm-try
Change-Id: I087b9b6db438d77f9cb147afa7ce00256a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474401
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-20 06:43:42 -08:00
Slava Egorov 0fee95455c [vm] Cleanup Profiler lifecycle
Move away from setting command line flags and calling Cleanup or Init
to reinitialize the profiler. Split starting and stopping the profiler
into separate methods and keep only one-time initialization/cleanup
in Init and Cleanup methods. Create a separate method for reconfiguring
the profiler Profiler::SetConfig.

This removes data races which were plaguing older code and makes it
simpler to reason about.

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

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I679aa0a8724e39624e76abfad6814fe06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472862
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-20 05:58:38 -08:00
Lasse R.H. Nielsen 8d1ed4b750 Move VM-specific tests out of tests/{language,corelib}.
Change-Id: Iaeae638d2e3fb46409f04982975e78ad4c4eebe5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472865
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-19 04:17:22 -08:00
dexter 234127f73a Fix VM service smaps path NUL termination to prevent OOB reads
Closes https://github.com/dart-lang/sdk/pull/62415

GitOrigin-RevId: d50a6de006545e64ea8706027f5055cc5dc46ef6
Change-Id: Ide1bbceb184d4c5a9137f667023aa42c32df6d20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473161
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-15 04:24:46 -08:00
Alexander Aprelev 5085be76ad [vm/ia32] Ensure far jump to a slowpath entry.
Follow-up to https://dart.googlesource.com/sdk/+/eb75c53d95f485fb8307779a5aafe9019ab5b5cd.

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

Change-Id: Ie631048b7219642d520da4b2fad5698090c88382
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473102
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-14 15:02:32 -08:00
Alexander Aprelev eb75c53d95 [vm/shared] Perform deeply-immutable initialization runtime check.
When an initial value is assigned into a class tagged as deeply-immutable, perform runtime check of that value. This is needed to support proper initialization of the closures as part of deeply-immutable classes.

BUG=https://github.com/dart-lang/sdk/issues/61962
TEST=run_isolate_group_run_test

Change-Id: I550746c0d22ca06ffb89959e8384cc9e6d28d590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-14 08:42:22 -08:00
Slava Egorov 832a205895 [vm] Drop Android 6.0.0 specific workaround
Flutter does not support Android versions below Android 7 (API level 
24).

Simplify the code by removing workaround introduced in 
a013de84e0 to work-around crashes
which only happen on Android 6.0.0.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm_x64-try,vm-aot-android-release-arm64c-try
Change-Id: Ib29535e66e87b17bc9b2ac72bcbb46e06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-01-14 03:53:04 -08:00
Slava Egorov d222ed2656 [vm] Ignore races on TimelineStream::enabled
These should be benign as actual state is guarded by 
RecorderSynchronizationLock, and disabling and enabling streams can 
happen concurrently with threads which actually produce events.

Issue https://github.com/dart-lang/sdk/issues/62038

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I640b33e0bea475e4a4651ce212e7f91b6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472860
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-01-14 03:52:59 -08:00
Ryan Macnak 68e2db8ce6 [vm] Allocate aligned memory directly on Windows when VirtualAlloc2 is available.
TEST=ci
Change-Id: Ie0e436dd9fba332de309a68bcb2ae2c469949adf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472422
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-13 14:28:00 -08:00
Ryan Macnak a26681f951 [vm] Avoid call in the middle of ReadFill loop.
Hoist more of header computation from the variable-cid clusters.

TEST=ci
Change-Id: I14269992f9156383fd7c702f076bdc4de49be1e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472421
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-13 09:59:22 -08:00
Ryan Macnak 59778a5358 [vm, win] Further disable ASAN when the profiler reads stack slots.
TEST=asan
Bug: https://github.com/dart-lang/sdk/issues/62263
Change-Id: Iba599665a14edcce04458938c4e9330393862aaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471025
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-12 09:48:54 -08:00
Alexander Aprelev b4c47fd691 [ubsan] Fix parameter type mismatch ubsan for DestroyWatch callback.
Fixes https://github.com/dart-lang/sdk/issues/62365
TEST=ci

Change-Id: I70232a592c3382b1833eeffa499e713ef2cadbc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471342
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-12 09:41:47 -08:00
Ryan Macnak a50083ef29 [test] Reduce size of field scaling tests.
Bug: https://github.com/dart-lang/sdk/issues/62370
Change-Id: Ic2c7c849821d7fb44e8652744f6089987b2ae094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471327
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-12 09:40:50 -08:00
Alexander Aprelev 118d84fedd [vm/unsendable] Fix field handling in finding retaining path for unsendable values.
BUG=https://github.com/dart-lang/sdk/issues/62371
TEST=ci

Change-Id: I0fa7a931c4866cb43faee228f2d60f4e701e751a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471621
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-09 07:44:49 -08:00
Alexander Markov 1c4a218105 [gardening] Mark vm/dart/heap_snapshot_referrers_test as Slow if using sanitizers
TEST=ci
Closes https://github.com/dart-lang/sdk/issues/62333

Change-Id: I72259a22da099076a9c2e8597b2881ddd7ccba07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471522
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2026-01-08 09:19:40 -08:00
Alexander Markov ff3a562acf [vm] Fix gcc build
This change fixes the following gcc build errors:

```
../../runtime/vm/simulator_arm.cc:1403:44: error: ‘function’ attribute directive ignored [-Werror=attributes]
 1403 |                                  int32_t r4) {
      |                                            ^
../../runtime/vm/simulator_arm.cc:1417:47: error: ‘function’ attribute directive ignored [-Werror=attributes]
 1417 |                                      double d1) {
      |                                               ^
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
```

It looks like gcc doesn't support [[no_sanitize("function")]]
attribute, so limit its usage to clang.

TEST=ci

Change-Id: Id054970b9970dd1bf9fec78e97b4dbed5fd12c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471521
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-01-08 08:43:09 -08:00
Ivan Inozemtsev 8a228466a8 Revert "[vm] Allocate aligned memory directly on Windows."
This reverts commit b6881e8b5a.

Reason for revert: blocks dart -> flutter roll

Original change's description:
> [vm] Allocate aligned memory directly on Windows.
>
> TEST=ci
> Change-Id: I033327c7dffb197e7cc3c4014a3bdd4d9d5ff719
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470821
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I5d0bc54b9bdbcd7b0b27f867e46af26a63d44b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471001
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2026-01-08 00:57:50 -08:00
Alexander Aprelev 89717eae46 [vm/ubsan] Fix NO_SANITIZE_UNDEFINED definition.
This is a follow-up to 61c3fbc220 to make it accomodate android builds.

Fixes https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/vm-ffi-android-product-arm64c/10387 breakage.
TEST=ci

Change-Id: I0d18446014516b7de94ca1ed7336c0b98d699ee6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471324
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-01-07 14:01:31 -08:00
Ryan Macnak 894a5fa7d5 [vm, mac] Disable TSAN during profiler sample collection.
The suspended thread might hold a TSAN-internal lock to a location that will be read by the sampling thread, which would cause a dead lock.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/62332
Change-Id: I0ac6a05c25067749b52ed83b14f80ab1850013a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471321
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-07 12:47:21 -08:00
Alexander Aprelev 61c3fbc220 [vm/build/ubsan/win] Fix ubsan build on Windows
- copy sanitizer runtime when using ubsan;
- avoid use of winnt.h CONTAINING_RECORD since it triggers ubsan "member access within null-pointer of type" error, use our copy which uses `offsetof`;
- have default virtual destructor in `ValueObject` to avoid ubsan complains about "insufficient space for an object of type 'dart:ValueObject'" at NoTemporaryAllocator use/declaration site;
- have virtual destructor in ZoneAllocated to avoid ubsan complains about "not having enough space to allocate object" at new RegExpEmpty() instantiation site;
- avoid using crashpad with ubsan as it causes dartvm to exit with error code 3;
- switch to windows, mac-friendly `[[gnu::no_sanitize(check)]]` from `__GNUC__` and `__has_feature` checks.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62267
Change-Id: I8b922a8da329af276d4cefaa88fb841cc0457124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-07 12:38:27 -08:00
Ryan Macnak d0cad8a098 [vm] Allocate guard regions around the compressed heap.
TEST=ci
Change-Id: Ifd053d426df5a5b777da63d2bb76a53530a7f8e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461221
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-07 11:47:14 -08:00
Alexander Markov d95e527aab [dyn_modules] Improve support for extendable mixins with private members
When mixin is applied, its instance members are cloned and copies
of the members would override original members.

This change fixes bugs and improved usability of extendable mixins with
private members:

- All instance members of extendable mixins and mixin classes are
  marked as can-be-overridden to allow overriding by cloned members
  when mixin is applied.

- TFA no longer takes privacy into account, as private members of
  mixins can be overridden by their clones in other libraries.

- Dynamic module validator always unwraps cloned members to originals
  before verifying if overriding is allowed. This eliminates overriding
  errors between clone(s) and original members of mixins.

TEST=pkg/dynamic_modules/test/data/mixin_private_member1,
     pkg/dynamic_modules/test/data/mixin_private_member2

Fixes b/470461203
Fixes b/469094721

Change-Id: If369c42c58e5ea4d707be83b1e7078ee9a8cc3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470803
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2026-01-07 08:26:38 -08:00
Ryan Macnak b6881e8b5a [vm] Allocate aligned memory directly on Windows.
TEST=ci
Change-Id: I033327c7dffb197e7cc3c4014a3bdd4d9d5ff719
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470821
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-06 09:51:51 -08:00
Ryan Macnak 0e9676ea1f [vm, compiler] Some shorter load immediate sequences for RISC-V.
TEST=ci
Change-Id: I34e72727b5560da88916f996f92b33ddc1ff6dff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468980
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-05 16:31:30 -08:00
Ryan Macnak 3ebbaf08fb [vm] Use C++20 bit manipulation implementations.
TEST=ci
Change-Id: I0aee472e2074ff4f03f05df573aff7616418c72c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468904
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-05 15:14:59 -08:00
Ryan Macnak b18ec187d0 [build] Bump mac_sdk_min to 14.0.
TEST=ci
Change-Id: I92eb459a037ce8e4d1f98d1e28d7fd483f08f242
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468883
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2026-01-05 13:06:49 -08:00
Ryan Macnak cee7000c1a [test] Enable TSAN thread leak detection for most tests.
Disable for tests that use dart:io's exit.

Add missing thread joins to cc tests.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/41811
Change-Id: Id4e1a468a986c886fb5ae9e9677b4d8d0281cc79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468880
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-05 10:04:25 -08:00
Daco Harkes b277407152 [ffi][cfe] Support @Native() external Array<Struct> fields
For structs, we were already loading the size of the struct at
runtime for the size of the memcopy. This CL makes that work for
the `Array`s as well.

TEST=pkg/vm/testcases/transformations/ffi/regress_62087.dart
TEST=tests/ffi/native_assets/asset_absolute_test.dart

Closes: https://github.com/dart-lang/sdk/issues/62087
Change-Id: I15a5796d713879a613971e080d18101111704b9b
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464706
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-01-05 08:01:26 -08:00
Alexander Aprelev a949c74530 [vm/shared] Ensure stores into shared static variables are checked.
Closures going into shared variables in particular have to be confirmed to capture appropriate values.

BUG=https://github.com/dart-lang/sdk/issues/62179
TEST=run_isolate_group_run_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-aot-dyn-linux-debug-x64-try
Change-Id: I27416773fd77077018739ea4dbcc6e4695e67be8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469103
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-22 07:53:44 -08:00
Ryan Macnak 7bb5e4c192 [build] Fix Windows ASAN build to actually use ASAN.
Bug: https://github.com/dart-lang/sdk/issues/62263
Change-Id: I77a44aeff0a0685730ff3e5c897e338ddc5561a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464781
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-12-17 14:08:00 -08:00
Ryan Macnak 8b4bd49b6b [gardening] Fix gcc build.
TEST=build
Change-Id: I03574459c178f31f15f3a9200358cea4bde75573
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-12-17 13:18:10 -08:00
Ben Konyi 4cbf367b94 [ dart2bytecode ] Skip more tests that depend on dart:mirrors
Change-Id: I3dadc31c7cb2ba351ec797d8a851d82bf5bab232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468920
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2025-12-17 11:54:43 -08:00
Ryan Macnak 674a42d292 [vm, compiler] Check for ASAN and MSAN violations from Dart generated code.
Inform ASAN and MSAN about reads and writes through FFI pointers or external typed data. Previously we only informed MSAN about writes, which was enough to prevent false positives in foreign code, but gave false negatives for Dart code. This mostly uses the same machinery used for TSAN, and replaces some of the existing MSAN unpoison calls.

Also fixes some marshalling of compounds by value that generate loads extending past the end of the compound.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62221
Change-Id: Ia3573edb5a0aec32b6a57035a63e8f323a655ecc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467401
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-17 07:37:29 -08:00
Slava Egorov 96eece84bd [vm/io] Avoid %ls in SetOsErrorMessage
This format specifier does not perform a wide char to utf8 conversion
but rather a locale dependent wide char to multibyte conversion 
(essentially wcstombs), which is not what this function is expecting
to do (it is expected to return utf8 encoded error message). 

Issue https://github.com/dart-lang/sdk/issues/62252

TEST=not tested, speculative fix

Change-Id: Icd5ddbf9969dbd4acd2f7f48626ce0bd6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468800
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-12-17 03:20:11 -08:00
Alexander Markov ecf78ee1ae [vm/corelib] Cleanup obsolete null checks from the VM patch files
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/40614
Change-Id: I019f4e1fb54adaa585c234a6e806ac50213c6d80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468640
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-12-16 15:07:39 -08:00
Ryan Macnak ee4ec6c84d [vm] Maintain W^X when mapping snapshots on Windows.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62249
Change-Id: I4ee4e7420527907d20217916acbc4162d9a53800
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468441
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-16 09:22:52 -08:00
Jens Johansen c56e94630e [vm] Allow Before/After GC to signal perf
This CL makes it possible for the Dart VM to start or stop `perf` while
doing GC, which gives a significantly more stable output.

Example usage:

Bash script that creates the correct file handles and calls dart under
`perf stat` based on the arguments given to the script:

```
DART=$1
shift
AOTSNAPSHOT=$1
shift

ctl_dir=/tmp/

ctl_fifo=${ctl_dir}perf_ctl.fifo
test -p ${ctl_fifo} && unlink ${ctl_fifo}
mkfifo ${ctl_fifo}
exec {ctl_fd}<>${ctl_fifo}

ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo
test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo}
mkfifo ${ctl_ack_fifo}
exec {ctl_fd_ack}<>${ctl_ack_fifo}

perf_ctl_fd=$ctl_fd perf_ctl_fd_ack=$ctl_fd_ack perf stat --delay=-1 --control fd:${ctl_fd},${ctl_fd_ack} -B -e "task-clock:u,context-switches:u,cpu-migrations:u,page-faults:u,cycles:u,instructions:u,branch-misses:u" $DART --perf_ctl_fd=${ctl_fd} --perf_ctl_fd_ack=${ctl_fd_ack} --perf_ctl_usage=1 --deterministic $AOTSNAPSHOT $@

exec {ctl_fd_ack}>&-
unlink ${ctl_ack_fifo}

exec {ctl_fd}>&-
unlink ${ctl_fifo}
```

This will start `perf stat` paused (which would require the run dart
aot-compiled script to start it when it wants to) and where the VM
pauses `perf` while doing GC.

In practise, looking at instruction counts reported by `perf stat`, I've
seen the difference between runs go from 2+ mio (and in some instances
23+ mio) to around 30,000 (!) on runs of the analyzer (tool
"stable_analysis").

TEST=manually

Change-Id: Iab955a5dd35e47f22c4f693ae50effc8ee633897
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468260
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-12-16 04:16:15 -08:00
Ryan Macnak 583fbe5962 [vm] Symbolize more Windows errors.
TEST=build
Bug: https://github.com/dart-lang/sdk/issues/62249
Change-Id: I66e5cff2c965c1078ee59338bf5f0c4d061cec95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468400
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-15 15:45:21 -08:00
Alexander Aprelev 011f0259f9 [vm/shared] Ensure that shared fields initialization is mutex-guarded even without experimental flag.
Shared fields have to be properly initialized even when experiment is not enabled.

TEST=shared_finalthreadlocal_init_test on a loop
BUG=https://github.com/dart-lang/sdk/issues/62238

Change-Id: Ib8d32bd2553cdcbefeea657e4dd2b75db18d31d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467921
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-15 08:22:10 -08:00
Alexander Markov 3c99ae9b68 [vm] Fix incorrect assumption about co-location of leaf and non-leaf runtime entries in Thread
Thread::OffsetFromThread from runtime_api.cc assumed that all fields
between leaf and non-leaf runtime entries in Thread have word size,
so the delta between runtime entries can be translated from host to
target by multiplying by the ratio between target and host word size.

Since leaf and non-leaf runtime entries are not co-located in Thread,
this assumption is incorrect. It is now fixed by using separate
bases when calculating offsets of leaf and non-leaf runtime entries.

Also, add FatalError runtime entry which is useful for
bootstrapping of the new compiler.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Iea4762b21285aa6423876b34328c863227ee1434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467900
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-12-15 08:00:53 -08:00
Tess Strickland ace5af00a3 [vm] Standardize printing of entry/exit frames in StackFrame::ToCString.
For entry/exit frames for compiled code, print that it's an entry or
exit frame like with interpreted code instead of printing the stub name
(with an erroneous offset for exit frames, since the pc of exit frames
is always 0).

While there are two possible stubs for entry frames (InvokeDartCode
vs. InvokeDartCodeFromBytecode), which is in use can be determined
from the preceding exit frame (if any).

TEST=ci (manual testing using --trace-debugger-stacktrace)

Change-Id: I7013e08fbc635f68400c9cdfa97837905121ccf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-12-12 06:44:20 -08:00
Slava Egorov d47c8388aa [vm] Avoid deadlocks in SampleBlockProcessor
Processor thread might end up entering a safepoint while holding the
processor's monitor which will make thread calling Cleanup deadlock
while trying to acquire the monitor.

Use SafepointMonitorLocker instead to avoid this. Startup is unlikely
to exhibit this situation but we change it as well for symmetry.

TEST=manually, as reliably hitting this is hard

Change-Id: Ifb88a0418be064450374503bfc485e576a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467801
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-12-12 03:30:33 -08:00
Alexander Markov 07c7c4ea50 [vm] Generate Dart declarations for runtime offsets
TEST=dart tools/run_offsets_extractor.dart
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Ic24111aa923214cfc332a8fb4677d8941a2999d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446700
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-12-11 08:23:57 -08:00
Ryan Macnak 1addcda04d [vm] Fix race between DartEntry::InvokeFunction and background compiler / other isolates.
Before:
  code := function.CurrentCode()
  safepoint transition VM->Generated (might yield to background compiler's safepoint operation)
  InvokeEntryStub(code)

After:
  safepoint transition VM->Generated (might yield to background compiler's safepoint operation)
  code := function.CurrentCode()
  InvokeEntryStub(code)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60492
Bug: https://github.com/dart-lang/sdk/issues/62169
Change-Id: I9f0ac207361ed38101ca3fae10766894c4c5e47c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467480
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-12-10 19:23:50 -08:00
Ryan Macnak 94942874b2 [vm] Nicer disassembly for RISC-V hints.
Add missing byte and halfword compare-and-swap.
Add missing clear of reservation after SC.
Define XLEN aliases for the AMOs.
Add wait-on-reservation-set.
More systematically print state on fault.

TEST=ci
Change-Id: Ia07e638a6e08cd40eecc1f8f7d242fd94ef2f2d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467200
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-12-10 11:19:19 -08:00
Alexander Aprelev f1a1f6a986 [vm/shared] Maintain visited set when assessing immutability in closures.
Fixes https://github.com/dart-lang/sdk/issues/62178
TEST=run_isolate_group_run_test

Change-Id: Ia722ef6417e5cf2506bbc70d55299ce1ec04d13f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466842
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-12-10 09:19:04 -08:00
Tess Strickland 883859cd4e [vm] Improvements for --trace-debugger-stacktrace output.
Improves the readability of the tracing output by adding beginning and
ending markers for debugger stacktrace collection and using specific
spacing instead of \t in output, so that output is more naturally nested
via indention:
* beginning/ending markers are not indented,
* frames are indented by two spaces, and
* additional output while collecting a frame is indented by four spaces.

Adds tracing for DebuggerStackTrace::CollectAsyncAwaiters(). A different
ending marker is used in the case when the collected trace is discarded
due to a lack of async awaiters.

ActivationFrame::GetSavedCurrentContext now takes an optional out
parameter for the current context variable index, which is only used by
CollectDartFrame and used to print the index there. This eliminates
extra output when this method is used outside collecting stack traces.

When the current context variable index is requested,
GetSavedCurrentContext ignores the cached context if any so that the
index is appropriately set if an appropriate variable is found.

By default, skips tracing of non-collected frames and repeated async
suspensions in async awaiter traces. Use the new
--trace-debugger-stacktrace-verbose flag to add tracing for these cases.

TEST=ci (tested manually, only affects debugging output)

Change-Id: I2978d540f41b444251a61b62a57b6785a3dd8df0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467300
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-12-10 08:50:30 -08:00
Alexander Aprelev 170df25b66 [vm/shared] Prohibit capturing of 'late final' variables by isolategroup-bound closures.
TEST=run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/62181

Change-Id: I50037ede337367020176262b98d2c2fd100b050a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466820
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-10 08:29:57 -08:00