Commit Graph

15705 Commits

Author SHA1 Message Date
Ryan Macnak f972499915 [vm, compiler] Generate smaller far branches on RISC-V.
TEST=ci
Change-Id: I860596aafd8b11a36f0c1090759fe22e0beb81ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392462
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-11-06 19:44:04 +00:00
Ryan Macnak f6f8134ef2 [vm, compiler] Fix compressed instructions for larger shift values.
TEST=ci
Change-Id: I7b49c7479cce80f91c068cf6f82d8bb4d19d45e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393605
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-11-06 17:25:56 +00:00
Alexander Markov 9645a7114c [vm/compiler] Simplify code generation of comparisons by moving constant operands to the right
TEST=ci

Change-Id: Ifa17f11ca297de9da733dffc132ade498c9e0f00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393604
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-11-06 13:58:40 +00:00
Siva Annamalai 74c5aa3a7a Revert ""[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory""
This reverts commit f81a402aa1.

Reason for revert: golem benchmarks are failing to run

TEST=ci

Original change's description:
> "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
>
> Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime
>
> This reverts commit 75e6a748f7.
>
> TEST=ci
>
> Original change's description:
> > Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
> >
> > This reverts commit 1b331d05c2.
> >
> > Reason for revert: golem builds are failing
> >
> > Original change's description:
> > > [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
> > >
> > > TEST=ci
> > >
>
> Change-Id: Id0f383eabb496c06c0acebc639c8e3b056ba82d0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393781
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: Iec494940412aa31dbefdc5280e35ae99e8cecb26
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393764
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-11-06 05:37:46 +00:00
asiva f81a402aa1 "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime

This reverts commit 75e6a748f7.

TEST=ci

Original change's description:
> Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
>
> This reverts commit 1b331d05c2.
>
> Reason for revert: golem builds are failing
>
> Original change's description:
> > [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
> >
> > TEST=ci
> >

Change-Id: Id0f383eabb496c06c0acebc639c8e3b056ba82d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393781
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-11-06 03:10:31 +00:00
Ryan Macnak 4fa616b254 [vm] Fix code patcher assertions for RISC-V.
TEST=ci
Change-Id: I313d2bb7f03c9ce8fd9fe423e732b34a5a2420e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393584
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-05 22:16:59 +00:00
Siva Annamalai 75e6a748f7 Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
This reverts commit 1b331d05c2.

Reason for revert: golem builds are failing

Original change's description:
> [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
>
> TEST=ci
>
> Change-Id: I96ed52994e0d955300c18026032e68003504666d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389760
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Change-Id: I5dc14973f4ee4e577b2c996839d5e497c97fb440
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393761
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-11-05 21:58:09 +00:00
asiva 1b331d05c2 [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
TEST=ci

Change-Id: I96ed52994e0d955300c18026032e68003504666d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389760
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2024-11-05 20:39:15 +00:00
Alexander Markov f09afbe719 [vm/compiler] Cleanup unused handling of stack slot locations in comparisons
Location summary for inputs of integer comparisons uses either
RequiresRegister or LocationRegisterOrConstant, so operand cannot be a
StackSlot.

TEST=ci

Change-Id: Idff0f09074be2055f0f9a46d8629c769155eb8ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393044
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-11-05 13:50:55 +00:00
Alexander Markov 52cb60b34e [vm/compiler] Rename Comparison to Condition, introduce proper Comparison
Previously, ComparisonInstr base class represented arbitrary conditions
used in Branch, IfThenElse and CheckCondition instructions and included
subclasses TestInt, TestCids, TestRange and unary DoubleTestOp which are
not comparisons. So this refactoring renames ComparisonInstr to
ConditionInstr.

In addition, a new Comparison instruction is added as a base class for
StrictCompare, EqualityCompare and RelationalOp.

TEST=ci (pure refactoring)

Change-Id: Ic8756ee5913ff2bc974c95cea8004370c9f5527f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393420
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-11-05 13:50:08 +00:00
Ryan Macnak b0e3448240 [vm, compiler] Fix LR/SC assembler tests.
Compare 4242ff536f.

TEST=ci
Change-Id: I3cc69504c380af02fa3869e73beef4112a60accb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393381
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-04 18:26:02 +00:00
Alexander Aprelev 8519914049 [gardening] Fix riscv32 build, remove unused variable.
Fixes https://github.com/dart-lang/sdk/issues/57021
TEST=local riscv32 build

Change-Id: I142a50a5998ec35fc40e82fd0bd2533c5f2097c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393361
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2024-11-04 17:04:54 +00:00
Alexander Markov 2bcb7361d5 [vm/compiler] Remove speculative int32 range checks
UnboxedInt32 representation is no longer speculative, so
all speculative int32 range checks are removed from Unbox and
IntConverter instructions. Unbox and IntConverter instructions
are now always truncating. IntConverter cannot deoptimize.

TEST=ci

Change-Id: Ie9a83e055e8b8372859b0721ac6fbcf73da39ab8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392740
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-11-01 13:15:36 +00:00
Alexander Markov 507d40fd95 [vm/compiler] Fix constant propagation of truncating Unbox instructions
TEST=ffi/data_test
Fixes https://github.com/dart-lang/sdk/issues/56996

Change-Id: I153a468d784eae16d65722e91a039347930fd801
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392841
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-10-31 21:52:48 +00:00
Alexander Markov c919ade017 [vm/compiler] Remove speculative inputs from IL instructions
All inputs of IL instructions are now non-speculative,
SelectRepresentations pass now always inserts non-speculative
unboxing instructions.

In call specializer, where JIT compiler speculates, speculative Unbox
instructions are now explicitly added for inputs which may have
incorrect type. Unbox instructions now have 'value_mode' (either
kHasValidType or kCheckType) instead of speculative mode.
Added canonicalization rule to change value mode if
compiler can prove that value has correct type.

Also, cleaned up speculations around UnboxedInt32 representation in
JIT mode, which aligns this representation with other unboxed
representations.

TEST=ci

Change-Id: I52f5c959c3f6515b1a7c9e8ab15b420beed0e3f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391492
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-10-30 19:35:48 +00:00
Ryan Macnak f359a4367e [vm, compiler] Improve TestImmediate on RISC-V for higher single-bit tests.
Shifting the interesting bit to the sign bit is shorter than loading a large immediate.

TEST=ci
Change-Id: Ibd3dadf3885b554643e4606e8cbf83fcc6ba3d30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392463
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-10-30 16:40:18 +00:00
Ryan Macnak e65b892d12 [vm, compiler] Enable argument registers for RISC-V.
dart2js.aot.rv64gc  28061800 -> 27559904 (-1.8%)
dart2js.aot.rv64gcb 27996112 -> 27510728 (-1.7%)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54955
Change-Id: Ic18ab8c33f59c36561fa7e7aed4d06f4e8f8c9dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357215
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-30 16:34:12 +00:00
Alexander Markov 3f717df415 [vm/compiler] Infer array element type from static type Iterable<E>
Inferring array element type E from static type Iterable<E> allows
compiler to remove extra checks left from iterator code.
This is valid as List<E> implements Iterable<E>.

This change makes for-in loops over built-in lists with static types
Iterable<E> as efficient as loops over List<E>.

TEST=runtime/tests/vm/dart/regress_56840_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56840

Change-Id: Ie52208b9c3e92dcc52079e66c910b023f09a2173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392401
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-10-30 15:41:41 +00:00
Liam Appelbe 50f367b283 [vm] Early-out in NativeCallable trampoline if isolate creation disabled
I haven't been able to get a solid repro the tsan flake locally, and I'm not sure how to write a test for it, but this change is pretty uncontroversial anyway, so I'm inclined to just land it and see what happens.

I have some weak evidence that this fixes the issue though. Before this change I ran the flaky command about 500 times before I saw a failure (though I didn't get any useful data from the failure, and it didn't look quite the same as the bug). With the change, the command ran 3500 times before flaking. I'm not sure if it's the same flake though (rr isn't working for me atm).

Bug: https://github.com/dart-lang/sdk/issues/56900
Fixes: https://github.com/dart-lang/sdk/issues/56900
Change-Id: I939e8ceca4051ec91e942ca38a2b01477b67ddd8
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392162
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2024-10-29 22:26:59 +00:00
Ryan Macnak c2c8a984f3 [vm, compiler] Handle invalid shift amount during code generation by emitting a break instead of asserting.
The compiler sometimes fails to remove unreachable IL instructions, and such instructions can have contradictory range information.

TEST=dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/56947
Change-Id: I435019ea87804fdb649e7ff8cee855d08be24019
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392403
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-10-29 20:44:13 +00:00
Ryan Macnak 2a4a7d91d4 [vm, compiler] Don't introduce spurious connections to check bounds instructions during LICM.
TEST=dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/56947
Change-Id: Icf593c246f226dd9d8d8b6b055122f8b567be35e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391682
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-29 19:53:11 +00:00
Ryan Macnak 949eb447a4 [vm, gc] Add write-write fence after initializing object headers, or defer marking new-space objects in an active TLAB.
On architectures with a weak memory model, there is the possibility that the concurrent marker can see the publishing store of a new object before it sees the initializing store of that object's header. On an M1, the barrier to prevent reordering these stores is fairly cheap, so we emit this barrier on Mac/iOS ARM64. Otherwise, this barrier is very expensive (or at least expensive for some hardware within the ABI), so instead we avoid the race by deferring marking of objects inside an active TLAB.

Disable TSAN instrumentation on the marker setting the mark bit, as TSAN does not understand fences.

TEST=ooo arm64 machines
Bug: https://github.com/dart-lang/sdk/issues/56845
Change-Id: I0676661a7cf941fdc6b451e516d890c26826bb3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389265
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-10-28 22:41:39 +00:00
asiva cd31961c0b [vm] - Fix gcc compilation error
56962 - MutatorMarkerRace_DetectInTLAB test compile error on GCC

TEST=ci

Change-Id: I16038dc5f2fd8656652c13c55e7e4b403c4f859a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392063
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-10-28 17:26:36 +00:00
Ryan Macnak e25601e129 [vm, compiler] Use bit-manipulation extensions when targeting Android or Fuchsia RISC-V.
Use Zbb instructions when available for ClampedUint8List stores.
Use Zba instructions when available for IntConverter zero extensions.
Fix LslImmediate(kUnsignedFourBytes) when Zba is enabled.

TEST=locally switch to RV64GCB
Change-Id: If9fc0ac3fd2c5248785322f949e2003024e5152a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385640
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-28 17:08:39 +00:00
Ryan Macnak 36da75d075 [vm, compiler] Fix mismatch between ARM's StoreIndexedInstr::MakeLocationSummary and EmitNativeCode.
TEST=dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/56948
Change-Id: I7241071df2aedb34a88817896005eb0fdff674eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391487
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-28 17:04:10 +00:00
Ryan Macnak 9e28e19002 [test] Synthetic versions of the mutator-marker race.
TEST=vm/cc/MutatorMarkerRace_*
Bug: https://github.com/dart-lang/sdk/issues/56895
Change-Id: I3e3f25b2c43aec09a409377f77c6d2fec287bccb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390263
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-24 03:24:08 +00:00
Stephen Adams e288d38ce7 [vm] Don't do pragma_unsafe_no_bounds_check_test on IA32
TEST=ci
Bug: #56910
Change-Id: Iaed0cbf5ed139a14cfa4736839fbd6013bcfccfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391702
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-10-24 00:12:41 +00:00
Alexander Markov 2b899adb4c Revert "[vm] Enforce that entry points must be annotated by default."
This reverts commit cb9ecbc363.

Reason for revert: causes failures during Dart->Flutter roll and on Flutter HHH bots (see comments on the original CL).

Original change's description:
> [vm] Enforce that entry points must be annotated by default.
>
> Changes the default value of the --verify-entry-points flag
> to true.
>
> Changes the default value for the check_is_entrypoint argument to
> to the Invoke/InvokeGetter/InvokeSetter flags to true. The mirrors
> library implementation and calls via vm-service explicitly pass
> false for this argument now.
>
> Add annotations as needed, such as annotating classes with
> annotated generative constructors. In some cases, the annotations
> were more general than needed (e.g., annotating with a no-argument
> entry point annotation when only the setter is needed), so make
> those annotations more specific.
>
> As this pattern is already common in downstream code, allow
> Dart_Invoke on fields as long as the field is annotated for getter
> access. (That is, calling Dart_Invoke for a field is equivalent to
> retrieving the closure value via Dart_GetField and then calling
> Dart_InvokeClosure.)
>
> TEST=vm/cc/DartAPI_MissingEntryPoints
>      vm/dart/entrypoints_verification_test
>
> Issue: https://github.com/dart-lang/sdk/issues/50649
> Issue: https://github.com/flutter/flutter/issues/118608
>
> Change-Id: Ibb3bf15632ab2958d8791b449af8651d47f871a5
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try
> CoreLibraryReviewExempt: adding/editing vm-only pragma annotations
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363566
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/50649
Issue: https://github.com/flutter/flutter/issues/118608
Change-Id: Idba168f77b0636a50ad93309e29dc9989cc1f388
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391460
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-10-22 14:18:04 +00:00
Tess Strickland cb9ecbc363 [vm] Enforce that entry points must be annotated by default.
Changes the default value of the --verify-entry-points flag
to true.

Changes the default value for the check_is_entrypoint argument to
to the Invoke/InvokeGetter/InvokeSetter flags to true. The mirrors
library implementation and calls via vm-service explicitly pass
false for this argument now.

Add annotations as needed, such as annotating classes with
annotated generative constructors. In some cases, the annotations
were more general than needed (e.g., annotating with a no-argument
entry point annotation when only the setter is needed), so make
those annotations more specific.

As this pattern is already common in downstream code, allow
Dart_Invoke on fields as long as the field is annotated for getter
access. (That is, calling Dart_Invoke for a field is equivalent to
retrieving the closure value via Dart_GetField and then calling
Dart_InvokeClosure.)

TEST=vm/cc/DartAPI_MissingEntryPoints
     vm/dart/entrypoints_verification_test

Issue: https://github.com/dart-lang/sdk/issues/50649
Issue: https://github.com/flutter/flutter/issues/118608

Change-Id: Ibb3bf15632ab2958d8791b449af8651d47f871a5
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try
CoreLibraryReviewExempt: adding/editing vm-only pragma annotations
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363566
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-22 09:34:22 +00:00
Stephen Adams 066962ff60 [vm] Defer removal of bounds checks
Change how `@pragma('vm:unsafe:no-bounds-checks')` works.

Instead of never inserting the bounds check, the bounds check is added to the flow graph with a flag that it should later be removed, `omit_check`. The removal occurs in `RangeAnalysis::EliminateRedundantBoundsChecks`. This ensures that the indexed load is pinned by the check, preventing illegal code motion.

`@pragma('vm:unsafe:no-bounds-checks')` is not a mechanism to allow unsafe access. It means that the access is known to be safe because of invariants not apparent to the compiler. Keeping the bounds check in the flow graph allows range analysis to learn from the bounds constraints and perhaps remove other checks. A test was added for this scenario. I didn't see this in the wild, but I did see one case where a refined range allowed a boxing to be removed.

Bug: #56808
TEST=BoundsCheckElimination_Pragma_learning, BoundsCheckElimination_Pragma_learning_control
Change-Id: I5b3f4470d6c40c988a8a0ee563c765f4f5f9128b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-10-16 23:10:11 +00:00
Ryan Macnak da8f17762c [vm, gc] Allocate card tables up front.
This avoids data races when multiple mutators compete to install the card table, and allows removing the initialization check from the write barrier.

TEST=ci, tsan
Bug: https://github.com/dart-lang/sdk/issues/56895
Change-Id: I30fe4687d3ca771f6c00dfa59e8dadec23d557a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390023
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-16 21:25:17 +00:00
Derek Xu 30dc2de34f [VM/Service] Report the requested column in the error messages of CannotAddBreakpoint errors
TEST=CI

Change-Id: Ia74bd61ef0b166275d5828fb21cfa9c92c5f00cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389280
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-10-15 16:57:36 +00:00
Derek Xu cdacfd80f1 [VM/Debugger] Ensure that a breakpoint can only resolve on the exact line that was specified in a request
TEST=CI

Fixes: https://github.com/dart-lang/sdk/issues/56820
Change-Id: Ic04400ce6a15d7a2450b05bd5753087350ae52b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388460
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-10-15 16:57:36 +00:00
Ryan Macnak 889e5795bb [vm, compiler] Use immediate forms for BinaryUint32Op.
dart2js.aot.arm64  28757440 -> 28691320 (-66k)
dart2js.aot.x64    28311232 -> 28310536 (-1k)
dart2js.aot.rv64   27971912 -> 27955200 (-16k)
dart2js.aot.arm32  27793504 -> 27775936 (-17k)

TEST=vm/dart/uint32_op_imm_test
Change-Id: I25e486ea1ab3b20369c0c5a5fafae5d1ea53b1c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388120
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-09 16:47:48 +00:00
Jens Johansen 54f1ee4067 [VM/CFE] Fix expression compilation with record types
Fixes https://github.com/dart-lang/sdk/issues/56859

TEST=pkg/vm_service/test/evaluate_with_record_{1,2}_test.dart + CFE test

Change-Id: I4fdd2bc8e6c04fc59aaad28a192fe0b1833f000d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388841
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-10-09 11:01:57 +00:00
Ryan Macnak ccbd0c6129 [vm] Avoid reordered stores during Thread::SuspendStateInternal.
The profiler will crash if the signal handler runs between clearing the OSThread from the Thread and setting the TLS to the OSThread if they are reordered. The window here is much larger on Android because of Android's slow emutls. This doesn't affect standalone Dart because the two stores are in different translation units, but Flutter uses LTO.

TEST=flutter
Bug: https://github.com/flutter/flutter/issues/143178
Change-Id: I96a4d154083949f6bdd33a17a75a88d611c9a34a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388743
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-08 20:36:14 +00:00
Ryan Macnak 262b759e06 [vm] Place regexp sources in their own directory.
This makes it easier to see their cost in binary size tools.

TEST=ci
Change-Id: I6079ad9fb9b7c9450bb8d255e9a794a38ec9ae62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388641
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-08 17:28:49 +00:00
Derek Xu bdff12304d [VM/Debugger] Delete a TODO
I didn't mean to commit this TODO, it was just a reminder I left as I was working on a CL.

TEST=CI

Change-Id: I5e3f7592bd4d7d92f85b92ef44c6adf26465c772
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388380
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-10-08 17:23:43 +00:00
Vyacheslav Egorov 284e9e91c8 [vm] Allocation profiling via uprobes
This CL adds basic infrastructure and tooling to perform allocation
profiling using uprobes.

See runtime/tools/profiling/README.md for more details.

TEST=manually tested, requires root access

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-release-arm64-try
Change-Id: Id68d181740dbf227a12d8cdba84b11a9518e75a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382405
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-10-08 13:56:45 +00:00
Tess Strickland 2b1e82b4fe [gardening] Satisfy UBSAN for possibly negative left shifts.
TEST=vm/cc/Assembler_LslImmediate on ubsan trybots

Fixes: https://github.com/dart-lang/sdk/issues/56860
Cq-Include-Trybots: luci.dart.try:vm-ubsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-aot-ubsan-linux-release-x64-try
Change-Id: Iad1332d638af633373bbb588ea554e6a0da71c93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388840
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-08 09:47:59 +00:00
Ryan Macnak 2142d8e148 Search in more locations for the system's root certificates.
TEST=access pub under wolfi
Bug: https://github.com/dart-lang/sdk/issues/56734
Change-Id: Ie2033d3551966180dfdf3eff1b5ef39ac0b79ce7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388080
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-07 23:33:09 +00:00
Ryan Macnak 0ab55451f4 [vm] Cleanup reload debugging code.
TEST=ci
Change-Id: I840fc1a614186e0f330f4b2313a6706452af6998
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388665
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-07 22:29:49 +00:00
Ryan Macnak fa75e88591 [vm] Avoid massive vtables for IL instructions.
Implement type checks for leaf IL instructions using the instruction tag
 instead of per-type virtual functions, which scale quadratically with the number of IL instructions.

out/ReleaseX64/exe.stripped/gen_snapshot 7601248 -> 6890640 (-9.3%)

TEST=ci
Change-Id: I3d9c84c67e6ab0f3020ebb02068451e6f1c150f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388043
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-07 22:14:29 +00:00
Tess Strickland b9ac6de902 [vm/compiler] Add requested change to ARM7 ArithmeticShiftRightImmediate.
This is a change to address the last comment in
https://dart-review.googlesource.com/c/sdk/+/386180, which got
accidentally submitted without it.

TEST=ci

Change-Id: I8c7b12370d282d01b3fe8b2543ec7242461aaccd
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try,vm-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388008
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-04 11:10:45 +00:00
Tess Strickland b23584eaa0 [vm/compiler] Add reg, reg, imm forms for lsl/asr/and assembler macros.
For non-x86 architectures, these forms directly translate to a
single instruction when possible. On x86 architectures,
XImmediate(dst, src, imm) where X is in {Lsl, ArithmeticShiftRight, And}
can be translated to:

  MoveRegister(dst, src);
  XImmediate(dst, imm);

in the general case since MoveRegister(dst, src) is a no-op if dst and
src are the same.

Also add versions of these assembler macros that take an OperandSize
and handle 32-bit OperandSizes appropriately on 64-bit architectures.

Ensure the implementation for LslImmediate and
ArithmeticShiftRightImmediate emits no instructions if shift == 0,
dst == src, and OperandSizeInBits(sz) == kBitsPerWord on all
architectures.

-----

Other changes:

Fix ConstantExpression::EmitMoveToLocation on ARM64 to match
other architectures, which allow any word-sized or less unboxed
integer representation.

Fill out ExtendValue on RISCV for previously unimplemented
OperandSizes, using the Zba and Zbb extensions when possible.

-----

TEST=vm/cc/Assembler_AndImmediate vm/cc/Assembler_LslImmediate
     vm/cc/Assembler_ArithmeticShiftRightImmediate

Separated out of https://dart-review.googlesource.com/c/sdk/+/378706
for easier debugging/reviewing.

Change-Id: I721f1334784f7011a958ea8af29f0e56c620726c
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-linux-product-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-mac-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-android-release-arm64c-try,vm-ffi-android-debug-arm64c-try,vm-aot-linux-debug-x64c-try,vm-linux-debug-x64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386180
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-04 10:07:51 +00:00
Ryan Macnak 783cd7fc25 [vm] Include version information in DW_AT_producer.
This follows gcc and clang's behavior.

TEST=readelf
Change-Id: Ic009d9439d1e233afda035d0dfd2592c590c0ce2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387821
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-02 19:39:00 +00:00
Ryan Macnak 07e7ec4978 [vm] Include line numbers in DWARF abstract functions.
Tools such as nm expect source positions here and won't try to find the first position in the line number table.

TEST=vm/dart/dwarf_nm_line_numbers_test
Change-Id: I0505b03eea22a75220b4454aaa9c0cde4e9fb698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387780
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-02 18:08:11 +00:00
Alexander Markov bea3f74a54 [vm, aot] Improve canonicalization of branch comparisons
Canonicalization

  v1 <- comparison(...)
  Branch if (StrictCompare(===, v1, true))
=>
  Branch if (comparison(...)

was not applied if comparison has unmatched representations.
However, checking for unmatched representations matters only
if comparison is speculative (in JIT mode).

Fixing this canonicalization rule improves range analysis in AOT.
As a result, range analysis can eliminate bounds check in a loop when
iterating over list using its iterator.

Also, add useful tracing to bounds check elimination code
under --trace_range_analysis.

In addition, BranchInstr::SpeculativeModeOfInput is fixed -
it should delegate to its comparison instead of returning
kGuardInputs default in order to support non-speculative
comparisons folded into branch.

Also, EqualityCompare canonicalization is now applied to
BranchInstr comparison, in order to keep optimizations which
were applied when EqualityCompare was not folded into
branches.

TEST=runtime/tests/vm/dart/regress_56807_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56807

Change-Id: Ib69294d7ccf30b63dd3ff7ae5a47c0a238824952
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387622
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-10-02 15:41:20 +00:00
Ryan Macnak c7f9914497 [vm, reload] Use a more stable hash code for implicit closure functions.
The old hash code used the absolute token position, which made the hash code of a closure change for any insertions or deletions above it in the same file.

TEST=vm/cc/IsolateReload_ClosureHashStablity
Bug: https://github.com/flutter/flutter/issues/153536
Change-Id: I75da3f0cdca1862637179467ec23cf20b9878d8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387602
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-01 19:35:51 +00:00
Alexander Markov d84b374683 [vm] Improve bounds check elimination in range analysis
* Infer range for CheckArrayBound and GenericCheckBound instructions.
* Extend Constraint instruction to non-Smi values bounded by list
  length.
* Unwrap UnboxInt64 during canonicalization of range boundaries.
* Use symbolic range for UnboxInt64 of list length.

As a result, bounds check can be eliminated in a loop over a growable
list:
```
  for (int i = 0; i < a.length; ++i) {
    final value = a[i];
    ...
  }
```

TEST=runtime/tests/vm/dart/regress_56726_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56726

Change-Id: Ic56df18f6fbf26abf91d6ecbff24d68678dccb60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386522
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-27 13:28:59 +00:00