Commit Graph

16000 Commits

Author SHA1 Message Date
Vyacheslav Egorov 593da80b8b [vm] Switch reloadSources to object parameters
Currently it using legacy stringified parameters which
makes it hard to pass complex structured data to it.

TEST=ci

CoreLibraryReviewExempt: vm-service implementation changes no affecting public corelib APIs.
Change-Id: I1291e0a2971ad51fef4bc4a2d53e7ec0a76b3131
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437221
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-06-27 06:53:41 -07:00
Alexander Markov d2923b2818 [vm,dyn_modules] Do not share bytecode between field getter and field initializer
Profiler does not allow 2 distinct Bytecode objects to use the same
range of bytecode, as it needs to map PC to a Bytecode unambiguously.

So this change removes reuse of the field initializer bytecodes for
a field getter (in case of const fields).

TEST=pkg/vm_service/test/get_perfetto_cpu_samples_rpc_test

Change-Id: I758286f6f4fcfe2e2169bbc19ae233594e263522
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436740
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-26 08:16:39 -07:00
Alexander Markov 1164ea7f7e [vm,dyn_modules] Support collecting source positions for a script declared in bytecode
TEST=pkg/vm_service/

Change-Id: If9111373f4ddf08bded2a23ab4bb130f1f6ad4a4
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436680
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-26 08:08:20 -07:00
Ryan Macnak a3bb94210c [vm] Fix stack traces from ASSERT/FATAL.
TEST=vm/dart/symbolized_crash_test
Bug: https://github.com/dart-lang/sdk/issues/60987
Cq-Include-Trybots: luci.dart.try:vm-linux-release-arm64-try,vm-aot-linux-release-arm64-try
Change-Id: I6e1859a99079087161d5af8a10d1728277740218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436760
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-06-25 09:44:11 -07:00
Alexander Aprelev 54d80f6341 [gardening] Add optional typename to fix flutter build.
Follow-up to https://dart.googlesource.com/sdk/+/74846b96c394e78c37060d8be7c350fa8c1b6a6d

TEST=flutter ci

Change-Id: I31cdfe067d65f7cc39912c58ab62e0f9a8157e32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436640
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-24 09:38:34 -07:00
Alexander Markov 05c2f3b0b1 [vm,dyn_modules] Hook interpreter to the standalone VM
When dynamic modules are enabled, standalone VM can now run bytecode
binaries directly. Also, if --interpreter flag is specified, Dart
source is compiled to bytecode and interpreter is used to run it.

This will allow us to test VM service capabilities including
debugging and hot reload against the interpreter.

TEST=manual

Change-Id: Ibb5a67f4844485c4ed90b8a7568dc42fa552fcac
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436421
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-24 05:59:21 -07:00
Alexander Aprelev 74846b96c3 [vm] Introduce ReentrantMonitor.
Existing Monitor is not reentrable, doesn't support acquiring it if it is already acquired by this thread.

TEST=ReentrantMonitorAllowsReentrance

Change-Id: Id74479388a99ca907bca6e379c3a7e08191e841b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436542
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-23 21:08:19 -07:00
Ryan Macnak 69f76f1086 [vm] Only include predefined symbols C strings in gen_snapshot.
Saves about 29k of binary size and kNumPredefinedSymbols map lookups at startup.

TEST=ci
Change-Id: I186c17a839ebfc6a800a35f08ca2f2c0776984ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433862
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-23 17:00:52 -07:00
Ryan Macnak 67c6da2beb [vm, gc] Shorten extent of the freelist lock during scavenge.
Helps break a cycle for https://dart-review.googlesource.com/c/sdk/+/435241

TEST=ci
Change-Id: I98994a3d2f5e11f0f9bb20e38d3c2b9fa9e48d08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436521
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-23 16:31:17 -07:00
Alexander Aprelev cabc717e76 [vm/shared] Ensure shared initial field table is used with shared fields.
Fixes https://github.com/flutter/flutter/issues/170038
TEST=shared_static_final_test

Change-Id: Ia242b5d9c661782e5a6018ba96211a75cc47c1a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436200
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-23 14:17:40 -07:00
Alexander Markov 36087ec8f7 [vm] Remove unused kernel bytes in case of compile-time errors
In case of compile-time errors kernel service has been serializing kernel AST anyway and has been passing kernel bytes to the VM.
VM does not use those kernel bytes except a few unit tests.

This change removes the unnecessary kernel serialization and freeing
of kernel bytes and cleans up unit tests.

TEST=ci

Change-Id: Ic2464e50f56227bc998df53dd2b594c1abcf9468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436360
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-23 10:01:09 -07:00
Alexander Markov e0c561cf13 [dyn_modules] Support interpreted frames in the profiler
TEST=pkg/vm_service/test

Change-Id: Iba7b8e78feeff888eb0657a6e3790602a8b3d7ca
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435240
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-23 06:45:22 -07:00
Vyacheslav Egorov c111f693c7 [vm] Fix freelist interaction with dual mapping
Freelist implementation was trying to mark pages executable (RX)
which does not respect possibility that it is working with RW mapping
which can't be directly marked as executable. It needed to use RO
permission instead if dual mapping is enabled.

This CL consolidates all code mentioning RX permission in one place:
VirtualMemory::WriteProtectCode so that we avoid this mistake in the future.

R=kustermann@google.com
TEST=tested by doing large reloads which cause more churn in code space

Change-Id: If99692cac3ce3ff54b907e4c43d7f26bae7439ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435860
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-06-20 03:29:19 -07:00
Ryan Macnak af7397b1f9 [vm] Disable simulator when we detect we can JIT.
TEST=local Flutter engine build
Bug: https://github.com/flutter/flutter/issues/163984
Change-Id: Id16e75dada9571636b1ee3ef3988825beb67707b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435640
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-18 15:10:59 -07:00
Ryan Macnak 7973eacdd0 [vm] Rename USING_SIMULATOR to DART_INCLUDE_SIMULATOR.
We now have a mode where the simulator is available but not always used.

TEST=ci
Change-Id: If271f334150e2a125a014a4baa2e03d726300d35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435562
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-18 13:07:22 -07:00
Ryan Macnak f5eaefd5b6 [vm] Runtime option to not use the simulator for simarm64_arm64.
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-ffi-mac-debug-simarm64_arm64-try,vm-ffi-mac-release-simarm64_arm64-try
Change-Id: Id98d337ce16ba4b434b5c69016f01eec9b85f9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434982
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-18 10:45:05 -07:00
Ryan Macnak 88df3fe713 [vm] Fix host-mac target-linux build.
TEST=ci
Cq-Include-Trybots: luci.dart.try:dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try
Change-Id: I8d827b5ee0ef9a0c25c9d09c2ea989dbb18fa2ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435443
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-18 10:09:35 -07:00
Vyacheslav Egorov dc0567c02c [vm] Rework RX workarounds
* Disable RX workarounds on simulators: they cause host OS to crash;
* Remove Mac OS test for RX workarounds: it can cause host OS to crash;
* Remove old outdated code paths for OS versions that don't
need workarounds.
* Add code which detects whether workaround worked or not by intercepting EXC_BAD_ACCESS.
* Avoid using vm_remap in FFI callbacks when JITing, it does not work.
Instead restore old logic which manually copies page content, but adjust
FFI callbacks implementation to respect possible dual mapping.

This reworks changes done in commit
d194fcecaf after additional testing on a
wider range of hardware.

TEST=manually on physical devices and simulators

Change-Id: I339379386183c532fec25e88fa436ff0b970c2cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435120
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-06-18 06:09:14 -07:00
Tess Strickland 12994040e0 [vm] Add compact unwinding info to ARM64 Mach-O snapshots.
For other architectures, a __eh_frame section is generated like
for non-MacOS platforms.

TEST=vm/dart/unwinding_information_test

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I46c6ff1357c222f73a129e1becd9b12b3fb6ef9c
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-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433020
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-17 06:22:15 -07:00
Tess Strickland b85d7622f5 [vm] Add N_OSO symbolic debugging symbol to unstripped Mach-O symtabs.
Adding this allows dsymutil to parse a DebugMap from the Mach-O file,
which allows it to then create an appropriate .dSYM package for the
dylib if desired.

TEST=vm/dart/unobfuscated_static_symbols_test

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-release-arm64-try,vm-aot-linux-release-simarm_x64-try
Bug: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I723fde90b73d74e06840418c693858f5729cea58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434381
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-17 02:40:40 -07:00
Ryan Macnak ab4f9351b1 Rename vm_platform_strong.dill to vm_platform.dill.
The name has always been annoying because it did not add strong typing. And now there aren't variants of the VM platform to distinguish.

Leave a copy at the old name to not immediately break illegal uses.

TEST=ci
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,flutter-frontend-try,flutter-linux-try
Change-Id: Ie76fa7f16940aa1ba8d582eb5197f0ae55dc8938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429828
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-16 18:33:38 -07:00
Ryan Macnak fd3c238973 [vm] Shrink object store name metadata.
Saves 18k.

TEST=ci
Change-Id: Ie30eee4589f124e705bf922e5b6f8f8cedfdab25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434240
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-06-16 10:20:33 -07:00
Alexander Markov a0ffef2ebe [vm] Fix ia32 build
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/433940.

TEST=tools/build.py -a ia32 -m release runtime

Cq-Include-Trybots: luci.dart.try:vm-linux-debug-ia32-try,vm-linux-release-ia32-try
Change-Id: Ic19d807330ad243b9896728abd3e322965f0589c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434524
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-13 07:28:59 -07:00
Vyacheslav Egorov d194fcecaf [vm] Use dual mapping of code pages on certain OS versions
Heap references always point into R/RW mapping (this simplifies the
marker) and entry points are retargeted into RX.

To simplify implementation we assume that there are no image pages
created - which means we can always go from Instructions to the start of
the page and check where it is dual mapped to.

TEST=vm/dart/macos_dual_mapping_smoke_test and manually on physical
device

Change-Id: Idbe02b7b695b3c048072cf92f7d062f5ab6e1beb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433940
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-06-12 20:46:54 -07:00
Ben Konyi 60b217ff2d [ Observatory ] Remove Observatory from the Dart VM
Also cleans up some references to Observatory in various places.

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

TEST=N/A
CoreLibraryReviewExempt: Not modifying public core libraries.
Change-Id: I1f36b4e6f1fd9a59a579d719aafa599906eedb3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429141
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-06-11 15:19:55 -07:00
Tess Strickland 14889cc06d [vm] Handle Windows unwinding records better in the Mach-O loader.
The Mach-O writer puts the unwinding records in a __unwind_info
section, so just find the appropriate section and use its contents
instead of forcing it to be at the end of the segment's memory space.

Create an overload of UnwindingRecordsPlatform::RegisterExecutableMemory
that takes a pointer to the start of the unwinding records for use by
the Mach-O loader.

Add __unwind_info for any executable segments that are not the text
segment as well.

Instead of testing host/target windows plus 64-bit arch, use the
defines provided by platform/unwinding_records.h in the Mach-O
writer and the ELF and Mach-O loaders.

TEST=ci on Windows trybots

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: Iee53c6725a681f44ac98ed9c9aecf1b75853ece5
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-gcc-linux-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/+/432960
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-11 04:43:24 -07:00
Ryan Macnak ad437479a3 [vm] Move some VM defines out of platform.
TEST=build
Bug: https://github.com/dart-lang/sdk/issues/32364
Change-Id: Icf0d8f69235ec0369cbe135f833a522a1269319f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433962
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-10 14:06:45 -07:00
Alexander Markov f9860f9db9 [dyn_modules] Add source positions to bytecode
dart2bytecode can optionally add source position information
(including line starts) to the generated bytecode
(when '--bytecode-options=source-positions' flag is specified).

If bytecode has source positions, they are now shown in stack traces
involving interpreter frames.

TEST=ci

Change-Id: I1ae3326bac21201040be32c712514e71e96f51e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433760
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-10 12:15:25 -07:00
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
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
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 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
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
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
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 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