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

Unified Diff: runtime/vm/object.cc

Issue 206003005: Ensure PrintToJSONStream can be called on all heap objects without crashing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 34253)
+++ runtime/vm/object.cc (working copy)
@@ -4037,7 +4037,7 @@
NameVisibility name_visibility) const {
ASSERT(from_index + len <= Length());
String& name = String::Handle();
- const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">".
+ const intptr_t num_strings = (len == 0) ? 2 : 2*len + 1; // "<""T"", ""T"">".
const Array& strings = Array::Handle(Array::New(num_strings));
intptr_t s = 0;
strings.SetAt(s++, Symbols::LAngleBracket());
@@ -6326,7 +6326,12 @@
id = cls.FindFunctionIndex(*this);
selector = "functions";
}
turnidge 2014/03/23 22:24:20 Did you consider grabbing an id from the object id
koda 2014/03/24 17:18:34 I wasn't sure whether all fields still work in all
- ASSERT(id >= 0);
+ // TODO(17697): Oddball functions are treated as plain objects and use the
+ // object id ring. Current known examples are signature functions of closures
+ // and stubs like 'megamorphic_miss'.
+ if (id < 0) {
+ return Object::PrintToJSONStream(stream, ref);
+ }
intptr_t cid = cls.id();
JSONObject jsobj(stream);
jsobj.AddProperty("type", JSONType(ref));
@@ -13481,6 +13486,10 @@
void Type::PrintToJSONStream(JSONStream* stream, bool ref) const {
+ // TODO(koda): Decide whether to assign stable ids to non-canonical types.
+ if (!IsCanonical()) {
+ return Object::PrintToJSONStream(stream, ref);
+ }
turnidge 2014/03/23 22:24:20 Ditto previous comment. You could print an id fro
koda 2014/03/24 17:18:34 Also, here: not sure whether all printed propertie
ASSERT(IsCanonical());
JSONObject jsobj(stream);
jsobj.AddProperty("type", JSONType(ref));
@@ -16756,9 +16765,8 @@
JSONObject jselement(&jsarr);
jselement.AddProperty("index", index);
- Instance& instance = Instance::Handle();
- instance ^= At(index);
- jselement.AddProperty("value", instance);
+ Object& element = Object::Handle(At(index));
+ jselement.AddProperty("value", element);
}
}
}
@@ -17096,9 +17104,8 @@
JSONObject jselement(&jsarr);
jselement.AddProperty("index", index);
- Instance& instance = Instance::Handle();
- instance ^= At(index);
- jselement.AddProperty("value", instance);
+ Object& element = Object::Handle(At(index));
+ jselement.AddProperty("value", element);
}
}
}
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698