Commit Graph

16252 Commits

Author SHA1 Message Date
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 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
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 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
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
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
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
Ryan Macnak d0b5024e40 [vm] Fix use of GetCurrentThreadStackLimits on Windows IA32.
TEST=flutter
Change-Id: Iaba4cd9c2b6f2555c02e62efb2a0913aca89a63a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467141
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-09 10:56:53 -08:00
Tess Strickland 5ba92c999d [vm,dyn_modules] Improve StackFrame::ToCString() for interpreted frames.
Unify the handling of compiled and interpreted frames so that the offset
into the corresponding block of instructions is printed for interpreted
frames as well.

TEST=ci (tested manually with --trace-debugger-stacktrace)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I8820a96b3dc48afda2ff59d3f27b8ee414ce6593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-12-09 06:05:22 -08:00
Ryan Macnak e53115a98c [vm] Fix crash on GC after service id zone deletion.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62154
Change-Id: Ib1ca89aa7344614de1ffc2fae6e6f93850e4a1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466880
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-08 13:17:40 -08:00
Ryan Macnak f94c325bd1 [vm] Use GetCurrentThreadStackLimits on Windows.
TEST=ci
Change-Id: I97b7cb23449bbec94223235fc4b99215466adf23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465987
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-08 12:22:42 -08:00
Alexander Aprelev f04ff0410e [vm/shared/bytecode] Support use of vm:shared in bytecode/interpreter.
Fixes https://github.com/dart-lang/sdk/issues/62032
TEST=ci

Change-Id: I80600d81ee73b16338a337f7139bf4e898af6eca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466124
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-05 21:38:41 -08:00
Tess Strickland 702b0250ac [vm,dyn_modules] Print jump targets as absolute or relative PC.
Previously, the jump target was printed as the value of the offset
from the current PC. Instead, print it as the absolute or relative
PC corresponding to the jump target, depending on the value of
FLAG_disassemble_relative.

To facilitate this, pipe the base PC for relative outputs through
the various formatting functions.

TEST=ci (tested manually while debugging)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I9db6baa845bf89df70b36635277893686d73d842
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465921
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-12-04 03:13:53 -08:00
Ryan Macnak f19440c37b [vm, compiler] Use Zicond for IfThenElse.
TEST=locally increase baseline to RVA23
Change-Id: Ib28ee2edeea087b19b2cd146134d0dcf93c3fe0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465482
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-12-03 10:16:04 -08:00
Alexander Aprelev 6b72a9c0bc Reapply "[vm] Add graph intrinsics for ThreadLocal hasValue and getValue methods."
This reverts commit 4d7467abd6.

The fix for the failure that caused revert is in patchset 2.

TEST=ci
Change-Id: I9b7ff0dd049062b086ad43c8368c6ede130edf35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465781
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-12-03 06:30:20 -08:00
Alexander Aprelev 4d7467abd6 Revert "[vm] Add graph intrinsics for ThreadLocal hasValue and getValue methods."
This reverts commit 3a4d3681d7.

Reason for revert: broke vm-aot-android-release-arm_x64 lib/math/pi_test, https://github.com/dart-lang/sdk/issues/62149

Original change's description:
> [vm] Add graph intrinsics for ThreadLocal hasValue and getValue methods.
>
> This gets rid of native calls for ThreadLocal hasValue/getValue
>
> ===
> - 51.34%     4.46%  DartWorker       JsonEncode.dart.bin   [.] double.toString
>  - 46.89% double.toString
>   - 43.06% double._toString
>    - 42.48% stub CallBootstrapNative
>     - 41.52% dart::NativeEntry::BootstrapNativeCallWrapper(_Dart_NativeArguments*, void (*)(_Dart_NativeArguments*
>      + 27.38% dart::Number::ToString(dart::Heap::Space) const
>      + 5.79% dart::OneByteString::New(unsigned char const*, long, dart::Heap::Space)
>      + 1.79% dart::BootstrapNatives::DN_Double_toString(dart::Thread*, dart::Zone*, dart::NativeArguments*)
>        1.27% __strlen_evex
>        0.92% dart::TransitionGeneratedToVM::TransitionGeneratedToVM(dart::Thread*)
>        0.88% dart::StackZone::StackZone(dart::ThreadState*)
>        0.72% __memmove_evex_unaligned_erms
>        0.71% dart::StackZone::~StackZone()
>     1.47% _DoubleToStringCache.store
>  + 4.44% start_thread
> ===
>
> Benchmark improvements:
> - JsonEncode.Numbers.FromString (Raspberry Pi 4) 50.25%
> - JsonEncode.Numbers.FromBytes  (Raspberry Pi 4) 48.69%
>
> BUG=https://github.com/dart-lang/sdk/issues/62046
> TEST=ci
>
> Change-Id: I3cdbaf085dfc23fcad4544be8a299b7520c7d825
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464320
> Commit-Queue: Alexander Aprelev <aam@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>

Bug: https://github.com/dart-lang/sdk/issues/62046
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I06db44ff6b7eb5021c2a2f4d5af6ff659205cb2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465641
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-12-02 09:34:58 -08:00
Alexander Aprelev 3a4d3681d7 [vm] Add graph intrinsics for ThreadLocal hasValue and getValue methods.
This gets rid of native calls for ThreadLocal hasValue/getValue

===
- 51.34%     4.46%  DartWorker       JsonEncode.dart.bin   [.] double.toString
 - 46.89% double.toString
  - 43.06% double._toString
   - 42.48% stub CallBootstrapNative
    - 41.52% dart::NativeEntry::BootstrapNativeCallWrapper(_Dart_NativeArguments*, void (*)(_Dart_NativeArguments*
     + 27.38% dart::Number::ToString(dart::Heap::Space) const
     + 5.79% dart::OneByteString::New(unsigned char const*, long, dart::Heap::Space)
     + 1.79% dart::BootstrapNatives::DN_Double_toString(dart::Thread*, dart::Zone*, dart::NativeArguments*)
       1.27% __strlen_evex
       0.92% dart::TransitionGeneratedToVM::TransitionGeneratedToVM(dart::Thread*)
       0.88% dart::StackZone::StackZone(dart::ThreadState*)
       0.72% __memmove_evex_unaligned_erms
       0.71% dart::StackZone::~StackZone()
    1.47% _DoubleToStringCache.store
 + 4.44% start_thread
===

Benchmark improvements:
- JsonEncode.Numbers.FromString (Raspberry Pi 4) 50.25%
- JsonEncode.Numbers.FromBytes  (Raspberry Pi 4) 48.69%

BUG=https://github.com/dart-lang/sdk/issues/62046
TEST=ci

Change-Id: I3cdbaf085dfc23fcad4544be8a299b7520c7d825
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464320
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-12-02 07:55:25 -08:00
Tess Strickland 140b901f1c [vm] Don't use the null context as a signal for lazy context loading.
The null context is a valid context for frames that don't involve
contexts, so instead add a flag field for whether or not the context
has been loaded.

TEST=ci

Change-Id: Ie9c0efd1c61297c5a6e754d31e958baca09ac6a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464742
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-12-02 06:39:20 -08:00
Tess Strickland 96adbf5e00 [vm,dyn_modules] Fix evaluation expression function self-reference.
If the evaluation expression function is for an expression in the scope
of a generic function with a parameter whose type includes one of its
type parameters, then the graph for the parameter type will contain a
self reference to the evaluation expression function.

Normally, this self reference would be resolved via the scoped_function_
field. However, while scoped_function_class_ is set to the class containing the expression evaluation function (as expected),
if ReadObject() encounters that class, it returns the "real" class
the evaluation expression should be evaluated in. This means the
self-reference isn't detected.

Add an additional check for the right name/class for the expression
evaluation function.

TEST=pkg/vm_service/test/evaluate_function_type_parameters_test

Fixes: https://github.com/dart-lang/sdk/issues/61948
Cq-Include-Trybots: luci.dart.try:vm-linux-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Id04735059d00d964a8f00885857d3255c18ecf99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464520
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-12-02 06:33:19 -08:00
Tess Strickland 7af4d14267 [vm,dyn_modules] Mark extension type members appropriately.
TEST=pkg/vm_service/test/step_through_extension_type_method_call_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I3bf331e175847280964fd42eb027e9f812598bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464705
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-12-02 06:31:15 -08:00
Ryan Macnak 7708addac2 [vm, compiler] Add --target-address-sanitizer.
The throw stub will need to be different under ASAN.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62095
Change-Id: Idd079fbab22d1c3f29c0d7e216998d54a521545c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464786
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-01 16:15:39 -08:00
Ryan Macnak 1d1527adf9 [vm] Report the current sanitizer in the compiler environment.
TEST=ci
Change-Id: I56585a1fdb1bb6b92eab706fd0a66f78888bc55d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464620
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-01 15:10:50 -08:00
Ryan Macnak e1ea898cbf [vm] Fix Fuchsia RISC-V build.
TEST=local build
Change-Id: If21f38e98d76c962519434504dfc5003332831ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464783
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-01 12:47:18 -08:00
Ryan Macnak 6d4cfab927 [vm, compiler] Combine cset+sub into csetm for ARM64 IfThenElse.
TEST=ci
Change-Id: I64f70325ceca589ee93663f651a784c9c833ce36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464763
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-01 11:15:43 -08:00
Johnni Winther 5bc2037cb0 [kernel] Implement InvalidInitializer
This updates the Initializer classes such that InvalidInitializer has a message and will throw at runtime, similar to InvalidExpression. All initializers have positions and only FieldInitializer and SuperInitializer have an isSynthetic field.

TEST=pkg/front_end/testcases/general/invalid_initializer.dart

Change-Id: Ic444bb1dc273b433ac70249240527d115deaa332
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463661
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 01:53:23 -08:00
Ryan Macnak 2a446270a4 [vm] Add missing save of shadow call stack in DartEntryScope.
Thread::saved_shadow_call_stack_ has the value for the top-most Dart entry, and needs to be saved and restored for nested Dart entries.

TEST=fuchsia
Change-Id: Id035bec7e798458fdfcf85678a7246d5f7eef850
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464603
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-11-26 10:44:51 -08:00
Ryan Macnak 4e4fc120c1 [vm] Add Zimop and Zcmop.
TEST=ci, local QEMU
Change-Id: I5946292a1442336882edc947107e28cd2c7c9baf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464461
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-11-25 11:04:06 -08:00
Ryan Macnak 144b3955e8 [vm] Add Zacas.
TEST=ci, local qemu
Change-Id: If1a2d187107da9fda6bfe7c94925960e6d351205
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464322
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-11-25 08:14:02 -08:00
Liam Appelbe 7b422f440d [vm] Fix branch coverage finally edge cases
StreamingFlowGraphBuilder::BuildTryFinally talks about 5 different
cases where a finally block needs to be executed:
1) break/continue in a loop
2) continue in a switch
3) return statement
4) try body is an open fragment
5) exception is thrown inside try

StreamingFlowGraphBuilder::BuildTryFinally itself only handles cases
4 and 5. So when we added branch coverage to the finally inside
BuildTryFinally, we missed cases 1, 2, and 3, which go through
TranslateFinallyFinalizers instead.

Bug: https://github.com/dart-lang/tools/issues/2241
Change-Id: I02b38a18452be709d5fabd9945d6570a2f1b5120
Fixes: https://github.com/dart-lang/tools/issues/2241
TEST=SourceReport_BranchCoverage_finallyEdgeCases
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463220
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-11-24 15:59:56 -08:00
Slava Egorov badeb15e5d [vm] Do not interrupt mutator when SampleBlock is complete
This code was added when samples streaming was implemented and should
not be necessary. Let background thread drain samples instead.

This significantly reduces the overhead of activating profiler when
using NativeRuntime.streamTimelineTo from 2-3x to ~10% in AOT mode
and around ~20-25% in JIT.

TEST=ci

Change-Id: I4c6026f832d6a952b24323632b4126df6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464183
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-11-24 13:29:52 -08:00
Alexander Markov ea75975e03 [vm,ia32] Avoid clobbering callee-save register in assembler test
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/62061

Change-Id: I453a7f30927562dace1d0189f29a7bd91646e3a0
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-ia32-try,vm-linux-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463702
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-11-24 09:59:27 -08:00
Tess Strickland 6230f5bd9d [vm] Skip appending Windows unwinding sections for relocatable objects.
Mach-O relocatable objects aren't a native shared object format on
Windows, can't be loaded by the non-native Mach-O loader, and aren't
required to have the same memory layout as the snapshot like separate
debugging information, so there's no reason to output these sections.

TEST=vm/dart/use_dwarf_stack_traces_flag_test on
     vm-aot-win-debug-arm64

Fixes: https://github.com/dart-lang/sdk/issues/62057
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try
Change-Id: Ic85eedfda120fe4c8669678298d330146c9a036a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464181
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-11-24 07:52:22 -08:00
Tess Strickland 2c804fa251 [vm] Handle the context of implicit instance closures in the debugger.
Since the only captured variable in the context for an implicit
instance closure is this, the allocation of a context object is
elided and instead the instance is stored directly as the "context".

In the debugger, create the elided context object for implicit instance
closures when retrieving the saved context from an implicit instance
closure activation frame.

Without this, any attempt to GetSavedCurrentContext() on an
ActivationFrame for an implicit instance closure (e.g., when
--trace-debugger-stacktrace is enabled) breaks due to the assert
in debug mode, and returns a null context (which isn't correct either)
in non-debug modes.

TEST=vm/dart/regress_cl_463021

Change-Id: I2ba22407695f432a30d23d342f33dfe2a00ba308
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463021
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-11-24 04:39:04 -08:00