OLD | NEW |
---|---|
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 Loading... | |
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 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1590 } | 1589 } |
1591 } else { | 1590 } else { |
1592 PrintJSONImpl(stream, ref); | 1591 PrintJSONImpl(stream, ref); |
1593 } | 1592 } |
1594 } | 1593 } |
1595 | 1594 |
1596 | 1595 |
1597 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1596 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1598 JSONObject jsobj(stream); | 1597 JSONObject jsobj(stream); |
1599 AddTypeProperties(&jsobj, "Object", JSONType(), ref); | 1598 AddTypeProperties(&jsobj, "Object", JSONType(), ref); |
1600 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 1599 jsobj.AddServiceId("id", *this); |
turnidge
2015/05/11 19:48:45
This is nicer.
| |
1601 const intptr_t id = ring->GetIdForObject(raw()); | |
1602 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
1603 if (ref) { | 1600 if (ref) { |
1604 return; | 1601 return; |
1605 } | 1602 } |
1606 Class& cls = Class::Handle(this->clazz()); | 1603 Class& cls = Class::Handle(this->clazz()); |
1607 jsobj.AddProperty("class", cls); | 1604 jsobj.AddProperty("class", cls); |
1608 jsobj.AddProperty("size", raw()->Size()); | 1605 jsobj.AddProperty("size", raw()->Size()); |
1609 } | 1606 } |
1610 | 1607 |
1611 | 1608 |
1612 RawString* Object::DictionaryName() const { | 1609 RawString* Object::DictionaryName() const { |
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4409 | 4406 |
4410 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4407 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { |
4411 JSONObject jsobj(stream); | 4408 JSONObject jsobj(stream); |
4412 // The index in the canonical_type_arguments table cannot be used as part of | 4409 // The index in the canonical_type_arguments table cannot be used as part of |
4413 // the object id (as in typearguments/id), because the indices are not | 4410 // the object id (as in typearguments/id), because the indices are not |
4414 // preserved when the table grows and the entries get rehashed. Use the ring. | 4411 // preserved when the table grows and the entries get rehashed. Use the ring. |
4415 Isolate* isolate = Isolate::Current(); | 4412 Isolate* isolate = Isolate::Current(); |
4416 ObjectStore* object_store = isolate->object_store(); | 4413 ObjectStore* object_store = isolate->object_store(); |
4417 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 4414 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
4418 ASSERT(table.Length() > 0); | 4415 ASSERT(table.Length() > 0); |
4419 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
4420 const intptr_t id = ring->GetIdForObject(raw()); | |
4421 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref); | 4416 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref); |
4422 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 4417 jsobj.AddServiceId("id", *this); |
4423 const String& user_name = String::Handle(PrettyName()); | 4418 const String& user_name = String::Handle(PrettyName()); |
4424 const String& vm_name = String::Handle(Name()); | 4419 const String& vm_name = String::Handle(Name()); |
4425 AddNameProperties(&jsobj, user_name, vm_name); | 4420 AddNameProperties(&jsobj, user_name, vm_name); |
4426 if (ref) { | 4421 if (ref) { |
4427 return; | 4422 return; |
4428 } | 4423 } |
4429 { | 4424 { |
4430 JSONArray jsarr(&jsobj, "types"); | 4425 JSONArray jsarr(&jsobj, "types"); |
4431 AbstractType& type_arg = AbstractType::Handle(); | 4426 AbstractType& type_arg = AbstractType::Handle(); |
4432 for (intptr_t i = 0; i < Length(); i++) { | 4427 for (intptr_t i = 0; i < Length(); i++) { |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6798 const char* function_name = String::Handle(name()).ToCString(); | 6793 const char* function_name = String::Handle(name()).ToCString(); |
6799 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6794 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
6800 static_str, abstract_str, kind_str, const_str) + 1; | 6795 static_str, abstract_str, kind_str, const_str) + 1; |
6801 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6796 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
6802 OS::SNPrint(chars, len, kFormat, function_name, | 6797 OS::SNPrint(chars, len, kFormat, function_name, |
6803 static_str, abstract_str, kind_str, const_str); | 6798 static_str, abstract_str, kind_str, const_str); |
6804 return chars; | 6799 return chars; |
6805 } | 6800 } |
6806 | 6801 |
6807 | 6802 |
6808 static const char* GetFunctionServiceId(const Function& f, const Class& cls) { | 6803 static void SetFunctionServiceId(const JSONObject& jsobj, |
turnidge
2015/05/11 19:48:45
AddFunctionServiceId or AddFunctionServiceIdProper
Cutch
2015/05/12 14:59:57
Done.
| |
6809 Zone* zone = Isolate::Current()->current_zone(); | 6804 const Function& f, |
6805 const Class& cls) { | |
6810 // Special kinds of functions use indices in their respective lists. | 6806 // Special kinds of functions use indices in their respective lists. |
6811 intptr_t id = -1; | 6807 intptr_t id = -1; |
6812 const char* selector = NULL; | 6808 const char* selector = NULL; |
6813 if (f.IsNonImplicitClosureFunction()) { | 6809 if (f.IsNonImplicitClosureFunction()) { |
6814 id = cls.FindClosureIndex(f); | 6810 id = cls.FindClosureIndex(f); |
6815 selector = "closures"; | 6811 selector = "closures"; |
6816 } else if (f.IsImplicitClosureFunction()) { | 6812 } else if (f.IsImplicitClosureFunction()) { |
6817 id = cls.FindImplicitClosureFunctionIndex(f); | 6813 id = cls.FindImplicitClosureFunctionIndex(f); |
6818 selector = "implicit_closures"; | 6814 selector = "implicit_closures"; |
6819 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { | 6815 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { |
6820 id = cls.FindInvocationDispatcherFunctionIndex(f); | 6816 id = cls.FindInvocationDispatcherFunctionIndex(f); |
6821 selector = "dispatchers"; | 6817 selector = "dispatchers"; |
6822 } | 6818 } |
6823 if (id != -1) { | 6819 if (id != -1) { |
6824 ASSERT(selector != NULL); | 6820 ASSERT(selector != NULL); |
6825 return zone->PrintToString("classes/%" Pd "/%s/%" Pd "", | 6821 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", |
6826 cls.id(), selector, id); | 6822 cls.id(), selector, id); |
6823 return; | |
6827 } | 6824 } |
6828 // Regular functions known to their owner use their name (percent-encoded). | 6825 // Regular functions known to their owner use their name (percent-encoded). |
6829 String& name = String::Handle(f.name()); | 6826 String& name = String::Handle(f.name()); |
6830 if (cls.LookupFunction(name) == f.raw()) { | 6827 if (cls.LookupFunction(name) == f.raw()) { |
6831 name = String::EncodeIRI(name); | 6828 name = String::EncodeIRI(name); |
6832 return zone->PrintToString("classes/%" Pd "/functions/%s", | 6829 jsobj.AddPropertyF("id", "classes/%" Pd "/functions/%s", |
6833 cls.id(), name.ToCString()); | 6830 cls.id(), name.ToCString()); |
6831 return; | |
6834 } | 6832 } |
6835 // Oddball functions (not known to their owner) fall back to use the object | 6833 // Oddball functions (not known to their owner) fall back to use the object |
6836 // id ring. Current known examples are signature functions of closures | 6834 // id ring. Current known examples are signature functions of closures |
6837 // and stubs like 'megamorphic_miss'. | 6835 // and stubs like 'megamorphic_miss'. |
6838 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 6836 jsobj.AddServiceId("id", f); |
6839 id = ring->GetIdForObject(f.raw()); | |
6840 return zone->PrintToString("objects/%" Pd "", id); | |
6841 } | 6837 } |
6842 | 6838 |
6843 | 6839 |
6844 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 6840 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
6845 Class& cls = Class::Handle(Owner()); | 6841 Class& cls = Class::Handle(Owner()); |
6846 ASSERT(!cls.IsNull()); | 6842 ASSERT(!cls.IsNull()); |
6847 Error& err = Error::Handle(); | 6843 Error& err = Error::Handle(); |
6848 err ^= cls.EnsureIsFinalized(Isolate::Current()); | 6844 err ^= cls.EnsureIsFinalized(Isolate::Current()); |
6849 ASSERT(err.IsNull()); | 6845 ASSERT(err.IsNull()); |
6850 JSONObject jsobj(stream); | 6846 JSONObject jsobj(stream); |
6851 AddTypeProperties(&jsobj, "Function", JSONType(), ref); | 6847 AddTypeProperties(&jsobj, "Function", JSONType(), ref); |
6852 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); | 6848 SetFunctionServiceId(jsobj, *this, cls); |
6853 const String& user_name = String::Handle(PrettyName()); | 6849 const String& user_name = String::Handle(PrettyName()); |
6854 const String& vm_name = String::Handle(name()); | 6850 const String& vm_name = String::Handle(name()); |
6855 AddNameProperties(&jsobj, user_name, vm_name); | 6851 AddNameProperties(&jsobj, user_name, vm_name); |
6856 const Function& parent = Function::Handle(parent_function()); | 6852 const Function& parent = Function::Handle(parent_function()); |
6857 if (!parent.IsNull()) { | 6853 if (!parent.IsNull()) { |
6858 jsobj.AddProperty("owner", parent); | 6854 jsobj.AddProperty("owner", parent); |
6859 } else if (cls.IsTopLevel()) { | 6855 } else if (cls.IsTopLevel()) { |
6860 const Library& library = Library::Handle(cls.library()); | 6856 const Library& library = Library::Handle(cls.library()); |
6861 jsobj.AddProperty("owner", library); | 6857 jsobj.AddProperty("owner", library); |
6862 } else { | 6858 } else { |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7989 const char* TokenStream::ToCString() const { | 7985 const char* TokenStream::ToCString() const { |
7990 return "TokenStream"; | 7986 return "TokenStream"; |
7991 } | 7987 } |
7992 | 7988 |
7993 | 7989 |
7994 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { | 7990 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { |
7995 JSONObject jsobj(stream); | 7991 JSONObject jsobj(stream); |
7996 AddTypeProperties(&jsobj, "Object", JSONType(), ref); | 7992 AddTypeProperties(&jsobj, "Object", JSONType(), ref); |
7997 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off | 7993 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off |
7998 // a Script object but do not have a back reference to generate a stable id. | 7994 // a Script object but do not have a back reference to generate a stable id. |
7999 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 7995 jsobj.AddServiceId("id", *this); |
8000 const intptr_t id = ring->GetIdForObject(raw()); | |
8001 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
8002 if (ref) { | 7996 if (ref) { |
8003 return; | 7997 return; |
8004 } | 7998 } |
8005 Class& cls = Class::Handle(this->clazz()); | 7999 Class& cls = Class::Handle(this->clazz()); |
8006 jsobj.AddProperty("class", cls); | 8000 jsobj.AddProperty("class", cls); |
8007 jsobj.AddProperty("size", raw()->Size()); | 8001 jsobj.AddProperty("size", raw()->Size()); |
8008 const String& private_key = String::Handle(PrivateKey()); | 8002 const String& private_key = String::Handle(PrivateKey()); |
8009 jsobj.AddProperty("privateKey", private_key); | 8003 jsobj.AddProperty("privateKey", private_key); |
8010 // TODO(johnmccutchan): Add support for printing LiteralTokens and add | 8004 // TODO(johnmccutchan): Add support for printing LiteralTokens and add |
8011 // them to members array. | 8005 // them to members array. |
(...skipping 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10658 iter.TryIndex()); | 10652 iter.TryIndex()); |
10659 } | 10653 } |
10660 return buffer; | 10654 return buffer; |
10661 } | 10655 } |
10662 | 10656 |
10663 | 10657 |
10664 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | 10658 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
10665 AddTypeProperties(jsobj, "Object", JSONType(), ref); | 10659 AddTypeProperties(jsobj, "Object", JSONType(), ref); |
10666 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | 10660 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code |
10667 // object but do not have a back reference to generate an ID. | 10661 // object but do not have a back reference to generate an ID. |
10668 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 10662 jsobj->AddServiceId("id", *this); |
10669 const intptr_t id = ring->GetIdForObject(raw()); | |
10670 jsobj->AddPropertyF("id", "objects/%" Pd "", id); | |
10671 if (ref) { | 10663 if (ref) { |
10672 return; | 10664 return; |
10673 } | 10665 } |
10674 Class& cls = Class::Handle(this->clazz()); | 10666 Class& cls = Class::Handle(this->clazz()); |
10675 jsobj->AddProperty("class", cls); | 10667 jsobj->AddProperty("class", cls); |
10676 jsobj->AddProperty("size", raw()->Size()); | 10668 jsobj->AddProperty("size", raw()->Size()); |
10677 JSONArray members(jsobj, "members"); | 10669 JSONArray members(jsobj, "members"); |
10678 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 10670 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
10679 while (iter.MoveNext()) { | 10671 while (iter.MoveNext()) { |
10680 JSONObject descriptor(&members); | 10672 JSONObject descriptor(&members); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10941 return buffer; | 10933 return buffer; |
10942 } | 10934 } |
10943 | 10935 |
10944 | 10936 |
10945 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, | 10937 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, |
10946 bool ref) const { | 10938 bool ref) const { |
10947 JSONObject jsobj(stream); | 10939 JSONObject jsobj(stream); |
10948 AddTypeProperties(&jsobj, "Object", JSONType(), ref); | 10940 AddTypeProperties(&jsobj, "Object", JSONType(), ref); |
10949 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off | 10941 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off |
10950 // a Code object but do not have a back reference to generate an ID. | 10942 // a Code object but do not have a back reference to generate an ID. |
10951 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 10943 jsobj.AddServiceId("id", *this); |
10952 const intptr_t id = ring->GetIdForObject(raw()); | |
10953 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
10954 if (ref) { | 10944 if (ref) { |
10955 return; | 10945 return; |
10956 } | 10946 } |
10957 Class& cls = Class::Handle(this->clazz()); | 10947 Class& cls = Class::Handle(this->clazz()); |
10958 jsobj.AddProperty("class", cls); | 10948 jsobj.AddProperty("class", cls); |
10959 jsobj.AddProperty("size", raw()->Size()); | 10949 jsobj.AddProperty("size", raw()->Size()); |
10960 JSONArray members(&jsobj, "members"); | 10950 JSONArray members(&jsobj, "members"); |
10961 String& var_name = String::Handle(); | 10951 String& var_name = String::Handle(); |
10962 for (intptr_t i = 0; i < Length(); i++) { | 10952 for (intptr_t i = 0; i < Length(); i++) { |
10963 RawLocalVarDescriptors::VarInfo info; | 10953 RawLocalVarDescriptors::VarInfo info; |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12829 IndentN(indent); | 12819 IndentN(indent); |
12830 OS::PrintErr("}\n"); | 12820 OS::PrintErr("}\n"); |
12831 } | 12821 } |
12832 | 12822 |
12833 | 12823 |
12834 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { | 12824 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { |
12835 JSONObject jsobj(stream); | 12825 JSONObject jsobj(stream); |
12836 // TODO(turnidge): Should the user level type for Context be Context | 12826 // TODO(turnidge): Should the user level type for Context be Context |
12837 // or Object? | 12827 // or Object? |
12838 AddTypeProperties(&jsobj, "Context", JSONType(), ref); | 12828 AddTypeProperties(&jsobj, "Context", JSONType(), ref); |
12839 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 12829 jsobj.AddServiceId("id", *this); |
12840 const intptr_t id = ring->GetIdForObject(raw()); | |
12841 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
12842 | 12830 |
12843 jsobj.AddProperty("length", num_variables()); | 12831 jsobj.AddProperty("length", num_variables()); |
12844 | 12832 |
12845 if (ref) { | 12833 if (ref) { |
12846 return; | 12834 return; |
12847 } | 12835 } |
12848 | 12836 |
12849 Class& cls = Class::Handle(this->clazz()); | 12837 Class& cls = Class::Handle(this->clazz()); |
12850 jsobj.AddProperty("class", cls); | 12838 jsobj.AddProperty("class", cls); |
12851 | 12839 |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14033 return; | 14021 return; |
14034 } else if (raw() == Object::transition_sentinel().raw()) { | 14022 } else if (raw() == Object::transition_sentinel().raw()) { |
14035 jsobj.AddProperty("type", "Sentinel"); | 14023 jsobj.AddProperty("type", "Sentinel"); |
14036 jsobj.AddProperty("id", "objects/being-initialized"); | 14024 jsobj.AddProperty("id", "objects/being-initialized"); |
14037 jsobj.AddProperty("valueAsString", "<being initialized>"); | 14025 jsobj.AddProperty("valueAsString", "<being initialized>"); |
14038 return; | 14026 return; |
14039 } | 14027 } |
14040 | 14028 |
14041 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | 14029 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
14042 PrintSharedInstanceJSON(&jsobj, ref); | 14030 PrintSharedInstanceJSON(&jsobj, ref); |
14043 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14031 jsobj.AddServiceId("id", *this); |
14044 const intptr_t id = ring->GetIdForObject(raw()); | |
14045 if (IsClosure()) { | 14032 if (IsClosure()) { |
14046 const Function& closureFunc = Function::Handle(Closure::function(*this)); | 14033 const Function& closureFunc = Function::Handle(Closure::function(*this)); |
14047 jsobj.AddProperty("closureFunc", closureFunc); | 14034 jsobj.AddProperty("closureFunc", closureFunc); |
14048 const Context& closureCtxt = Context::Handle(Closure::context(*this)); | 14035 const Context& closureCtxt = Context::Handle(Closure::context(*this)); |
14049 jsobj.AddProperty("closureCtxt", closureCtxt); | 14036 jsobj.AddProperty("closureCtxt", closureCtxt); |
14050 } | 14037 } |
14051 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
14052 if (ref) { | 14038 if (ref) { |
14053 return; | 14039 return; |
14054 } | 14040 } |
14055 } | 14041 } |
14056 | 14042 |
14057 | 14043 |
14058 bool AbstractType::IsResolved() const { | 14044 bool AbstractType::IsResolved() const { |
14059 // AbstractType is an abstract class. | 14045 // AbstractType is an abstract class. |
14060 UNREACHABLE(); | 14046 UNREACHABLE(); |
14061 return false; | 14047 return false; |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15143 AddTypeProperties(&jsobj, "Type", JSONType(), ref); | 15129 AddTypeProperties(&jsobj, "Type", JSONType(), ref); |
15144 PrintSharedInstanceJSON(&jsobj, ref); | 15130 PrintSharedInstanceJSON(&jsobj, ref); |
15145 if (IsCanonical()) { | 15131 if (IsCanonical()) { |
15146 const Class& type_cls = Class::Handle(type_class()); | 15132 const Class& type_cls = Class::Handle(type_class()); |
15147 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 15133 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
15148 ASSERT(id >= 0); | 15134 ASSERT(id >= 0); |
15149 intptr_t cid = type_cls.id(); | 15135 intptr_t cid = type_cls.id(); |
15150 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); | 15136 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
15151 jsobj.AddProperty("typeClass", type_cls); | 15137 jsobj.AddProperty("typeClass", type_cls); |
15152 } else { | 15138 } else { |
15153 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15139 jsobj.AddServiceId("id", *this); |
15154 const intptr_t id = ring->GetIdForObject(raw()); | |
15155 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
15156 } | 15140 } |
15157 const String& user_name = String::Handle(PrettyName()); | 15141 const String& user_name = String::Handle(PrettyName()); |
15158 const String& vm_name = String::Handle(Name()); | 15142 const String& vm_name = String::Handle(Name()); |
15159 AddNameProperties(&jsobj, user_name, vm_name); | 15143 AddNameProperties(&jsobj, user_name, vm_name); |
15160 if (ref) { | 15144 if (ref) { |
15161 return; | 15145 return; |
15162 } | 15146 } |
15163 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 15147 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
15164 if (!typeArgs.IsNull()) { | 15148 if (!typeArgs.IsNull()) { |
15165 jsobj.AddProperty("typeArguments", typeArgs); | 15149 jsobj.AddProperty("typeArguments", typeArgs); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15328 OS::SNPrint(chars, len, format, type_cstr); | 15312 OS::SNPrint(chars, len, format, type_cstr); |
15329 return chars; | 15313 return chars; |
15330 } | 15314 } |
15331 } | 15315 } |
15332 | 15316 |
15333 | 15317 |
15334 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15318 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15335 JSONObject jsobj(stream); | 15319 JSONObject jsobj(stream); |
15336 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); | 15320 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); |
15337 PrintSharedInstanceJSON(&jsobj, ref); | 15321 PrintSharedInstanceJSON(&jsobj, ref); |
15338 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15322 jsobj.AddServiceId("id", *this); |
15339 const intptr_t id = ring->GetIdForObject(raw()); | |
15340 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
15341 const String& user_name = String::Handle(PrettyName()); | 15323 const String& user_name = String::Handle(PrettyName()); |
15342 const String& vm_name = String::Handle(Name()); | 15324 const String& vm_name = String::Handle(Name()); |
15343 AddNameProperties(&jsobj, user_name, vm_name); | 15325 AddNameProperties(&jsobj, user_name, vm_name); |
15344 if (ref) { | 15326 if (ref) { |
15345 return; | 15327 return; |
15346 } | 15328 } |
15347 jsobj.AddProperty("refType", AbstractType::Handle(type())); | 15329 jsobj.AddProperty("refType", AbstractType::Handle(type())); |
15348 } | 15330 } |
15349 | 15331 |
15350 | 15332 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15564 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15546 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15565 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 15547 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
15566 return chars; | 15548 return chars; |
15567 } | 15549 } |
15568 | 15550 |
15569 | 15551 |
15570 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15552 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15571 JSONObject jsobj(stream); | 15553 JSONObject jsobj(stream); |
15572 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); | 15554 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); |
15573 PrintSharedInstanceJSON(&jsobj, ref); | 15555 PrintSharedInstanceJSON(&jsobj, ref); |
15574 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15556 jsobj.AddServiceId("id", *this); |
15575 const intptr_t id = ring->GetIdForObject(raw()); | |
15576 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
15577 const String& user_name = String::Handle(PrettyName()); | 15557 const String& user_name = String::Handle(PrettyName()); |
15578 const String& vm_name = String::Handle(Name()); | 15558 const String& vm_name = String::Handle(Name()); |
15579 AddNameProperties(&jsobj, user_name, vm_name); | 15559 AddNameProperties(&jsobj, user_name, vm_name); |
15580 const Class& param_cls = Class::Handle(parameterized_class()); | 15560 const Class& param_cls = Class::Handle(parameterized_class()); |
15581 jsobj.AddProperty("parameterizedClass", param_cls); | 15561 jsobj.AddProperty("parameterizedClass", param_cls); |
15582 if (ref) { | 15562 if (ref) { |
15583 return; | 15563 return; |
15584 } | 15564 } |
15585 jsobj.AddProperty("index", index()); | 15565 jsobj.AddProperty("index", index()); |
15586 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 15566 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15782 OS::SNPrint( | 15762 OS::SNPrint( |
15783 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 15763 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
15784 return chars; | 15764 return chars; |
15785 } | 15765 } |
15786 | 15766 |
15787 | 15767 |
15788 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15768 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15789 JSONObject jsobj(stream); | 15769 JSONObject jsobj(stream); |
15790 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); | 15770 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); |
15791 PrintSharedInstanceJSON(&jsobj, ref); | 15771 PrintSharedInstanceJSON(&jsobj, ref); |
15792 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15772 jsobj.AddServiceId("id", *this); |
15793 const intptr_t id = ring->GetIdForObject(raw()); | |
15794 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
15795 const String& user_name = String::Handle(PrettyName()); | 15773 const String& user_name = String::Handle(PrettyName()); |
15796 const String& vm_name = String::Handle(Name()); | 15774 const String& vm_name = String::Handle(Name()); |
15797 AddNameProperties(&jsobj, user_name, vm_name); | 15775 AddNameProperties(&jsobj, user_name, vm_name); |
15798 if (ref) { | 15776 if (ref) { |
15799 return; | 15777 return; |
15800 } | 15778 } |
15801 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); | 15779 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); |
15802 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); | 15780 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); |
15803 } | 15781 } |
15804 | 15782 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15887 // Integer is an interface. No instances of Integer should exist. | 15865 // Integer is an interface. No instances of Integer should exist. |
15888 UNREACHABLE(); | 15866 UNREACHABLE(); |
15889 return "Integer"; | 15867 return "Integer"; |
15890 } | 15868 } |
15891 | 15869 |
15892 | 15870 |
15893 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15871 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15894 JSONObject jsobj(stream); | 15872 JSONObject jsobj(stream); |
15895 AddTypeProperties(&jsobj, "int", JSONType(), ref); | 15873 AddTypeProperties(&jsobj, "int", JSONType(), ref); |
15896 PrintSharedInstanceJSON(&jsobj, ref); | 15874 PrintSharedInstanceJSON(&jsobj, ref); |
15897 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15875 jsobj.AddServiceId("id", *this); |
15898 const intptr_t id = ring->GetIdForObject(raw()); | |
15899 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
15900 jsobj.AddProperty("valueAsString", ToCString()); | 15876 jsobj.AddProperty("valueAsString", ToCString()); |
15901 } | 15877 } |
15902 | 15878 |
15903 | 15879 |
15904 // Throw JavascriptIntegerOverflow exception. | 15880 // Throw JavascriptIntegerOverflow exception. |
15905 static void ThrowJavascriptIntegerOverflow(const Integer& i) { | 15881 static void ThrowJavascriptIntegerOverflow(const Integer& i) { |
15906 const Array& exc_args = Array::Handle(Array::New(1)); | 15882 const Array& exc_args = Array::Handle(Array::New(1)); |
15907 const String& i_str = String::Handle(String::New(i.ToCString())); | 15883 const String& i_str = String::Handle(String::New(i.ToCString())); |
15908 exc_args.SetAt(0, i_str); | 15884 exc_args.SetAt(0, i_str); |
15909 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, | 15885 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16582 return buffer; | 16558 return buffer; |
16583 } | 16559 } |
16584 | 16560 |
16585 | 16561 |
16586 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16562 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16587 JSONObject jsobj(stream); | 16563 JSONObject jsobj(stream); |
16588 // Suppress the fact that the internal vm name for this type is | 16564 // Suppress the fact that the internal vm name for this type is |
16589 // "Double". Return "double" instead. | 16565 // "Double". Return "double" instead. |
16590 AddTypeProperties(&jsobj, "double", "double", ref); | 16566 AddTypeProperties(&jsobj, "double", "double", ref); |
16591 PrintSharedInstanceJSON(&jsobj, ref); | 16567 PrintSharedInstanceJSON(&jsobj, ref); |
16592 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 16568 jsobj.AddServiceId("id", *this); |
16593 const intptr_t id = ring->GetIdForObject(raw()); | |
16594 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
16595 jsobj.AddProperty("valueAsString", ToCString()); | 16569 jsobj.AddProperty("valueAsString", ToCString()); |
16596 } | 16570 } |
16597 | 16571 |
16598 | 16572 |
16599 bool Bigint::Neg() const { | 16573 bool Bigint::Neg() const { |
16600 return Bool::Handle(neg()).value(); | 16574 return Bool::Handle(neg()).value(); |
16601 } | 16575 } |
16602 | 16576 |
16603 | 16577 |
16604 void Bigint::SetNeg(bool value) const { | 16578 void Bigint::SetNeg(bool value) const { |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18175 // TODO(turnidge): This is a hack. The user could have this | 18149 // TODO(turnidge): This is a hack. The user could have this |
18176 // special string in their program. Fixing this involves updating | 18150 // special string in their program. Fixing this involves updating |
18177 // the debugging api a bit. | 18151 // the debugging api a bit. |
18178 jsobj.AddProperty("type", "Sentinel"); | 18152 jsobj.AddProperty("type", "Sentinel"); |
18179 jsobj.AddProperty("id", "objects/optimized-out"); | 18153 jsobj.AddProperty("id", "objects/optimized-out"); |
18180 jsobj.AddProperty("valueAsString", "<optimized out>"); | 18154 jsobj.AddProperty("valueAsString", "<optimized out>"); |
18181 return; | 18155 return; |
18182 } | 18156 } |
18183 AddTypeProperties(&jsobj, "String", JSONType(), ref); | 18157 AddTypeProperties(&jsobj, "String", JSONType(), ref); |
18184 PrintSharedInstanceJSON(&jsobj, ref); | 18158 PrintSharedInstanceJSON(&jsobj, ref); |
18185 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 18159 jsobj.AddServiceId("id", *this); |
18186 const intptr_t id = ring->GetIdForObject(raw()); | |
18187 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
18188 if (ref) { | 18160 if (ref) { |
18189 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); | 18161 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); |
18190 if (did_truncate) { | 18162 if (did_truncate) { |
18191 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); | 18163 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); |
18192 } | 18164 } |
18193 } else { | 18165 } else { |
18194 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); | 18166 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); |
18195 ASSERT(!did_truncate); | 18167 ASSERT(!did_truncate); |
18196 } | 18168 } |
18197 } | 18169 } |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19200 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19172 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
19201 OS::SNPrint(chars, len, format, Length()); | 19173 OS::SNPrint(chars, len, format, Length()); |
19202 return chars; | 19174 return chars; |
19203 } | 19175 } |
19204 | 19176 |
19205 | 19177 |
19206 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19178 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19207 JSONObject jsobj(stream); | 19179 JSONObject jsobj(stream); |
19208 AddTypeProperties(&jsobj, "List", JSONType(), ref); | 19180 AddTypeProperties(&jsobj, "List", JSONType(), ref); |
19209 PrintSharedInstanceJSON(&jsobj, ref); | 19181 PrintSharedInstanceJSON(&jsobj, ref); |
19210 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 19182 jsobj.AddServiceId("id", *this); |
19211 const intptr_t id = ring->GetIdForObject(raw()); | |
19212 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
19213 jsobj.AddProperty("length", Length()); | 19183 jsobj.AddProperty("length", Length()); |
19214 if (ref) { | 19184 if (ref) { |
19215 return; | 19185 return; |
19216 } | 19186 } |
19217 { | 19187 { |
19218 JSONArray jsarr(&jsobj, "elements"); | 19188 JSONArray jsarr(&jsobj, "elements"); |
19219 for (intptr_t index = 0; index < Length(); index++) { | 19189 for (intptr_t index = 0; index < Length(); index++) { |
19220 JSONObject jselement(&jsarr); | 19190 JSONObject jselement(&jsarr); |
19221 jselement.AddProperty("index", index); | 19191 jselement.AddProperty("index", index); |
19222 | 19192 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19453 OS::SNPrint(chars, len, format, Length()); | 19423 OS::SNPrint(chars, len, format, Length()); |
19454 return chars; | 19424 return chars; |
19455 } | 19425 } |
19456 | 19426 |
19457 | 19427 |
19458 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 19428 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
19459 bool ref) const { | 19429 bool ref) const { |
19460 JSONObject jsobj(stream); | 19430 JSONObject jsobj(stream); |
19461 AddTypeProperties(&jsobj, "List", JSONType(), ref); | 19431 AddTypeProperties(&jsobj, "List", JSONType(), ref); |
19462 PrintSharedInstanceJSON(&jsobj, ref); | 19432 PrintSharedInstanceJSON(&jsobj, ref); |
19463 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 19433 jsobj.AddServiceId("id", *this); |
19464 const intptr_t id = ring->GetIdForObject(raw()); | |
19465 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
19466 jsobj.AddProperty("length", Length()); | 19434 jsobj.AddProperty("length", Length()); |
19467 if (ref) { | 19435 if (ref) { |
19468 return; | 19436 return; |
19469 } | 19437 } |
19470 { | 19438 { |
19471 JSONArray jsarr(&jsobj, "elements"); | 19439 JSONArray jsarr(&jsobj, "elements"); |
19472 for (intptr_t index = 0; index < Length(); index++) { | 19440 for (intptr_t index = 0; index < Length(); index++) { |
19473 JSONObject jselement(&jsarr); | 19441 JSONObject jselement(&jsarr); |
19474 jselement.AddProperty("index", index); | 19442 jselement.AddProperty("index", index); |
19475 | 19443 |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20503 | 20471 |
20504 const char* WeakProperty::ToCString() const { | 20472 const char* WeakProperty::ToCString() const { |
20505 return "_WeakProperty"; | 20473 return "_WeakProperty"; |
20506 } | 20474 } |
20507 | 20475 |
20508 | 20476 |
20509 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20477 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20510 JSONObject jsobj(stream); | 20478 JSONObject jsobj(stream); |
20511 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | 20479 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
20512 PrintSharedInstanceJSON(&jsobj, ref); | 20480 PrintSharedInstanceJSON(&jsobj, ref); |
20513 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 20481 jsobj.AddServiceId("id", *this); |
20514 const intptr_t id = ring->GetIdForObject(raw()); | |
20515 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
20516 | |
20517 if (ref) { | 20482 if (ref) { |
20518 return; | 20483 return; |
20519 } | 20484 } |
20520 | 20485 |
20521 const Object& key_handle = Object::Handle(key()); | 20486 const Object& key_handle = Object::Handle(key()); |
20522 jsobj.AddProperty("key", key_handle); | 20487 jsobj.AddProperty("key", key_handle); |
20523 const Object& value_handle = Object::Handle(value()); | 20488 const Object& value_handle = Object::Handle(value()); |
20524 jsobj.AddProperty("value", value_handle); | 20489 jsobj.AddProperty("value", value_handle); |
20525 } | 20490 } |
20526 | 20491 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20577 | 20542 |
20578 const char* MirrorReference::ToCString() const { | 20543 const char* MirrorReference::ToCString() const { |
20579 return "_MirrorReference"; | 20544 return "_MirrorReference"; |
20580 } | 20545 } |
20581 | 20546 |
20582 | 20547 |
20583 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20548 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20584 JSONObject jsobj(stream); | 20549 JSONObject jsobj(stream); |
20585 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | 20550 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
20586 PrintSharedInstanceJSON(&jsobj, ref); | 20551 PrintSharedInstanceJSON(&jsobj, ref); |
20587 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 20552 jsobj.AddServiceId("id", *this); |
20588 const intptr_t id = ring->GetIdForObject(raw()); | |
20589 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
20590 | 20553 |
20591 if (ref) { | 20554 if (ref) { |
20592 return; | 20555 return; |
20593 } | 20556 } |
20594 | 20557 |
20595 const Object& referent_handle = Object::Handle(referent()); | 20558 const Object& referent_handle = Object::Handle(referent()); |
20596 jsobj.AddProperty("referent", referent_handle); | 20559 jsobj.AddProperty("referent", referent_handle); |
20597 } | 20560 } |
20598 | 20561 |
20599 | 20562 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20724 return tag_label.ToCString(); | 20687 return tag_label.ToCString(); |
20725 } | 20688 } |
20726 | 20689 |
20727 | 20690 |
20728 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20691 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20729 Instance::PrintJSONImpl(stream, ref); | 20692 Instance::PrintJSONImpl(stream, ref); |
20730 } | 20693 } |
20731 | 20694 |
20732 | 20695 |
20733 } // namespace dart | 20696 } // namespace dart |
OLD | NEW |