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

Unified Diff: runtime/vm/service.cc

Issue 351703002: Class view: list all/sample instances on request. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/bin/vmservice/client/lib/src/elements/class_view.html ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
===================================================================
--- runtime/vm/service.cc (revision 37660)
+++ runtime/vm/service.cc (working copy)
@@ -1138,17 +1138,19 @@
}
-class GetInstancesVisitor : public ObjectVisitor {
+class GetInstancesVisitor : public ObjectGraph::Visitor {
public:
- GetInstancesVisitor(Isolate* isolate, const Class& cls, const Array& storage)
- : ObjectVisitor(isolate), cls_(cls), storage_(storage), count_(0) {}
+ GetInstancesVisitor(const Class& cls, const Array& storage)
+ : cls_(cls), storage_(storage), count_(0) {}
- virtual void VisitObject(RawObject* raw_obj) {
+ virtual Direction VisitObject(ObjectGraph::StackIterator* it) {
+ RawObject* raw_obj = it->Get();
if (raw_obj->IsFreeListElement()) {
- return;
+ return kProceed;
}
- REUSABLE_OBJECT_HANDLESCOPE(isolate());
- Object& obj = isolate()->ObjectHandle();
+ Isolate* isolate = Isolate::Current();
+ REUSABLE_OBJECT_HANDLESCOPE(isolate);
+ Object& obj = isolate->ObjectHandle();
obj = raw_obj;
if (obj.GetClassId() == cls_.id()) {
if (!storage_.IsNull() && count_ < storage_.Length()) {
@@ -1156,6 +1158,7 @@
}
++count_;
}
+ return kProceed;
}
intptr_t count() const { return count_; }
@@ -1180,8 +1183,9 @@
return true;
}
Array& storage = Array::Handle(Array::New(limit));
- GetInstancesVisitor visitor(isolate, cls, storage);
- isolate->heap()->IterateObjects(&visitor);
+ GetInstancesVisitor visitor(cls, storage);
+ ObjectGraph graph(isolate);
+ graph.IterateObjects(&visitor);
intptr_t count = visitor.count();
if (count < limit) {
// Truncate the list using utility method for GrowableObjectArray.
@@ -1190,7 +1194,12 @@
wrapper.SetLength(count);
storage = Array::MakeArray(wrapper);
}
- storage.PrintJSON(js, true);
+ JSONObject jsobj(js);
+ jsobj.AddProperty("type", "InstanceSet");
+ jsobj.AddProperty("id", "instance_set");
+ jsobj.AddProperty("totalCount", count);
+ jsobj.AddProperty("sampleCount", storage.Length());
+ jsobj.AddProperty("sample", storage);
return true;
}
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/class_view.html ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698