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

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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/service.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 27342)
+++ 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);
@@ -2918,20 +2919,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();
}
@@ -3015,8 +3009,7 @@
void UnresolvedClass::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3239,8 +3232,7 @@
void AbstractTypeArguments::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3580,8 +3572,7 @@
void TypeArguments::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3669,8 +3660,7 @@
void InstantiatedTypeArguments::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -3686,8 +3676,7 @@
void PatchClass::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -4134,6 +4123,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)) {
@@ -5092,22 +5084,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:
@@ -5143,15 +5128,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()));
}
@@ -5199,8 +5182,7 @@
void ClosureData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5235,8 +5217,7 @@
void RedirectionData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5420,8 +5401,7 @@
void Field::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -5643,8 +5623,7 @@
void LiteralToken::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -6059,8 +6038,7 @@
void TokenStream::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -6411,8 +6389,7 @@
void Script::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7448,36 +7425,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();
}
@@ -7622,8 +7592,7 @@
void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7638,8 +7607,7 @@
void Namespace::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -7903,8 +7871,7 @@
void Instructions::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8058,8 +8025,7 @@
void PcDescriptors::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8214,8 +8180,7 @@
void Stackmap::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8285,8 +8250,7 @@
void LocalVarDescriptors::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8470,8 +8434,7 @@
void ExceptionHandlers::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8569,8 +8532,7 @@
void DeoptInfo::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -8965,27 +8927,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();
}
@@ -9116,8 +9074,7 @@
void Context::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9236,8 +9193,7 @@
void ContextScope::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9709,8 +9665,7 @@
void ICData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9826,8 +9781,7 @@
void MegamorphicCache::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9903,8 +9857,7 @@
void SubtypeTestCache::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9922,8 +9875,7 @@
void Error::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -9968,8 +9920,7 @@
void ApiError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10014,8 +9965,7 @@
void LanguageError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10089,8 +10039,7 @@
void UnhandledException::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10126,8 +10075,7 @@
void UnwindError::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10481,8 +10429,7 @@
void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -10840,8 +10787,7 @@
void AbstractType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11288,8 +11234,7 @@
void Type::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11476,8 +11421,7 @@
void TypeParameter::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11645,8 +11589,7 @@
void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11661,8 +11604,7 @@
void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11705,8 +11647,7 @@
void Number::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -11718,8 +11659,7 @@
void Integer::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12137,8 +12077,7 @@
void Smi::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12257,8 +12196,7 @@
void Mint::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12364,8 +12302,7 @@
void Double::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -12536,8 +12473,7 @@
void Bigint::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13140,8 +13076,7 @@
void String::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13862,8 +13797,7 @@
void Bool::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -13946,8 +13880,7 @@
void Array::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14158,8 +14091,7 @@
void GrowableObjectArray::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14264,8 +14196,7 @@
void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14370,8 +14301,7 @@
void Uint32x4::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14420,8 +14350,7 @@
void TypedData::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14457,8 +14386,7 @@
void ExternalTypedData::PrintToJSONStream(JSONStream* stream,
bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14645,8 +14573,7 @@
void Stacktrace::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14843,8 +14770,7 @@
void JSRegExp::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
@@ -14864,8 +14790,7 @@
void WeakProperty::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
RawAbstractType* MirrorReference::GetAbstractTypeReferent() const {
@@ -14927,8 +14852,7 @@
void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
- stream->OpenObject();
- stream->CloseObject();
+ JSONObject jsobj(stream);
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698