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

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
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 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
6802 const char* function_name = String::Handle(name()).ToCString(); 6797 const char* function_name = String::Handle(name()).ToCString();
6803 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 6798 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
6804 static_str, abstract_str, kind_str, const_str) + 1; 6799 static_str, abstract_str, kind_str, const_str) + 1;
6805 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6800 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6806 OS::SNPrint(chars, len, kFormat, function_name, 6801 OS::SNPrint(chars, len, kFormat, function_name,
6807 static_str, abstract_str, kind_str, const_str); 6802 static_str, abstract_str, kind_str, const_str);
6808 return chars; 6803 return chars;
6809 } 6804 }
6810 6805
6811 6806
6812 static const char* GetFunctionServiceId(const Function& f, const Class& cls) { 6807 static void AddFunctionServiceId(const JSONObject& jsobj,
6813 Zone* zone = Isolate::Current()->current_zone(); 6808 const Function& f,
6809 const Class& cls) {
6814 // Special kinds of functions use indices in their respective lists. 6810 // Special kinds of functions use indices in their respective lists.
6815 intptr_t id = -1; 6811 intptr_t id = -1;
6816 const char* selector = NULL; 6812 const char* selector = NULL;
6817 if (f.IsNonImplicitClosureFunction()) { 6813 if (f.IsNonImplicitClosureFunction()) {
6818 id = cls.FindClosureIndex(f); 6814 id = cls.FindClosureIndex(f);
6819 selector = "closures"; 6815 selector = "closures";
6820 } else if (f.IsImplicitClosureFunction()) { 6816 } else if (f.IsImplicitClosureFunction()) {
6821 id = cls.FindImplicitClosureFunctionIndex(f); 6817 id = cls.FindImplicitClosureFunctionIndex(f);
6822 selector = "implicit_closures"; 6818 selector = "implicit_closures";
6823 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { 6819 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) {
6824 id = cls.FindInvocationDispatcherFunctionIndex(f); 6820 id = cls.FindInvocationDispatcherFunctionIndex(f);
6825 selector = "dispatchers"; 6821 selector = "dispatchers";
6826 } 6822 }
6827 if (id != -1) { 6823 if (id != -1) {
6828 ASSERT(selector != NULL); 6824 ASSERT(selector != NULL);
6829 return zone->PrintToString("classes/%" Pd "/%s/%" Pd "", 6825 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "",
6830 cls.id(), selector, id); 6826 cls.id(), selector, id);
6827 return;
6831 } 6828 }
6832 // Regular functions known to their owner use their name (percent-encoded). 6829 // Regular functions known to their owner use their name (percent-encoded).
6833 String& name = String::Handle(f.name()); 6830 String& name = String::Handle(f.name());
6834 if (cls.LookupFunction(name) == f.raw()) { 6831 if (cls.LookupFunction(name) == f.raw()) {
6835 name = String::EncodeIRI(name); 6832 name = String::EncodeIRI(name);
6836 return zone->PrintToString("classes/%" Pd "/functions/%s", 6833 jsobj.AddPropertyF("id", "classes/%" Pd "/functions/%s",
6837 cls.id(), name.ToCString()); 6834 cls.id(), name.ToCString());
6835 return;
6838 } 6836 }
6839 // Oddball functions (not known to their owner) fall back to use the object 6837 // Oddball functions (not known to their owner) fall back to use the object
6840 // id ring. Current known examples are signature functions of closures 6838 // id ring. Current known examples are signature functions of closures
6841 // and stubs like 'megamorphic_miss'. 6839 // and stubs like 'megamorphic_miss'.
6842 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 6840 jsobj.AddServiceId("id", f);
6843 id = ring->GetIdForObject(f.raw());
6844 return zone->PrintToString("objects/%" Pd "", id);
6845 } 6841 }
6846 6842
6847 6843
6848 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { 6844 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
6849 Class& cls = Class::Handle(Owner()); 6845 Class& cls = Class::Handle(Owner());
6850 ASSERT(!cls.IsNull()); 6846 ASSERT(!cls.IsNull());
6851 Error& err = Error::Handle(); 6847 Error& err = Error::Handle();
6852 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6848 err ^= cls.EnsureIsFinalized(Isolate::Current());
6853 ASSERT(err.IsNull()); 6849 ASSERT(err.IsNull());
6854 JSONObject jsobj(stream); 6850 JSONObject jsobj(stream);
6855 AddTypeProperties(&jsobj, "Function", JSONType(), ref); 6851 AddTypeProperties(&jsobj, "Function", JSONType(), ref);
6856 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); 6852 AddFunctionServiceId(jsobj, *this, cls);
6857 const String& user_name = String::Handle(PrettyName()); 6853 const String& user_name = String::Handle(PrettyName());
6858 const String& vm_name = String::Handle(name()); 6854 const String& vm_name = String::Handle(name());
6859 AddNameProperties(&jsobj, user_name, vm_name); 6855 AddNameProperties(&jsobj, user_name, vm_name);
6860 const Function& parent = Function::Handle(parent_function()); 6856 const Function& parent = Function::Handle(parent_function());
6861 if (!parent.IsNull()) { 6857 if (!parent.IsNull()) {
6862 jsobj.AddProperty("owner", parent); 6858 jsobj.AddProperty("owner", parent);
6863 } else if (cls.IsTopLevel()) { 6859 } else if (cls.IsTopLevel()) {
6864 const Library& library = Library::Handle(cls.library()); 6860 const Library& library = Library::Handle(cls.library());
6865 jsobj.AddProperty("owner", library); 6861 jsobj.AddProperty("owner", library);
6866 } else { 6862 } else {
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
7993 const char* TokenStream::ToCString() const { 7989 const char* TokenStream::ToCString() const {
7994 return "TokenStream"; 7990 return "TokenStream";
7995 } 7991 }
7996 7992
7997 7993
7998 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { 7994 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const {
7999 JSONObject jsobj(stream); 7995 JSONObject jsobj(stream);
8000 AddTypeProperties(&jsobj, "Object", JSONType(), ref); 7996 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
8001 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off 7997 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off
8002 // a Script object but do not have a back reference to generate a stable id. 7998 // a Script object but do not have a back reference to generate a stable id.
8003 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 7999 jsobj.AddServiceId("id", *this);
8004 const intptr_t id = ring->GetIdForObject(raw());
8005 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
8006 if (ref) { 8000 if (ref) {
8007 return; 8001 return;
8008 } 8002 }
8009 Class& cls = Class::Handle(this->clazz()); 8003 Class& cls = Class::Handle(this->clazz());
8010 jsobj.AddProperty("class", cls); 8004 jsobj.AddProperty("class", cls);
8011 jsobj.AddProperty("size", raw()->Size()); 8005 jsobj.AddProperty("size", raw()->Size());
8012 const String& private_key = String::Handle(PrivateKey()); 8006 const String& private_key = String::Handle(PrivateKey());
8013 jsobj.AddProperty("privateKey", private_key); 8007 jsobj.AddProperty("privateKey", private_key);
8014 // TODO(johnmccutchan): Add support for printing LiteralTokens and add 8008 // TODO(johnmccutchan): Add support for printing LiteralTokens and add
8015 // them to members array. 8009 // them to members array.
(...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after
10693 iter.TryIndex()); 10687 iter.TryIndex());
10694 } 10688 }
10695 return buffer; 10689 return buffer;
10696 } 10690 }
10697 10691
10698 10692
10699 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { 10693 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
10700 AddTypeProperties(jsobj, "Object", JSONType(), ref); 10694 AddTypeProperties(jsobj, "Object", JSONType(), ref);
10701 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code 10695 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
10702 // object but do not have a back reference to generate an ID. 10696 // object but do not have a back reference to generate an ID.
10703 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10697 jsobj->AddServiceId("id", *this);
10704 const intptr_t id = ring->GetIdForObject(raw());
10705 jsobj->AddPropertyF("id", "objects/%" Pd "", id);
10706 if (ref) { 10698 if (ref) {
10707 return; 10699 return;
10708 } 10700 }
10709 Class& cls = Class::Handle(this->clazz()); 10701 Class& cls = Class::Handle(this->clazz());
10710 jsobj->AddProperty("class", cls); 10702 jsobj->AddProperty("class", cls);
10711 jsobj->AddProperty("size", raw()->Size()); 10703 jsobj->AddProperty("size", raw()->Size());
10712 JSONArray members(jsobj, "members"); 10704 JSONArray members(jsobj, "members");
10713 Iterator iter(*this, RawPcDescriptors::kAnyKind); 10705 Iterator iter(*this, RawPcDescriptors::kAnyKind);
10714 while (iter.MoveNext()) { 10706 while (iter.MoveNext()) {
10715 JSONObject descriptor(&members); 10707 JSONObject descriptor(&members);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
10976 return buffer; 10968 return buffer;
10977 } 10969 }
10978 10970
10979 10971
10980 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, 10972 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream,
10981 bool ref) const { 10973 bool ref) const {
10982 JSONObject jsobj(stream); 10974 JSONObject jsobj(stream);
10983 AddTypeProperties(&jsobj, "Object", JSONType(), ref); 10975 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
10984 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off 10976 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off
10985 // a Code object but do not have a back reference to generate an ID. 10977 // a Code object but do not have a back reference to generate an ID.
10986 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10978 jsobj.AddServiceId("id", *this);
10987 const intptr_t id = ring->GetIdForObject(raw());
10988 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
10989 if (ref) { 10979 if (ref) {
10990 return; 10980 return;
10991 } 10981 }
10992 Class& cls = Class::Handle(this->clazz()); 10982 Class& cls = Class::Handle(this->clazz());
10993 jsobj.AddProperty("class", cls); 10983 jsobj.AddProperty("class", cls);
10994 jsobj.AddProperty("size", raw()->Size()); 10984 jsobj.AddProperty("size", raw()->Size());
10995 JSONArray members(&jsobj, "members"); 10985 JSONArray members(&jsobj, "members");
10996 String& var_name = String::Handle(); 10986 String& var_name = String::Handle();
10997 for (intptr_t i = 0; i < Length(); i++) { 10987 for (intptr_t i = 0; i < Length(); i++) {
10998 RawLocalVarDescriptors::VarInfo info; 10988 RawLocalVarDescriptors::VarInfo info;
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
12864 IndentN(indent); 12854 IndentN(indent);
12865 OS::PrintErr("}\n"); 12855 OS::PrintErr("}\n");
12866 } 12856 }
12867 12857
12868 12858
12869 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { 12859 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
12870 JSONObject jsobj(stream); 12860 JSONObject jsobj(stream);
12871 // TODO(turnidge): Should the user level type for Context be Context 12861 // TODO(turnidge): Should the user level type for Context be Context
12872 // or Object? 12862 // or Object?
12873 AddTypeProperties(&jsobj, "Context", JSONType(), ref); 12863 AddTypeProperties(&jsobj, "Context", JSONType(), ref);
12874 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 12864 jsobj.AddServiceId("id", *this);
12875 const intptr_t id = ring->GetIdForObject(raw());
12876 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
12877 12865
12878 jsobj.AddProperty("length", num_variables()); 12866 jsobj.AddProperty("length", num_variables());
12879 12867
12880 if (ref) { 12868 if (ref) {
12881 return; 12869 return;
12882 } 12870 }
12883 12871
12884 Class& cls = Class::Handle(this->clazz()); 12872 Class& cls = Class::Handle(this->clazz());
12885 jsobj.AddProperty("class", cls); 12873 jsobj.AddProperty("class", cls);
12886 12874
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
14068 return; 14056 return;
14069 } else if (raw() == Object::transition_sentinel().raw()) { 14057 } else if (raw() == Object::transition_sentinel().raw()) {
14070 jsobj.AddProperty("type", "Sentinel"); 14058 jsobj.AddProperty("type", "Sentinel");
14071 jsobj.AddProperty("id", "objects/being-initialized"); 14059 jsobj.AddProperty("id", "objects/being-initialized");
14072 jsobj.AddProperty("valueAsString", "<being initialized>"); 14060 jsobj.AddProperty("valueAsString", "<being initialized>");
14073 return; 14061 return;
14074 } 14062 }
14075 14063
14076 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 14064 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
14077 PrintSharedInstanceJSON(&jsobj, ref); 14065 PrintSharedInstanceJSON(&jsobj, ref);
14078 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14066 jsobj.AddServiceId("id", *this);
14079 const intptr_t id = ring->GetIdForObject(raw());
14080 if (IsClosure()) { 14067 if (IsClosure()) {
14081 const Function& closureFunc = Function::Handle(Closure::function(*this)); 14068 const Function& closureFunc = Function::Handle(Closure::function(*this));
14082 jsobj.AddProperty("closureFunc", closureFunc); 14069 jsobj.AddProperty("closureFunc", closureFunc);
14083 const Context& closureCtxt = Context::Handle(Closure::context(*this)); 14070 const Context& closureCtxt = Context::Handle(Closure::context(*this));
14084 jsobj.AddProperty("closureCtxt", closureCtxt); 14071 jsobj.AddProperty("closureCtxt", closureCtxt);
14085 } 14072 }
14086 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
14087 if (ref) { 14073 if (ref) {
14088 return; 14074 return;
14089 } 14075 }
14090 } 14076 }
14091 14077
14092 14078
14093 bool AbstractType::IsResolved() const { 14079 bool AbstractType::IsResolved() const {
14094 // AbstractType is an abstract class. 14080 // AbstractType is an abstract class.
14095 UNREACHABLE(); 14081 UNREACHABLE();
14096 return false; 14082 return false;
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
15178 AddTypeProperties(&jsobj, "Type", JSONType(), ref); 15164 AddTypeProperties(&jsobj, "Type", JSONType(), ref);
15179 PrintSharedInstanceJSON(&jsobj, ref); 15165 PrintSharedInstanceJSON(&jsobj, ref);
15180 if (IsCanonical()) { 15166 if (IsCanonical()) {
15181 const Class& type_cls = Class::Handle(type_class()); 15167 const Class& type_cls = Class::Handle(type_class());
15182 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 15168 intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
15183 ASSERT(id >= 0); 15169 ASSERT(id >= 0);
15184 intptr_t cid = type_cls.id(); 15170 intptr_t cid = type_cls.id();
15185 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); 15171 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id);
15186 jsobj.AddProperty("typeClass", type_cls); 15172 jsobj.AddProperty("typeClass", type_cls);
15187 } else { 15173 } else {
15188 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15174 jsobj.AddServiceId("id", *this);
15189 const intptr_t id = ring->GetIdForObject(raw());
15190 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15191 } 15175 }
15192 const String& user_name = String::Handle(PrettyName()); 15176 const String& user_name = String::Handle(PrettyName());
15193 const String& vm_name = String::Handle(Name()); 15177 const String& vm_name = String::Handle(Name());
15194 AddNameProperties(&jsobj, user_name, vm_name); 15178 AddNameProperties(&jsobj, user_name, vm_name);
15195 if (ref) { 15179 if (ref) {
15196 return; 15180 return;
15197 } 15181 }
15198 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); 15182 const TypeArguments& typeArgs = TypeArguments::Handle(arguments());
15199 if (!typeArgs.IsNull()) { 15183 if (!typeArgs.IsNull()) {
15200 jsobj.AddProperty("typeArguments", typeArgs); 15184 jsobj.AddProperty("typeArguments", typeArgs);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
15363 OS::SNPrint(chars, len, format, type_cstr); 15347 OS::SNPrint(chars, len, format, type_cstr);
15364 return chars; 15348 return chars;
15365 } 15349 }
15366 } 15350 }
15367 15351
15368 15352
15369 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { 15353 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
15370 JSONObject jsobj(stream); 15354 JSONObject jsobj(stream);
15371 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); 15355 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref);
15372 PrintSharedInstanceJSON(&jsobj, ref); 15356 PrintSharedInstanceJSON(&jsobj, ref);
15373 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15357 jsobj.AddServiceId("id", *this);
15374 const intptr_t id = ring->GetIdForObject(raw());
15375 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15376 const String& user_name = String::Handle(PrettyName()); 15358 const String& user_name = String::Handle(PrettyName());
15377 const String& vm_name = String::Handle(Name()); 15359 const String& vm_name = String::Handle(Name());
15378 AddNameProperties(&jsobj, user_name, vm_name); 15360 AddNameProperties(&jsobj, user_name, vm_name);
15379 if (ref) { 15361 if (ref) {
15380 return; 15362 return;
15381 } 15363 }
15382 jsobj.AddProperty("refType", AbstractType::Handle(type())); 15364 jsobj.AddProperty("refType", AbstractType::Handle(type()));
15383 } 15365 }
15384 15366
15385 15367
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
15599 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15581 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15600 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); 15582 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr);
15601 return chars; 15583 return chars;
15602 } 15584 }
15603 15585
15604 15586
15605 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { 15587 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
15606 JSONObject jsobj(stream); 15588 JSONObject jsobj(stream);
15607 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); 15589 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref);
15608 PrintSharedInstanceJSON(&jsobj, ref); 15590 PrintSharedInstanceJSON(&jsobj, ref);
15609 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15591 jsobj.AddServiceId("id", *this);
15610 const intptr_t id = ring->GetIdForObject(raw());
15611 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15612 const String& user_name = String::Handle(PrettyName()); 15592 const String& user_name = String::Handle(PrettyName());
15613 const String& vm_name = String::Handle(Name()); 15593 const String& vm_name = String::Handle(Name());
15614 AddNameProperties(&jsobj, user_name, vm_name); 15594 AddNameProperties(&jsobj, user_name, vm_name);
15615 const Class& param_cls = Class::Handle(parameterized_class()); 15595 const Class& param_cls = Class::Handle(parameterized_class());
15616 jsobj.AddProperty("parameterizedClass", param_cls); 15596 jsobj.AddProperty("parameterizedClass", param_cls);
15617 if (ref) { 15597 if (ref) {
15618 return; 15598 return;
15619 } 15599 }
15620 jsobj.AddProperty("index", index()); 15600 jsobj.AddProperty("index", index());
15621 const AbstractType& upper_bound = AbstractType::Handle(bound()); 15601 const AbstractType& upper_bound = AbstractType::Handle(bound());
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
15817 OS::SNPrint( 15797 OS::SNPrint(
15818 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); 15798 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr);
15819 return chars; 15799 return chars;
15820 } 15800 }
15821 15801
15822 15802
15823 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { 15803 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const {
15824 JSONObject jsobj(stream); 15804 JSONObject jsobj(stream);
15825 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); 15805 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref);
15826 PrintSharedInstanceJSON(&jsobj, ref); 15806 PrintSharedInstanceJSON(&jsobj, ref);
15827 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15807 jsobj.AddServiceId("id", *this);
15828 const intptr_t id = ring->GetIdForObject(raw());
15829 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15830 const String& user_name = String::Handle(PrettyName()); 15808 const String& user_name = String::Handle(PrettyName());
15831 const String& vm_name = String::Handle(Name()); 15809 const String& vm_name = String::Handle(Name());
15832 AddNameProperties(&jsobj, user_name, vm_name); 15810 AddNameProperties(&jsobj, user_name, vm_name);
15833 if (ref) { 15811 if (ref) {
15834 return; 15812 return;
15835 } 15813 }
15836 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); 15814 jsobj.AddProperty("boundedType", AbstractType::Handle(type()));
15837 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); 15815 jsobj.AddProperty("upperBound", AbstractType::Handle(bound()));
15838 } 15816 }
15839 15817
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
15922 // Integer is an interface. No instances of Integer should exist. 15900 // Integer is an interface. No instances of Integer should exist.
15923 UNREACHABLE(); 15901 UNREACHABLE();
15924 return "Integer"; 15902 return "Integer";
15925 } 15903 }
15926 15904
15927 15905
15928 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { 15906 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
15929 JSONObject jsobj(stream); 15907 JSONObject jsobj(stream);
15930 AddTypeProperties(&jsobj, "int", JSONType(), ref); 15908 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15931 PrintSharedInstanceJSON(&jsobj, ref); 15909 PrintSharedInstanceJSON(&jsobj, ref);
15932 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15910 jsobj.AddServiceId("id", *this);
15933 const intptr_t id = ring->GetIdForObject(raw());
15934 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15935 jsobj.AddProperty("valueAsString", ToCString()); 15911 jsobj.AddProperty("valueAsString", ToCString());
15936 } 15912 }
15937 15913
15938 15914
15939 // Throw JavascriptIntegerOverflow exception. 15915 // Throw JavascriptIntegerOverflow exception.
15940 static void ThrowJavascriptIntegerOverflow(const Integer& i) { 15916 static void ThrowJavascriptIntegerOverflow(const Integer& i) {
15941 const Array& exc_args = Array::Handle(Array::New(1)); 15917 const Array& exc_args = Array::Handle(Array::New(1));
15942 const String& i_str = String::Handle(String::New(i.ToCString())); 15918 const String& i_str = String::Handle(String::New(i.ToCString()));
15943 exc_args.SetAt(0, i_str); 15919 exc_args.SetAt(0, i_str);
15944 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, 15920 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError,
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
16617 return buffer; 16593 return buffer;
16618 } 16594 }
16619 16595
16620 16596
16621 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { 16597 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
16622 JSONObject jsobj(stream); 16598 JSONObject jsobj(stream);
16623 // Suppress the fact that the internal vm name for this type is 16599 // Suppress the fact that the internal vm name for this type is
16624 // "Double". Return "double" instead. 16600 // "Double". Return "double" instead.
16625 AddTypeProperties(&jsobj, "double", "double", ref); 16601 AddTypeProperties(&jsobj, "double", "double", ref);
16626 PrintSharedInstanceJSON(&jsobj, ref); 16602 PrintSharedInstanceJSON(&jsobj, ref);
16627 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 16603 jsobj.AddServiceId("id", *this);
16628 const intptr_t id = ring->GetIdForObject(raw());
16629 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
16630 jsobj.AddProperty("valueAsString", ToCString()); 16604 jsobj.AddProperty("valueAsString", ToCString());
16631 } 16605 }
16632 16606
16633 16607
16634 bool Bigint::Neg() const { 16608 bool Bigint::Neg() const {
16635 return Bool::Handle(neg()).value(); 16609 return Bool::Handle(neg()).value();
16636 } 16610 }
16637 16611
16638 16612
16639 void Bigint::SetNeg(bool value) const { 16613 void Bigint::SetNeg(bool value) const {
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
18210 // TODO(turnidge): This is a hack. The user could have this 18184 // TODO(turnidge): This is a hack. The user could have this
18211 // special string in their program. Fixing this involves updating 18185 // special string in their program. Fixing this involves updating
18212 // the debugging api a bit. 18186 // the debugging api a bit.
18213 jsobj.AddProperty("type", "Sentinel"); 18187 jsobj.AddProperty("type", "Sentinel");
18214 jsobj.AddProperty("id", "objects/optimized-out"); 18188 jsobj.AddProperty("id", "objects/optimized-out");
18215 jsobj.AddProperty("valueAsString", "<optimized out>"); 18189 jsobj.AddProperty("valueAsString", "<optimized out>");
18216 return; 18190 return;
18217 } 18191 }
18218 AddTypeProperties(&jsobj, "String", JSONType(), ref); 18192 AddTypeProperties(&jsobj, "String", JSONType(), ref);
18219 PrintSharedInstanceJSON(&jsobj, ref); 18193 PrintSharedInstanceJSON(&jsobj, ref);
18220 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18194 jsobj.AddServiceId("id", *this);
18221 const intptr_t id = ring->GetIdForObject(raw());
18222 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18223 if (ref) { 18195 if (ref) {
18224 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); 18196 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128);
18225 if (did_truncate) { 18197 if (did_truncate) {
18226 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); 18198 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate);
18227 } 18199 }
18228 } else { 18200 } else {
18229 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); 18201 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this);
18230 ASSERT(!did_truncate); 18202 ASSERT(!did_truncate);
18231 } 18203 }
18232 } 18204 }
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
19235 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 19207 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
19236 OS::SNPrint(chars, len, format, Length()); 19208 OS::SNPrint(chars, len, format, Length());
19237 return chars; 19209 return chars;
19238 } 19210 }
19239 19211
19240 19212
19241 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { 19213 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
19242 JSONObject jsobj(stream); 19214 JSONObject jsobj(stream);
19243 AddTypeProperties(&jsobj, "List", JSONType(), ref); 19215 AddTypeProperties(&jsobj, "List", JSONType(), ref);
19244 PrintSharedInstanceJSON(&jsobj, ref); 19216 PrintSharedInstanceJSON(&jsobj, ref);
19245 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19217 jsobj.AddServiceId("id", *this);
19246 const intptr_t id = ring->GetIdForObject(raw());
19247 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19248 jsobj.AddProperty("length", Length()); 19218 jsobj.AddProperty("length", Length());
19249 if (ref) { 19219 if (ref) {
19250 return; 19220 return;
19251 } 19221 }
19252 { 19222 {
19253 JSONArray jsarr(&jsobj, "elements"); 19223 JSONArray jsarr(&jsobj, "elements");
19254 for (intptr_t index = 0; index < Length(); index++) { 19224 for (intptr_t index = 0; index < Length(); index++) {
19255 JSONObject jselement(&jsarr); 19225 JSONObject jselement(&jsarr);
19256 jselement.AddProperty("index", index); 19226 jselement.AddProperty("index", index);
19257 19227
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
19488 OS::SNPrint(chars, len, format, Length()); 19458 OS::SNPrint(chars, len, format, Length());
19489 return chars; 19459 return chars;
19490 } 19460 }
19491 19461
19492 19462
19493 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, 19463 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
19494 bool ref) const { 19464 bool ref) const {
19495 JSONObject jsobj(stream); 19465 JSONObject jsobj(stream);
19496 AddTypeProperties(&jsobj, "List", JSONType(), ref); 19466 AddTypeProperties(&jsobj, "List", JSONType(), ref);
19497 PrintSharedInstanceJSON(&jsobj, ref); 19467 PrintSharedInstanceJSON(&jsobj, ref);
19498 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19468 jsobj.AddServiceId("id", *this);
19499 const intptr_t id = ring->GetIdForObject(raw());
19500 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19501 jsobj.AddProperty("length", Length()); 19469 jsobj.AddProperty("length", Length());
19502 if (ref) { 19470 if (ref) {
19503 return; 19471 return;
19504 } 19472 }
19505 { 19473 {
19506 JSONArray jsarr(&jsobj, "elements"); 19474 JSONArray jsarr(&jsobj, "elements");
19507 for (intptr_t index = 0; index < Length(); index++) { 19475 for (intptr_t index = 0; index < Length(); index++) {
19508 JSONObject jselement(&jsarr); 19476 JSONObject jselement(&jsarr);
19509 jselement.AddProperty("index", index); 19477 jselement.AddProperty("index", index);
19510 19478
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
20538 20506
20539 const char* WeakProperty::ToCString() const { 20507 const char* WeakProperty::ToCString() const {
20540 return "_WeakProperty"; 20508 return "_WeakProperty";
20541 } 20509 }
20542 20510
20543 20511
20544 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { 20512 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
20545 JSONObject jsobj(stream); 20513 JSONObject jsobj(stream);
20546 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 20514 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
20547 PrintSharedInstanceJSON(&jsobj, ref); 20515 PrintSharedInstanceJSON(&jsobj, ref);
20548 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 20516 jsobj.AddServiceId("id", *this);
20549 const intptr_t id = ring->GetIdForObject(raw());
20550 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
20551
20552 if (ref) { 20517 if (ref) {
20553 return; 20518 return;
20554 } 20519 }
20555 20520
20556 const Object& key_handle = Object::Handle(key()); 20521 const Object& key_handle = Object::Handle(key());
20557 jsobj.AddProperty("key", key_handle); 20522 jsobj.AddProperty("key", key_handle);
20558 const Object& value_handle = Object::Handle(value()); 20523 const Object& value_handle = Object::Handle(value());
20559 jsobj.AddProperty("value", value_handle); 20524 jsobj.AddProperty("value", value_handle);
20560 } 20525 }
20561 20526
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
20612 20577
20613 const char* MirrorReference::ToCString() const { 20578 const char* MirrorReference::ToCString() const {
20614 return "_MirrorReference"; 20579 return "_MirrorReference";
20615 } 20580 }
20616 20581
20617 20582
20618 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { 20583 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
20619 JSONObject jsobj(stream); 20584 JSONObject jsobj(stream);
20620 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); 20585 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
20621 PrintSharedInstanceJSON(&jsobj, ref); 20586 PrintSharedInstanceJSON(&jsobj, ref);
20622 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 20587 jsobj.AddServiceId("id", *this);
20623 const intptr_t id = ring->GetIdForObject(raw());
20624 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
20625 20588
20626 if (ref) { 20589 if (ref) {
20627 return; 20590 return;
20628 } 20591 }
20629 20592
20630 const Object& referent_handle = Object::Handle(referent()); 20593 const Object& referent_handle = Object::Handle(referent());
20631 jsobj.AddProperty("referent", referent_handle); 20594 jsobj.AddProperty("referent", referent_handle);
20632 } 20595 }
20633 20596
20634 20597
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
20759 return tag_label.ToCString(); 20722 return tag_label.ToCString();
20760 } 20723 }
20761 20724
20762 20725
20763 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20726 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20764 Instance::PrintJSONImpl(stream, ref); 20727 Instance::PrintJSONImpl(stream, ref);
20765 } 20728 }
20766 20729
20767 20730
20768 } // namespace dart 20731 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698