Commit Graph

22210 Commits

Author SHA1 Message Date
Ryan Macnak b0fd6d4a15 [vm] Fix some Google3 ClangTidy warnings.
TEST=google3
Change-Id: I23236f32d78920388c0b7d2beb738e7cec965226
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433580
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-09 11:05:59 -07:00
asiva 5a95bd8b2c Add mcp server instantiation to the list of commands parsed by the VM.
TEST=ci

Change-Id: I080dd6f8b1d864d35689701207d282447aaf879f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433560
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-06-09 10:51:49 -07:00
Alexander Aprelev 4715ebd181 [vm/shared] Update mutator count as entering/exiting mutator thread.
Running dart code on mutator thread outside of isolate still should follow limits on number of concurrent mutators in the vm.
Also this fixes inconsistency when entering isolate group as mutator, where original worker was marked as blocked while thread was actually running dart code. That inconsitency showed up as sporadic crash on isolate_group_shared_init_test with increased number of spawned isolates.

TEST=isolate_group_shared_init_test
BUG=https://github.com/dart-lang/sdk/issues/60877

Change-Id: I8917be903bb5517940dad3e5dab143d5ed5fdf79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-09 10:34:40 -07:00
Ivan Inozemtsev 15c58a889f Add static variants of Dart engine library and update samples
Fixes https://github.com/dart-lang/sdk/issues/60799

Change-Id: I16a8dd2c854ed6915f14e1b71547879f50f2de0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432920
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-06-06 04:00:45 -07:00
Alexander Aprelev ef4e39a6ef [vm/shared] Ensure exclusive execution of shared field initialization.
Add a mutex to guard execution of vm:shared field initialization.

TEST=isolate_group_shared_init_test
BUG=dartbug.com/60699

Change-Id: If544351fc26bfcc7fb9703954efe785989d488bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431742
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-06-05 14:12:33 -07:00
Derek Xu c9c8929099 [package:vm_service] Add kTimerSignificantlyOverdue field to EventKind
I overlooked making this additon earlier. This CL also prepares
`package:vm_service 15.0.2` to be published.

TEST=CI

Change-Id: I4d28d87c027d27c4e532e5608f57b62eaa290e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433082
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-06-05 07:34:51 -07:00
Ryan Macnak bc17496b00 [vm] Fix Google3 ClangTidy warnings.
TEST=presubmit
Change-Id: Ifa4e77cc4548729526a90683ee163c68517e87ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433001
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-04 15:14:15 -07:00
Ryan Macnak 87575b2578 [vm] Remove --trace_optimized_ic_calls.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54377
Change-Id: Ibd3b2d05de241dffe3fa99b5d3a54cd20e0c4fdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433041
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-06-04 13:21:22 -07:00
Ryan Macnak caf311f681 [vm, compiler] Fix incorrect write barrier eliminiation after catch control flow.
Write barrier elimination applies when there is no potential Dart call between a StoreFieldInstr and an AllocateObjectInstr. But the control flow between all potentially throwing instructions in a try block and the corresponding catch block is not explicitly repreresented in the flow graph, so the writer barrier elimination pass needs to handle catch entries specially.

TEST=vm/dart/write_barrier_catch_entry_test
Bug: https://github.com/dart-lang/sdk/issues/60836
Change-Id: I96d5999433320e87da095f85e4a7438bcf5e134f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432880
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-03 17:22:00 -07:00
Ryan Macnak 13779dea53 [vm] Give the native call wrappers C linkage.
This avoids undefined behavior.

Cf. 18aa7d3678

TEST=ci
Change-Id: I2dd82517177ee812b3cd3ae4b1c748de129ec665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432720
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-03 10:36:23 -07:00
Tess Strickland 5c1f5cadb2 [build] Re-add targets used by Flutter.
TEST=ci

Cq-Include-Trybots: luci.dart.try:flutter-linux-try
Change-Id: Ifd8412fdc74095ffb027e80c8217ce1b5804a607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432702
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-06-03 09:46:43 -07:00
Alexander Markov 5e15e6f168 [gardening] Remove deleted test from stress_test_list.json
Follow-up to https://dart-review.googlesource.com/c/sdk/+/431360.

Change-Id: I2722e116b720906c3d75c65caf13b7085d17650b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432721
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-03 08:46:12 -07:00
Tess Strickland 4689b49490 [vm] Generate __eh_frame section in non-MacOS Mach-O snapshots.
Factor out the .eh_frame section content generation from ElfWriter,
putting in as a static method in Dwarf instead.

Create a __eh_frame section in the __TEXT section of non-MacOS Mach-O
snapshots with the same information as .eh_frame in ELF snapshots.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I4e123f586e59e1263385c838b755c1575a6330eb
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431600
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-03 05:56:59 -07:00
Tess Strickland f7699740cc [vm] Allow manual loading of Mach-O dynamic library snapshots.
Adds a Mach-O loader, similar to the existing ELF loader, that
can be used on platforms that do not support loading Mach-O dynamic
libraries via dlopen().

Other changes:

* Renames the --force-load-elf-from-memory command line argument
  to --force-load-from-memory.
* Use CPU_TYPE_ANY and CPU_SUBTYPE_ANY for architectures that do
  not have specific constants in <mach/machine.h> (e.g., RISCV),
  as the snapshot header check after loading also catches architecture
  mismatches.
* Emit the unwinding information at the end of the text segment
  for Windows Mach-O snapshots as is done for ELF ones.

TEST=vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I34a2a334f47d18d5c4f4a712956e71fd0ac94024
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430100
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-03 05:56:59 -07:00
Ryan Macnak 03301c9bfb [vm] Support assembly output for Windows.
The resulting DLL lacks debugging information / PDB.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60812
Bug: https://github.com/dart-lang/sdk/issues/60813
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try
Change-Id: I305bad0081ec24f27249ad9b75ff8d32fa9c4893
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 12:12:04 -07:00
Ryan Macnak 56636971dc [test_runner] Remove nnbd mode options.
In particular, this means the VM tests stop getting invoked with the now-invalid --sound-null-safety flag.

Change-Id: Ia8f5a59e0bf1fd7094508fdc4bb146ebf3034148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431360
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 10:59:31 -07:00
Alexander Aprelev 65d0d8581a [vm/shared] Move forward_table from Isolate to Thread.
Having forwarding tables on the Thread allows for those tables to be used in dart mutator thread running in IsolateGroup-shared context. On 32-bit platforms(arm) the forwarding tables are used during [SendPort.send] message verification.

Fixes https://github.com/dart-lang/sdk/issues/60817
TEST=isolate_group_shared_send_test

Change-Id: I58b33c14026584330b594776e812fe1d48bc2fd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431942
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-02 10:04:39 -07:00
Ryan Macnak 2565128cb0 [infra] Shard Mac AOT builders.
Use a combination of gen_snapshot's new ability to generate dylibs directly and the copy of llvm in buildtools to avoid using XCode, which is not available in shards.

Add definitions for debug builders now that they can complete without timing out.

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-product-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try
Change-Id: I79924128f11aafab4cd74ea6e9ab5848c64557da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431700
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 08:21:35 -07:00
Alexander Markov c006202dc6 [vm,dyn_modules] Convert function type args to instance type args when allocating an object in constructor tear-off
TEST=tests/language/regress/regress60816_test.dart
Fixes https://github.com/dart-lang/sdk/issues/60816

Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try
Change-Id: Id4c9ae3dc14cf680ba5f04d54d019ebe589ad96d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432100
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-02 07:30:58 -07:00
Ryan Macnak ebef427bc5 [vm] Remove dead VerifyCanonicalVisitor.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47378
Change-Id: Icd6debb309e2fd185330b089464f8934f1550190
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431680
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-28 11:23:12 -07:00
asiva 2ecc1ee8e8 Close open file descriptors that are not needed during process spawn or exec.
TEST=ci

Change-Id: I8ee94b4f54bcb858646739cc6e9add333a25a724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430841
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-05-28 10:28:20 -07:00
Ryan Macnak b061f911f9 [vm] Fix dynamic module build.
Broken by 18aa7d3678.

TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try
Change-Id: If6a11d4f541012c0503d82b4e26592ef0b810208
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431560
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
2025-05-28 06:43:47 -07:00
Ryan Macnak 786b6c5612 [dartfuzz] Extend VM flag fuzzing to dartfuzz and iso-stress.
Extend fuzzing to run dart2wasm.

Increase flag fuzzing timeout to equal generated program fuzzing timeout.

Adjust dartfuzz_test and iso-stress to use relative paths for ease of copy-pasting commands for reproduction.

Cq-Include-Trybots: luci.dart.try:iso-stress-linux-arm64-try,iso-stress-linux-x64-try
Bug: https://github.com/dart-lang/sdk/issues/60804
Bug: https://github.com/dart-lang/sdk/issues/60805
Change-Id: I6898f30b710f26f2c624726f7affee3187804334
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430280
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-27 13:22:18 -07:00
Ryan Macnak b916392008 [vm] Move handle check after barrier in CompileFunction runtime entry.
Remove redundant AOT runtime guard against compilation.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/53718
Change-Id: I1f1b5b0f01cfa08c13b3d3b7695297fac02c9cce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431300
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-27 10:58:19 -07:00
Ryan Macnak 18aa7d3678 [vm] Refactor runtime entries.
- Reduce header surface area.
- Remove runtime_entry_<arch>.cc, which no longer include code generation.
- Fix signature of DLRT_Enter/ExitSafepoint.
- Give non-leaf runtime functions C linkage, as C++ does not have a defined ABI.

TEST=ci
Change-Id: I21e21a50ad9e4f9b32b1204d755bfa69a2ae9b17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430981
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-27 10:46:24 -07:00
Tess Strickland 6b53073eae Reland "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This is a reland of commit 38ef28a058

Fixes:

* Fix comparisons in ASSERT_EQUAL statements on 32-bit architectures.
* Take simulated architectures into account when deciding whether
  to use dlopen() for native shared object formats.
* Fix struct/field name collision for GCC.
* Use CPU_TYPE_ANY/CPU_SUBTYPE_ANY for architectures that do not
  have more specific cpu_type_t/cpu_subtype_t constants defined.

Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles
     ci on trybots that failed on the original CL

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try
Change-Id: Iaffea0ddc6173100c8b5b2a9fe46c45f4f611a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431240
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-27 06:30:20 -07:00
Tess Strickland 38ea3a8f5e Revert "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This reverts commit 38ef28a058.

Reason for revert: Breaks build on debug mode 32-bit arches,
                   release mode simarm_x64

Issue: https://github.com/dart-lang/sdk/issues/60307
Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/60307
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iff2ab4c84a513a184784129f456bd357ae8e3a67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431220
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-05-27 01:05:48 -07:00
Tess Strickland 38ef28a058 [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
This is the initial framework for creating snapshots as Mach-O dynamic
libraries. Note that this framework is not 100% feature complete
compared to generating Mach-O snapshots via assembly. In particular,
the directly-compiled Mach-O dylib does not yet contain compact
unwinding information.

Other changes:

* Adds UuidCommand to the native_stack_traces package's Mach-O reader,
  which now appropriately returns the UUID as the build ID for Mach-O
  shared objects.

* Adds Utils::Basename(path) for portably retrieving the basename
  from a path. (Returns nullptr for all arguments where it is not
  currently implemented on Fuchsia or Windows.)

* Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
  as that interferes with uses of the namespaced Mach-O definitions
  in platform/mach_o.h.

* Only attempt to dlopen() a snapshot if ELF is the native format
  for the host platform or the snapshot is not an ELF shared object.
  If dlopen() is used, report the error message if it fails rather
  than attempting to manually load the snapshot as an ELF shared object.

* Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
  dynamic libraries.

* Remove the detection of reverse-endian Mach-O magic numbers in
  DartUtils::SniffForMagicNumber(), since all our Mach-O related code
  assumes host-endian Mach-O files and so there's no point other than
  to give a slightly better error message when failing.

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-26 08:52:26 -07:00
Chloe Stefantsova 6fa858cfe8 Enable 'getter-setter-error' flag in 3.9
TEST=existing

Change-Id: Ic4a5735adda7cf8ef1565b9356ca277d9b62b064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-26 08:08:31 -07:00
Roy c9ba43db45 [vm] Adding static_field_offset to Field objects.
This adds the offset of static fields within their field table.

TEST=vm/dart/analyze_snapshot_binary_test

Change-Id: I90b13760fa3203ca2e3c5611e3fd890a74c97728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-23 12:45:41 -07:00
Alexander Aprelev 6497b412e2 [vm/shared] Ensure dart mutator thread stack is walked during gc.
Fix asynchronous aspect of the test.

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

Change-Id: Ife311d5663665e7fa6e8dd3977fc31f5ed22cc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430580
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2025-05-23 07:23:22 -07:00
Tess Strickland 9a2234461a [vm] Use a non-native definition of the runtime function structure.
Attempting to use the native definition when available causes problems
when cross-compiling, and the original attempts to avoid this broke in
subtle ways. Instead, just make a non-native definition that mimics
the native definition and use that with reinterpret_casts when sending
uses of the non-native definition to Windows API calls that expect
a value of the native definition.

TEST=windows ci

Fixes: https://github.com/dart-lang/sdk/issues/60771
Change-Id: I347fcaf8cccd809a3d8e6f041cc7e360b0b8226e
Cq-Include-Trybots: luci.dart.try:vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-arm64-try,vm-win-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,pkg-win-release-try,pkg-win-release-arm64-try,dart-sdk-win-try,dart-sdk-win-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430400
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-23 06:19:16 -07:00
Alexander Aprelev 3718baa446 [ffi/isolate_group_shared] Keep isolate alive for isolate group shared callback.
To fix encountered tsan race(patchset 3)  split Metadata into MetadataEntry as discussed on https://github.com/dart-lang/sdk/issues/60728#event-17760701621

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

Change-Id: I9308d6fb6a9b819221f7fe4668aefb3a578fe8a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430122
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-22 09:02:01 -07:00
Alexander Aprelev 56819231be [vm/shared] Fix LoadStaticField calls initializer behavior.
With b32e5e5a91 under --experimental_shared_data flag, `LoadStaticField` calls initializer stub to confirm presence of isolate when accessing non-shared static fields. This breaks the role that `calls_initializer` attribute/parameter used to play where it was specifically describing neccessity to call initializer, which is important in how `LoadStaticField` instruction is used in static field setters - it should not attempt to call initialzer.

This CL fixes the problem by renaming current `calls_initializer` `LoadStaticFieldInstr` attribute to `does_slow_checks`, and "adding" separate `calls_initializer` parameter to the instruction to signify specifically whether initializer has to be called.

TEST=ci

Change-Id: Ib81424864c98d889fb6dbb9dd15dac9a39c530f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429062
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-22 09:02:01 -07:00
Alexander Markov f7790bb65b [gardening] Fix gcc and msvc builds
Fix the following compile-time errors:

C:\b\s\w\ir\cache\builder\sdk\runtime\vm\elf.cc(601) : error C2220: the following warning is treated as an error
C:\b\s\w\ir\cache\builder\sdk\runtime\vm\elf.cc(601) : warning C4715: 'dart::ElfSymbolTable::ElfSymbolType': not all control paths return a value

../../runtime/vm/elf.cc: In static member function ‘static intptr_t dart::ElfSymbolTable::ElfSymbolType(dart::SharedObjectWriter::SymbolData::Type)’:
../../runtime/vm/elf.cc:601:3: error: control reaches end of non-void function [-Werror=return-type]
  601 |   }
      |   ^

TEST=ci

Change-Id: Ib06339405b406ea4a6f6d395a04a16573d92c704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430321
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-22 07:50:49 -07:00
Martin Kustermann bbb847eb71 [vm] Allow running analyze_snapshot tool on MacOS
This allows development of the `analyze_snapshot` tool on a MacBook.

TEST=vm/dart/analyze_snapshot_binary_test

Change-Id: I3b1ec108bbff5db2f1e69dc98d65ddeaf11e5230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429941
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-21 02:53:49 -07:00
Tess Strickland 84a1b114cd [vm] Add base class for shared object writers.
This CL pulls out the refactorings used to support the new MachOWriter
in a followup CL to allow them to be reviewed separately.

Rename Elf -> ElfWriter. Also rename model classes used by ElfWriter
for concepts that exist both in ELF and Mach-O to ElfX. For example,
the old ELF-specific SymbolTable is renamed to ElfSymbolTable.

Adds SharedObjectWriter to serve as a base class for both ElfWriter
and the upcoming MachOWriter.

Adds a new AbstractWriteStream that serves as a common superclass
of both BaseWriteStream and SharedObjectWriter::WriteStream and
allows the creation of fully delegating WriteStreams that do not
maintain a local buffer.

Abstract the old Elf::SymbolData class into
SharedObjectWriter::SymbolData, which stores an enum value as the type
of the symbol instead of storing the ELF encoding of the type.

Rename the DwarfElfStream (which actually wasn't ELF specific, as
all the ELF-specific DWARF information is handled by ElfWriter) to
DwarfSharedObjectStream and put it in a separate header file.

Rename Image::compiled_to_elf() to Image::compiled_to_shared_object()
and add a separate Image::compiled_to_elf() that checks for the ELF
magic value at the DSO base. Also add Image::shared_object_start()
and Image::build_id_start() to return pointers to the DSO base and
the build ID note, respectively.

Refactor Image::build_id() and Image::build_id_length() to check
compiled_for_elf() prior to decoding the data pointed to by
build_id_start() as an ELF note section.

Create an AOTSnapshotType enum to specific the snapshot writer to use
in CreateAppAOTSnapshot instead of using an as_elf boolean.

TEST=refactorings, so existing tests on ci

Change-Id: Ia3ab37a4dff93b6e00390b123753be5a51fbdaaa
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421301
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-21 01:36:22 -07:00
Vyacheslav Egorov 9ff77fd414 [vm] Mark _FutureListener.handleValue invisible
Instead of hiding it by skipping it in AsyncAwareStackUnwinder.

Skipping it manually meant that we don't expand and see
functions which are inlined into handleValue in the
stacktrace which might be undesirable and makes
stacktraces unnecessarily sensitive to inlining.

Filtering based on visibility happens after inlined
frame expansion which makes stack trace more stable.

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

TEST=vm/dart/awaiter_stacks/*

CoreLibraryReviewExempt: pragma only change
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try
Change-Id: Ie6e0ad65285dd1d6f77e27e7488e8d46d30c176c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-05-20 11:12:02 -07:00
Ben Konyi a067d75f8f [ Observatory ] Remove legacy Observatory VM service tests
Clean up test_runner and the test matrix to remove all references to
the service test suite and delete the tests.

Work towards https://github.com/dart-lang/sdk/issues/50233

TEST=N/A

Change-Id: Ie3adb0d007d71f9a223843d739e57cbdb5be0d59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429140
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
2025-05-20 10:33:53 -07:00
Ryan Macnak 0a6fa7ac03 [vm] Fix --gc_at_throw, etc for isolate group callbacks.
TEST=ffi/isolate_group_shared_callback_test
Change-Id: Ib4c241d59a36544495c264c51848753a0bc22bf4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-19 14:07:50 -07:00
Ryan Macnak 3d32a60b55 [vm] Fix race between VM shutdown and in-flight API call.
TEST=vm/cc/DartAPI_TimelineEvents_Loop
Change-Id: I4175fb50991f8bf842437507cc4bf18fc926889d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428622
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-19 10:44:33 -07:00
Ryan Macnak ecfce50b5d [infra] Remove IA32 from dartfuzz, GCC and MSVC testing.
Bug: https://github.com/dart-lang/sdk/issues/49969
Cq-Include-Trybots: luci.dart.try:vm-gcc-linux-try,vm-msvc-windows-try
Change-Id: Idf24c48fee5fc5bb757b49bd8941573822496090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429223
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-05-19 10:28:00 -07:00
Chloe Stefantsova 1f26ddfee2 [ffi] Account for position variance in converting native types
This CL introduces variance-dependent treatment of the `Handle` native
type when converting native types to Dart types. Since `Handle` can
represent any object, it should match any type. To achive that in
cases when `Handle` appears as the subtype in the subtype checks, it's
converted to `Never` in covariant positions and to `Object?` in
covariant ones.

TEST=existing

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

Change-Id: Ie16a210491ada80d21f4d0f1c0fa3b3804881ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-15 22:53:41 -07:00
Alexander Aprelev e6784e0580 [gardening] Fix temp variable intptr_t type to match offset uint32_t.
Follow-up to 52dc7979c6
Fixes failed build https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/vm-aot-linux-debug-simarm_x64/4968/overview

TEST=ci

Change-Id: Ifea13d795638e2ba7b6a1e6d50f3e91f012945cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428841
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-05-15 09:47:40 -07:00
Ryan Macnak 52dc7979c6 [vm] Fix truncation of slot offsets during heap snapshots.
Truncation caused sorting to place the field at offset 2^16 before the field at offset 8, etc.

TEST=iso-stress
Bug: https://github.com/dart-lang/sdk/issues/60717
Change-Id: Ie75c9fa74b830bc08b386533b16e8b01127b0f26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428565
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-15 09:02:20 -07:00
Alexander Markov 1f4707ae0c [vm,dyn_modules] Avoid static calls to bytecode functions from optimized JIT code
Static (direct) calls in the optimized JIT are performed through Code
objects without passing Function objects. This is not compatible with
bytecode interpreter calling conventions, so optimized JIT should
avoid static calls to bytecode functions.

This change disables devirtualized and guarded static calls to
functions declared in bytecode.

TEST=ci

Closes https://github.com/dart-lang/sdk/issues/60716

Change-Id: I95e4fa0706f376355f4fa7aea7fddf44f303e0a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428340
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 07:11:23 -07:00
Alexander Markov e0673fec9c [vm,dyn_modules] Fix printing of interpreter entry and exit frames
TEST=ci

Change-Id: I49139dd3f03df74e3a6a94f7a4366b9d4dfdc0fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428580
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 06:46:16 -07:00
Alexander Markov 081211fd4d [vm,dyn_modules] Fix parameter names for closures declared in bytecode
TEST=existing (e.g. language/vm/regress_32502_test)

Change-Id: I2ea118aa34046a52c7c0d648e60f0d928c7702f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 06:46:11 -07:00
Derek Xu 3dc9d8dcf9 [VM/Service] Add getQueuedMicrotasks RPC
TEST=pkg/vm_service/test/get_queued_microtasks_rpc_test

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes within
sdk/lib/vmservice/.
Change-Id: Ie5488f498e4d0f3d201e3f31423fd5029b74a726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425160
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-13 14:29:37 -07:00
Derek Xu 0ead16d05b [VM] Make it so that --profile-microtasks is processed by the code in both runtime/bin/main_options.h and runtime/vm/flags.h
TEST=pkg/vm_service/test/timeline_events_for_completed_microtasks_test

Change-Id: Ia544cabc7bfe6e322955d16d3078cab461b803ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425100
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-13 14:29:37 -07:00