Commit Graph

707 Commits

Author SHA1 Message Date
Tony 57b27a7b44 Refactor Dart runtime to replace DART_DYNAMIC_MODULES with DART_BYTECODE_INTERPRETER
- Updated conditional compilation flags throughout the runtime codebase to transition from DART_DYNAMIC_MODULES to DART_BYTECODE_INTERPRETER.
- Adjusted logic in various files including object_graph_copy.cc, object_reload.cc, profiler.cc, and others to ensure compatibility with the new interpreter model.
- Ensured that all references to dynamic modules are replaced with bytecode interpreter checks, maintaining functionality for interpreted code execution.
- Modified stack frame handling and service-related code to align with the new interpreter architecture.
- Updated tests and service implementations to reflect the changes in the runtime environment.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-06-25 01:58:41 +08:00
Ryan Macnak 9b8d908379 Speed up RISCV QEMU testing.
- Skip/delete some large tests.
 - Reduce some large tests.
 - Explicitly choose the CPU features, which seems to be disabling something expensive.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63465
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try
Change-Id: Ifa591d6600da3e20c9de4d123906a7747029df7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509200
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-08 13:27:27 -07:00
Alexander Aprelev 5b0285866d Revert "Reland "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable""
This reverts commit 415b040d6f.

Reason for revert: breaks riscv https://github.com/dart-lang/sdk/issues/63479

Original change's description:
> Reland "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable"
>
> The previous attempt was reverted because it broke unoptimized JIT
> on ARM 32. This reland force-optimizes the two getters.
>
> Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
> (commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
> when a hardware fast path is available; otherwise the newly added
> Dart bodies inline at call sites via vm:prefer-inline. The C++
> natives are removed.
>
> Backend codegen
> ---------------
> ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
> ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
>            register pair (ctz).
> x64:       popcntq when TargetCPUFeatures::popcnt_supported();
>            LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
>            on BMI1+, preserves dest on zero otherwise).
> RISC-V 64: cpop / ctz when RV_baseline includes Zbb.
>
> Per-arch availability is encapsulated in
> UnaryInt64OpInstr::IsSupported(Token::Kind).
>
> Apple M-series ARM64, AOT (us/iter, lower is better):
>   cardinality.swar              371
>   cardinality.accelerated       154    (2.4x)
>   forEachSetBit.swar          19031
>   forEachSetBit.accelerated    4988    (3.8x)
>   select.swar                   199
>   select.accelerated             77    (2.6x)
>   complementCardinality.swar    399
>   complementCardinality.accel   152    (2.6x)
>
> Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
> and ctz intrinsification).
>
> Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
> BitSet implementation).
>
> Fixes https://github.com/dart-lang/sdk/issues/52673
> Fixes https://github.com/dart-lang/sdk/issues/38346
> Fixes https://github.com/dart-lang/sdk/issues/63436
> Issue https://github.com/dart-lang/sdk/issues/10212
> Issue https://github.com/dart-lang/sdk/issues/5798
> TEST=tests/corelib/int_bit_count_test
>
> Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
> Change-Id: Ib812cbaec6e371b9720df7a543411f78e524cac1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506060
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iaf11d03d394fa615098bed8fcdea38ba40c7e45f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507520
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2026-05-29 10:29:33 -07:00
Modestas Valauskas 415b040d6f Reland "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable"
The previous attempt was reverted because it broke unoptimized JIT
on ARM 32. This reland force-optimizes the two getters.

Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
(commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
when a hardware fast path is available; otherwise the newly added
Dart bodies inline at call sites via vm:prefer-inline. The C++
natives are removed.

Backend codegen
---------------
ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
           register pair (ctz).
x64:       popcntq when TargetCPUFeatures::popcnt_supported();
           LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
           on BMI1+, preserves dest on zero otherwise).
RISC-V 64: cpop / ctz when RV_baseline includes Zbb.

Per-arch availability is encapsulated in
UnaryInt64OpInstr::IsSupported(Token::Kind).

Apple M-series ARM64, AOT (us/iter, lower is better):
  cardinality.swar              371
  cardinality.accelerated       154    (2.4x)
  forEachSetBit.swar          19031
  forEachSetBit.accelerated    4988    (3.8x)
  select.swar                   199
  select.accelerated             77    (2.6x)
  complementCardinality.swar    399
  complementCardinality.accel   152    (2.6x)

Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
and ctz intrinsification).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Fixes https://github.com/dart-lang/sdk/issues/52673
Fixes https://github.com/dart-lang/sdk/issues/38346
Fixes https://github.com/dart-lang/sdk/issues/63436
Issue https://github.com/dart-lang/sdk/issues/10212
Issue https://github.com/dart-lang/sdk/issues/5798
TEST=tests/corelib/int_bit_count_test

Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
Change-Id: Ib812cbaec6e371b9720df7a543411f78e524cac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506060
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-29 06:01:17 -07:00
Ryan Macnak 58ea063ca8 [vm, compiler] Fix high hash collision rate in a large run of sequential double values.
TEST=many_double_literals_test
Change-Id: Ieddaa44ddc0cc67eb8913a62daab44b5579123a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506140
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-26 06:42:00 -07:00
Alexander Aprelev 8765d80177 Revert "[vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable"
This reverts commit 0bef837817.

Reason for revert: simarm, xarm bot failures https://github.com/dart-lang/sdk/issues/63436

Original change's description:
> [vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable
>
> Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
> (commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
> when a hardware fast path is available; otherwise the newly added
> Dart bodies inline at call sites via vm:prefer-inline. The C++
> natives are removed.
>
> Backend codegen
> ---------------
> ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
> ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
>            register pair (ctz).
> x64:       popcntq when TargetCPUFeatures::popcnt_supported();
>            LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
>            on BMI1+, preserves dest on zero otherwise).
> RISC-V 64: cpop / ctz when RV_baseline includes Zbb.
>
> Per-arch availability is encapsulated in
> UnaryInt64OpInstr::IsSupported(Token::Kind).
>
> Apple M-series ARM64, AOT (us/iter, lower is better):
>   cardinality.swar              371
>   cardinality.accelerated       154    (2.4x)
>   forEachSetBit.swar          19031
>   forEachSetBit.accelerated    4988    (3.8x)
>   select.swar                   199
>   select.accelerated             77    (2.6x)
>   complementCardinality.swar    399
>   complementCardinality.accel   152    (2.6x)
>
> Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
> and ctz intrinsification).
>
> Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
> BitSet implementation).
>
> Fixes https://github.com/dart-lang/sdk/issues/52673
> Fixes https://github.com/dart-lang/sdk/issues/38346
> Issue https://github.com/dart-lang/sdk/issues/10212
> Issue https://github.com/dart-lang/sdk/issues/5798
> TEST=tests/corelib/int_bit_count_test
>
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
> Change-Id: I9c2c4225fd63d54e190398a0fb6649366317dd17
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504221
> Commit-Queue: Slava Egorov <vegorov@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I4eaca9e25a919ba494f2e7e9819f1ea7d5a13078
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505941
Auto-Submit: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
2026-05-22 14:22:30 -07:00
Modestas Valauskas 0bef837817 [vm] Recognize int.trailingZeroBitCount/oneBitCount as graph-inlinable
Stacks on top of the int.{trailingZeroBitCount,oneBitCount} API CL
(commit 754239b077). Both getters route through OTHER_RECOGNIZED_LIST
when a hardware fast path is available; otherwise the newly added
Dart bodies inline at call sites via vm:prefer-inline. The C++
natives are removed.

Backend codegen
---------------
ARM64:     NEON CNT + UADDLV (popcount); RBIT + CLZ (ctz).
ARM:       NEON CNT + VPADDL chain (popcount); RBIT + CLZ on the
           register pair (ctz).
x64:       popcntq when TargetCPUFeatures::popcnt_supported();
           LoadImmediate(64) + rep_bsfq for ctz (decodes as tzcnt
           on BMI1+, preserves dest on zero otherwise).
RISC-V 64: cpop / ctz when RV_baseline includes Zbb.

Per-arch availability is encapsulated in
UnaryInt64OpInstr::IsSupported(Token::Kind).

Apple M-series ARM64, AOT (us/iter, lower is better):
  cardinality.swar              371
  cardinality.accelerated       154    (2.4x)
  forEachSetBit.swar          19031
  forEachSetBit.accelerated    4988    (3.8x)
  select.swar                   199
  select.accelerated             77    (2.6x)
  complementCardinality.swar    399
  complementCardinality.accel   152    (2.6x)

Work towards https://github.com/dart-lang/sdk/issues/6486 (popcount
and ctz intrinsification).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Fixes https://github.com/dart-lang/sdk/issues/52673
Fixes https://github.com/dart-lang/sdk/issues/38346
Issue https://github.com/dart-lang/sdk/issues/10212
Issue https://github.com/dart-lang/sdk/issues/5798
TEST=tests/corelib/int_bit_count_test

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,dart-sdk-linux-riscv64-try
Change-Id: I9c2c4225fd63d54e190398a0fb6649366317dd17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504221
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
2026-05-22 05:58:10 -07:00
Ryan Macnak af43c1a3d4 [vm] Switch FAR_TMP to X7 for compatibility with Zicfilp.
When enabled, indirect calls and jumps must set X7 to a label value that matches the label in a so-called landing pad at the call target. This check does not apply if the indirect call is made through X1/RA, X5/RA2 or X7/T2, with the expectation that the compiler will limit use of these registers for logically direct calls like an AUPIC+JALR pair, or for software guarded branches like a bounds-checked jump table. We use FAR_TMP for logically direct jumps that exceed J-type range, and blocking it from register allocation limits the availablity of gadgets that set X7.

Compare x64's IBT and arm64's BTI.

TEST=ci
Change-Id: Ic00195eb3c04cc10379f9965e05ef84052e02933
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494861
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-20 17:46:32 -07:00
Ryan Macnak 3e05df3856 [vm] Fix more cases of the profiler failing to identify the entry frame.
TEST=dart-fuzz
Bug: https://github.com/dart-lang/sdk/issues/63105
Change-Id: I081a719a1d91c0e003a45ce1249e7856aa46a530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495784
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-15 15:23:51 -07:00
Ryan Macnak 813afcee43 [vm] Simulator support for Zicfilp.
TEST=ci
Change-Id: Ibf9adb39da37ebb350097e3830202940e138c7d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-13 14:00:21 -07:00
Alexander Markov 51d1c8923a Reland "[vm,dart2bytecode,modular_aot] Variable-length closure objects"
This is a reland of commit 88496ba1c3

Fixes on top of the original change:

* Closure layout is changed to avoid gap between fixed fields and
  variable-length elements on compressed pointers architecture.
  This gap was causing crashes in the GC when scanning closure
  objects.

* pkg/vm_snapshot_analysis/test/instruction_sizes_test is fixed
  on arm64 by decreasing threshold for detecting size changes.

Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
>  - delayed type arguments;
>  - instantiator type arguments;
>  - function type arguments;
>  - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635

Change-Id: I8685e632e2d0832766ecdc470f3cf9a6b880de48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494243
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-10 06:15:22 -07:00
Alexander Markov 0dfaa16dc7 Revert "[vm,dart2bytecode,modular_aot] Variable-length closure objects"
This reverts commit 88496ba1c3.

Reason for revert: crashes on arm64c

Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
>  - delayed type arguments;
>  - instantiator type arguments;
>  - function type arguments;
>  - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/61572
> Issue: https://github.com/dart-lang/sdk/issues/61635
>
> Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I94c88f8922f6ea49251e942ba791fee714911e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494261
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-04-09 14:12:09 -07:00
Alexander Markov 88496ba1c3 [vm,dart2bytecode,modular_aot] Variable-length closure objects
Extend closure objects with variable number of elements to capture.
This is needed to support capturing multiple independent contexts
after capturing is computed in the front-end.

The following fixed Closure fields are moved into variable-length
elements:
 - delayed type arguments;
 - instantiator type arguments;
 - function type arguments;
 - context.

Number of elements and presence/indices of various type arguments
are encoded into the new length_and_flags field in the Closure.

Most closure objects don't need any of the type arguments so this
change will reduce average Closure object size.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635

Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2026-04-09 12:22:21 -07:00
Ryan Macnak 90195a6a81 [vm, compiler] Shrink code size for ARM PushRegisters with SIMD registers.
TEST=ci
Change-Id: Ie9c79365fadc060fbf9a4ba8d224527444bab733
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491685
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-31 12:27:31 -07:00
Ryan Macnak 91cef061c7 [vm, compiler] Create a proper frame in the FFI callback trampoline.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62932
Change-Id: I2b8de8555b3810e4838f4ac36d590a24159291ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490740
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-31 11:13:00 -07:00
Tess Strickland 0bbb2ae821 [vm,dyn_modules] Fix/skip vm/cc tests that crash for dynamic modules.
Skip IR or snapshot-related tests when running from bytecode.

TEST=vm/cc/DartAPI_DeepStackTraceInfo
     vm/cc/DartAPI_HeapSampling_UserDefinedClass
     vm/cc/DartAPI_StackTraceInfo
     vm/cc/DartAPI_StackOverflowStackTraceInfoArrowFunction
     vm/cc/DartAPI_StackOverflowStackTraceInfoBraceFunction1
     vm/cc/DartAPI_StackOverflowStackTraceInfoBraceFunction2
     vm/cc/FrameLookup
     vm/cc/Service_LocalVarDescriptors

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: I396a4e8ddacdbb88b3844e4113dc5c4ff6287e30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490083
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-03-26 08:21:00 -07:00
Tess Strickland 7ad5ee3dae [vm,dyn_modules] Print line and column for synthetic token positions.
When using the --dump-kernel-bytecode flag, also print the line and
number of the source position encoded by a synthetic token position.

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

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

TEST=manual use during debugging

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ic16e320e9a10d8343e8a37c8270c7076bb7052c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484943
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-03 06:58:35 -08:00
Tess Strickland 5792b6ecb7 [vm, dyn_modules] Fix tracing the original instruction at breakpoints.
https://dart-review.googlesource.com/c/sdk/+/481782 removed the tracing
of the original instruction for breakpoints. This CL adds it back.

Also increments icount_ before calling TraceInstruction in the dispatch
loop instead of afterwards so that breakpoint/single step tracing can
just use icount_ without adjusting it. In particular, this means tracing
the original instruction at a breakpoint can just use TraceInstruction
instead of duplicating it.

Also, now both the breakpoint instruction and the original instruction
are written to the instruction trace if requested, instead of only the
breakpoint instruction.

TEST=debugging only changes, so manually tested.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I1999f1d9e7ba55b950c508e848ff12db0c8d5cab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482320
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-02-23 03:45:57 -08:00
Ryan Macnak 7d5361ab02 [vm] Remove helpers for pre-C++11 64-bit literals.
TEST=ci
Change-Id: Icb198c9d0eb11c11f9fa61f41c37c8705f68001c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481165
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-17 14:14:59 -08:00
Alexander Markov 5c319b2914 [vm] Remove most uses of inc/dec instructions on x64 and ia32
Inc/dec instructions partially update flags register,
which creates false dependencies between instructions,
so they should be only used when optimizing for size.

TEST=ci

Change-Id: I0be2a00044820592689884037dd4784ee4765e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479700
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-02-11 10:01:50 -08:00
Ryan Macnak 737888b223 [vm] Make Dart Zones more similar to V8 Zones.
This eases the porting of Irregexp.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56573
Change-Id: If31a0585ced3eabaf2dac6af04f83d387a8eab5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478080
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-04 10:16:41 -08:00
Alexander Markov 46cbb8152f [vm,arm64] Fix disassembly of add/sub with extended register and rd = SP
Aliases cmn and cmp should be used only for adds/subs (with S bit set).

TEST=vm/cc/AddExtReg

Change-Id: Id453282f8397a1a696771d901e66bf77697bf7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476864
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-02 09:41:16 -08:00
Ryan Macnak 1d91605c25 [vm, compiler] Handle 32-bit constant indices for Load/StoreIndexedInstr on ARM64 and RISC-V.
This extends the set of indices that are not processed by the register allocator to match X64. This avoids slowness in the register allocator for large list literals. For some cases, it also reduces code size.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62411
Change-Id: Iab71a6dea2f2f75b06c51e4b23626bc991e1a20f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475720
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-26 14:37:58 -08:00
Ryan Macnak b6937c6dc4 [vm] Use btrq for x64 write barrier tag updates.
TEST=ci
Change-Id: Ibc5789a0d93c815abe9b7e612f1b2f008a6e725b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474764
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-26 09:41:19 -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 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
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
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
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
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 b8ad514530 [pkg,dyn_modules] Use bytecode payload start for relative disassembly.
Add an additional argument to the base implementation of KernelBytecodeDisassembler::Disassemble that is the base address to use
when FLAG_disassemble_relative is enabled.

For the delegating versions of KernelBytecodeDisassembler::Disassemble
that take a Bytecode object, the payload start of the bytecode object
is retrieved and used as the base.

For the delegating versions of KernelBytecodeDisassembler::Disassemble
that take neither a base or a bytecode object, the start is used as
the base.

When tracing instructions in the interpreter, the bytecode is retrieved
via the frame pointer and then its payload start is passed in as the
base, so that the relative offset printed with the instructions match
the relative offsets printed when dumping function bytecode.

TEST=manual use of --disassemble-relative while tracing/dumping bytecode

Change-Id: I7f931037970acd950a330fa6be024df5beb144a7
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463022
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-11-19 07:56:49 -08:00
Ryan Macnak 61fff77154 [vm, compiler] Add just enough of the vector extension to implement memcpy and memset.
TEST=ci, local qemu
Change-Id: I9518049ca927fa42d3c04e9e045c6cec1342c789
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462462
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-11-18 14:33:11 -08:00
Ryan Macnak 3125f46f5b [vm] Add Zicfiss.
TEST=ci, local qemu
Change-Id: Iea22fff14362a6eef937f22ab9121376c7e27014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460883
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-11-11 11:21:46 -08:00
Ryan Macnak 8c73b534f5 [vm] Use dmb ishst instead of dmb ish for store-store fence.
TEST=ci
Change-Id: Id7fb33bb4d9626ad420fd5aac2df86b47bd5c7bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459662
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-11-05 13:29:00 -08:00
Ryan Macnak fca41fa22f [vm, compiler] Refactor IA32 leaf runtime calls to be more like the other architectures.
TEST=ci
Change-Id: I2e5902649df3a09c83240ecda26d0f514755e56d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456101
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-10-21 10:22:01 -07:00
Ryan Macnak 0a1678c06c [vm] Record stack for JIT TSAN.
The main interesting thing is that deopt can expand one optimized frame to multiple unoptimized frames, so deopt needs to call  __tsan_func_entry enough times to rebalance the stack.

Also fixes stack balance for throw error slow paths for AOT.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/61352
Change-Id: I3fdc8481bc8db7a3aec0fa1938ac3e0e96ac13a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452943
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-20 10:49:20 -07:00
Ryan Macnak c59549e957 [vm, compiler] More specific assembly comments for runtime calls.
TEST=ci
Change-Id: Iaabdbceedbddffd2f980fb0828a8fc211524a3d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455180
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-15 09:21:52 -07:00
Ryan Macnak f80d794475 [vm] Fixes for TSAN in debug mode.
TEST=local build
Change-Id: I99550b012531717dd942f397495a25599154ec69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454180
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-10-13 13:24:35 -07:00
Tess Strickland df693c20b0 [vm,dyn_modules] Add flags to bytecode source positions.
There are two possible flags for each source position currently:
a flag that marks the source position as synthetic and a flag that
marks the source position as within a yield point.

Synthetic source positions in bytecode are treated the same as synthetic
source positions in compiled code. That is, they encode the source
position in the text that caused them to be synthesized, but denote that
the covered instructions are internal and not to be used for debugger
pause points or for call site/branch coverage information.

Adding these flags allow us to mark appropriate parts of the async
machinery as synthetic, and also allow us to mark all the bytecode
involved in yield points as having the same token position.

The latter fixes tests where the code would step over a previous
expression, thus being paused at the start of the await bytecode,
and would record the fp and token position there as the ones to
ignore. However, since a new source position wasn't emitted until the
direct call to the await method, the recorded token position would
be the token position prior to the await call, and so the change
in token position at the await call would trigger an early pause.

TEST=pkg/vm_service/test/async_single_step_exception_test
     pkg/vm_service/test/async_single_step_into_test
     pkg/vm_service/test/async_single_step_out_test
     pkg/vm_service/test/async_star_single_step_into_test
     pkg/vm_service/test/async_step_out_test
     pkg/vm_service/test/positive_token_pos_test
     pkg/vm_service/test/step_into_async_no_await_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-product-x64-try
Change-Id: Ic7642a74fb76227a473f461f360e84dd3d5a45a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453322
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-10-09 09:15:42 -07:00
Tess Strickland 3c26fcf597 [vm] Delimit and escape string constants when disassembling to stdout.
TEST=ci (only affects output used for debugging the VM)

Change-Id: If9732db5695a19943ecf88362deb96a93a2bd843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-10-09 02:19:50 -07:00
Ryan Macnak f1ba8ceacf [vm] Make some IgnoreRace functions inlinable.
Fix GCC TSAN build.
Cleanup sanitizer includes.

TEST=ci
Change-Id: Ib68bbfa701b4309c03514ed689391051094208e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452226
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-10-01 09:41:26 -07:00
Ryan Macnak 305189ec8f [vm] Fix IA32.
TEST=ci
Change-Id: I5559a1cf11d8ec5ae96deb87d098cf7ee9caac8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451401
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-09-24 15:14:32 -07:00
Ryan Macnak 78d280a2df [vm] Symbolize JIT Dart frames for TSAN.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/61352
Change-Id: I0e64e563b19bbd7b67e6f275dbc373db08b9d2c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449980
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-09-24 13:14:32 -07:00
Tess Strickland e01fad78df [vm,dyn_modules] Fix Scope check in ActivationFrame::ContextLevel.
The end PC offset for the scope is inclusive, not exclusive.

Also rename PrintDescriptorsError -> PrintContextLevelError and
print the Bytecode local variable information since that is what
is searched for the context level for interpreted frames.

TEST=pkg/vm_service/test/step_through_closure
     pkg/vm_service/test/step_through_function_expression

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ib53d0a7cff81de16c957b73ce9ec7dcb0e4aaa34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449740
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-09-16 05:52:51 -07:00
Tess Strickland 827551f8e0 [vm,dyn_modules] Fix ActivationFrame::ContextLevel for bytecode frames.
Instead of using the computed LocalVarDescriptors when the
frame is interpreted, use the LocalVariableInfo in the serialized
bytecode to find which Scope is currently active.

Add printing of local variable information to the bytecode
disassembler.

TEST=pkg/vm_service/test

Change-Id: I7bd15056e4e2a947ad16ffb83a50447c2ba59994
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449340
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-09-15 08:14:47 -07:00
Ryan Macnak 08964e235b [vm, compiler] Make the leaf runtime call spill set more consistent between architectures.
Remove unnecessary spill of FpuTMP.
Remove unnecessary spill of TMP on x64.

TEST=ci
Change-Id: I6e56e4dfe1a817ff2c1f53229be305640b89eee6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446740
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-08-26 14:05:27 -07:00
Ryan Macnak e01d4b3cc6 [vm, compiler] Get the full Dart stack in TSAN reports.
Call __tsan_func_entry/__tsan_func_exit in functions that use __tsan_read/__tsan_write or call other functions. Call __tsan_func_exit once per frame when unwinding for exceptions. Do so only in AOT, since TSAN won't be able to symbolize JIT functions anyway.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/61352
Cq-Include-Trybots: luci.dart.try:vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: Ie52c978c25664d78b834e9b72ecf7eb2a12cc2ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444181
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-08-26 11:50:13 -07:00
Alexander Markov 8f41c9194b [vm] Fix msvc build
Use standard constant instead of gcc/clang specific extension.

TEST=ci

Change-Id: I4b6a8e2ad62f180bebac39c90fff62cd60857d2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444440
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-08-08 08:27:19 -07:00