Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index acf260b0e979bed29da4ba958564e47d96074f64..55b36fa9fcbb38f0c4c4e4f5adca9cbbdba197fa 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -32,7 +32,6 @@ |
| #include "vm/heap.h" |
| #include "vm/intermediate_language.h" |
| #include "vm/intrinsifier.h" |
| -#include "vm/object_id_ring.h" |
| #include "vm/object_store.h" |
| #include "vm/parser.h" |
| #include "vm/report.h" |
| @@ -1597,9 +1596,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); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
|
turnidge
2015/05/11 19:48:45
This is nicer.
|
| if (ref) { |
| return; |
| } |
| @@ -4416,10 +4413,8 @@ void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| ObjectStore* object_store = isolate->object_store(); |
| const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
| ASSERT(table.Length() > 0); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(Name()); |
| AddNameProperties(&jsobj, user_name, vm_name); |
| @@ -6805,8 +6800,9 @@ const char* Function::ToCString() const { |
| } |
| -static const char* GetFunctionServiceId(const Function& f, const Class& cls) { |
| - Zone* zone = Isolate::Current()->current_zone(); |
| +static void SetFunctionServiceId(const JSONObject& jsobj, |
|
turnidge
2015/05/11 19:48:45
AddFunctionServiceId or AddFunctionServiceIdProper
Cutch
2015/05/12 14:59:57
Done.
|
| + const Function& f, |
| + const Class& cls) { |
| // Special kinds of functions use indices in their respective lists. |
| intptr_t id = -1; |
| const char* selector = NULL; |
| @@ -6822,22 +6818,22 @@ static const char* GetFunctionServiceId(const Function& f, const Class& cls) { |
| } |
| if (id != -1) { |
| ASSERT(selector != NULL); |
| - return zone->PrintToString("classes/%" Pd "/%s/%" Pd "", |
| - cls.id(), selector, id); |
| + jsobj.AddPropertyF("id", "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); |
| - return zone->PrintToString("classes/%" Pd "/functions/%s", |
| - cls.id(), name.ToCString()); |
| + jsobj.AddPropertyF("id", "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'. |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - id = ring->GetIdForObject(f.raw()); |
| - return zone->PrintToString("objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", f); |
| } |
| @@ -6849,7 +6845,7 @@ void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| ASSERT(err.IsNull()); |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "Function", JSONType(), ref); |
| - jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); |
| + SetFunctionServiceId(jsobj, *this, cls); |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(name()); |
| AddNameProperties(&jsobj, user_name, vm_name); |
| @@ -7996,9 +7992,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. |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| if (ref) { |
| return; |
| } |
| @@ -10665,9 +10659,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. |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj->AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj->AddServiceId("id", *this); |
| if (ref) { |
| return; |
| } |
| @@ -10948,9 +10940,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. |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| if (ref) { |
| return; |
| } |
| @@ -12836,9 +12826,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); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| jsobj.AddProperty("length", num_variables()); |
| @@ -14040,15 +14028,13 @@ void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| + jsobj.AddServiceId("id", *this); |
| 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) { |
| return; |
| } |
| @@ -15150,9 +15136,7 @@ void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
| jsobj.AddProperty("typeClass", type_cls); |
| } else { |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| } |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(Name()); |
| @@ -15335,9 +15319,7 @@ void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(Name()); |
| AddNameProperties(&jsobj, user_name, vm_name); |
| @@ -15571,9 +15553,7 @@ void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(Name()); |
| AddNameProperties(&jsobj, user_name, vm_name); |
| @@ -15789,9 +15769,7 @@ void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| const String& user_name = String::Handle(PrettyName()); |
| const String& vm_name = String::Handle(Name()); |
| AddNameProperties(&jsobj, user_name, vm_name); |
| @@ -15894,9 +15872,7 @@ void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "int", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| jsobj.AddProperty("valueAsString", ToCString()); |
| } |
| @@ -16589,9 +16565,7 @@ void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| // "Double". Return "double" instead. |
| AddTypeProperties(&jsobj, "double", "double", ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| jsobj.AddProperty("valueAsString", ToCString()); |
| } |
| @@ -18182,9 +18156,7 @@ void String::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| } |
| AddTypeProperties(&jsobj, "String", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| if (ref) { |
| bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); |
| if (did_truncate) { |
| @@ -19207,9 +19179,7 @@ void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "List", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| jsobj.AddProperty("length", Length()); |
| if (ref) { |
| return; |
| @@ -19460,9 +19430,7 @@ void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "List", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| jsobj.AddProperty("length", Length()); |
| if (ref) { |
| return; |
| @@ -20510,10 +20478,7 @@ void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| - |
| + jsobj.AddServiceId("id", *this); |
| if (ref) { |
| return; |
| } |
| @@ -20584,9 +20549,7 @@ void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| JSONObject jsobj(stream); |
| AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
| PrintSharedInstanceJSON(&jsobj, ref); |
| - ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| - const intptr_t id = ring->GetIdForObject(raw()); |
| - jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| + jsobj.AddServiceId("id", *this); |
| if (ref) { |
| return; |