Commit Graph

22093 Commits

Author SHA1 Message Date
Derek Xu 75311aefa8 [VM/Timeline] Add Microtask stream
TEST=runtime/vm/dart_api_impl_test.cc

Change-Id: Icb078489f3600ac0fb8b314ca3bf748f482a687e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422860
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-04-22 07:42:27 -07:00
Konstantin Shcheglov 6e88d87c02 Elements. Migrate runtime/tools/dartfuzz/
Change-Id: I9ec2bbcbe47573a0f4bac1f56019708048fcfc8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422900
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-16 17:28:11 -07:00
Ryan Macnak e480c74d01 [vm] Fix corruption of null and following objects during OOM.
Array::New[Uninitialized] don't expect to get null from Object::Allocate. Using longjmp seems more robust than adding checks everywhere.

TEST=vm/dart/gc/scavenger_abort_test
Bug: https://github.com/dart-lang/sdk/issues/60552
Change-Id: I2750427c41751f8306d5c8dc28afaf052b6e9d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422902
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-16 16:17:13 -07:00
Ryan Macnak 779a1962ae [vm] Restore write protection of the VM isolate.
TEST=vm/cc/VMIsolateImmutability
Bug: https://github.com/dart-lang/sdk/issues/60552
Change-Id: I5a51718996ce735a67c73500c46f0e7cc16f654a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-04-16 15:26:08 -07:00
Ryan Macnak 58b5237e23 [vm, gc] Access the OOM reservation under safepoint operations.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/60544
Change-Id: I19d1e3bf2ff7dfb4f6b43fa8513a552dadece929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422800
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-16 13:12:54 -07:00
Ryan Macnak 2a388bdee4 [vm] At least give module+offset when symbols are missing on Windows.
TEST=manually added crash
Change-Id: I73c8a9417a52efb1c9a1fd0fbe913c60637f9613
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422541
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-15 15:46:59 -07:00
Ryan Macnak 3ef86d2807 [vm] Use atomics for isolate group flags.
TEST=tsan
Change-Id: I1aaa29046ff6808e9aa19b83a2854d31f1776757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422542
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-15 15:04:10 -07:00
Ryan Macnak 8505c558da [vm] Evaluate abstract origin DIE offsets sooner in DWARF assembly output.
This greatly improves assembler performance in XCode 16, presumably by convincing the assembler it doesn't need to keep track of relocations for abstract origin labels.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/43299
Bug: b/410018517
Change-Id: I68c6783d76bdf3c818c460c9a2cf559b88544993
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-15 12:43:39 -07:00
Ryan Macnak a9dd011f94 [vm] Make out-of-memory scenarios a bit more robust.
- Don't scavenge when there is no OOM reservation, so refilling the OOM reservation will get the first go once free space is available instead it being consumed by promotions.
 - Increase the desired free space in new space needed to continue scavenging. Since new space became paged, 1 KB / 64 pages only guarentees the ability to allocate a 16 byte object.
 - Stop issuing stress test reloads after an OOM is encountered.
 - Add a HANDLESCOPE to reload to make memory collectible sooner after an error.

TEST=vm/out_of_memory
Bug: https://github.com/dart-lang/sdk/issues/48920
Bug: https://github.com/dart-lang/sdk/issues/53455
Bug: https://github.com/dart-lang/sdk/issues/43642
Change-Id: Ife8bed52e341648a66f78d55bfa60b3944be5d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422324
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-15 10:39:32 -07:00
Derek Xu de32acf9ac [VM] Introduce ListQueue class
TEST=list_queue_test.cc

Change-Id: Ie85055475f35a9fdc4f31e61d5f1f5d04eb707a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420220
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-15 09:07:59 -07:00
Daco Harkes 7427e655f6 Revert "[ffi] Remove deprecated Pointer.elementAt"
This reverts commit 789302053e.

Reason for revert: This breaks flutter engine

```
../../../../../../../.pub-cache/hosted/pub.dev/posix-6.0.1/lib/src/util/conversions.dart:32:32: Error: The method 'elementAt' isn't defined for the class 'Pointer<Pointer<Int8>>'.
 - 'Pointer' is from 'dart:ffi'.
 - 'Int8' is from 'dart:ffi'.
Try correcting the name to the name of an existing method, or defining a method named 'elementAt'.
    final _value = cStringList.elementAt(count).value;
```

```
ui 0.0.0
├── archive 4.0.3
│   ├── posix 6.0.1
│   │   ├── ffi 2.1.4
│   │   ├── meta...
│   │   └── path...
```

Reverting while we remove uses upstream.

https://github.com/onepub-dev/dart_posix/pull/17

Original change's description:
> [ffi] Remove deprecated `Pointer.elementAt`
>
> Bug: https://github.com/dart-lang/sdk/issues/54250
>
> TEST=tests/ffi
>
> CoreLibraryReviewExempt: Removing deprecated member after 1+ year.
> Change-Id: I2234f28126e0788860a54cbe6aa82bc76b49c8d8
> Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421740
> Reviewed-by: Hossein Yousefi <yousefi@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

Bug: https://github.com/dart-lang/sdk/issues/54250
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Change-Id: I9cd3d4800840bf28182225824b82c469eb957087
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422460
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-04-15 08:11:57 -07:00
Liam Appelbe 79ff5836c4 [test] Delete old failing test
Test was already migrated to
pkg/vm_service/test/get_source_report_const_coverage_test.dart

Bug: https://github.com/dart-lang/sdk/issues/60522
Change-Id: I9094636c98d26fb2d3be5eeb873501c52a33d470
Fixes: https://github.com/dart-lang/sdk/issues/60522
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422280
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-04-14 15:56:20 -07:00
Alexander Aprelev 7c9ded3a8d [vm] Avoid mutex lock when clearing catch entry cache.
Fixes https://github.com/dart-lang/sdk/issues/60535
TEST=iso_stress_linux ci

Change-Id: I8f7c6faf23645f6e35b9abdf5b5e8a3684879624
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422346
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-04-14 12:33:19 -07:00
Vyacheslav Egorov 5f32e78a09 [vm] Fix running under HWASAN
HWASAN tags stack regions (and stack pointers) with 0,
but also selectively tags some stack allocations with
non-zero tags. These tags need to be cleared when
allocation goes out of scope so that stack can be
later safely reused - otherwise stale tags confuse
HWASAN instrumentation later.

This CL teaches Exceptions::JumpToFrame to do that.

CL also adds basic build changes to support building
with HWASAN, though I don't wire it into CI for now
as it can only really run on Android ARM64

TEST=manually on Android phone and on internal tests

Bug: b/374433249
Change-Id: I678443dc1de693c999a226bee0d71a6f3582d4f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421180
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2025-04-14 10:14:54 -07:00
Derek Xu 1d69b0b980 [VM] Add automatic detection of timers that are significantly overdue
This change makes it so that when the VM detects that a timer is at
least 100 ms overdue, it sends a warning in a VM Service event on the
'Timer' stream.

TEST=Built an Android Flutter app with a modified Engine that contained
a `sleep` call in `eventhandler_linux.cc` and confirmed that the warning
event got sent, built an iOS Flutter app with a modified Engine that
contained a `sleep` call in `eventhandler_macos.cc` and verified that
the warning event got sent,
pkg/vm_service/test/overdue_timer_detection_test

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes.
Change-Id: Ie8db047116b7f63cfb5413f763eaf56c7bdd6975
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409500
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-14 07:36:31 -07:00
Liam Appelbe 50a3bf663b [vm] Improve const constructor coverage
The way coverage collection was implemented for const constructors was a bit of a hack. After ordinary coverage collection was complete and all ordinary source ranges had been added to the report, SourceReport::CollectConstConstructorCoverageFromScripts would iterate through all the const constructors and add extra ranges to the source report that reported them as being hit. The old ranges were still in the report, reporting the constructors as missed, but the miss was overwritten by the hit when package:coverage turned the source report into a coverage report. That hacky approach didn't work for branch coverage.

I've refactored it to gather all those const constructor hits before ordinary coverage gathering, and store the hits in the script table. Then during the ordinary coverage collection flow, when we see one of those const constructors, we mark everything inside the function as hit.

This also fixes a related bug that we hadn't noticed before, where calls inside the const constructor were treated as missed.

Note: If there are dozens of const constructors in a single script, it might be worth sorting ScriptTableEntry.const_constructor_hits and then binary searching it, but I don't think that's worth doing atm.

Bug: https://github.com/dart-lang/tools/issues/513
Fixes: https://github.com/dart-lang/tools/issues/513
Change-Id: Ie66a153fbeaac5b3ecfc9a28a7f8d129ab61114a
TEST=source_report_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421720
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-04-10 18:00:30 -07:00
Daco Harkes 789302053e [ffi] Remove deprecated Pointer.elementAt
Bug: https://github.com/dart-lang/sdk/issues/54250

TEST=tests/ffi

CoreLibraryReviewExempt: Removing deprecated member after 1+ year.
Change-Id: I2234f28126e0788860a54cbe6aa82bc76b49c8d8
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421740
Reviewed-by: Hossein Yousefi <yousefi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-04-10 11:14:02 -07:00
Derek Xu 2cc25a8baf [VM/Timeline] Fix bug in timeline proto arguments
TEST=This can only be tested by writing events using the C++ timeline
API. My tests for microtask profiling will cover this.

Change-Id: Ie68dcee5b696f41c3f2244ae524199f57986a94d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421860
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-10 08:55:19 -07:00
Ivan Inozemtsev 8773b6618f Reland "Update libcxx and libcxxabi"
This is a reland of commit 3491f72880

Original change's description:
> Update libcxx and libcxxabi
>
> Add libc, required by libcxx.
>
> Based on https://github.com/flutter/flutter/pull/165621.
>
> Change-Id: I5b929dc81b2572e3b919a8d20e031f98196375e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416220
> Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>

Change-Id: I9392f4cdc2ccb985085768c90bd293d353bf4c95
Cq-Include-Trybots: luci.dart.try:vm-aot-tsan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-asan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421300
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-04-09 09:04:51 -07:00
Alexander Aprelev 7a44485843 [vm] Move catch_entry_cache, handler_info_cache to IsolateGroup.
This should help speeding up new isolate creation (or running dart code on mutator thread when it is supported).

TEST=ci

Change-Id: I88b5deeb33e72694cb3e2727cf5668ce15fd8c6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420361
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-04-08 09:13:39 -07:00
Vyacheslav Egorov a2ae02e3f0 [vm] Add HANDLESCOPE in KernelLoader::LoadLibrary
This reduces amount of handles and live data kept around
after each library is loaded which helps on large
apps.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try
Change-Id: I9ae8f31a5912c589b4668f0937e4744315c21d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420321
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-04-08 04:57:05 -07:00
Vyacheslav Egorov 76581515c1 [vm] Fix JumpToFrame for dynamic modules
Change 8085a97a63 moved commonly
invoked StackResource::Unwind(...) from several different code
paths (simulators & interpreter) into Exceptions::JumpToFrame.

However the change did not account for the order of operations
in Exceptions::JumpToFrame which broke interpreter. This CL
fixes that by moving Interpreter::JumpToFrame under
StackResource::Unwind(...).

We also forgot to remove StackResource::Unwind from RISC-V
simulator - but that's benign because calling it the second
time simply does nothing.

TEST=vm-aot-dyn-linux-debug-x64

Change-Id: Ia93fc6997b768180fbbb5e54bb0c0fd5c713a244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421060
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2025-04-08 03:15:49 -07:00
Derek Xu 19e2a2d58c [VM/Debugger] Make Debugger::FindBestFit skip functions with non-real start or end positions
TEST=confirmed that pkg/vm_service/test/regress_60396_test passes with
the changes in this CL and fails without them

Fixes: https://github.com/dart-lang/sdk/issues/60396
Change-Id: I093fa3abf98b41c47786f0d37987ae771efe072e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420880
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-04-07 13:48:53 -07:00
Bogdan Lukin 82559e241f [vm] postpone creation of handles for show/hide lists
Closes https://github.com/dart-lang/sdk/pull/60473

GitOrigin-RevId: 4e731c9b4959955edab7aafa9905f609bd151df0
Change-Id: I5dd9b179ff0ed4f546ca0fea16456ccda7545f10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420301
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-07 10:10:30 -07:00
Vyacheslav Egorov 8085a97a63 [vm] Fix JumpToFrame execution state transition
Instead of handling FFI related execution state and safepoint
in assembly handle it in runtime code.

The transition needs to be done before JumpToFrame unwinds
stack because unwinding destroys exit frame and this can't
be done at safepoint as GC might be traversing the stack.

An incorrect order of operation was manifesting as crashes in
GC when one isolate in a group was encountering a lot of
exceptions thrown from an FFI call and another isolate is
triggering GCs.

To catch this in the future added a bit of validation to
ExitSafepoint runtime call which triggers when --use-slow-path
is enabled. Though after refactoring this code does not
trigger this code path anymore because it was completely
removed - but it is better than nothing.

This CL also removes a lot of unnecessary complexity which
was associated with handling this transition in the stub
itself.

TEST=ffi/vmspecific_handle_test

Bug: b/408377905
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Change-Id: Ia073cb6bb9e1b5a0ea8514c7e048cee6019b84d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420324
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2025-04-07 05:22:56 -07:00
Ryan Macnak 174acd490d [vm] Print some resource usage and limits when pthread_create fails.
TEST=ulimit
Bug: https://github.com/flutter/flutter/issues/164591
Change-Id: Ica782d6e9dbf8da3017f6cf65196564bbed40f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419988
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-02 15:49:11 -07:00
Alexander Aprelev e0dc78bbf6 [vm/oom] If unable to create OOM stack trace, report OOM without stack trace.
Fixes flaky out_of_memory tests failures.

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

Change-Id: I5c9192c6cc25660e83f6c03d4293360c353b02d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419583
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-04-02 13:09:52 -07:00
Ryan Macnak 383cd496ce [vm] Use dlopen for loading AOT snapshots on Fuchsia.
This will play better with native tooling compared to Dart_LoadELF.

Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Change-Id: If5265d079200d7be754b82a9775d977aa66c15f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419684
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zijie He <zijiehe@google.com>
2025-04-02 12:46:55 -07:00
Ryan Macnak d4cb7a4f21 [vm] Fix COPY_FP_REGISTER for Windows x64, arm, arm64.
This should improve DumpStackTrace from assertion failures, though x64 still doesn't work for lack of frame pointers in the runtime code.

TEST=manually add assertion failure.
Change-Id: Ie632f79b21fd14a2ece3cde23736adc097938315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419800
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-02 11:20:48 -07:00
Ivan Inozemtsev 9c88769967 Dartdev cross compilation support
- Add `target-arch` option to `dart compile exe|aot-snapshot`
- Add artifacts cache in `~/.dart`, and download gen_snapshot and
  dartaotruntime from cloud storage if necessary

I've manually built an aot snapshot and exe on macOS ARM64 for Linux
X64, copied them over to a linux machine, and made sure they work.

Change-Id: I74dd581ecb573ff4069a2fe19f9d04aaa352538e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417801
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-04-02 08:14:28 -07:00
Alexander Markov 6eaeccf82f [vm] Handle null field values in record type testing stubs
TEST=vm/cc/TTS_RecordSubtypeRangeCheck

Issue: https://github.com/dart-lang/sdk/issues/60419
Change-Id: Ibe85d1da750e0c8feb82415df36990927a6413e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419483
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-04-02 05:58:18 -07:00
Ryan Macnak 0bed1ac7f1 [test] Disable the background compiler during vm/cc/DartAPI_OptimizedExternalByteDataAccess.
This avoid racy access to the optimization counter threshold.

TEST=tsan
Change-Id: I5bba52e88957022007060893159e26ebe47e40a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419421
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-01 09:56:48 -07:00
Ryan Macnak 4ab313cf09 [vm, test] Enable some AOT testing for Fuchsia.
Fix the standalone embedder's ELF loader to open files with the executable permission.

TEST=ci
Bug: b/399714829
Bug: https://github.com/dart-lang/sdk/issues/60442
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Change-Id: I2652a5849462ce63585550e6c581cc578a228955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419341
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zijie He <zijiehe@google.com>
2025-04-01 09:50:12 -07:00
Tess Strickland 3d0a29d159 [vm/compiler] Allow Slot::Equals to be used with native slots.
Before this change, Slot::Equals would hit the default UNREACHABLE()
case if used to compare two equal native slots. That's surprising and
also unavoidable if code comparing arbitrary slots wants to check Slot
equality, since there's no existing predicate to determine whether an
arbitrary slot is native.

TEST=ci

Cq-Include-Trybots: luci.dart.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-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-mac-release-arm64-try
Change-Id: Ia794a33fc607013bf35435b0427ceb02bdae4b0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419560
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-04-01 03:53:30 -07:00
Ben Konyi 138924c1e8 [ dart:io ] Add tmux terminals to list of terminals known to support ANSI
Fixes https://github.com/flutter/flutter/issues/142861

TEST=N/A

Change-Id: I208c597f33c622d19419202351dd17d39ec82bc3
CoreLibraryReviewExempt: only dart:io
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419280
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-03-31 14:31:47 -07:00
Ryan Macnak 92df34dfd5 [build] Remove Fuchsia sub-builds.
The builders at https://ci.chromium.org/p/fuchsia/g/dart/console no longer exist.

TEST=build
Change-Id: I1b801d7892b3e6cba37d7b9549e3d08306cc9723
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417907
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-03-31 13:07:29 -07:00
Alexander Markov 733ca506c1 [dynamic modules] Add pragmas to core library classes and members used to implement language features
This change adds pragmas which can be used in dart:* libraries to
specify classes and members which are used by the compiler
to implement certain language features. Compiler can insert
references to those classes and members when desugaring language
constructs, so dynamic module code can use these classes and members
implicitly even if they are private.

Previously, we required to specify these members in the
dynamic_interface.yaml before dynamic modules could use them.
However, this is cumbersome and error-prone.

Now, the following pragmas are recognized:

@pragma('dyn-module:language-impl:extendable')
@pragma('dyn-module:language-impl:can-be-overridden')
@pragma('dyn-module:language-impl:callable')

If dynamic interface yaml file is specified during compilation,
then classes/members annotated with these pragmas are treated as if
they are used in corresponding sections of dynamic_interface.yaml.

If dynamic interface yaml file is not specified, these pragmas
are ignored.

Bug: b/395992622

TEST=existing
CoreLibraryReviewExempt: no API changes, only adding pragmas.
Change-Id: I6606467fc5e5264a2565d7eb8e8baccc2eebea84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418663
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-03-31 11:33:50 -07:00
Alexander Aprelev 4a46bed718 [vm/prealloc] Don't preallocate oom, unwind errors, stacktrace object during isolate startup.
For out-of-memory events vm reserves (and if used, then replenishes) small chunk of memory for handling those, so preallocation of oom and stacktrace is not needed.
Unwind error can be created once as part of vm launch, kept in vm isolate.

This should reduce overhead of starting new isolate.

TEST=ci

Change-Id: Ibe2c85f250a521a8e838cc5690984fe9fa287a98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419261
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-03-31 11:17:18 -07:00
Lasse R.H. Nielsen a824ee3206 Include or remove stray pubspec.yaml files.
There were `pubspec.yaml` files in `tools/` that were not
included in the global package config.
That means that their imports were irrelevant, which could
be misleading. And if any tool would look at the
`pubspec.yaml` file, it might be inconsistent with
the actual package resolution.

Makes every `pubspec.yaml` file either be included by the
`tools/generate_package_config.dart` script, or deletes them
if they seem to be stale and unused.
(Compare vs. `git ls-files '**/pubspec.yaml'`.)

Excepted `tools/dart2js/sourceMapViewer/pubspec.yaml`.
The entire directory might be stale. The dependencies of
that pubspec are not SDK dependencies otherwise,
the pubspec has no SDK min-version, which is now a requirement,
and the README refers to a *packages directory*.
Keeping as-is and filing issue to have owners take a look.

Added `lib/` directory to `tools/` to avoid `tools/bots/`
being inside the package URI root of the `tools/` package,
which would cause its `../../pkg/...` import to fail.

Makes every `pubspec.yaml` file use a `^...` SDK constraint instead
of the longer `>= ... < ...` format.

Tested: No new tests, goal is to keep running the same way
Change-Id: I688e463fe985fc4de43550a1f4c7ff350536cffc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414020
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-03-31 08:30:33 -07:00
asiva 284a7ee8c5 [VM/IO] Fix error path in SocketAddress::GetSockAddr
Dart_TypedDataReleaseData was not called in an error path.

Should fix https://github.com/dart-lang/sdk/issues/60421

TEST=tests/standalone/io/datagram_error_test.dart

Change-Id: I1935af1c5beed9d696a0543d0e97f2d549743879
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418701
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-03-28 14:49:19 -07:00
Eric Seidel 47d7d4d5f2 fix: gcc builds broken by clang-only warning flag
Closes https://github.com/dart-lang/sdk/pull/60422

GitOrigin-RevId: 8e32b0bea95193aa5ab6f61e4e3cb8224b9a7c31
Change-Id: I034d5db35873c065fa83d1407ce7674476884abb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418662
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-03-28 11:44:10 -07:00
Mayank Patke cc0527decb Remove babel from DEPS and (dart2js) IE support from test infra.
Tested: N/A
Change-Id: Ib1804b49c40cac9be52e732090e8160444ebb48d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417948
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-03-28 11:26:47 -07:00
Eric Seidel 63a1c907f8 Add -Wnewline-eof to match Flutter
Closes https://github.com/dart-lang/sdk/pull/60404

GitOrigin-RevId: 240ca662e51067e2d45d21f3de904df992076003
Change-Id: I278b1298fed6e89ad94298ea59cd885a77daac64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417863
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-03-28 05:54:59 -07:00
Vyacheslav Egorov 39dc9d8a7d [vm] Intern callstacks when writing Perfetto profile
This significantly reduces the space occupied by callstacks
e.g. 5 second recording of fibonacci computation goes from
1.5Mb to 600Kb.

Also fixes flakiness of pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.

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

This relands commit f07915cb6e
with a fix for Android build.

TEST=ci

Change-Id: Id182692d30e953b20ad2f6ade587e4036fac7e7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418221
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-03-27 06:44:23 -07:00
Vyacheslav Egorov 2a437c54a0 [vm] Intern strings when writing Perfetto timeline
Intern the following fields:

* Category names
* Event labels
* Debug annotation keys and values

This significantly reduces the size of the timeline
(e.g. a timeline containing 60k slices goes from 15Mb
to 5Mb timeline)

This relands commit f2614d24f8
with a fix for Android build.

TEST=ci and manually

Cq-Include-Trybots: luci.dart.try:vm-ffi-android-release-arm64c-try
Change-Id: I88d4c5e1142ff66b270a22b82bacd1e9313fa953
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418220
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-27 06:44:23 -07:00
asiva 8af371c1e8 Fix for App crash when File class receive an empty string
TEST=new test added
Change-Id: I575d85c5ab13a2094114a6fa2a7fe9f06ebeabe4
FIXES: https://github.com/dart-lang/sdk/issues/60331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417962
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-03-26 21:26:49 -07:00
Vyacheslav Egorov f9e5b9282b Revert "[vm] Intern strings when writing Perfetto timeline"
This reverts commit f2614d24f8.

Reason for revert: Android build broken

Original change's description:
> [vm] Intern strings when writing Perfetto timeline
>
> Intern the following fields:
>
> * Category names
> * Event labels
> * Debug annotation keys and values
>
> This significantly reduces the size of the timeline
> (e.g. a timeline containing 60k slices goes from 15Mb
> to 5Mb timeline)
>
> TEST=ci and manually
>
> Change-Id: I59e850279b6714b8b75c5b8e79e6a8b0a981a261
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417202
> Reviewed-by: Derek Xu <derekx@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I17b83f06ca78fb4b91af554ff4b2aff00366d107
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418024
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2025-03-26 14:26:58 -07:00
Vyacheslav Egorov f07915cb6e [vm] Intern callstacks when writing Perfetto profile
This significantly reduces the space occupied by callstacks
e.g. 5 second recording of fibonacci computation goes from
1.5Mb to 600Kb.

Also fixes flakiness of pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test.

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

TEST=ci

Change-Id: I6202ce7e87ceb64f4330b7052e72e519a848e571
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417521
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-26 14:08:23 -07:00
Vyacheslav Egorov f2614d24f8 [vm] Intern strings when writing Perfetto timeline
Intern the following fields:

* Category names
* Event labels
* Debug annotation keys and values

This significantly reduces the size of the timeline
(e.g. a timeline containing 60k slices goes from 15Mb
to 5Mb timeline)

TEST=ci and manually

Change-Id: I59e850279b6714b8b75c5b8e79e6a8b0a981a261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417202
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-26 14:05:39 -07:00
Vyacheslav Egorov 00b3627b7f [vm] Reduce duplication when writing Perfetto packets
Consolidate code populating TracePacket in a single
function instead of multiple helpers. Most of the
duplication in the previous code was caused by
how Duration events were handled - this CL
avoids this duplication by making the core helper
takes event_type, timestamp and timeline event.

This allows to perform Duration split simply by
doing:

  PopulateAndWritePacket(TimelineEvent::kBegin, event.TimeOrigin(), event);
  PopulateAndWritePacket(TimelineEvent::kEnd, event.TimeEnd(), event);

Instead of duplicating large chunks of code.

TEST=ci

Change-Id: Ica5d00264f3e872b939059ea90fcbfbf6c8768e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417201
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-26 11:29:03 -07:00