Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1168)

Unified Diff: runtime/vm/object_graph.cc

Issue 3008593002: Add external sizes to the heap dominator tree. (Closed)
Patch Set: review Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_graph.cc
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc
index ea8d2a742d34875bdd038ed5d418ca028a21c196..283143b74e9f3dc7653084381358fac9a0f2042c 100644
--- a/runtime/vm/object_graph.cc
+++ b/runtime/vm/object_graph.cc
@@ -5,6 +5,7 @@
#include "vm/object_graph.h"
#include "vm/dart.h"
+#include "vm/dart_api_state.h"
#include "vm/growable_array.h"
#include "vm/isolate.h"
#include "vm/object.h"
@@ -596,6 +597,26 @@ class WriteGraphVisitor : public ObjectGraph::Visitor {
intptr_t count_;
};
+class WriteGraphExternalSizesVisitor : public HandleVisitor {
+ public:
+ WriteGraphExternalSizesVisitor(Thread* thread, WriteStream* stream)
+ : HandleVisitor(thread), stream_(stream) {}
+
+ void VisitHandle(uword addr) {
+ FinalizablePersistentHandle* weak_persistent_handle =
+ reinterpret_cast<FinalizablePersistentHandle*>(addr);
+ if (!weak_persistent_handle->raw()->IsHeapObject()) {
+ return; // Free handle.
+ }
+
+ WritePtr(weak_persistent_handle->raw(), stream_);
+ stream_->WriteUnsigned(weak_persistent_handle->external_size());
+ }
+
+ private:
+ WriteStream* stream_;
+};
+
intptr_t ObjectGraph::Serialize(WriteStream* stream,
SnapshotRoots roots,
bool collect_garbage) {
@@ -641,6 +662,11 @@ intptr_t ObjectGraph::Serialize(WriteStream* stream,
WriteGraphVisitor visitor(isolate(), stream, roots);
IterateObjects(&visitor);
+ stream->WriteUnsigned(0);
+
+ WriteGraphExternalSizesVisitor external_visitor(Thread::Current(), stream);
+ isolate()->VisitWeakPersistentHandles(&external_visitor);
+ stream->WriteUnsigned(0);
intptr_t object_count = visitor.count();
if (roots == kVM) {
« no previous file with comments | « runtime/observatory/lib/src/heap_snapshot/heap_snapshot.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698