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

Unified Diff: runtime/vm/object.cc

Issue 532063002: Teach the Observatory about Contexts. Factor out object graph information from the instance view. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/observatory/test/contexts_test.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.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 256f38fc3a8903bb5f46bac22c295b4934be1d3e..03cde270d4a2258e515a95c700d348db305f3da8 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -12443,7 +12443,33 @@ void Context::Dump(int indent) const {
void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
- Object::PrintJSONImpl(stream, ref);
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("type", JSONType(ref));
+ ObjectIdRing* ring = Isolate::Current()->object_id_ring();
+ const intptr_t id = ring->GetIdForObject(raw());
+ jsobj.AddPropertyF("id", "objects/%" Pd "", id);
+
+ jsobj.AddProperty("length", num_variables());
+
+ if (ref) {
+ return;
+ }
+
+ Class& cls = Class::Handle(this->clazz());
+ jsobj.AddProperty("class", cls);
+
+ jsobj.AddProperty("size", raw()->Size());
+
+ const Context& parent_context = Context::Handle(parent());
+ jsobj.AddProperty("parent", parent_context);
+
+ JSONArray jsarr(&jsobj, "variables");
+ for (intptr_t i = 0; i < num_variables(); i++) {
+ const Instance& var = Instance::Handle(At(i));
+ JSONObject jselement(&jsarr);
+ jselement.AddProperty("index", i);
+ jselement.AddProperty("value", var);
+ }
}
@@ -13621,6 +13647,8 @@ void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
if (IsClosure()) {
const Function& closureFunc = Function::Handle(Closure::function(*this));
jsobj.AddProperty("closureFunc", closureFunc);
+ const Context& closureCtxt = Context::Handle(Closure::context(*this));
+ jsobj.AddProperty("closureCtxt", closureCtxt);
}
jsobj.AddPropertyF("id", "objects/%" Pd "", id);
if (ref) {
« no previous file with comments | « runtime/bin/vmservice/observatory/test/contexts_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698