Commit Graph

1323 Commits

Author SHA1 Message Date
Tony 08139af589 Add compact AOT patching support and related APIs
- Introduced Dart_SetObfuscationMap to restore obfuscation maps before AOT precompilation.
- Added Dart_AotPatchInstallOptions structure for AOT patch installation options.
- Implemented Dart_AotPatchingEnabled to check if compact AOT patching is supported.
- Created Dart_SetAotPatchKeyCallback for AES key resolution during AOT patch installation.
- Developed Dart_InstallAotPatch for validating and installing encrypted AOT patches.
- Added Dart_FreeAotPatchPayload to free memory allocated for patch payloads.
- Updated runtime_args.gni to include dart_enable_aot_patching flag.
- Added tests for AOT patching functionality and ensured exported symbols include new APIs.
- Refactored existing code to accommodate new AOT patching features and improve error handling.
2026-06-24 03:00:14 +08:00
Ryan Macnak 6c3cf9ea51 Roll Clang from a3f244e2d555 to deb6854eec93
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/clang-dart-sdk
Please CC dart-engprod@google.com,dart-vm-gardener@rotations.google.com,dart-vm-team@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Clang: https://bugs.fuchsia.dev/p/fuchsia/issues/list?q=component%3AToolchain
To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

TEST=ci
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try;luci.dart.try:dart-sdk-linux-arm64-try;luci.dart.try:dart-sdk-mac-try;luci.dart.try:dart-sdk-mac-arm64-try;luci.dart.try:dart-sdk-win-try;luci.dart.try:vm-asan-mac-release-arm64-try
Change-Id: Iddd7439c096af8c37076756330a067ccb7d10a35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510520
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-10 11:05:58 -07:00
Ryan Macnak 546bf07f7d [vm] Remove transitions for removing VM isolate.
TEST=ci
Change-Id: I65c315e9efc3cd7b8b47d2c167681986278644da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-06-02 10:28:10 -07:00
Alexander Aprelev 02b30d5275 [vm/shared] Implement Isolate pinToCurrentThread, isPinnedToCurrentThread.
TEST=threading_pinning_test

Change-Id: I9a80543a06dbf51c070fed5c0e64eeba247497de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497126
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-29 07:58:23 -07:00
Alexander Aprelev 488ba69e41 [vm/shared] Introduce isolate event loop handling dart api.
Implement api methods to create and shutdown isolates from IsolateGroup-bound callbacks (normally invoked from native code), run dart code on such isolates.
The rest of the api is not implemented yet.

TEST=tests/ffi/threading_test.dart
BUG=https://github.com/dart-lang/sdk/issues/62407
CoreLibraryReviewExempt: vm-only change to isolate library
Change-Id: I0271ead8ba011dfe9d7953769415d6a88a962854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486522
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-27 11:31:11 -07:00
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00
Ryan Macnak 94347fdf01 [vm] Don't use ApiError to represent errors during startup.
With the removal of the VM isolate and less bootstrapping being repeated in the AOT runtime, ApiError cannot be instantiated until after snapshot loading succeeds.

TEST=ci
Change-Id: I5be295e87e6d6351ada40d2837825b1f93672ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501262
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-12 08:41:20 -07:00
Alexander Markov 6195ea86bc [vm] Remove irregular type arguments parameter from factories
In the VM, factory constructors always had an extra "type arguments"
parameter, even if class is not generic. Factory constructor bodies
were using class type parameters instead of function type parameters.

This results in extra code when calling non-generic factories
which is slightly inefficient in terms of code size and performance.
Also, it creates an additional complexity throughout the system as
factories should be special cased in many places.

This change removes artificial "type arguments" parameter, treating
factory constructors basically as static methods. This matches
kernel AST representation.

TEST=ci

Change-Id: I957583cb2ce9a3c408699880a04036e06b01dd31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501762
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-12 06:11:15 -07:00
Ryan Macnak 55f91b69a5 [vm] Remove unneeded HandleScope immediately after StackZone.
There's no point in unwinding the zone's scoped handle blocks just before deleting the entire zone.

TEST=ci
Change-Id: I364c717bffd16f727d6f2427a7b9693a83d74c13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-29 15:36:54 -07:00
Ryan Macnak e860a9b0fa [vm, ffi] Emit the FFI callback stub as a raw blob and place it in the Fuchsia package.
Any blob in the package can be loaded as an executable VMO.

TEST=child CL
Bug: https://dartbug.com/52579
Change-Id: I61f7a84453da4da4733c5a70d4d19f0a6652581b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496661
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-20 11:31:19 -07:00
Ryan Macnak e98e6a1198 [vm] Per isolate group roots accessed via TLS.
Remove special case for null in message snapshots; snapshots are sometimes read or written with no current isolate group.

Currently still all copies pointing into the VM isolate.

TEST=ci
Change-Id: I4d2e35a01880885d4e92e1c623c0f39a35e06065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493866
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-08 15:26:06 -07:00
Alexander Aprelev 8999b65531 [vm/cleanup] Remove unused start_callback, enable_vm_service, paused_for_messages.
TEST=ci

Change-Id: I101a355de9b0c2b36c8977c3af962a3e283a72d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493862
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-04-08 10:05:40 -07:00
Ryan Macnak 1cea4f514e [vm] Gather global variables pointing into the VM isolate.
TEST=ci
Change-Id: Ia2110904f4b88aa13b06210902c5a673d9be475c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491705
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-31 12:55:51 -07:00
Ryan Macnak 0a30a91dd7 [vm] Update ApiNativeScope to C11 thread locals.
TEST=ci
Change-Id: Iec314b13981c0cd11f6dd28c2e881281c3a10a8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490300
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-24 11:26:23 -07:00
Ryan Macnak e443b89f23 [vm] Update Irregexp to V8 commit 254cc758346f10be2a7e22e55d90d4defe9cad74.
Includes support for modifier spans and duplicate named capture groups.

Drops the flow graph implementation to ease maintenance.

TEST=corelib/regexp
Bug: https://github.com/dart-lang/sdk/issues/56573
Bug: https://github.com/dart-lang/sdk/issues/61337
Bug: https://github.com/dart-lang/sdk/issues/62349
Bug: https://github.com/dart-lang/sdk/issues/62708
Change-Id: I05640ba945a4fa5476e7ad463738f4f39d842c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 09:54:47 -08:00
Liam Appelbe 4679c040c6 [vm] Sync ffi callbacks can enter owned target isolate
Adds a new code path for NativeCallable.isolateLocal invocations. If
the current thread is not entered into any isolate, but owns the
target isolate, then it enters the target isolate, invokes, then exits
the isolate.

Fixes: https://github.com/dart-lang/sdk/issues/61623
TEST=tests/ffi/function_callbacks_isolate_ownership_test.dart
Change-Id: I401f185fadf7d2a55190dafd15387e1c418c67c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-02-05 01:29:23 -08:00
Slava Egorov 0fee95455c [vm] Cleanup Profiler lifecycle
Move away from setting command line flags and calling Cleanup or Init
to reinitialize the profiler. Split starting and stopping the profiler
into separate methods and keep only one-time initialization/cleanup
in Init and Cleanup methods. Create a separate method for reconfiguring
the profiler Profiler::SetConfig.

This removes data races which were plaguing older code and makes it
simpler to reason about.

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

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I679aa0a8724e39624e76abfad6814fe06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472862
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-20 05:58:38 -08:00
Alexander Aprelev eb75c53d95 [vm/shared] Perform deeply-immutable initialization runtime check.
When an initial value is assigned into a class tagged as deeply-immutable, perform runtime check of that value. This is needed to support proper initialization of the closures as part of deeply-immutable classes.

BUG=https://github.com/dart-lang/sdk/issues/61962
TEST=run_isolate_group_run_test

Change-Id: I550746c0d22ca06ffb89959e8384cc9e6d28d590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-14 08:42:22 -08:00
Ryan Macnak 1d1527adf9 [vm] Report the current sanitizer in the compiler environment.
TEST=ci
Change-Id: I56585a1fdb1bb6b92eab706fd0a66f78888bc55d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464620
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-01 15:10:50 -08:00
Alexander Markov a37d042e68 [vm] Initial implementation of module snapshot reader
TEST=manual
Issue: https://github.com/dart-lang/sdk/issues/61635

Change-Id: I27f712d9687d45a09173b1018bc08812dd18658e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460580
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-11-21 06:42:16 -08:00
Slava Egorov 2282387a5b [vm] Fix profiler in PRODUCT mode.
* Make sure to start and stop profiler as mutator pauses and resumes.
* Allow profiler to call Code::GetPrologOffset without crashing
* Make sure to emit mapping with id 0 into the perfetto output if
  necessary, otherwise Perfetto UI can't load the profile

The last item seems a bug in Perfetto UI because 0 is supposed
to mean "value not set".

TEST=tested by running _perf_witness tests

Change-Id: I57578ba3efafd2aaf83c2c41b0e0b1f36a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459744
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-11-21 05:34:55 -08:00
Tess Strickland bc021bbc01 [vm] Output accompaning relocatable object for Mach-O snapshots.
In order to appropriately generate .dSYMs for a snapshot and allow
the strip tool to be used on the snapshot afterwards, add a mode that
not only outputs the snapshot (sans DWARF information) but also
an associated relocatable object file that contains the program's DWARF
information. That allows dsymutil to retrieve the DWARF information
from the relocatable object when run on the snapshot prior to stripping.

To specify that the relocatable object file should be output, use
the new --macho-object command line argument to gen_snapshot
to specify where the object file should be written.

This CL also adds an additional command line argument,
--macho-reduce-padding, which reduces the alignment used for segments
and the text/const sections in Mach-O outputs from 16KB to 64 bytes.
The larger padding is needed for some uses, like non-native loading
of Mach-O objects, but can be elided for other uses like Flutter builds.

TEST=vm/dart/use_dwarf_stack_traces_flag_test
     vm/dart/use_macho_reduce_padding_flag_test

Change-Id: I2bf4bacb70c41299b8b6fdb7635c2374acf7a07d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457420
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-11-19 07:45:52 -08:00
Ryan Macnak 2608c03824 [vm, gc] Avoid growth policy data race.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/61862
Change-Id: Icd16140999282b33fd9fbcceda901b82e4267c7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458421
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-10-29 15:46:01 -07:00
Vyacheslav Egorov 489f63a3bd [vm] Add NativeRuntime.streamTimelineTo
This API allows to programmatically generate timeline information 
including profiling samples if timeline format supports it.

This change also includes Perfetto timeline writer and profiler 
into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
has increased by 34352 bytes (0.7%).

This relands commit 553887bc56 with fixes
for Android builds.

TEST=vm/dart/stream_timeline_to_test

CoreLibraryReviewExempt: VM specific dart:developer API.
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm-try,vm-ffi-android-release-arm-try,vm-aot-android-release-arm64c-try
Change-Id: Ifb7c66982fe9d17d2f5c9acb163a94c56a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457301
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-10-24 04:34:01 -07:00
Artem Strygin 1dc1d36820 [vm] Add C Api for maps making.
Also allow to write simple conversions from std::map to "Dart Map" using
"c++ template magic".

R=alexmarkov@google.com

TEST=vm/cc/DartAPI_MapCreate

Bug: nothing
Change-Id: I11f3271df6880825bd417ee5532c56bacfa7278d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449280
Auto-Submit: Art Snake <art-snake@yandex-team.ru>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-09-18 06:56:21 -07:00
Artem Strygin 522e611c9d [vm] Add useful type getters to C API
This allows direct access to String, int, bool, double, Object types
instead of requiring name based lookups via Dart_LookupLibrary and
Dart_GetType.

R=dacoharkes@google.com

TEST=vm/cc/DartAPI_CoreTypes

Change-Id: I2aba317be3b4be21f37d61843a328a5146417e54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450160
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Art Snake <art-snake@yandex-team.ru>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-09-18 04:45:29 -07:00
Alexander Aprelev 2d7c7b039c [vm/usertag] Move usertags from Isolate to Thread.
This allows use of usertag api in isolategroup-bound context.

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

Change-Id: I73d5631ba6eddcc06965b982bc199221ac021cd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445967
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-08-25 14:43:41 -07:00
Alexander Aprelev 7e75e84ab4 [vm/shared] Guard deferred-libraries and environment access from being used in isolate group bound dart code.
TEST=ffi/run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/61323
BUG=https://github.com/dart-lang/sdk/issues/61324

Change-Id: Ib66ab85424adde58b0d4771f8785f8584c021c75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446000
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-08-19 13:35:51 -07:00
Alexander Markov c124f459ac [vm,test_runner] Run vm/* tests against interpreter
Introduce Dart_LoadLibraryFromBytecode to support loading unit test
libraries from bytecode.

TEST=ci

Change-Id: I7706fdb2acaf906f01f27f671e7193b9755efe0f
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/+/439080
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-07-08 06:49:34 -07:00
Alexander Aprelev bd0d029792 [vm/shared] Remove "single mutator" fastpath from RunWithStoppedMutators.
In presence of isolate-less mutators, the check for "single mutator"-scenario is not-trivial, acquiring active_mutator_count mutex results in circular mutex dependencies.

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

Change-Id: I5a12f9b8d4bc54042137012668ed1afee7c7739f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435241
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-06-30 10:31:57 -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
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 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 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
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
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
Alexander Aprelev fddb38ecab [vm/shared] Introduce IsolateGroup.runSync()
Allow dart code execution on mutator thread, do not require an isolate.

It moves some states that was kept on an isolate to thread or isolate group.

Bug: https://github.com/dart-lang/sdk/issues/54530
Bug: https://github.com/dart-lang/sdk/issues/56841

TEST=run_isolate_group_run_test

CoreLibraryReviewExempt: only internal library is being updated
Change-Id: I99df09e23954755387ea6230bfd166493d78e989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418503
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-05 14:52:07 -07:00
Ryan Macnak 077d7c9e89 [vm] Don't acquire safepoint locks while participating in reload safepoints.
Also disable lint intended to guard against use of std::thread::detach as it has too many false positives against dart::FinalizerEntry::detach.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60638
Change-Id: I19a0fde743fc5c5658a8dd96cecb5b074481a035
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425324
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-29 16:23:20 -07:00
Alexander Aprelev 69485e9b28 [vm] Move origin_id from isolate to isolate group.
Isolates in one group share same origin_id anyway, so it makes sense to store it on the group too.


Remove isolate's _originNumber from service api - isolate group should be used instead.

Based on feedback from https://dart-review.git.corp.google.com/c/sdk/+/418503/21/runtime/lib/isolate.cc#107

TEST=ci
Change-Id: Iab4b6393a042c9302e911a276a6afc6dab63e70d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424140
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-04-23 15:26:21 -07:00
Ryan Macnak 101516eb18 [vm] Allow reload during FFI and native calls.
TEST=many_isolates_blocked_* under reload stress testing
Bug: https://github.com/dart-lang/sdk/issues/60098
Change-Id: Ifb9838735e1846236e30820d7d957e3a51fd9e99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410960
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-03-12 12:33:50 -07:00
Liam Appelbe cb02b8726a [vm] Isolate ownership API
go/dart-isolate-ownership-api

Change-Id: Ia778a916de3fecec9f0aa1a5c8bc9fd7dd421267
Bug: https://github.com/dart-lang/native/issues/1908
TEST=runtime/vm/dart_api_impl_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2025-02-11 20:09:11 -08:00
Ryan Macnak 2a08770912 [vm] If waiting for an active mutator slot for too long, steal a slot from a thread at a native safepoint.
The thread whose slot was stolen will take the slow path attempting to exit its safepoint and wait to reacquire an active mutator slot.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54687
Change-Id: I49c4c12b38d38d7afa4df6b346c2a464f75ef6e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406404
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-02-10 09:38:42 -08:00
Tess Strickland 9098b79160 [vm] Verify entry point annotations in Dart_GetStaticMethodClosure.
Methods that are accessed via Dart_GetStaticMethodClosure should
be annotated as a getter entry point, so now the runtime verifies that.

See the discussion on https://github.com/flutter/engine/pull/57158
for additional context.

TEST=vm/cc/DartAPI_GetStaticMethodClosure

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-linux-release-x64-try,vm-appjit-linux-product-x64-try
Change-Id: I4b65ed4332dfabe662a364e7cde0ef0596beee54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400583
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-12-13 08:32:21 -08:00
Tess Strickland 9b06e26620 Reland "[vm] Enforce that entry points must be annotated by default."
This is a reland of commit cb9ecbc363

This reland only turns on the entry point verification flag by
default in AOT mode. After Flutter tests that use native access
in JIT mode have been appropriately updated, a followup CL will
turn this flag on by default in JIT mode as well.

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

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

Change-Id: I24919c32ab4760c7c5435c378879791086256f02
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try,flutter-linux-try,vm-linux-debug-x64-try,vm-linux-release-x64-try,vm-appjit-linux-product-x64-try
CoreLibraryReviewExempt: adding/editing vm-only pragma annotations
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391620
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-12-04 14:36:46 +00:00
Alexander Markov 2b899adb4c Revert "[vm] Enforce that entry points must be annotated by default."
This reverts commit cb9ecbc363.

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

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

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

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

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

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

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

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

Change-Id: Ibb3bf15632ab2958d8791b449af8651d47f871a5
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try
CoreLibraryReviewExempt: adding/editing vm-only pragma annotations
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363566
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2024-10-22 09:34:22 +00:00
Vyacheslav Egorov dfccc4a268 [vm/aot] Fix debug-info generation
The algorithm for ordering sections in `CreateProgramTable` permitted
skew between the order of sections in snapshot and corresponding
debug info. This skew can lead to inconsistencies in `.text` section
memory offset between two generated ELF files making debug info
invalid.

This skew was left unnoticed for a long time because executable
segment has a huge alignment requirement (64K) while the effect
of the skew was usually rather small and thus hidden by realignment.

This CL adds a strict verification pass (always enabled) which
guards against such skew in the future.

A better architecture would be to ditch parallel generation of
snapshot and corresponding ELF files altogether and other implement
splitting as a post processing path over generated ELF or
rely on external tooling. But this is a much bigger change
than I am willing to invest time into right now.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try
Change-Id: I0881783237faa6534eb3c076b6cae472bbdc7243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384742
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-11 12:51:23 +00:00
Alexander Markov 84fd647969 [vm] Refactor access to Integer value
Add methods to provide uniform access to values of Dart integers:

  Integer::Value()
  Integer::Value(IntegerPtr)

  Smi::Value()
  Smi::Value(SmiPtr)

  Mint::Value()
  Mint::Value(MintPtr)

Remove

  AsInt64Value()
  AsTruncatedInt64Value()
  AsTruncatedUint32Value()
  GetInt64Value(IntegerPtr)

Also, rename AsDoubleValue() to ToDouble() and
remove unused (FitsIntoSmi, AsValidInteger) and
value-based methods (IsZero, IsNegative).

TEST=ci

Change-Id: I28786ec3a14703574b7a192ead42eeefdbd09106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380586
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-19 21:46:26 +00:00