Commit Graph

668 Commits

Author SHA1 Message Date
Tony 57b27a7b44 Refactor Dart runtime to replace DART_DYNAMIC_MODULES with DART_BYTECODE_INTERPRETER
- Updated conditional compilation flags throughout the runtime codebase to transition from DART_DYNAMIC_MODULES to DART_BYTECODE_INTERPRETER.
- Adjusted logic in various files including object_graph_copy.cc, object_reload.cc, profiler.cc, and others to ensure compatibility with the new interpreter model.
- Ensured that all references to dynamic modules are replaced with bytecode interpreter checks, maintaining functionality for interpreted code execution.
- Modified stack frame handling and service-related code to align with the new interpreter architecture.
- Updated tests and service implementations to reflect the changes in the runtime environment.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-06-25 01:58:41 +08:00
Nourhan Hasan bd5ccf95d1 [vm/service]: Add OS::SafeReadMemory for macOS using mach_vm_read_overwrite
TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/try:vm-asan-mac-release-arm64-try,vm-dyn-mac-debug-arm64-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-mac-release-arm64-try
Change-Id: I1be990f3debb7e0b7102f54e8c5bec25252756d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507040
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-06-11 11:30:22 -07:00
Nourhan Hasan db905b9711 [vm/service]: Add OS::SafeReadMemory for Windows using ReadProcessMemory
TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/try:vm-asan-linux-release-x64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-arm64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-simarm-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-win-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try
Change-Id: I7afabe66211657139981e18d8b1a14c2081d3f5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506640
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-06-10 10:58:15 -07:00
Nourhan Hasan 80f770eb57 [vm/service]: Add _readNativeMemory RPC and OS::SafeReadMemory for safe native memory inspection
- Declare OS::SafeReadMemory in os.h
- Implement using pread64(/proc/self/mem) on Linux and Android
- Add _readNativeMemory VM Service RPC with pre-checks for null
  and address overflow

TEST=runtime/vm/service_test.cc

Cq-Include-Trybots: dart/try:vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-linux-debug-arm64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-simarm-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try
Change-Id: Id15a82bf478bc4822c08d7fdf0a5c8bfd71a1fe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505781
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-06-02 23:09:24 -07:00
Ryan Macnak b2911c0bf1 Fix GCC build.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/63406
Change-Id: I3bb3963fcc182777c5d2c0e062ae4bbf3c5aae75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504800
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-20 08:21:30 -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
Nourhan Hasan 046d473d5e [vm/service]: use a map for service ID zones to avoid ID reuse and unbounded growth (#62205)
Replace the growable array with a hash map so that zones are truly
removed on deletion and IDs are never reused.

TEST=Manually tested with test_zones.dart (IDs increase, map size
toggles); existing service tests pass

Fixes: https://github.com/dart-lang/sdk/issues/62205
Change-Id: I0bbec4a0fc0aef9ed8679a3aa5ce832fea9bfde8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489720
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-18 03:57:44 -07:00
Ben Konyi 0b68c62fc5 [Service] Add support for resident frontend server to package:dart_runtime_service_vm
TEST=Existing, ran locally.
Change-Id: Idc1f35eb3d4cf0c7251a64b02b801e8110cc323b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499000
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-30 17:04:19 -07:00
Slava Egorov 53ac68e2dd [vm_service] Deprecate Stack.messages
Make VM always return empty array in the response.

Current implementation for this field comes with a bunch of complexity
because it locks message handler and then invokes Dart code which
makes it difficult to reason about various invariants. This code is 
furthermore demonstrated to cause deadlocks. Given that nobody uses 
it - it is simpler to remove this code altogether.

Fixes https://github.com/flutter/flutter/issues/185156

TEST=ci

Change-Id: I497210e0f1542860caa0d765d634f8ec6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-20 10:28:01 -07:00
Nourhan 734e12ac96 [vm/service]: Add VM memory mappings for Windows
Implement AddVMMappings for Windows using VirtualQuery and
GetMappedFileNameA, matching the existing Linux/Android implementation.

TEST=tested manually on Windows by opening some tool and looking at
values

Fixes: https://github.com/dart-lang/sdk/issues/46166
Change-Id: I2ad9229c1cc39ffedca7a2c0fc50d5e3da36953d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493020
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-04-15 09:44:59 -07:00
Tess Strickland e1f76cb03e [vm_service] Separate retrieval and serialization of persistent handles.
Serializing the object stored in a handle may require allocation, so
serialization of the current (weak) persistent handles should not be
done under a no safepoint scope.

Instead, retrieve the stored objects and any needed metadata for the
current (weak) persistent handles under a no safepoint scope, and then
separately serialize the retrieved information outside of that scope.

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

TEST=vm/cc/Service_PersistentHandles on vm-dyn-*, which revealed this
     issue.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ie9e32c758140aaebc7bd87a704119a8b82d0f8a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491300
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-07 06:09:01 -07:00
Ryan Macnak 28f94515fe [vm] Fix warning on newer GCC.
TEST=local build
Change-Id: Ic54b6bd6ae53cd4b5ef6dfa3d57ce05d8dff1755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488522
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-17 12:28:30 -07: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
dexter 234127f73a Fix VM service smaps path NUL termination to prevent OOB reads
Closes https://github.com/dart-lang/sdk/pull/62415

GitOrigin-RevId: d50a6de006545e64ea8706027f5055cc5dc46ef6
Change-Id: Ide1bbceb184d4c5a9137f667023aa42c32df6d20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473161
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-15 04:24:46 -08:00
Tess Strickland 21952afc1d [vm,dyn_modules] Handle bytecode in LookupHeapObjectCode.
TEST=pkg/vm_service/test/code
     pkg/vm_service/test/fetch_all_types

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,vm-dyn-mac-debug-arm64-try
Change-Id: I4e630911ec836ddcad2cadd338bc59be50827316
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449801
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-09-16 09:14:39 -07:00
Ryan Macnak d8117e1b08 [vm] Finer labeling of roots in heap snapshots.
Add missing object id zone roots, which should have been part of ffbbdb5a10 when they switched from weak to strong.

TEST=examine snapshot after using inspect
Bug: https://github.com/dart-lang/sdk/issues/61036
Change-Id: I3bea765e4ae487babfd86eccbaa87bab80320dcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439160
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-07-07 17:02:17 -07:00
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
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
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
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
Ryan Macnak c0e2f38f02 [dart:io] Fix some code to be safe in the face of reflective invocation.
Reflection can invoke public members of dart:* private types when values of the private types can be returned from public members.

TEST=lib/mirrors/invocation_fuzz_test
CoreLibraryReviewExempt: does not change public API
Bug: https://github.com/dart-lang/sdk/issues/31838
Bug: https://github.com/dart-lang/sdk/issues/46435
Bug: https://github.com/dart-lang/sdk/issues/51213
Change-Id: I969cd935d60455bd9cf4775b8df19838f9e6107c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428065
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-13 10:39:23 -07:00
Ryan Macnak 81a7f3e131 [vm, gc] Remove some dead code.
- Serial scavenge
- Serial marking
- Redudant safepoint operation scope
- Redudant Thread::Current
- Unused HandleVisitor::thread_
- Profile tag updates in PRODUCT mode
- Freelist printing

TEST=ci
Change-Id: I2de4c50df37c7ebe9d267514bcbd548dd61a5a57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426582
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-05 15:21:13 -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
Derek Xu 1d69b0b980 [VM] Add automatic detection of timers that are significantly overdue
This change makes it so that when the VM detects that a timer is at
least 100 ms overdue, it sends a warning in a VM Service event on the
'Timer' stream.

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

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes.
Change-Id: Ie8db047116b7f63cfb5413f763eaf56c7bdd6975
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409500
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-14 07:36:31 -07:00
Derek Xu 337e07fab6 [VM/Service] Use the resident frontend server for hot reload when it's available
TEST=pkg/vm_service/test/reload_sources_with_resident_compiler_test.dart
and pkg/vm_service/test/breakpoint_resolution_after_reloading_with_resident_compiler_test.dart

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes within
sdk/lib/vmservice/.
Change-Id: Ibc99cd37439ddd8aca97fa7e18a5112cbfc3b4cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401646
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-01-08 14:51:12 -08:00
Derek Xu 9a6f6c5a94 [ResidentFrontendServer] Add 'compileExpression' endpoint
TEST=test cases added to
`pkg/frontend_server/test/src/resident_frontend_server_test.dart`

Change-Id: I6ffb810d38fc4b13326cb828785aaf6eb6de90f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394764
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-12-20 09:00:17 -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
Derek Xu 9c18545e5f [VM/Service] Fix the behaviour of the pause parameter of ReloadSources
The changes to `pkg/vm_service/test/reload_sources_test.dart` in this CL
make it fail if running on a VM that does not also include the changes
to `runtime/vm/service.cc` in this CL. This happens because:

1) `pause_post_service_request` gets carried over from the RPC on line
   44 of `pkg/vm_service/test/reload_sources_test.dart`, and the isolate
   will actually pause after the `getIsolate` RPC within the
   `isolateIsRunning` test on line 51
2) `pause_post_service_request` gets carried over from the RPC on line
   54, and the isolate will actually pause after the `getIsolate` RPC
   within the `isolateIsRunning` test on line 60
3) `isolateIsRunning` on line 64 will fail

TEST=pkg/vm_service/test/reload_sources_test.dart

Change-Id: Id6486c485b1e22599cb920c0874aac0c1aa731c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397020
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-11-22 15:34:38 +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
Derek Xu 30dc2de34f [VM/Service] Report the requested column in the error messages of CannotAddBreakpoint errors
TEST=CI

Change-Id: Ia74bd61ef0b166275d5828fb21cfa9c92c5f00cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389280
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-10-15 16:57:36 +00:00
Jens Johansen 54f1ee4067 [VM/CFE] Fix expression compilation with record types
Fixes https://github.com/dart-lang/sdk/issues/56859

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

Change-Id: I4fdd2bc8e6c04fc59aaad28a192fe0b1833f000d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388841
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-10-09 11:01:57 +00:00
Derek Xu 6121c396ee [VM/Service] Expose Service ID zone APIs in service.md and package:vm_service
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes in
sdk/lib/vmservice/running_isolates.dart.
Change-Id: Id63180fd08a88865064435b056fa3269835cd476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-09-25 17:28:44 +00:00
Ryan Macnak 2a96956cd3 Roll Clang to 3928edecfbd116d56bbe7411365d50bb567380a1.
Re-run clang-format.

TEST=ci
Change-Id: If40a619e32a17ae95c5ee39e36ef0effd07e90b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385363
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-23 23:36:48 +00:00
Derek Xu 8fa0f56f45 [VM/Service] Add private _deleteIdZone RPC
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
Change-Id: I0b951505edd98364373d5913b7a01f6d4775998e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380360
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-08-28 16:41:50 +00:00
Derek Xu daa8cbb29e [VM/Service] Add private _invalidateIdZone RPC
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
Change-Id: I02fcb2502b698066885b3f090435e43a34ed6fcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379820
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-08-28 16:41:50 +00:00
Derek Xu 6b978a8339 [VM/Service] Add secret _idZoneId parameters to all Service methods
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes in
sdk/lib/vmservice/running_isolates.dart.
Change-Id: Ib8af3f073f6db9172df90a5ea221269411f72156
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379545
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-08-28 16:41:50 +00:00
Derek Xu 8b9be74d23 [VM/Service] Add private _createIdZone RPC
TEST=pkg/vm_service/test/id_zones_test.dart,
runtime/vm/object_id_ring_test.cc, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
Change-Id: I6b092ea6ba4c7787635671af26e09af496ad9a5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379544
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-08-28 16:41:50 +00:00
Derek Xu b1d1836082 Reland "[VM/Service] Change how the default Service ID zone is stored in an Isolate"
This is a reland of commit c5935aa16e

Initialization of `service_id_zones_` has been made lazy in this reland
CL. I performed a Golem run
(https://golem.corp.goog/Comparison?repository=dart#targetA%3Ddart%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D111556%3BpatchA%3Dderekx-Reland---VM%2FService--Change-how-the-default-Service-ID-zone-is-stored-in-an-Isolate--2%3BtargetB%3Ddart%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D111542%3BpatchB%3DNone)
on this reland CL, and confirmed that the benchmarks that had gotten
regressed by my original CL
(https://golem.corp.goog/Revision?repository=dart&revision=111543) no
longer get regressed.

Original change's description:
> [VM/Service] Change how the default Service ID zone is stored in an Isolate
>
> This CL makes it so that the default Service ID zone of an Isolate will
> now be stored in a MallocGrowableArray, in preparation for adding the
> ability for Isolates to each store multiple Service ID zones.
>
> TEST=CI
>
> Issue: https://github.com/dart-lang/sdk/issues/55869
> Change-Id: Ie729c1854faac1f61a466ae893ee8ad0a2128499
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379543
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

TEST=CI

Change-Id: I01cf0f54b05ae82a2dfd9f9c7fd48cda1ddfa90e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381061
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-08-20 20:38:19 +00:00
Derek Xu cce42a346b Revert "[VM/Service] Change how the default Service ID zone is stored in an Isolate"
This reverts commit c5935aa16e.

Reason for revert: Golem regressions

Original change's description:
> [VM/Service] Change how the default Service ID zone is stored in an Isolate
>
> This CL makes it so that the default Service ID zone of an Isolate will
> now be stored in a MallocGrowableArray, in preparation for adding the
> ability for Isolates to each store multiple Service ID zones.
>
> TEST=CI
>
> Issue: https://github.com/dart-lang/sdk/issues/55869
> Change-Id: Ie729c1854faac1f61a466ae893ee8ad0a2128499
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379543
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Issue: https://github.com/dart-lang/sdk/issues/55869
Change-Id: I76fc2dc15d896a24ac8b9ec4bb44e67eaaf50fd2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380801
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-08-16 16:59:37 +00:00
Derek Xu c5935aa16e [VM/Service] Change how the default Service ID zone is stored in an Isolate
This CL makes it so that the default Service ID zone of an Isolate will
now be stored in a MallocGrowableArray, in preparation for adding the
ability for Isolates to each store multiple Service ID zones.

TEST=CI

Issue: https://github.com/dart-lang/sdk/issues/55869
Change-Id: Ie729c1854faac1f61a466ae893ee8ad0a2128499
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379543
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-08-15 20:15:36 +00:00
Alexander Markov bf2fba78e0 [vm] Fix ObjectPtr::IsSmi and other ObjectPtr::Is* methods to account for Smis
Arbitrary ObjectPtr can be a non-heap object (Smi), so methods
ObjectPtr::Is* which test class id should account for Smi.

Changed ObjectPtr::GetClassId to account for Smi similarly to
Object::GetClassId. Added unsafe ObjectPtr::GetClassIdOfHeapObject
which can be used when caller knows the heap nature of the object.

This change also fixes Integer::GetInt64Value which was relying on ObjectPtr::IsSmi.

TEST=vm/cc/Smi, vm/cc/Mint

Change-Id: I1391600e2acedc7b2a8f35c814df113ec9ba8698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380280
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-14 17:09:07 +00:00
Derek Xu 47b9e95ec7 [VM/Debugger] Prepare for Debugger::FindCompiledFunctions to return an ErrorPtr
In this CL, Debugger::FindCompiledFunctions always just returns
Error::null(), but when eager compilation of functions is implemented
(https://dart-review.googlesource.com/c/sdk/+/338740), it will introduce
the possibility of Debugger::FindCompiledFunctions truly returning
errors. So, this CL adds the error propagation logic in advance to
avoid making the eager function compilation CL too large.

TEST=this is effectively just a refactor, so CI

Change-Id: Ibedbebf19fed306c8b93c98ba71b7cc57b90e174
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369161
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-06-24 22:00:28 +00:00
Ryan Macnak f5fe3dddcc [vm] Avoid strdup during the segfault handler.
malloc is not signal-safe.

TEST=tsan
Change-Id: I8bd6cae743b7ae2d64525f4e88fb412373d4e3df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365187
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-02 16:36:20 +00:00
Daco Harkes f98a2138b7 [vm] Run clang-format on code base
When uploading CLs, the presubmit checks verify that the lines in the
diff are formatted correctly according to `git cl format runtime`.

However, when `buildtools/<os>-<arch>/clang/bin/clang-format` is
updated, it does not force reformatting of files that would be
reformatted.

This leads to two issues:
* Inconsistent style within the code base and within a single file.
* Spurious reformatting in CLs when (1) clang-format is used on the
  whole file, or (2) the diff lines overlap.

`clang-format` doesn't change that frequently, so in general this is
not a large issue, but I've seen a bit too many "spurious formatting,
please revert" comments on CLs recently.

This CL formats the runtime to be in line with the current pinned
`clang-format`:

```
$ find runtime/ -iname *.h -o -iname *.cc | xargs buildtools/mac-arm64/clang/bin/clang-format -i
```

`git cl format` (which only formats changed lines, and does so with
`clang-format`) seems to not agree with itself, or clang-format, or
cpplint in a handful of places. This CL adds `// clang-format off`
for these. (See previous patchsets for the specific instances.)

TEST=A variety of bots including GCC, MacOS and Windows.

Change-Id: I470892e898971899fda14bb3b8f2c8efefd67686
Cq-Include-Trybots: luci.dart.try:vm-gcc-linux-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-win-debug-x64-try,vm-win-debug-x64c-try,vm-mac-debug-x64-try,vm-mac-debug-arm64-try,vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-04-17 19:14:41 +00:00
Derek Xu 391c0fb6c0 [VM] Remove deprecated Dart_TimelineEvent embedder API
TEST=CI

Change-Id: I094c32ec44a886a8154692de22b6575661918d29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353240
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-02-20 18:18:30 +00:00
Ryan Macnak 48cbd9b322 [vm] Identify the vm isolate etc by construction not by name.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54855
Change-Id: I31699c4343822e99a8fa275ba00dcdfa51cdd06b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351220
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-02-13 23:32:01 +00:00
Ryan Macnak 58bf203064 [VM] Add support for allocation tracing in AOT
TEST=Manual
Bug: https://github.com/dart-lang/sdk/issues/51234
Change-Id: I4ab75bb85898a41dfb091b38402711170fd3b972
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271420
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-01-17 13:50:49 +00:00
Liam Appelbe 0a20707e3f [vm/service] Fix JSON array parsing bug that causes seg fault
Changed the definition of `end` to point 1 past the end of the element,
rather than the end of the element, which avoids the need for buggy
look-ahead style lookups.

I think this must have been a long standing bug, and we just never sent
empty JSON arrays to the service until now, because I didn't change this
logic when I refactored it.

Bug: https://github.com/dart-lang/sdk/issues/53990
Fixes: https://github.com/dart-lang/sdk/issues/53990
Change-Id: I89ece7a036d0b71610a153e708f40aeabab5367c
TEST=Added Service_ParseJSONArray
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335980
Commit-Queue: Liam Appelbe <liama@google.com>
Auto-Submit: Liam Appelbe <liama@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-11-14 16:13:59 +00:00
Jens Johansen 73466729f3 [vm] Pass offset and script uri for expression compilation
This CL passes the offset and uri of the file (here called a script uri
as opposed to a library uri, the two will be different if we're in a
part) when doing expression compilation.

This CL only passes the data, but doesn't actually use it.
Future CL(s) will use this data to calculate the static type of
available variables which is needed for an upcomming feature.

TEST=Existing tests.
CoreLibraryReviewExempt: Not changing SDK APIs.
Change-Id: I67ead461ab4bb9341424e693946f3e4afe35ce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329322
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-10-12 10:22:38 +00:00