OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/debugger.h" | 5 #include "vm/debugger.h" |
6 #include "vm/disassembler.h" | 6 #include "vm/disassembler.h" |
7 #include "vm/object.h" | 7 #include "vm/object.h" |
8 #include "vm/object_store.h" | 8 #include "vm/object_store.h" |
9 #include "vm/stub_code.h" | 9 #include "vm/stub_code.h" |
10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 77 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
78 Isolate* isolate = Isolate::Current(); | 78 Isolate* isolate = Isolate::Current(); |
79 JSONObject jsobj(stream); | 79 JSONObject jsobj(stream); |
80 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 80 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
81 // TODO(turnidge): This is weird and needs to be changed. | 81 // TODO(turnidge): This is weird and needs to be changed. |
82 jsobj.AddProperty("type", "null"); | 82 jsobj.AddProperty("type", "null"); |
83 return; | 83 return; |
84 } | 84 } |
85 AddCommonObjectProperties(&jsobj, "Class", ref); | 85 AddCommonObjectProperties(&jsobj, "Class", ref); |
86 jsobj.AddFixedServiceId("classes/%" Pd "", id()); | 86 jsobj.AddFixedServiceId("classes/%" Pd "", id()); |
87 const String& user_name = String::Handle(PrettyName()); | 87 const String& user_name = String::Handle(UserVisibleName()); |
88 const String& vm_name = String::Handle(Name()); | 88 const String& vm_name = String::Handle(Name()); |
89 AddNameProperties(&jsobj, user_name, vm_name); | 89 AddNameProperties(&jsobj, user_name, vm_name); |
90 if (ref) { | 90 if (ref) { |
91 return; | 91 return; |
92 } | 92 } |
93 | 93 |
94 const Error& err = Error::Handle(EnsureIsFinalized(Thread::Current())); | 94 const Error& err = Error::Handle(EnsureIsFinalized(Thread::Current())); |
95 if (!err.IsNull()) { | 95 if (!err.IsNull()) { |
96 jsobj.AddProperty("error", err); | 96 jsobj.AddProperty("error", err); |
97 } | 97 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 JSONObject jsobj(stream); | 177 JSONObject jsobj(stream); |
178 // The index in the canonical_type_arguments table cannot be used as part of | 178 // The index in the canonical_type_arguments table cannot be used as part of |
179 // the object id (as in typearguments/id), because the indices are not | 179 // the object id (as in typearguments/id), because the indices are not |
180 // preserved when the table grows and the entries get rehashed. Use the ring. | 180 // preserved when the table grows and the entries get rehashed. Use the ring. |
181 Isolate* isolate = Isolate::Current(); | 181 Isolate* isolate = Isolate::Current(); |
182 ObjectStore* object_store = isolate->object_store(); | 182 ObjectStore* object_store = isolate->object_store(); |
183 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 183 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
184 ASSERT(table.Length() > 0); | 184 ASSERT(table.Length() > 0); |
185 AddCommonObjectProperties(&jsobj, "TypeArguments", ref); | 185 AddCommonObjectProperties(&jsobj, "TypeArguments", ref); |
186 jsobj.AddServiceId(*this); | 186 jsobj.AddServiceId(*this); |
187 const String& user_name = String::Handle(PrettyName()); | 187 const String& user_name = String::Handle(UserVisibleName()); |
188 const String& vm_name = String::Handle(Name()); | 188 const String& vm_name = String::Handle(Name()); |
189 AddNameProperties(&jsobj, user_name, vm_name); | 189 AddNameProperties(&jsobj, user_name, vm_name); |
190 if (ref) { | 190 if (ref) { |
191 return; | 191 return; |
192 } | 192 } |
193 { | 193 { |
194 JSONArray jsarr(&jsobj, "types"); | 194 JSONArray jsarr(&jsobj, "types"); |
195 AbstractType& type_arg = AbstractType::Handle(); | 195 AbstractType& type_arg = AbstractType::Handle(); |
196 for (intptr_t i = 0; i < Length(); i++) { | 196 for (intptr_t i = 0; i < Length(); i++) { |
197 type_arg = TypeAt(i); | 197 type_arg = TypeAt(i); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 264 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
265 Class& cls = Class::Handle(Owner()); | 265 Class& cls = Class::Handle(Owner()); |
266 ASSERT(!cls.IsNull()); | 266 ASSERT(!cls.IsNull()); |
267 Error& err = Error::Handle(); | 267 Error& err = Error::Handle(); |
268 err ^= cls.EnsureIsFinalized(Thread::Current()); | 268 err ^= cls.EnsureIsFinalized(Thread::Current()); |
269 ASSERT(err.IsNull()); | 269 ASSERT(err.IsNull()); |
270 JSONObject jsobj(stream); | 270 JSONObject jsobj(stream); |
271 AddCommonObjectProperties(&jsobj, "Function", ref); | 271 AddCommonObjectProperties(&jsobj, "Function", ref); |
272 AddFunctionServiceId(jsobj, *this, cls); | 272 AddFunctionServiceId(jsobj, *this, cls); |
273 const String& user_name = String::Handle(PrettyName()); | 273 const String& user_name = String::Handle(UserVisibleName()); |
274 const String& vm_name = String::Handle(name()); | 274 const String& vm_name = String::Handle(name()); |
275 AddNameProperties(&jsobj, user_name, vm_name); | 275 AddNameProperties(&jsobj, user_name, vm_name); |
276 const Function& parent = Function::Handle(parent_function()); | 276 const Function& parent = Function::Handle(parent_function()); |
277 if (!parent.IsNull()) { | 277 if (!parent.IsNull()) { |
278 jsobj.AddProperty("owner", parent); | 278 jsobj.AddProperty("owner", parent); |
279 } else if (cls.IsTopLevel()) { | 279 } else if (cls.IsTopLevel()) { |
280 const Library& library = Library::Handle(cls.library()); | 280 const Library& library = Library::Handle(cls.library()); |
281 jsobj.AddProperty("owner", library); | 281 jsobj.AddProperty("owner", library); |
282 } else { | 282 } else { |
283 jsobj.AddProperty("owner", cls); | 283 jsobj.AddProperty("owner", cls); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 335 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
336 JSONObject jsobj(stream); | 336 JSONObject jsobj(stream); |
337 Class& cls = Class::Handle(owner()); | 337 Class& cls = Class::Handle(owner()); |
338 String& field_name = String::Handle(name()); | 338 String& field_name = String::Handle(name()); |
339 field_name = String::EncodeIRI(field_name); | 339 field_name = String::EncodeIRI(field_name); |
340 AddCommonObjectProperties(&jsobj, "Field", ref); | 340 AddCommonObjectProperties(&jsobj, "Field", ref); |
341 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", | 341 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", |
342 cls.id(), field_name.ToCString()); | 342 cls.id(), field_name.ToCString()); |
343 | 343 |
344 const String& user_name = String::Handle(PrettyName()); | 344 const String& user_name = String::Handle(UserVisibleName()); |
345 const String& vm_name = String::Handle(name()); | 345 const String& vm_name = String::Handle(name()); |
346 AddNameProperties(&jsobj, user_name, vm_name); | 346 AddNameProperties(&jsobj, user_name, vm_name); |
347 if (cls.IsTopLevel()) { | 347 if (cls.IsTopLevel()) { |
348 const Library& library = Library::Handle(cls.library()); | 348 const Library& library = Library::Handle(cls.library()); |
349 jsobj.AddProperty("owner", library); | 349 jsobj.AddProperty("owner", library); |
350 } else { | 350 } else { |
351 jsobj.AddProperty("owner", cls); | 351 jsobj.AddProperty("owner", cls); |
352 } | 352 } |
353 | 353 |
354 AbstractType& declared_type = AbstractType::Handle(type()); | 354 AbstractType& declared_type = AbstractType::Handle(type()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 474 } |
475 | 475 |
476 | 476 |
477 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { | 477 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { |
478 intptr_t id = index(); | 478 intptr_t id = index(); |
479 ASSERT(id >= 0); | 479 ASSERT(id >= 0); |
480 JSONObject jsobj(stream); | 480 JSONObject jsobj(stream); |
481 AddCommonObjectProperties(&jsobj, "Library", ref); | 481 AddCommonObjectProperties(&jsobj, "Library", ref); |
482 jsobj.AddFixedServiceId("libraries/%" Pd "", id); | 482 jsobj.AddFixedServiceId("libraries/%" Pd "", id); |
483 const String& vm_name = String::Handle(name()); | 483 const String& vm_name = String::Handle(name()); |
484 const String& user_name = | 484 const String& user_name = String::Handle(String::ScrubName(vm_name)); |
485 String::Handle(String::IdentifierPrettyName(vm_name)); | |
486 AddNameProperties(&jsobj, user_name, vm_name); | 485 AddNameProperties(&jsobj, user_name, vm_name); |
487 const String& library_url = String::Handle(url()); | 486 const String& library_url = String::Handle(url()); |
488 jsobj.AddPropertyStr("uri", library_url); | 487 jsobj.AddPropertyStr("uri", library_url); |
489 if (ref) { | 488 if (ref) { |
490 return; | 489 return; |
491 } | 490 } |
492 jsobj.AddProperty("debuggable", IsDebuggable()); | 491 jsobj.AddProperty("debuggable", IsDebuggable()); |
493 { | 492 { |
494 JSONArray jsarr(&jsobj, "classes"); | 493 JSONArray jsarr(&jsobj, "classes"); |
495 ClassDictionaryIterator class_iter(*this); | 494 ClassDictionaryIterator class_iter(*this); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 } | 811 } |
813 } | 812 } |
814 | 813 |
815 | 814 |
816 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { | 815 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { |
817 JSONObject jsobj(stream); | 816 JSONObject jsobj(stream); |
818 AddCommonObjectProperties(&jsobj, "Code", ref); | 817 AddCommonObjectProperties(&jsobj, "Code", ref); |
819 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "", | 818 jsobj.AddFixedServiceId("code/%" Px64"-%" Px "", |
820 compile_timestamp(), | 819 compile_timestamp(), |
821 EntryPoint()); | 820 EntryPoint()); |
822 const String& user_name = String::Handle(PrettyName()); | 821 const String& user_name = String::Handle(UserVisibleName()); |
823 const String& vm_name = String::Handle(Name()); | 822 const String& vm_name = String::Handle(Name()); |
824 AddNameProperties(&jsobj, user_name, vm_name); | 823 AddNameProperties(&jsobj, user_name, vm_name); |
825 const bool is_stub = IsStubCode() || IsAllocationStubCode(); | 824 const bool is_stub = IsStubCode() || IsAllocationStubCode(); |
826 if (is_stub) { | 825 if (is_stub) { |
827 jsobj.AddProperty("kind", "Stub"); | 826 jsobj.AddProperty("kind", "Stub"); |
828 } else { | 827 } else { |
829 jsobj.AddProperty("kind", "Dart"); | 828 jsobj.AddProperty("kind", "Dart"); |
830 } | 829 } |
831 jsobj.AddProperty("_optimized", is_optimized()); | 830 jsobj.AddProperty("_optimized", is_optimized()); |
832 const Object& obj = Object::Handle(owner()); | 831 const Object& obj = Object::Handle(owner()); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 if (IsCanonical()) { | 1114 if (IsCanonical()) { |
1116 const Class& type_cls = Class::Handle(type_class()); | 1115 const Class& type_cls = Class::Handle(type_class()); |
1117 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 1116 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
1118 ASSERT(id >= 0); | 1117 ASSERT(id >= 0); |
1119 intptr_t cid = type_cls.id(); | 1118 intptr_t cid = type_cls.id(); |
1120 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | 1119 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); |
1121 jsobj.AddProperty("typeClass", type_cls); | 1120 jsobj.AddProperty("typeClass", type_cls); |
1122 } else { | 1121 } else { |
1123 jsobj.AddServiceId(*this); | 1122 jsobj.AddServiceId(*this); |
1124 } | 1123 } |
1125 const String& user_name = String::Handle(PrettyName()); | 1124 const String& user_name = String::Handle(UserVisibleName()); |
1126 const String& vm_name = String::Handle(Name()); | 1125 const String& vm_name = String::Handle(Name()); |
1127 AddNameProperties(&jsobj, user_name, vm_name); | 1126 AddNameProperties(&jsobj, user_name, vm_name); |
1128 if (ref) { | 1127 if (ref) { |
1129 return; | 1128 return; |
1130 } | 1129 } |
1131 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 1130 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
1132 if (!typeArgs.IsNull()) { | 1131 if (!typeArgs.IsNull()) { |
1133 jsobj.AddProperty("typeArguments", typeArgs); | 1132 jsobj.AddProperty("typeArguments", typeArgs); |
1134 } | 1133 } |
1135 } | 1134 } |
1136 | 1135 |
1137 | 1136 |
1138 void FunctionType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1137 void FunctionType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1139 JSONObject jsobj(stream); | 1138 JSONObject jsobj(stream); |
1140 PrintSharedInstanceJSON(&jsobj, ref); | 1139 PrintSharedInstanceJSON(&jsobj, ref); |
1141 jsobj.AddProperty("kind", "FunctionType"); | 1140 jsobj.AddProperty("kind", "FunctionType"); |
1142 if (IsCanonical()) { | 1141 if (IsCanonical()) { |
1143 const Class& scope_cls = Class::Handle(scope_class()); | 1142 const Class& scope_cls = Class::Handle(scope_class()); |
1144 intptr_t id = scope_cls.FindCanonicalTypeIndex(*this); | 1143 intptr_t id = scope_cls.FindCanonicalTypeIndex(*this); |
1145 ASSERT(id >= 0); | 1144 ASSERT(id >= 0); |
1146 intptr_t cid = scope_cls.id(); | 1145 intptr_t cid = scope_cls.id(); |
1147 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | 1146 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); |
1148 jsobj.AddProperty("scopeClass", scope_cls); | 1147 jsobj.AddProperty("scopeClass", scope_cls); |
1149 } else { | 1148 } else { |
1150 jsobj.AddServiceId(*this); | 1149 jsobj.AddServiceId(*this); |
1151 } | 1150 } |
1152 const String& user_name = String::Handle(PrettyName()); | 1151 const String& user_name = String::Handle(UserVisibleName()); |
1153 const String& vm_name = String::Handle(Name()); | 1152 const String& vm_name = String::Handle(Name()); |
1154 AddNameProperties(&jsobj, user_name, vm_name); | 1153 AddNameProperties(&jsobj, user_name, vm_name); |
1155 if (ref) { | 1154 if (ref) { |
1156 return; | 1155 return; |
1157 } | 1156 } |
1158 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 1157 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
1159 if (!typeArgs.IsNull()) { | 1158 if (!typeArgs.IsNull()) { |
1160 jsobj.AddProperty("typeArguments", typeArgs); | 1159 jsobj.AddProperty("typeArguments", typeArgs); |
1161 } | 1160 } |
1162 } | 1161 } |
1163 | 1162 |
1164 | 1163 |
1165 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1164 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1166 JSONObject jsobj(stream); | 1165 JSONObject jsobj(stream); |
1167 PrintSharedInstanceJSON(&jsobj, ref); | 1166 PrintSharedInstanceJSON(&jsobj, ref); |
1168 jsobj.AddProperty("kind", "TypeRef"); | 1167 jsobj.AddProperty("kind", "TypeRef"); |
1169 jsobj.AddServiceId(*this); | 1168 jsobj.AddServiceId(*this); |
1170 const String& user_name = String::Handle(PrettyName()); | 1169 const String& user_name = String::Handle(UserVisibleName()); |
1171 const String& vm_name = String::Handle(Name()); | 1170 const String& vm_name = String::Handle(Name()); |
1172 AddNameProperties(&jsobj, user_name, vm_name); | 1171 AddNameProperties(&jsobj, user_name, vm_name); |
1173 if (ref) { | 1172 if (ref) { |
1174 return; | 1173 return; |
1175 } | 1174 } |
1176 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 1175 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
1177 } | 1176 } |
1178 | 1177 |
1179 | 1178 |
1180 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1179 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1181 JSONObject jsobj(stream); | 1180 JSONObject jsobj(stream); |
1182 PrintSharedInstanceJSON(&jsobj, ref); | 1181 PrintSharedInstanceJSON(&jsobj, ref); |
1183 jsobj.AddProperty("kind", "TypeParameter"); | 1182 jsobj.AddProperty("kind", "TypeParameter"); |
1184 jsobj.AddServiceId(*this); | 1183 jsobj.AddServiceId(*this); |
1185 const String& user_name = String::Handle(PrettyName()); | 1184 const String& user_name = String::Handle(UserVisibleName()); |
1186 const String& vm_name = String::Handle(Name()); | 1185 const String& vm_name = String::Handle(Name()); |
1187 AddNameProperties(&jsobj, user_name, vm_name); | 1186 AddNameProperties(&jsobj, user_name, vm_name); |
1188 const Class& param_cls = Class::Handle(parameterized_class()); | 1187 const Class& param_cls = Class::Handle(parameterized_class()); |
1189 jsobj.AddProperty("parameterizedClass", param_cls); | 1188 jsobj.AddProperty("parameterizedClass", param_cls); |
1190 if (ref) { | 1189 if (ref) { |
1191 return; | 1190 return; |
1192 } | 1191 } |
1193 jsobj.AddProperty("parameterIndex", index()); | 1192 jsobj.AddProperty("parameterIndex", index()); |
1194 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 1193 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
1195 jsobj.AddProperty("bound", upper_bound); | 1194 jsobj.AddProperty("bound", upper_bound); |
1196 } | 1195 } |
1197 | 1196 |
1198 | 1197 |
1199 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1198 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1200 JSONObject jsobj(stream); | 1199 JSONObject jsobj(stream); |
1201 PrintSharedInstanceJSON(&jsobj, ref); | 1200 PrintSharedInstanceJSON(&jsobj, ref); |
1202 jsobj.AddProperty("kind", "BoundedType"); | 1201 jsobj.AddProperty("kind", "BoundedType"); |
1203 jsobj.AddServiceId(*this); | 1202 jsobj.AddServiceId(*this); |
1204 const String& user_name = String::Handle(PrettyName()); | 1203 const String& user_name = String::Handle(UserVisibleName()); |
1205 const String& vm_name = String::Handle(Name()); | 1204 const String& vm_name = String::Handle(Name()); |
1206 AddNameProperties(&jsobj, user_name, vm_name); | 1205 AddNameProperties(&jsobj, user_name, vm_name); |
1207 if (ref) { | 1206 if (ref) { |
1208 return; | 1207 return; |
1209 } | 1208 } |
1210 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 1209 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
1211 jsobj.AddProperty("bound", AbstractType::Handle(bound())); | 1210 jsobj.AddProperty("bound", AbstractType::Handle(bound())); |
1212 } | 1211 } |
1213 | 1212 |
1214 | 1213 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 jsobj.AddProperty("mirrorReferent", referent_handle); | 1592 jsobj.AddProperty("mirrorReferent", referent_handle); |
1594 } | 1593 } |
1595 | 1594 |
1596 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1595 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1597 Instance::PrintJSONImpl(stream, ref); | 1596 Instance::PrintJSONImpl(stream, ref); |
1598 } | 1597 } |
1599 | 1598 |
1600 #endif | 1599 #endif |
1601 | 1600 |
1602 } // namespace dart | 1601 } // namespace dart |
OLD | NEW |