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

Side by Side Diff: runtime/vm/object.cc

Issue 1132323002: Add Service ID zones to service protocol (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/object_id_ring.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 14 matching lines...) Expand all
25 #include "vm/disassembler.h" 25 #include "vm/disassembler.h"
26 #include "vm/double_conversion.h" 26 #include "vm/double_conversion.h"
27 #include "vm/exceptions.h" 27 #include "vm/exceptions.h"
28 #include "vm/flow_graph_builder.h" 28 #include "vm/flow_graph_builder.h"
29 #include "vm/flow_graph_compiler.h" 29 #include "vm/flow_graph_compiler.h"
30 #include "vm/growable_array.h" 30 #include "vm/growable_array.h"
31 #include "vm/hash_table.h" 31 #include "vm/hash_table.h"
32 #include "vm/heap.h" 32 #include "vm/heap.h"
33 #include "vm/intermediate_language.h" 33 #include "vm/intermediate_language.h"
34 #include "vm/intrinsifier.h" 34 #include "vm/intrinsifier.h"
35 #include "vm/object_id_ring.h"
36 #include "vm/object_store.h" 35 #include "vm/object_store.h"
37 #include "vm/parser.h" 36 #include "vm/parser.h"
38 #include "vm/report.h" 37 #include "vm/report.h"
39 #include "vm/reusable_handles.h" 38 #include "vm/reusable_handles.h"
40 #include "vm/runtime_entry.h" 39 #include "vm/runtime_entry.h"
41 #include "vm/scopes.h" 40 #include "vm/scopes.h"
42 #include "vm/stack_frame.h" 41 #include "vm/stack_frame.h"
43 #include "vm/symbols.h" 42 #include "vm/symbols.h"
44 #include "vm/tags.h" 43 #include "vm/tags.h"
45 #include "vm/timer.h" 44 #include "vm/timer.h"
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 } 1593 }
1595 } else { 1594 } else {
1596 PrintJSONImpl(stream, ref); 1595 PrintJSONImpl(stream, ref);
1597 } 1596 }
1598 } 1597 }
1599 1598
1600 1599
1601 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { 1600 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
1602 JSONObject jsobj(stream); 1601 JSONObject jsobj(stream);
1603 AddTypeProperties(&jsobj, "Object", JSONType(), ref); 1602 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
1604 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 1603 jsobj.AddServiceId("id", *this);
1605 const intptr_t id = ring->GetIdForObject(raw());
1606 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
1607 if (ref) { 1604 if (ref) {
1608 return; 1605 return;
1609 } 1606 }
1610 Class& cls = Class::Handle(this->clazz()); 1607 Class& cls = Class::Handle(this->clazz());
1611 jsobj.AddProperty("class", cls); 1608 jsobj.AddProperty("class", cls);
1612 jsobj.AddProperty("size", raw()->Size()); 1609 jsobj.AddProperty("size", raw()->Size());
1613 } 1610 }
1614 1611
1615 1612
1616 RawString* Object::DictionaryName() const { 1613 RawString* Object::DictionaryName() const {
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
4413 4410
4414 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { 4411 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
4415 JSONObject jsobj(stream); 4412 JSONObject jsobj(stream);
4416 // The index in the canonical_type_arguments table cannot be used as part of 4413 // The index in the canonical_type_arguments table cannot be used as part of
4417 // the object id (as in typearguments/id), because the indices are not 4414 // the object id (as in typearguments/id), because the indices are not
4418 // preserved when the table grows and the entries get rehashed. Use the ring. 4415 // preserved when the table grows and the entries get rehashed. Use the ring.
4419 Isolate* isolate = Isolate::Current(); 4416 Isolate* isolate = Isolate::Current();
4420 ObjectStore* object_store = isolate->object_store(); 4417 ObjectStore* object_store = isolate->object_store();
4421 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 4418 const Array& table = Array::Handle(object_store->canonical_type_arguments());
4422 ASSERT(table.Length() > 0); 4419 ASSERT(table.Length() > 0);
4423 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
4424 const intptr_t id = ring->GetIdForObject(raw());
4425 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref); 4420 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref);
4426 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 4421 jsobj.AddServiceId("id", *this);
4427 const String& user_name = String::Handle(PrettyName()); 4422 const String& user_name = String::Handle(PrettyName());
4428 const String& vm_name = String::Handle(Name()); 4423 const String& vm_name = String::Handle(Name());
4429 AddNameProperties(&jsobj, user_name, vm_name); 4424 AddNameProperties(&jsobj, user_name, vm_name);
4430 if (ref) { 4425 if (ref) {
4431 return; 4426 return;
4432 } 4427 }
4433 { 4428 {
4434 JSONArray jsarr(&jsobj, "types"); 4429 JSONArray jsarr(&jsobj, "types");
4435 AbstractType& type_arg = AbstractType::Handle(); 4430 AbstractType& type_arg = AbstractType::Handle();
4436 for (intptr_t i = 0; i < Length(); i++) { 4431 for (intptr_t i = 0; i < Length(); i++) {
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
6803 const char* function_name = String::Handle(name()).ToCString(); 6798 const char* function_name = String::Handle(name()).ToCString();
6804 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 6799 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
6805 static_str, abstract_str, kind_str, const_str) + 1; 6800 static_str, abstract_str, kind_str, const_str) + 1;
6806 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6801 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6807 OS::SNPrint(chars, len, kFormat, function_name, 6802 OS::SNPrint(chars, len, kFormat, function_name,
6808 static_str, abstract_str, kind_str, const_str); 6803 static_str, abstract_str, kind_str, const_str);
6809 return chars; 6804 return chars;
6810 } 6805 }
6811 6806
6812 6807
6813 static const char* GetFunctionServiceId(const Function& f, const Class& cls) { 6808 static void AddFunctionServiceId(const JSONObject& jsobj,
6814 Zone* zone = Isolate::Current()->current_zone(); 6809 const Function& f,
6810 const Class& cls) {
6815 // Special kinds of functions use indices in their respective lists. 6811 // Special kinds of functions use indices in their respective lists.
6816 intptr_t id = -1; 6812 intptr_t id = -1;
6817 const char* selector = NULL; 6813 const char* selector = NULL;
6818 if (f.IsNonImplicitClosureFunction()) { 6814 if (f.IsNonImplicitClosureFunction()) {
6819 id = cls.FindClosureIndex(f); 6815 id = cls.FindClosureIndex(f);
6820 selector = "closures"; 6816 selector = "closures";
6821 } else if (f.IsImplicitClosureFunction()) { 6817 } else if (f.IsImplicitClosureFunction()) {
6822 id = cls.FindImplicitClosureFunctionIndex(f); 6818 id = cls.FindImplicitClosureFunctionIndex(f);
6823 selector = "implicit_closures"; 6819 selector = "implicit_closures";
6824 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { 6820 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) {
6825 id = cls.FindInvocationDispatcherFunctionIndex(f); 6821 id = cls.FindInvocationDispatcherFunctionIndex(f);
6826 selector = "dispatchers"; 6822 selector = "dispatchers";
6827 } 6823 }
6828 if (id != -1) { 6824 if (id != -1) {
6829 ASSERT(selector != NULL); 6825 ASSERT(selector != NULL);
6830 return zone->PrintToString("classes/%" Pd "/%s/%" Pd "", 6826 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "",
6831 cls.id(), selector, id); 6827 cls.id(), selector, id);
6828 return;
6832 } 6829 }
6833 // Regular functions known to their owner use their name (percent-encoded). 6830 // Regular functions known to their owner use their name (percent-encoded).
6834 String& name = String::Handle(f.name()); 6831 String& name = String::Handle(f.name());
6835 if (cls.LookupFunction(name) == f.raw()) { 6832 if (cls.LookupFunction(name) == f.raw()) {
6836 name = String::EncodeIRI(name); 6833 name = String::EncodeIRI(name);
6837 return zone->PrintToString("classes/%" Pd "/functions/%s", 6834 jsobj.AddPropertyF("id", "classes/%" Pd "/functions/%s",
6838 cls.id(), name.ToCString()); 6835 cls.id(), name.ToCString());
6836 return;
6839 } 6837 }
6840 // Oddball functions (not known to their owner) fall back to use the object 6838 // Oddball functions (not known to their owner) fall back to use the object
6841 // id ring. Current known examples are signature functions of closures 6839 // id ring. Current known examples are signature functions of closures
6842 // and stubs like 'megamorphic_miss'. 6840 // and stubs like 'megamorphic_miss'.
6843 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 6841 jsobj.AddServiceId("id", f);
6844 id = ring->GetIdForObject(f.raw());
6845 return zone->PrintToString("objects/%" Pd "", id);
6846 } 6842 }
6847 6843
6848 6844
6849 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { 6845 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
6850 Class& cls = Class::Handle(Owner()); 6846 Class& cls = Class::Handle(Owner());
6851 ASSERT(!cls.IsNull()); 6847 ASSERT(!cls.IsNull());
6852 Error& err = Error::Handle(); 6848 Error& err = Error::Handle();
6853 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6849 err ^= cls.EnsureIsFinalized(Isolate::Current());
6854 ASSERT(err.IsNull()); 6850 ASSERT(err.IsNull());
6855 JSONObject jsobj(stream); 6851 JSONObject jsobj(stream);
6856 AddTypeProperties(&jsobj, "Function", JSONType(), ref); 6852 AddTypeProperties(&jsobj, "Function", JSONType(), ref);
6857 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); 6853 AddFunctionServiceId(jsobj, *this, cls);
6858 const String& user_name = String::Handle(PrettyName()); 6854 const String& user_name = String::Handle(PrettyName());
6859 const String& vm_name = String::Handle(name()); 6855 const String& vm_name = String::Handle(name());
6860 AddNameProperties(&jsobj, user_name, vm_name); 6856 AddNameProperties(&jsobj, user_name, vm_name);
6861 const Function& parent = Function::Handle(parent_function()); 6857 const Function& parent = Function::Handle(parent_function());
6862 if (!parent.IsNull()) { 6858 if (!parent.IsNull()) {
6863 jsobj.AddProperty("owner", parent); 6859 jsobj.AddProperty("owner", parent);
6864 } else if (cls.IsTopLevel()) { 6860 } else if (cls.IsTopLevel()) {
6865 const Library& library = Library::Handle(cls.library()); 6861 const Library& library = Library::Handle(cls.library());
6866 jsobj.AddProperty("owner", library); 6862 jsobj.AddProperty("owner", library);
6867 } else { 6863 } else {
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7991 const char* TokenStream::ToCString() const { 7987 const char* TokenStream::ToCString() const {
7992 return "TokenStream"; 7988 return "TokenStream";
7993 } 7989 }
7994 7990
7995 7991
7996 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { 7992 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const {
7997 JSONObject jsobj(stream); 7993 JSONObject jsobj(stream);
7998 AddTypeProperties(&jsobj, "Object", JSONType(), ref); 7994 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
7999 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off 7995 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off
8000 // a Script object but do not have a back reference to generate a stable id. 7996 // a Script object but do not have a back reference to generate a stable id.
8001 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 7997 jsobj.AddServiceId("id", *this);
8002 const intptr_t id = ring->GetIdForObject(raw());
8003 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
8004 if (ref) { 7998 if (ref) {
8005 return; 7999 return;
8006 } 8000 }
8007 Class& cls = Class::Handle(this->clazz()); 8001 Class& cls = Class::Handle(this->clazz());
8008 jsobj.AddProperty("class", cls); 8002 jsobj.AddProperty("class", cls);
8009 jsobj.AddProperty("size", raw()->Size()); 8003 jsobj.AddProperty("size", raw()->Size());
8010 const String& private_key = String::Handle(PrivateKey()); 8004 const String& private_key = String::Handle(PrivateKey());
8011 jsobj.AddProperty("privateKey", private_key); 8005 jsobj.AddProperty("privateKey", private_key);
8012 // TODO(johnmccutchan): Add support for printing LiteralTokens and add 8006 // TODO(johnmccutchan): Add support for printing LiteralTokens and add
8013 // them to members array. 8007 // them to members array.
(...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
10694 iter.TryIndex()); 10688 iter.TryIndex());
10695 } 10689 }
10696 return buffer; 10690 return buffer;
10697 } 10691 }
10698 10692
10699 10693
10700 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { 10694 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
10701 AddTypeProperties(jsobj, "Object", JSONType(), ref); 10695 AddTypeProperties(jsobj, "Object", JSONType(), ref);
10702 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code 10696 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
10703 // object but do not have a back reference to generate an ID. 10697 // object but do not have a back reference to generate an ID.
10704 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10698 jsobj->AddServiceId("id", *this);
10705 const intptr_t id = ring->GetIdForObject(raw());
10706 jsobj->AddPropertyF("id", "objects/%" Pd "", id);
10707 if (ref) { 10699 if (ref) {
10708 return; 10700 return;
10709 } 10701 }
10710 Class& cls = Class::Handle(this->clazz()); 10702 Class& cls = Class::Handle(this->clazz());
10711 jsobj->AddProperty("class", cls); 10703 jsobj->AddProperty("class", cls);
10712 jsobj->AddProperty("size", raw()->Size()); 10704 jsobj->AddProperty("size", raw()->Size());
10713 JSONArray members(jsobj, "members"); 10705 JSONArray members(jsobj, "members");
10714 Iterator iter(*this, RawPcDescriptors::kAnyKind); 10706 Iterator iter(*this, RawPcDescriptors::kAnyKind);
10715 while (iter.MoveNext()) { 10707 while (iter.MoveNext()) {
10716 JSONObject descriptor(&members); 10708 JSONObject descriptor(&members);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
10977 return buffer; 10969 return buffer;
10978 } 10970 }
10979 10971
10980 10972
10981 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, 10973 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream,
10982 bool ref) const { 10974 bool ref) const {
10983 JSONObject jsobj(stream); 10975 JSONObject jsobj(stream);
10984 AddTypeProperties(&jsobj, "Object", JSONType(), ref); 10976 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
10985 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off 10977 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off
10986 // a Code object but do not have a back reference to generate an ID. 10978 // a Code object but do not have a back reference to generate an ID.
10987 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10979 jsobj.AddServiceId("id", *this);
10988 const intptr_t id = ring->GetIdForObject(raw());
10989 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
10990 if (ref) { 10980 if (ref) {
10991 return; 10981 return;
10992 } 10982 }
10993 Class& cls = Class::Handle(this->clazz()); 10983 Class& cls = Class::Handle(this->clazz());
10994 jsobj.AddProperty("class", cls); 10984 jsobj.AddProperty("class", cls);
10995 jsobj.AddProperty("size", raw()->Size()); 10985 jsobj.AddProperty("size", raw()->Size());
10996 JSONArray members(&jsobj, "members"); 10986 JSONArray members(&jsobj, "members");
10997 String& var_name = String::Handle(); 10987 String& var_name = String::Handle();
10998 for (intptr_t i = 0; i < Length(); i++) { 10988 for (intptr_t i = 0; i < Length(); i++) {
10999 RawLocalVarDescriptors::VarInfo info; 10989 RawLocalVarDescriptors::VarInfo info;
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
12876 IndentN(indent); 12866 IndentN(indent);
12877 OS::PrintErr("}\n"); 12867 OS::PrintErr("}\n");
12878 } 12868 }
12879 12869
12880 12870
12881 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { 12871 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
12882 JSONObject jsobj(stream); 12872 JSONObject jsobj(stream);
12883 // TODO(turnidge): Should the user level type for Context be Context 12873 // TODO(turnidge): Should the user level type for Context be Context
12884 // or Object? 12874 // or Object?
12885 AddTypeProperties(&jsobj, "Context", JSONType(), ref); 12875 AddTypeProperties(&jsobj, "Context", JSONType(), ref);
12886 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 12876 jsobj.AddServiceId("id", *this);
12887 const intptr_t id = ring->GetIdForObject(raw());
12888 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
12889 12877
12890 jsobj.AddProperty("length", num_variables()); 12878 jsobj.AddProperty("length", num_variables());
12891 12879
12892 if (ref) { 12880 if (ref) {
12893 return; 12881 return;
12894 } 12882 }
12895 12883
12896 Class& cls = Class::Handle(this->clazz()); 12884 Class& cls = Class::Handle(this->clazz());
12897 jsobj.AddProperty("class", cls); 12885 jsobj.AddProperty("class", cls);
12898 12886
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
14080 return; 14068 return;
14081 } else if (raw() == Object::transition_sentinel().raw()) { 14069 } else if (raw() == Object::transition_sentinel().raw()) {
14082 jsobj.AddProperty("type", "Sentinel"); 14070 jsobj.AddProperty("type", "Sentinel");
14083 jsobj.AddProperty("id", "objects/being-initialized"); 14071 jsobj.AddProperty("id", "objects/being-initialized");
14084 jsobj.AddProperty("valueAsString", "<being initialized>"); 14072 jsobj.AddProperty("valueAsString", "<being initialized>");
14085 return; 14073 return;
14086 } 14074 }
14087 14075
14088 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 14076 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
14089 PrintSharedInstanceJSON(&jsobj, ref); 14077 PrintSharedInstanceJSON(&jsobj, ref);
14090 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14078 jsobj.AddServiceId("id", *this);
14091 const intptr_t id = ring->GetIdForObject(raw());
14092 if (IsClosure()) { 14079 if (IsClosure()) {
14093 const Function& closureFunc = Function::Handle(Closure::function(*this)); 14080 const Function& closureFunc = Function::Handle(Closure::function(*this));
14094 jsobj.AddProperty("closureFunc", closureFunc); 14081 jsobj.AddProperty("closureFunc", closureFunc);
14095 const Context& closureCtxt = Context::Handle(Closure::context(*this)); 14082 const Context& closureCtxt = Context::Handle(Closure::context(*this));
14096 jsobj.AddProperty("closureCtxt", closureCtxt); 14083 jsobj.AddProperty("closureCtxt", closureCtxt);
14097 } 14084 }
14098 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
14099 if (ref) { 14085 if (ref) {
14100 return; 14086 return;
14101 } 14087 }
14102 } 14088 }
14103 14089
14104 14090
14105 bool AbstractType::IsResolved() const { 14091 bool AbstractType::IsResolved() const {
14106 // AbstractType is an abstract class. 14092 // AbstractType is an abstract class.
14107 UNREACHABLE(); 14093 UNREACHABLE();
14108 return false; 14094 return false;
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
15190 AddTypeProperties(&jsobj, "Type", JSONType(), ref); 15176 AddTypeProperties(&jsobj, "Type", JSONType(), ref);
15191 PrintSharedInstanceJSON(&jsobj, ref); 15177 PrintSharedInstanceJSON(&jsobj, ref);
15192 if (IsCanonical()) { 15178 if (IsCanonical()) {
15193 const Class& type_cls = Class::Handle(type_class()); 15179 const Class& type_cls = Class::Handle(type_class());
15194 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 15180 intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
15195 ASSERT(id >= 0); 15181 ASSERT(id >= 0);
15196 intptr_t cid = type_cls.id(); 15182 intptr_t cid = type_cls.id();
15197 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); 15183 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id);
15198 jsobj.AddProperty("typeClass", type_cls); 15184 jsobj.AddProperty("typeClass", type_cls);
15199 } else { 15185 } else {
15200 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15186 jsobj.AddServiceId("id", *this);
15201 const intptr_t id = ring->GetIdForObject(raw());
15202 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15203 } 15187 }
15204 const String& user_name = String::Handle(PrettyName()); 15188 const String& user_name = String::Handle(PrettyName());
15205 const String& vm_name = String::Handle(Name()); 15189 const String& vm_name = String::Handle(Name());
15206 AddNameProperties(&jsobj, user_name, vm_name); 15190 AddNameProperties(&jsobj, user_name, vm_name);
15207 if (ref) { 15191 if (ref) {
15208 return; 15192 return;
15209 } 15193 }
15210 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); 15194 const TypeArguments& typeArgs = TypeArguments::Handle(arguments());
15211 if (!typeArgs.IsNull()) { 15195 if (!typeArgs.IsNull()) {
15212 jsobj.AddProperty("typeArguments", typeArgs); 15196 jsobj.AddProperty("typeArguments", typeArgs);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
15375 OS::SNPrint(chars, len, format, type_cstr); 15359 OS::SNPrint(chars, len, format, type_cstr);
15376 return chars; 15360 return chars;
15377 } 15361 }
15378 } 15362 }
15379 15363
15380 15364
15381 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { 15365 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
15382 JSONObject jsobj(stream); 15366 JSONObject jsobj(stream);
15383 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); 15367 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref);
15384 PrintSharedInstanceJSON(&jsobj, ref); 15368 PrintSharedInstanceJSON(&jsobj, ref);
15385 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15369 jsobj.AddServiceId("id", *this);
15386 const intptr_t id = ring->GetIdForObject(raw());
15387 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15388 const String& user_name = String::Handle(PrettyName()); 15370 const String& user_name = String::Handle(PrettyName());
15389 const String& vm_name = String::Handle(Name()); 15371 const String& vm_name = String::Handle(Name());
15390 AddNameProperties(&jsobj, user_name, vm_name); 15372 AddNameProperties(&jsobj, user_name, vm_name);
15391 if (ref) { 15373 if (ref) {
15392 return; 15374 return;
15393 } 15375 }
15394 jsobj.AddProperty("refType", AbstractType::Handle(type())); 15376 jsobj.AddProperty("refType", AbstractType::Handle(type()));
15395 } 15377 }
15396 15378
15397 15379
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
15611 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15593 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15612 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); 15594 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr);
15613 return chars; 15595 return chars;
15614 } 15596 }
15615 15597
15616 15598
15617 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { 15599 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
15618 JSONObject jsobj(stream); 15600 JSONObject jsobj(stream);
15619 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); 15601 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref);
15620 PrintSharedInstanceJSON(&jsobj, ref); 15602 PrintSharedInstanceJSON(&jsobj, ref);
15621 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15603 jsobj.AddServiceId("id", *this);
15622 const intptr_t id = ring->GetIdForObject(raw());
15623 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15624 const String& user_name = String::Handle(PrettyName()); 15604 const String& user_name = String::Handle(PrettyName());
15625 const String& vm_name = String::Handle(Name()); 15605 const String& vm_name = String::Handle(Name());
15626 AddNameProperties(&jsobj, user_name, vm_name); 15606 AddNameProperties(&jsobj, user_name, vm_name);
15627 const Class& param_cls = Class::Handle(parameterized_class()); 15607 const Class& param_cls = Class::Handle(parameterized_class());
15628 jsobj.AddProperty("parameterizedClass", param_cls); 15608 jsobj.AddProperty("parameterizedClass", param_cls);
15629 if (ref) { 15609 if (ref) {
15630 return; 15610 return;
15631 } 15611 }
15632 jsobj.AddProperty("index", index()); 15612 jsobj.AddProperty("index", index());
15633 const AbstractType& upper_bound = AbstractType::Handle(bound()); 15613 const AbstractType& upper_bound = AbstractType::Handle(bound());
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
15829 OS::SNPrint( 15809 OS::SNPrint(
15830 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); 15810 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr);
15831 return chars; 15811 return chars;
15832 } 15812 }
15833 15813
15834 15814
15835 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { 15815 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const {
15836 JSONObject jsobj(stream); 15816 JSONObject jsobj(stream);
15837 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); 15817 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref);
15838 PrintSharedInstanceJSON(&jsobj, ref); 15818 PrintSharedInstanceJSON(&jsobj, ref);
15839 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15819 jsobj.AddServiceId("id", *this);
15840 const intptr_t id = ring->GetIdForObject(raw());
15841 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15842 const String& user_name = String::Handle(PrettyName()); 15820 const String& user_name = String::Handle(PrettyName());
15843 const String& vm_name = String::Handle(Name()); 15821 const String& vm_name = String::Handle(Name());
15844 AddNameProperties(&jsobj, user_name, vm_name); 15822 AddNameProperties(&jsobj, user_name, vm_name);
15845 if (ref) { 15823 if (ref) {
15846 return; 15824 return;
15847 } 15825 }
15848 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); 15826 jsobj.AddProperty("boundedType", AbstractType::Handle(type()));
15849 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); 15827 jsobj.AddProperty("upperBound", AbstractType::Handle(bound()));
15850 } 15828 }
15851 15829
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
15934 // Integer is an interface. No instances of Integer should exist. 15912 // Integer is an interface. No instances of Integer should exist.
15935 UNREACHABLE(); 15913 UNREACHABLE();
15936 return "Integer"; 15914 return "Integer";
15937 } 15915 }
15938 15916
15939 15917
15940 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { 15918 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
15941 JSONObject jsobj(stream); 15919 JSONObject jsobj(stream);
15942 AddTypeProperties(&jsobj, "int", JSONType(), ref); 15920 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15943 PrintSharedInstanceJSON(&jsobj, ref); 15921 PrintSharedInstanceJSON(&jsobj, ref);
15944 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15922 jsobj.AddServiceId("id", *this);
15945 const intptr_t id = ring->GetIdForObject(raw());
15946 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15947 jsobj.AddProperty("valueAsString", ToCString()); 15923 jsobj.AddProperty("valueAsString", ToCString());
15948 } 15924 }
15949 15925
15950 15926
15951 // Throw JavascriptIntegerOverflow exception. 15927 // Throw JavascriptIntegerOverflow exception.
15952 static void ThrowJavascriptIntegerOverflow(const Integer& i) { 15928 static void ThrowJavascriptIntegerOverflow(const Integer& i) {
15953 const Array& exc_args = Array::Handle(Array::New(1)); 15929 const Array& exc_args = Array::Handle(Array::New(1));
15954 const String& i_str = String::Handle(String::New(i.ToCString())); 15930 const String& i_str = String::Handle(String::New(i.ToCString()));
15955 exc_args.SetAt(0, i_str); 15931 exc_args.SetAt(0, i_str);
15956 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, 15932 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError,
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
16629 return buffer; 16605 return buffer;
16630 } 16606 }
16631 16607
16632 16608
16633 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { 16609 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
16634 JSONObject jsobj(stream); 16610 JSONObject jsobj(stream);
16635 // Suppress the fact that the internal vm name for this type is 16611 // Suppress the fact that the internal vm name for this type is
16636 // "Double". Return "double" instead. 16612 // "Double". Return "double" instead.
16637 AddTypeProperties(&jsobj, "double", "double", ref); 16613 AddTypeProperties(&jsobj, "double", "double", ref);
16638 PrintSharedInstanceJSON(&jsobj, ref); 16614 PrintSharedInstanceJSON(&jsobj, ref);
16639 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 16615 jsobj.AddServiceId("id", *this);
16640 const intptr_t id = ring->GetIdForObject(raw());
16641 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
16642 jsobj.AddProperty("valueAsString", ToCString()); 16616 jsobj.AddProperty("valueAsString", ToCString());
16643 } 16617 }
16644 16618
16645 16619
16646 bool Bigint::Neg() const { 16620 bool Bigint::Neg() const {
16647 return Bool::Handle(neg()).value(); 16621 return Bool::Handle(neg()).value();
16648 } 16622 }
16649 16623
16650 16624
16651 void Bigint::SetNeg(bool value) const { 16625 void Bigint::SetNeg(bool value) const {
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
18222 // TODO(turnidge): This is a hack. The user could have this 18196 // TODO(turnidge): This is a hack. The user could have this
18223 // special string in their program. Fixing this involves updating 18197 // special string in their program. Fixing this involves updating
18224 // the debugging api a bit. 18198 // the debugging api a bit.
18225 jsobj.AddProperty("type", "Sentinel"); 18199 jsobj.AddProperty("type", "Sentinel");
18226 jsobj.AddProperty("id", "objects/optimized-out"); 18200 jsobj.AddProperty("id", "objects/optimized-out");
18227 jsobj.AddProperty("valueAsString", "<optimized out>"); 18201 jsobj.AddProperty("valueAsString", "<optimized out>");
18228 return; 18202 return;
18229 } 18203 }
18230 AddTypeProperties(&jsobj, "String", JSONType(), ref); 18204 AddTypeProperties(&jsobj, "String", JSONType(), ref);
18231 PrintSharedInstanceJSON(&jsobj, ref); 18205 PrintSharedInstanceJSON(&jsobj, ref);
18232 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18206 jsobj.AddServiceId("id", *this);
18233 const intptr_t id = ring->GetIdForObject(raw());
18234 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18235 if (ref) { 18207 if (ref) {
18236 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); 18208 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128);
18237 if (did_truncate) { 18209 if (did_truncate) {
18238 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); 18210 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate);
18239 } 18211 }
18240 } else { 18212 } else {
18241 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); 18213 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this);
18242 ASSERT(!did_truncate); 18214 ASSERT(!did_truncate);
18243 } 18215 }
18244 } 18216 }
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
19247 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 19219 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
19248 OS::SNPrint(chars, len, format, Length()); 19220 OS::SNPrint(chars, len, format, Length());
19249 return chars; 19221 return chars;
19250 } 19222 }
19251 19223
19252 19224
19253 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { 19225 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
19254 JSONObject jsobj(stream); 19226 JSONObject jsobj(stream);
19255 AddTypeProperties(&jsobj, "List", JSONType(), ref); 19227 AddTypeProperties(&jsobj, "List", JSONType(), ref);
19256 PrintSharedInstanceJSON(&jsobj, ref); 19228 PrintSharedInstanceJSON(&jsobj, ref);
19257 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19229 jsobj.AddServiceId("id", *this);
19258 const intptr_t id = ring->GetIdForObject(raw());
19259 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19260 jsobj.AddProperty("length", Length()); 19230 jsobj.AddProperty("length", Length());
19261 if (ref) { 19231 if (ref) {
19262 return; 19232 return;
19263 } 19233 }
19264 { 19234 {
19265 JSONArray jsarr(&jsobj, "elements"); 19235 JSONArray jsarr(&jsobj, "elements");
19266 for (intptr_t index = 0; index < Length(); index++) { 19236 for (intptr_t index = 0; index < Length(); index++) {
19267 JSONObject jselement(&jsarr); 19237 JSONObject jselement(&jsarr);
19268 jselement.AddProperty("index", index); 19238 jselement.AddProperty("index", index);
19269 19239
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
19500 OS::SNPrint(chars, len, format, Length()); 19470 OS::SNPrint(chars, len, format, Length());
19501 return chars; 19471 return chars;
19502 } 19472 }
19503 19473
19504 19474
19505 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, 19475 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
19506 bool ref) const { 19476 bool ref) const {
19507 JSONObject jsobj(stream); 19477 JSONObject jsobj(stream);
19508 AddTypeProperties(&jsobj, "List", JSONType(), ref); 19478 AddTypeProperties(&jsobj, "List", JSONType(), ref);
19509 PrintSharedInstanceJSON(&jsobj, ref); 19479 PrintSharedInstanceJSON(&jsobj, ref);
19510 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19480 jsobj.AddServiceId("id", *this);
19511 const intptr_t id = ring->GetIdForObject(raw());
19512 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19513 jsobj.AddProperty("length", Length()); 19481 jsobj.AddProperty("length", Length());
19514 if (ref) { 19482 if (ref) {
19515 return; 19483 return;
19516 } 19484 }
19517 { 19485 {
19518 JSONArray jsarr(&jsobj, "elements"); 19486 JSONArray jsarr(&jsobj, "elements");
19519 for (intptr_t index = 0; index < Length(); index++) { 19487 for (intptr_t index = 0; index < Length(); index++) {
19520 JSONObject jselement(&jsarr); 19488 JSONObject jselement(&jsarr);
19521 jselement.AddProperty("index", index); 19489 jselement.AddProperty("index", index);
19522 19490
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
20550 20518
20551 const char* WeakProperty::ToCString() const { 20519 const char* WeakProperty::ToCString() const {
20552 return "_WeakProperty"; 20520 return "_WeakProperty";
20553 } 20521 }
20554 20522
20555 20523
20556 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { 20524 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
20557 JSONObject jsobj(stream); 20525 JSONObject jsobj(stream);
20558 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 20526 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
20559 PrintSharedInstanceJSON(&jsobj, ref); 20527 PrintSharedInstanceJSON(&jsobj, ref);
20560 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 20528 jsobj.AddServiceId("id", *this);
20561 const intptr_t id = ring->GetIdForObject(raw());
20562 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
20563
20564 if (ref) { 20529 if (ref) {
20565 return; 20530 return;
20566 } 20531 }
20567 20532
20568 const Object& key_handle = Object::Handle(key()); 20533 const Object& key_handle = Object::Handle(key());
20569 jsobj.AddProperty("key", key_handle); 20534 jsobj.AddProperty("key", key_handle);
20570 const Object& value_handle = Object::Handle(value()); 20535 const Object& value_handle = Object::Handle(value());
20571 jsobj.AddProperty("value", value_handle); 20536 jsobj.AddProperty("value", value_handle);
20572 } 20537 }
20573 20538
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
20624 20589
20625 const char* MirrorReference::ToCString() const { 20590 const char* MirrorReference::ToCString() const {
20626 return "_MirrorReference"; 20591 return "_MirrorReference";
20627 } 20592 }
20628 20593
20629 20594
20630 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { 20595 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
20631 JSONObject jsobj(stream); 20596 JSONObject jsobj(stream);
20632 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 20597 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
20633 PrintSharedInstanceJSON(&jsobj, ref); 20598 PrintSharedInstanceJSON(&jsobj, ref);
20634 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 20599 jsobj.AddServiceId("id", *this);
20635 const intptr_t id = ring->GetIdForObject(raw());
20636 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
20637 20600
20638 if (ref) { 20601 if (ref) {
20639 return; 20602 return;
20640 } 20603 }
20641 20604
20642 const Object& referent_handle = Object::Handle(referent()); 20605 const Object& referent_handle = Object::Handle(referent());
20643 jsobj.AddProperty("referent", referent_handle); 20606 jsobj.AddProperty("referent", referent_handle);
20644 } 20607 }
20645 20608
20646 20609
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
20771 return tag_label.ToCString(); 20734 return tag_label.ToCString();
20772 } 20735 }
20773 20736
20774 20737
20775 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20738 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20776 Instance::PrintJSONImpl(stream, ref); 20739 Instance::PrintJSONImpl(stream, ref);
20777 } 20740 }
20778 20741
20779 20742
20780 } // namespace dart 20743 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/object_id_ring.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698