Commit graph

26 commits

Author SHA1 Message Date
Ryan Macnak dfbb0acbc7 [vm, service] Fix retaining path, inbound references, and heap snapshot tools for compressed pointers.
TEST=ci
Change-Id: Ib67f4ff1a9968cc97c0af91af62a03b0e64068ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200681
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-07-07 23:12:53 +00:00
Martin Kustermann 3c81d992ef [vm/concurrency] Distinguish "gc safepoint operations" from "deopt safepoint operations"
This extends the existing safepoint operation mechanism by allowing to
perform two different operations:

  * "gc safepoint operations": All mutators are stopped at places where
    it's safe to GC. It therefore requires stackmaps to be available for
    all optimized mutator frames.

  * "deopt safepoint operations": All mutators are stopped at places
    where it's safe to GC, but also safe to lazy-deopt mutator frames.
    It therefore requires deopt-id/deopt-info to be available for all
    optimized mutator frames.

Mutators can be asked to block for any of those two safepoint operations.
If a mutator is at a place where its safe to GC it will respond to "gc
safepoint operations" requests, if a mutator is additionally at a place
where it's also safe to lazy-deopt it will respond to "deopt safepoint
operation" requests.

Depending on how the runtime was entered (which is tracked via the
[Thread::runtime_call_deopt_ability_] value) - the mutator might
participate in both or only in gc safepoint operations.

During the start of a "deopt safepoint operation", the safepoint handler
will request all threads to stop at a "deopt safepoint". Some threads
might first want to initiate their own "gc safepoint operation"
(e.g. due to allocation failure) before they reach a "deopt safepoint".

We do allow this by letting the safepoint handler own a "deopt safepoint
operation" but still participate in other thread's "gc safepoint
operation" requests until all mutators are checked into places where
it's safe to lazy-deopt at which point the "deopt safepoint operation"
also owns a "gc safepoint operation".

In order to facilitate this, the Thread's safepoint_state will be
extended to consist of the following bits:

  * AtSafepoint
  * SafepointRequested
  * AtDeoptSafepoint
  * DeoptSafepointRequested
  * BlockedForSafepoint

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

TEST=vm/cc/SafepointOperation_*

Change-Id: Icdc2827718f6780818f99b829a5e806d6bb5b130
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196927
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-05-10 09:13:09 +00:00
Ryan Macnak b1c09ecd8f [vm] Make naming more consistent when converting between handles, tagged and untagged pointers.
Currently we have things called XPtr which are not what you get from ptr().

Old world:
handle->raw() returns RawObject* (tagged)
raw_obj->ptr() returns RawObject* (untagged)

After 6fe15f6df9:
handle->raw() returns ObjectPtr
obj_ptr->ptr() returns ObjectLayout*

New world:
handle->ptr() returns ObjectPtr
obj_ptr->untag() returns UntaggedObject*

TEST=ci
Change-Id: I6c7f34014cf20737607caaf84979838300d12df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149367
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-15 23:32:02 +00:00
Martin Kustermann 0f76981bb1 [vm/concurrency] Change references to class_table/object_store/heap from Isolate to IsolateGroup
As part of making the compiler and other subsystems independent
of `Isolate` we have to move various state from `Isolate` to
`IsolateGroup`.

The class_table and object_store were already moved to `IsolateGroup`.

This CL only replaces usages of `Isolate::{object_store,class_table}`
with the equivalent in `IsolateGroup`.

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

TEST=Pure refactoring - relying on existing test coverage.

Change-Id: I34a0682d715b054d6c5faff077a513980f59a348
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177126
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-01-06 15:22:11 +00:00
Daco Harkes 5278383736 [vm] Native API: Make Dart_NewWeakPersistentHandle not auto delete
Changes Dart_NewWeakPersistentHandle to no longer auto delete the
weak persistent handle.

Changes the signatures of WeakPersistentHandleFinalizers to no longer
have access to the handle.

Flutter PR: https://github.com/flutter/engine/pull/19843
g3 presubmit: cl/318028238

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

TEST=runtime/vm/dart_api_impl_test.cc

Change-Id: I3f77db9954d9486759f903b78c03a494f73c68ba
Cq-Include-Trybots:dart/try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151525
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-03 10:27:44 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Ryan Macnak df5036eb6e [vm] Require only an isolate group, not an isolate, in Dart_Delete[Weak]PersistentHandle.
Remove the now-misleading isolate parameter of Dart_DeleteWeakPersistentHandle.

Bug: https://github.com/dart-lang/sdk/issues/40836
Change-Id: I784f1ecf564484b59f60ebef53ddb975aff1bd23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138015
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-03-04 18:56:16 +00:00
Ryan Macnak 6e987b6eb5 [vm, service] Add requestHeapSnapshot.
This replaces _requestHeapSnapshot and _getObjectByAddresses, which relied on the invalid assumption that objects don't move and the heap hasn't mutated since the initial snapshot.

Updates Observatory to the new format. Adds treemap visualization of the dominator tree. Adds the ability to save and load heap snapshots to files. Removes analysis grouping references by source and target class. Removes ability to navigate from a pixel in the fragmentation view to inspector. Removes ability to query the top retaining instance from an ordinary class browser.

Change-Id: Ia7781c05d43bf3ec149f8b4ecab803b37c3ee981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112181
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2019-08-19 19:31:42 +00:00
Ben Konyi 5f32027e1d [ VM / Service ] Add getInboundReferences, getRetainingPath RPCs and InboundReferences, InboundReference, RetainingPath, RetainingObject objects.
Change-Id: I26211d13d49688037114d76f648e500b98ec3295
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108560
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-07-30 23:26:28 +00:00
Ryan Macnak 128139be71 [vm] Rename RawObject::Size to RawObject::HeapSize.
To avoid confusion between the heap size (includes header and rounding up) and number-of-elements size or payload size.

Change-Id: I714c4e8cec92d7ef963de39474d2a1bb23e5b4a3
Reviewed-on: https://dart-review.googlesource.com/c/92400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-02-08 18:48:46 +00:00
Ryan Macnak 466385ceb6 [vm, gc] Require a safepoint for heap iteration.
Assert a safepoint operation can only be started from a thread in the VM state. Fix several unit tests missing a native-to-vm transition.

R=asiva@google.com, danunez@google.com

Review-Url: https://codereview.chromium.org/2995543004 .
2017-08-07 17:51:25 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ben Konyi f2fd150ea0 Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run while the VM is alive. Tests created using the RAW_UNIT_TEST_CASE macro will run after the VM has shutdown to avoid having any worker threads contaminating the test results.
BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2666133002 .
2017-01-31 15:16:38 -08:00
Ryan Macnak 11975ab353 ObjectGraph: Establish a HeapIterationScope *before* making the heap writable, least the sweeper interfer.
Fixes #28030

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2566383002 .
2016-12-14 11:27:15 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

The ThreadRegistry class now contains only the thread list for an isolate and the functionality of scheduling a thread onto an Isolate and unscheduling it from teh isolate. We could fold this functionality into the Isolate class in a different CL.

R=rmacnak@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
Srdjan Mitrovic b9426418d8 Get rid of deprecated methods accessing mutator_thread_ instead of current thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1410643008 .
2015-10-20 10:26:08 -07:00
Ivan Posva 4bd7cdc75c - Ensure that HandleScope is initialized with a thread. (Remove
deprecated isolate based API.)
- Update all code impacted by this change. E.g. DARTSCOPE
- TEST_CASE now passes the current thread as a parameter to the   unit test.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1310463005 .
2015-09-01 17:18:55 -07:00
Daniel Andersson 3ce2b95070 Make ObjectGraph wait for concurrent sweeper before using mark bits
Attempt to extend test coverage by triggering a full GC in test. (Manual inspection did show the "Wait" being executed.)

BUG=https://github.com/dart-lang/sdk/issues/21620
R=iposva@google.com

Review URL: https://codereview.chromium.org//1179973005.
2015-06-17 14:22:51 -07:00
koda@google.com e3a345a84b Rename NoGCScope -> NoSafepointScope.
The old name makes less sense in the context of concurrent GC (and multiple threads in general).

Document the intended semantics of this (DEBUG-only) guard scope.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1016503005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44616 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-20 22:08:25 +00:00
koda@google.com 655b16b2d6 Include parent field/list index in retaining path.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//350403005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37956 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-02 20:37:56 +00:00
koda@google.com 5886e8ec95 Light-weight stats counters for temporary experiments/debugging.
A single statement is enough to add a counter:
  ...
  Isolate::Current()->counters()->Increment("allocated", size_in_bytes);
  ...

I've been using these myself for a while now, but figured others might
find them useful too. They are not intended for production use, just temporary local experiments/investigation.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//336683003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37367 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-16 17:13:20 +00:00
koda@google.com 61bde80790 Retaining path in Observatory.
Add retaining_path instance command to VM service, exposed in the Observatory
with a [find] eval-link in instance view. By default shows up to 10 elements,
possibly followed by [find more] which doubles the number of elements shown.

Change RetainingPath to include the object itself.

Always include an id in Object::PrintJSONImpl, to avoid instance-ref crashing on
internal objects.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//292663012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36516 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-22 17:31:47 +00:00
koda@google.com b9c9bb5dfe ObjectGraph::RetainingPath
Adds a utility method to find a retaining path and unit test.
Next step is to expose it via VM service and Observatory.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//286203015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36381 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-20 20:38:02 +00:00
koda@google.com 1c3a41ad13 Retained size for instance in Observatory.
Add objects/$id/retained message that uses ObjectGraph to compute retained size for an instance.
In the instance view, the user can request the size to be calculated.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//263803009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35757 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 19:41:12 +00:00
koda@google.com f9b6613cf4 Object graph visitor: general depth-first search.
Features:
 * Performs a pre-order, depth-first search.
 * Allows the visitor to direct whether to
   proceed, backtrack, or abort.
 * Provides a complete chain of parents to the root.
   (unlike the GC marking stack).

The plan is to use this in the observatory, e.g.:
 * inspect a path from the isolate roots to a particular object, or
 * determine how much memory is kept alive by some particular object or class of objects.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//266643002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35711 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-02 21:38:30 +00:00