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

Unified Diff: runtime/vm/object.cc

Issue 1157173005: Include 'fixedId' key when printing service ids (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/metrics_test.cc ('k') | 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
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b2b15947a47ac1013d96a5492035cbe0571e8e17..4c18a49e117a9ea660eb94efe635a3a0e6d23a04 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1609,7 +1609,7 @@ void Object::PrintJSON(JSONStream* stream, bool ref) const {
if (IsNull()) {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "null", JSONType(), ref);
- jsobj.AddProperty("id", "objects/null");
+ jsobj.AddFixedServiceId("objects/null");
jsobj.AddProperty("valueAsString", "null");
if (!ref) {
const Class& cls = Class::Handle(this->clazz());
@@ -1625,7 +1625,7 @@ void Object::PrintJSON(JSONStream* stream, bool ref) const {
void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Object", JSONType(), ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
return;
}
@@ -4113,7 +4113,7 @@ void Class::PrintJSONImpl(JSONStream* stream, bool ref) const {
return;
}
AddTypeProperties(&jsobj, "Class", JSONType(), ref);
- jsobj.AddPropertyF("id", "classes/%" Pd "", id());
+ jsobj.AddFixedServiceId("classes/%" Pd "", id());
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -4443,7 +4443,7 @@ void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
const Array& table = Array::Handle(object_store->canonical_type_arguments());
ASSERT(table.Length() > 0);
AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -6848,22 +6848,22 @@ static void AddFunctionServiceId(const JSONObject& jsobj,
}
if (id != -1) {
ASSERT(selector != NULL);
- jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "",
- cls.id(), selector, id);
+ jsobj.AddFixedServiceId("classes/%" Pd "/%s/%" Pd "",
+ cls.id(), selector, id);
return;
}
// Regular functions known to their owner use their name (percent-encoded).
String& name = String::Handle(f.name());
if (cls.LookupFunction(name) == f.raw()) {
name = String::EncodeIRI(name);
- jsobj.AddPropertyF("id", "classes/%" Pd "/functions/%s",
- cls.id(), name.ToCString());
+ jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s",
+ cls.id(), name.ToCString());
return;
}
// Oddball functions (not known to their owner) fall back to use the object
// id ring. Current known examples are signature functions of closures
// and stubs like 'megamorphic_miss'.
- jsobj.AddServiceId("id", f);
+ jsobj.AddServiceId(f);
}
@@ -7225,7 +7225,7 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
ASSERT(id >= 0);
intptr_t cid = cls.id();
AddTypeProperties(&jsobj, "Field", JSONType(), ref);
- jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id);
+ jsobj.AddFixedServiceId("classes/%" Pd "/fields/%" Pd "", cid, id);
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -8012,7 +8012,7 @@ void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const {
AddTypeProperties(&jsobj, "Object", JSONType(), ref);
// TODO(johnmccutchan): Generate a stable id. TokenStreams hang off
// a Script object but do not have a back reference to generate a stable id.
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
return;
}
@@ -8551,7 +8551,7 @@ void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
const Library& lib = Library::Handle(FindLibrary());
// TODO(rmacnak): This can fail for eval scripts. Use a ring-id for those.
intptr_t lib_index = (lib.IsNull()) ? -1 : lib.index();
- jsobj.AddPropertyF("id", "libraries/%" Pd "/scripts/%s",
+ jsobj.AddFixedServiceId("libraries/%" Pd "/scripts/%s",
lib_index, encoded_uri.ToCString());
jsobj.AddPropertyStr("uri", uri);
jsobj.AddProperty("kind", GetKindAsCString());
@@ -9895,7 +9895,7 @@ void Library::PrintJSONImpl(JSONStream* stream, bool ref) const {
ASSERT(id >= 0);
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Library", JSONType(), ref);
- jsobj.AddPropertyF("id", "libraries/%" Pd "", id);
+ jsobj.AddFixedServiceId("libraries/%" Pd "", id);
jsobj.AddProperty("name", library_name);
const String& library_url = String::Handle(url());
jsobj.AddPropertyStr("uri", library_url);
@@ -10703,7 +10703,7 @@ void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
AddTypeProperties(jsobj, "Object", JSONType(), ref);
// TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
// object but do not have a back reference to generate an ID.
- jsobj->AddServiceId("id", *this);
+ jsobj->AddServiceId(*this);
if (ref) {
return;
}
@@ -10984,7 +10984,7 @@ void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream,
AddTypeProperties(&jsobj, "Object", JSONType(), ref);
// TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off
// a Code object but do not have a back reference to generate an ID.
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
return;
}
@@ -12643,8 +12643,9 @@ bool Code::IsFunctionCode() const {
void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Code", JSONType(), ref);
- jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(),
- EntryPoint());
+ jsobj.AddFixedServiceId("code/%" Px64"-%" Px "",
+ compile_timestamp(),
+ EntryPoint());
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -12941,7 +12942,7 @@ void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
// TODO(turnidge): Should the user level type for Context be Context
// or Object?
AddTypeProperties(&jsobj, "Context", JSONType(), ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
jsobj.AddProperty("length", num_variables());
@@ -13360,7 +13361,6 @@ const char* ApiError::ToCString() const {
void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Error", JSONType(), ref);
- jsobj.AddProperty("id", "");
jsobj.AddProperty("message", ToErrorCString());
}
@@ -13498,7 +13498,6 @@ const char* LanguageError::ToCString() const {
void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Error", JSONType(), ref);
- jsobj.AddProperty("id", "");
jsobj.AddProperty("message", ToErrorCString());
}
@@ -13590,7 +13589,6 @@ void UnhandledException::PrintJSONImpl(JSONStream* stream,
bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Error", JSONType(), ref);
- jsobj.AddProperty("id", "");
jsobj.AddProperty("message", ToErrorCString());
Instance& instance = Instance::Handle();
@@ -13635,7 +13633,6 @@ const char* UnwindError::ToCString() const {
void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Error", JSONType(), ref);
- jsobj.AddProperty("id", "");
jsobj.AddProperty("message", ToErrorCString());
}
@@ -14131,19 +14128,19 @@ void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
// Handle certain special instance values.
if (raw() == Object::sentinel().raw()) {
jsobj.AddProperty("type", "Sentinel");
- jsobj.AddProperty("id", "objects/not-initialized");
+ jsobj.AddFixedServiceId("objects/not-initialized");
jsobj.AddProperty("valueAsString", "<not initialized>");
return;
} else if (raw() == Object::transition_sentinel().raw()) {
jsobj.AddProperty("type", "Sentinel");
- jsobj.AddProperty("id", "objects/being-initialized");
+ jsobj.AddFixedServiceId("objects/being-initialized");
jsobj.AddProperty("valueAsString", "<being initialized>");
return;
}
AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (IsClosure()) {
jsobj.AddProperty("function", Function::Handle(Closure::function(*this)));
jsobj.AddProperty("context", Context::Handle(Closure::context(*this)));
@@ -15246,10 +15243,10 @@ void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
ASSERT(id >= 0);
intptr_t cid = type_cls.id();
- jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id);
+ jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id);
jsobj.AddProperty("typeClass", type_cls);
} else {
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
}
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
@@ -15432,7 +15429,7 @@ void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -15666,7 +15663,7 @@ void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -15882,7 +15879,7 @@ void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
const String& user_name = String::Handle(PrettyName());
const String& vm_name = String::Handle(Name());
AddNameProperties(&jsobj, user_name, vm_name);
@@ -15985,7 +15982,7 @@ void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "int", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
jsobj.AddProperty("valueAsString", ToCString());
}
@@ -16414,7 +16411,7 @@ void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "int", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddPropertyF("id", "objects/int-%" Pd "", Value());
+ jsobj.AddFixedServiceId("objects/int-%" Pd "", Value());
jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
}
@@ -16678,7 +16675,7 @@ void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
// "Double". Return "double" instead.
AddTypeProperties(&jsobj, "double", "double", ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
jsobj.AddProperty("valueAsString", ToCString());
}
@@ -18263,13 +18260,13 @@ void String::PrintJSONImpl(JSONStream* stream, bool ref) const {
// special string in their program. Fixing this involves updating
// the debugging api a bit.
jsobj.AddProperty("type", "Sentinel");
- jsobj.AddProperty("id", "objects/optimized-out");
+ jsobj.AddFixedServiceId("objects/optimized-out");
jsobj.AddProperty("valueAsString", "<optimized out>");
return;
}
AddTypeProperties(&jsobj, "String", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128);
if (did_truncate) {
@@ -19180,7 +19177,7 @@ void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const {
// "Bool". Return "bool" instead.
AddTypeProperties(&jsobj, "bool", "bool", ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddPropertyF("id", "objects/bool-%s", str);
+ jsobj.AddFixedServiceId("objects/bool-%s", str);
jsobj.AddPropertyF("valueAsString", "%s", str);
}
@@ -19292,7 +19289,7 @@ void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "List", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
jsobj.AddProperty("length", Length());
if (ref) {
return;
@@ -19543,7 +19540,7 @@ void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "List", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
jsobj.AddProperty("length", Length());
if (ref) {
return;
@@ -20591,7 +20588,7 @@ void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
return;
}
@@ -20662,7 +20659,7 @@ void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
PrintSharedInstanceJSON(&jsobj, ref);
- jsobj.AddServiceId("id", *this);
+ jsobj.AddServiceId(*this);
if (ref) {
return;
« no previous file with comments | « runtime/vm/metrics_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698