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

Unified Diff: runtime/vm/object.cc

Issue 23875015: - Base JSON stream printing on stack objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 27302)
+++ runtime/vm/object.cc (working copy)
@@ -64,6 +64,7 @@
DECLARE_FLAG(bool, trace_deoptimization);
DECLARE_FLAG(bool, trace_deoptimization_verbose);
DECLARE_FLAG(bool, verbose_stacktrace);
+DECLARE_FLAG(bool, print_coverage);
static const char* kGetterPrefix = "get:";
static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix);
@@ -2923,20 +2924,13 @@
const char* class_name = String::Handle(UserVisibleName()).ToCString();
ObjectIdRing* ring = Isolate::Current()->object_id_ring();
intptr_t id = ring->GetIdForObject(raw());
- if (ref) {
- stream->OpenObject();
- stream->PrintProperty("type", "@Class");
- stream->PrintProperty("id", id);
- stream->PrintProperty("name", class_name);
- stream->CloseObject();
- return;
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("type", JSONType(ref));
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("name", class_name);
+ if (!ref) {
+ jsobj.AddProperty("library", Object::Handle(library()));
}
- stream->OpenObject();
- stream->PrintProperty("type", "Class");
- stream->PrintProperty("id", id);
- stream->PrintProperty("name", class_name);
- stream->PrintProperty("library", Object::Handle(library()));
- stream->CloseObject();
}
@@ -3020,8 +3014,7 @@
void UnresolvedClass::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3244,8 +3237,7 @@
void AbstractTypeArguments::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3585,8 +3577,7 @@
void TypeArguments::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3674,8 +3665,7 @@
void InstantiatedTypeArguments::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3691,8 +3681,7 @@
void PatchClass::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -4139,6 +4128,9 @@
bool Function::is_optimizable() const {
+ if (FLAG_print_coverage) {
+ return false;
+ }
if (OptimizableBit::decode(raw_ptr()->kind_tag_) &&
(script() != Script::null()) &&
((end_token_pos() - token_pos()) < FLAG_huge_method_cutoff_in_tokens)) {
@@ -5097,22 +5089,15 @@
String::Handle(QualifiedUserVisibleName()).ToCString();
ObjectIdRing* ring = Isolate::Current()->object_id_ring();
intptr_t id = ring->GetIdForObject(raw());
- if (ref) {
- stream->OpenObject();
- stream->PrintProperty("type", "@Function");
- stream->PrintProperty("id", id);
- stream->PrintProperty("name", function_name);
- stream->CloseObject();
- return;
- }
- stream->OpenObject();
- stream->PrintProperty("type", "Function");
- stream->PrintProperty("name", function_name);
- stream->PrintProperty("id", id);
- stream->PrintPropertyBool("is_static", is_static());
- stream->PrintPropertyBool("is_const", is_const());
- stream->PrintPropertyBool("is_optimizable", is_optimizable());
- stream->PrintPropertyBool("is_inlinable", IsInlineable());
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("type", JSONType(ref));
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("name", function_name);
+ if (ref) return;
+ jsobj.AddProperty("is_static", is_static());
+ jsobj.AddProperty("is_const", is_const());
+ jsobj.AddProperty("is_optimizable", is_optimizable());
+ jsobj.AddProperty("is_inlinable", IsInlineable());
const char* kind_string = NULL;
switch (kind()) {
case RawFunction::kRegularFunction:
@@ -5148,15 +5133,13 @@
default:
UNREACHABLE();
}
- stream->PrintProperty("kind", kind_string);
- stream->PrintProperty("unoptimized_code", Object::Handle(unoptimized_code()));
- stream->PrintProperty("usage_counter", usage_counter());
- stream->PrintProperty("optimized_call_site_count",
- optimized_call_site_count());
- stream->PrintProperty("code", Object::Handle(CurrentCode()));
- stream->PrintProperty("deoptimizations",
- static_cast<intptr_t>(deoptimization_counter()));
- stream->CloseObject();
+ jsobj.AddProperty("kind", kind_string);
+ jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code()));
+ jsobj.AddProperty("usage_counter", usage_counter());
+ jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count());
+ jsobj.AddProperty("code", Object::Handle(CurrentCode()));
+ jsobj.AddProperty("deoptimizations",
+ static_cast<intptr_t>(deoptimization_counter()));
}
@@ -5204,8 +5187,7 @@
void ClosureData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5240,8 +5222,7 @@
void RedirectionData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5425,8 +5406,7 @@
void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5648,8 +5628,7 @@
void LiteralToken::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -6064,8 +6043,7 @@
void TokenStream::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -6416,8 +6394,7 @@
void Script::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7476,36 +7453,29 @@
const char* library_url = String::Handle(url()).ToCString();
ObjectIdRing* ring = Isolate::Current()->object_id_ring();
intptr_t id = ring->GetIdForObject(raw());
- if (ref) {
- // Print a reference
- stream->OpenObject();
- stream->PrintProperty("type", "@Library");
- stream->PrintProperty("id", id);
- stream->PrintProperty("name", library_name);
- stream->CloseObject();
- return;
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("type", JSONType(ref));
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("name", library_name);
+ if (ref) return;
+ jsobj.AddProperty("url", library_url);
+ {
+ JSONArray jsarr(jsobj, "classes");
+ ClassDictionaryIterator class_iter(*this);
+ Class& klass = Class::Handle();
+ while (class_iter.HasNext()) {
+ klass = class_iter.GetNextClass();
+ jsarr.AddValue(klass);
+ }
}
- stream->OpenObject();
- stream->PrintProperty("type", "Library");
- stream->PrintProperty("id", id);
- stream->PrintProperty("name", library_name);
- stream->PrintProperty("url", library_url);
- ClassDictionaryIterator class_iter(*this);
- stream->OpenArray("classes");
- Class& klass = Class::Handle();
- while (class_iter.HasNext()) {
- klass = class_iter.GetNextClass();
- stream->PrintValue(klass);
+ {
+ JSONArray jsarr(jsobj, "libraries");
+ Library& lib = Library::Handle();
+ for (intptr_t i = 0; i < num_imports(); i++) {
+ lib = ImportLibraryAt(i);
+ jsarr.AddValue(lib);
+ }
}
- stream->CloseArray();
- stream->OpenArray("libraries");
- Library& lib = Library::Handle();
- for (intptr_t i = 0; i < num_imports(); i++) {
- lib = ImportLibraryAt(i);
- stream->PrintValue(lib);
- }
- stream->CloseArray();
- stream->CloseObject();
}
@@ -7660,8 +7630,7 @@
void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7676,8 +7645,7 @@
void Namespace::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7924,8 +7892,7 @@
void Instructions::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8079,8 +8046,7 @@
void PcDescriptors::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8235,8 +8201,7 @@
void Stackmap::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8306,8 +8271,7 @@
void LocalVarDescriptors::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8491,8 +8455,7 @@
void ExceptionHandlers::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8590,8 +8553,7 @@
void DeoptInfo::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8986,27 +8948,23 @@
void Code::PrintToJSONStream(JSONStream* stream, bool ref) const {
ObjectIdRing* ring = Isolate::Current()->object_id_ring();
intptr_t id = ring->GetIdForObject(raw());
+ JSONObject jsobj(stream);
if (ref) {
- stream->OpenObject();
- stream->PrintProperty("type", "@Code");
- stream->PrintProperty("id", id);
- stream->CloseObject();
+ jsobj.AddProperty("type", "@Code");
+ jsobj.AddProperty("id", id);
return;
}
- stream->OpenObject();
- stream->PrintProperty("type", "Code");
- stream->PrintProperty("id", id);
- stream->PrintPropertyBool("is_optimized", is_optimized());
- stream->PrintPropertyBool("is_alive", is_alive());
- stream->PrintProperty("function", Object::Handle(function()));
- stream->OpenArray("disassembly");
- DisassembleToJSONStream formatter(stream);
+ jsobj.AddProperty("type", "Code");
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("is_optimized", is_optimized());
+ jsobj.AddProperty("is_alive", is_alive());
+ jsobj.AddProperty("function", Object::Handle(function()));
+ JSONArray jsarr(jsobj, "disassembly");
+ DisassembleToJSONStream formatter(jsarr);
const Instructions& instr = Instructions::Handle(instructions());
uword start = instr.EntryPoint();
Disassembler::Disassemble(start, start + instr.size(), &formatter,
comments());
- stream->CloseArray();
- stream->CloseObject();
}
@@ -9137,8 +9095,7 @@
void Context::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9257,8 +9214,7 @@
void ContextScope::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9730,8 +9686,7 @@
void ICData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9847,8 +9802,7 @@
void MegamorphicCache::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9924,8 +9878,7 @@
void SubtypeTestCache::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9943,8 +9896,7 @@
void Error::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9989,8 +9941,7 @@
void ApiError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10035,8 +9986,7 @@
void LanguageError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10110,8 +10060,7 @@
void UnhandledException::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10147,8 +10096,7 @@
void UnwindError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10502,8 +10450,7 @@
void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10861,8 +10808,7 @@
void AbstractType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11309,8 +11255,7 @@
void Type::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11497,8 +11442,7 @@
void TypeParameter::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11666,8 +11610,7 @@
void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11682,8 +11625,7 @@
void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11726,8 +11668,7 @@
void Number::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11739,8 +11680,7 @@
void Integer::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12158,8 +12098,7 @@
void Smi::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12278,8 +12217,7 @@
void Mint::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12385,8 +12323,7 @@
void Double::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12557,8 +12494,7 @@
void Bigint::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13161,8 +13097,7 @@
void String::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13883,8 +13818,7 @@
void Bool::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13967,8 +13901,7 @@
void Array::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14179,8 +14112,7 @@
void GrowableObjectArray::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14285,8 +14217,7 @@
void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14391,8 +14322,7 @@
void Uint32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14441,8 +14371,7 @@
void TypedData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14478,8 +14407,7 @@
void ExternalTypedData::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14666,8 +14594,7 @@
void Stacktrace::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14864,8 +14791,7 @@
void JSRegExp::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14885,8 +14811,7 @@
void WeakProperty::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
RawAbstractType* MirrorReference::GetAbstractTypeReferent() const {
@@ -14948,8 +14873,7 @@
void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698