| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 | 237 |
| 238 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 238 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 239 Object::PrintJSONImpl(stream, ref); | 239 Object::PrintJSONImpl(stream, ref); |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 static void AddFunctionServiceId(const JSONObject& jsobj, | 243 static void AddFunctionServiceId(const JSONObject& jsobj, |
| 244 const Function& f, | 244 const Function& f, |
| 245 const Class& cls) { | 245 const Class& cls) { |
| 246 if (cls.IsNull()) { |
| 247 ASSERT(f.IsSignatureFunction()); |
| 248 jsobj.AddServiceId(f); |
| 249 return; |
| 250 } |
| 246 // Special kinds of functions use indices in their respective lists. | 251 // Special kinds of functions use indices in their respective lists. |
| 247 intptr_t id = -1; | 252 intptr_t id = -1; |
| 248 const char* selector = NULL; | 253 const char* selector = NULL; |
| 249 if (f.IsNonImplicitClosureFunction()) { | 254 if (f.IsNonImplicitClosureFunction()) { |
| 250 id = Isolate::Current()->FindClosureIndex(f); | 255 id = Isolate::Current()->FindClosureIndex(f); |
| 251 selector = "closures"; | 256 selector = "closures"; |
| 252 } else if (f.IsImplicitClosureFunction()) { | 257 } else if (f.IsImplicitClosureFunction()) { |
| 253 id = cls.FindImplicitClosureFunctionIndex(f); | 258 id = cls.FindImplicitClosureFunctionIndex(f); |
| 254 selector = "implicit_closures"; | 259 selector = "implicit_closures"; |
| 255 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { | 260 } else if (f.IsNoSuchMethodDispatcher() || f.IsInvokeFieldDispatcher()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 272 } | 277 } |
| 273 // Oddball functions (not known to their owner) fall back to use the object | 278 // Oddball functions (not known to their owner) fall back to use the object |
| 274 // id ring. Current known examples are signature functions of closures | 279 // id ring. Current known examples are signature functions of closures |
| 275 // and stubs like 'megamorphic_miss'. | 280 // and stubs like 'megamorphic_miss'. |
| 276 jsobj.AddServiceId(f); | 281 jsobj.AddServiceId(f); |
| 277 } | 282 } |
| 278 | 283 |
| 279 | 284 |
| 280 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 285 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 281 Class& cls = Class::Handle(Owner()); | 286 Class& cls = Class::Handle(Owner()); |
| 282 ASSERT(!cls.IsNull()); | 287 if (!cls.IsNull()) { |
| 283 Error& err = Error::Handle(); | 288 Error& err = Error::Handle(); |
| 284 err ^= cls.EnsureIsFinalized(Thread::Current()); | 289 err ^= cls.EnsureIsFinalized(Thread::Current()); |
| 285 ASSERT(err.IsNull()); | 290 ASSERT(err.IsNull()); |
| 291 } else { |
| 292 ASSERT(IsSignatureFunction()); |
| 293 } |
| 286 JSONObject jsobj(stream); | 294 JSONObject jsobj(stream); |
| 287 AddCommonObjectProperties(&jsobj, "Function", ref); | 295 AddCommonObjectProperties(&jsobj, "Function", ref); |
| 288 AddFunctionServiceId(jsobj, *this, cls); | 296 AddFunctionServiceId(jsobj, *this, cls); |
| 289 const String& user_name = String::Handle(UserVisibleName()); | 297 const String& user_name = String::Handle(UserVisibleName()); |
| 290 const String& vm_name = String::Handle(name()); | 298 const String& vm_name = String::Handle(name()); |
| 291 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); | 299 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); |
| 292 const Function& parent = Function::Handle(parent_function()); | 300 const Function& parent = Function::Handle(parent_function()); |
| 293 if (!parent.IsNull()) { | 301 if (!parent.IsNull()) { |
| 294 jsobj.AddProperty("owner", parent); | 302 jsobj.AddProperty("owner", parent); |
| 295 } else if (cls.IsTopLevel()) { | 303 } else if (!cls.IsNull()) { |
| 296 const Library& library = Library::Handle(cls.library()); | 304 if (cls.IsTopLevel()) { |
| 297 jsobj.AddProperty("owner", library); | 305 const Library& library = Library::Handle(cls.library()); |
| 298 } else { | 306 jsobj.AddProperty("owner", library); |
| 299 jsobj.AddProperty("owner", cls); | 307 } else { |
| 308 jsobj.AddProperty("owner", cls); |
| 309 } |
| 300 } | 310 } |
| 301 | 311 |
| 302 const char* kind_string = Function::KindToCString(kind()); | 312 const char* kind_string = Function::KindToCString(kind()); |
| 303 jsobj.AddProperty("_kind", kind_string); | 313 jsobj.AddProperty("_kind", kind_string); |
| 304 jsobj.AddProperty("static", is_static()); | 314 jsobj.AddProperty("static", is_static()); |
| 305 jsobj.AddProperty("const", is_const()); | 315 jsobj.AddProperty("const", is_const()); |
| 306 jsobj.AddProperty("_intrinsic", is_intrinsic()); | 316 jsobj.AddProperty("_intrinsic", is_intrinsic()); |
| 307 jsobj.AddProperty("_native", is_native()); | 317 jsobj.AddProperty("_native", is_native()); |
| 308 if (ref) { | 318 if (ref) { |
| 309 return; | 319 return; |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 } | 1102 } |
| 1093 } | 1103 } |
| 1094 | 1104 |
| 1095 | 1105 |
| 1096 void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1106 void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 1097 UNREACHABLE(); | 1107 UNREACHABLE(); |
| 1098 } | 1108 } |
| 1099 | 1109 |
| 1100 | 1110 |
| 1101 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1111 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 1112 // TODO(regis): Function types are not handled properly. |
| 1102 JSONObject jsobj(stream); | 1113 JSONObject jsobj(stream); |
| 1103 PrintSharedInstanceJSON(&jsobj, ref); | 1114 PrintSharedInstanceJSON(&jsobj, ref); |
| 1104 jsobj.AddProperty("kind", "Type"); | 1115 jsobj.AddProperty("kind", "Type"); |
| 1105 if (HasResolvedTypeClass()) { | 1116 if (HasResolvedTypeClass()) { |
| 1106 const Class& type_cls = Class::Handle(type_class()); | 1117 const Class& type_cls = Class::Handle(type_class()); |
| 1107 if (type_cls.CanonicalType() == raw()) { | 1118 if (type_cls.CanonicalType() == raw()) { |
| 1108 intptr_t cid = type_cls.id(); | 1119 intptr_t cid = type_cls.id(); |
| 1109 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0); | 1120 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0); |
| 1110 } else { | 1121 } else { |
| 1111 jsobj.AddServiceId(*this); | 1122 jsobj.AddServiceId(*this); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 jsobj.AddProperty("mirrorReferent", referent_handle); | 1590 jsobj.AddProperty("mirrorReferent", referent_handle); |
| 1580 } | 1591 } |
| 1581 | 1592 |
| 1582 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1593 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 1583 Instance::PrintJSONImpl(stream, ref); | 1594 Instance::PrintJSONImpl(stream, ref); |
| 1584 } | 1595 } |
| 1585 | 1596 |
| 1586 #endif | 1597 #endif |
| 1587 | 1598 |
| 1588 } // namespace dart | 1599 } // namespace dart |
| OLD | NEW |