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" |
11 #include "vm/type_table.h" | 11 #include "vm/type_table.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 #ifndef PRODUCT | 15 #ifndef PRODUCT |
16 | 16 |
17 static void AddNameProperties(JSONObject* jsobj, | 17 static void AddNameProperties(JSONObject* jsobj, |
18 const char* name, | 18 const char* name, |
19 const char* vm_name) { | 19 const char* vm_name) { |
20 jsobj->AddProperty("name", name); | 20 jsobj->AddProperty("name", name); |
21 if (strcmp(name, vm_name) != 0) { | 21 if (strcmp(name, vm_name) != 0) { |
22 jsobj->AddProperty("_vmName", vm_name); | 22 jsobj->AddProperty("_vmName", vm_name); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 | |
27 void Object::AddCommonObjectProperties(JSONObject* jsobj, | 26 void Object::AddCommonObjectProperties(JSONObject* jsobj, |
28 const char* protocol_type, | 27 const char* protocol_type, |
29 bool ref) const { | 28 bool ref) const { |
30 const char* vm_type = JSONType(); | 29 const char* vm_type = JSONType(); |
31 bool same_type = (strcmp(protocol_type, vm_type) == 0); | 30 bool same_type = (strcmp(protocol_type, vm_type) == 0); |
32 if (ref) { | 31 if (ref) { |
33 jsobj->AddPropertyF("type", "@%s", protocol_type); | 32 jsobj->AddPropertyF("type", "@%s", protocol_type); |
34 } else { | 33 } else { |
35 jsobj->AddProperty("type", protocol_type); | 34 jsobj->AddProperty("type", protocol_type); |
36 } | 35 } |
37 if (!same_type) { | 36 if (!same_type) { |
38 jsobj->AddProperty("_vmType", vm_type); | 37 jsobj->AddProperty("_vmType", vm_type); |
39 } | 38 } |
40 if (!ref || IsInstance() || IsNull()) { | 39 if (!ref || IsInstance() || IsNull()) { |
41 // TODO(turnidge): Provide the type arguments here too? | 40 // TODO(turnidge): Provide the type arguments here too? |
42 const Class& cls = Class::Handle(this->clazz()); | 41 const Class& cls = Class::Handle(this->clazz()); |
43 jsobj->AddProperty("class", cls); | 42 jsobj->AddProperty("class", cls); |
44 } | 43 } |
45 if (!ref) { | 44 if (!ref) { |
46 if (raw()->IsHeapObject()) { | 45 if (raw()->IsHeapObject()) { |
47 jsobj->AddProperty("size", raw()->Size()); | 46 jsobj->AddProperty("size", raw()->Size()); |
48 } else { | 47 } else { |
49 jsobj->AddProperty("size", (intptr_t)0); | 48 jsobj->AddProperty("size", (intptr_t)0); |
50 } | 49 } |
51 } | 50 } |
52 } | 51 } |
53 | 52 |
54 | |
55 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { | 53 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { |
56 JSONObject jsobj(stream); | 54 JSONObject jsobj(stream); |
57 AddCommonObjectProperties(&jsobj, "Object", ref); | 55 AddCommonObjectProperties(&jsobj, "Object", ref); |
58 jsobj.AddServiceId(*this); | 56 jsobj.AddServiceId(*this); |
59 if (ref) { | 57 if (ref) { |
60 return; | 58 return; |
61 } | 59 } |
62 } | 60 } |
63 | 61 |
64 | |
65 void Object::PrintJSON(JSONStream* stream, bool ref) const { | 62 void Object::PrintJSON(JSONStream* stream, bool ref) const { |
66 if (IsNull()) { | 63 if (IsNull()) { |
67 JSONObject jsobj(stream); | 64 JSONObject jsobj(stream); |
68 AddCommonObjectProperties(&jsobj, "Instance", ref); | 65 AddCommonObjectProperties(&jsobj, "Instance", ref); |
69 jsobj.AddProperty("kind", "Null"); | 66 jsobj.AddProperty("kind", "Null"); |
70 jsobj.AddFixedServiceId("objects/null"); | 67 jsobj.AddFixedServiceId("objects/null"); |
71 jsobj.AddProperty("valueAsString", "null"); | 68 jsobj.AddProperty("valueAsString", "null"); |
72 } else { | 69 } else { |
73 PrintJSONImpl(stream, ref); | 70 PrintJSONImpl(stream, ref); |
74 } | 71 } |
75 } | 72 } |
76 | 73 |
77 | |
78 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 74 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
79 Isolate* isolate = Isolate::Current(); | 75 Isolate* isolate = Isolate::Current(); |
80 JSONObject jsobj(stream); | 76 JSONObject jsobj(stream); |
81 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 77 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
82 // TODO(turnidge): This is weird and needs to be changed. | 78 // TODO(turnidge): This is weird and needs to be changed. |
83 jsobj.AddProperty("type", "null"); | 79 jsobj.AddProperty("type", "null"); |
84 return; | 80 return; |
85 } | 81 } |
86 AddCommonObjectProperties(&jsobj, "Class", ref); | 82 AddCommonObjectProperties(&jsobj, "Class", ref); |
87 jsobj.AddFixedServiceId("classes/%" Pd "", id()); | 83 jsobj.AddFixedServiceId("classes/%" Pd "", id()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 { | 166 { |
171 ClassTable* class_table = Isolate::Current()->class_table(); | 167 ClassTable* class_table = Isolate::Current()->class_table(); |
172 const ClassHeapStats* stats = class_table->StatsWithUpdatedSize(id()); | 168 const ClassHeapStats* stats = class_table->StatsWithUpdatedSize(id()); |
173 if (stats != NULL) { | 169 if (stats != NULL) { |
174 JSONObject allocation_stats(&jsobj, "_allocationStats"); | 170 JSONObject allocation_stats(&jsobj, "_allocationStats"); |
175 stats->PrintToJSONObject(*this, &allocation_stats); | 171 stats->PrintToJSONObject(*this, &allocation_stats); |
176 } | 172 } |
177 } | 173 } |
178 } | 174 } |
179 | 175 |
180 | |
181 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 176 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
182 Object::PrintJSONImpl(stream, ref); | 177 Object::PrintJSONImpl(stream, ref); |
183 } | 178 } |
184 | 179 |
185 | |
186 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { | 180 void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const { |
187 JSONObject jsobj(stream); | 181 JSONObject jsobj(stream); |
188 // The index in the canonical_type_arguments table cannot be used as part of | 182 // The index in the canonical_type_arguments table cannot be used as part of |
189 // the object id (as in typearguments/id), because the indices are not | 183 // the object id (as in typearguments/id), because the indices are not |
190 // preserved when the table grows and the entries get rehashed. Use the ring. | 184 // preserved when the table grows and the entries get rehashed. Use the ring. |
191 Thread* thread = Thread::Current(); | 185 Thread* thread = Thread::Current(); |
192 Zone* zone = thread->zone(); | 186 Zone* zone = thread->zone(); |
193 Isolate* isolate = thread->isolate(); | 187 Isolate* isolate = thread->isolate(); |
194 ObjectStore* object_store = isolate->object_store(); | 188 ObjectStore* object_store = isolate->object_store(); |
195 CanonicalTypeArgumentsSet typeargs_table( | 189 CanonicalTypeArgumentsSet typeargs_table( |
(...skipping 30 matching lines...) Expand all Loading... |
226 instantiation.AddProperty("instantiatorTypeArguments", type_args, true); | 220 instantiation.AddProperty("instantiatorTypeArguments", type_args, true); |
227 type_args ^= prior_instantiations.At(i + 1); | 221 type_args ^= prior_instantiations.At(i + 1); |
228 instantiation.AddProperty("functionTypeArguments", type_args, true); | 222 instantiation.AddProperty("functionTypeArguments", type_args, true); |
229 type_args ^= prior_instantiations.At(i + 2); | 223 type_args ^= prior_instantiations.At(i + 2); |
230 instantiation.AddProperty("instantiated", type_args, true); | 224 instantiation.AddProperty("instantiated", type_args, true); |
231 i += StubCode::kInstantiationSizeInWords; | 225 i += StubCode::kInstantiationSizeInWords; |
232 } | 226 } |
233 } | 227 } |
234 } | 228 } |
235 | 229 |
236 | |
237 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 230 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
238 Object::PrintJSONImpl(stream, ref); | 231 Object::PrintJSONImpl(stream, ref); |
239 } | 232 } |
240 | 233 |
241 | |
242 static void AddFunctionServiceId(const JSONObject& jsobj, | 234 static void AddFunctionServiceId(const JSONObject& jsobj, |
243 const Function& f, | 235 const Function& f, |
244 const Class& cls) { | 236 const Class& cls) { |
245 if (cls.IsNull()) { | 237 if (cls.IsNull()) { |
246 ASSERT(f.IsSignatureFunction()); | 238 ASSERT(f.IsSignatureFunction()); |
247 jsobj.AddServiceId(f); | 239 jsobj.AddServiceId(f); |
248 return; | 240 return; |
249 } | 241 } |
250 // Special kinds of functions use indices in their respective lists. | 242 // Special kinds of functions use indices in their respective lists. |
251 intptr_t id = -1; | 243 intptr_t id = -1; |
(...skipping 21 matching lines...) Expand all Loading... |
273 jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s", cls.id(), | 265 jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s", cls.id(), |
274 encoded_name); | 266 encoded_name); |
275 return; | 267 return; |
276 } | 268 } |
277 // Oddball functions (not known to their owner) fall back to use the object | 269 // Oddball functions (not known to their owner) fall back to use the object |
278 // id ring. Current known examples are signature functions of closures | 270 // id ring. Current known examples are signature functions of closures |
279 // and stubs like 'megamorphic_miss'. | 271 // and stubs like 'megamorphic_miss'. |
280 jsobj.AddServiceId(f); | 272 jsobj.AddServiceId(f); |
281 } | 273 } |
282 | 274 |
283 | |
284 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 275 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
285 Class& cls = Class::Handle(Owner()); | 276 Class& cls = Class::Handle(Owner()); |
286 if (!cls.IsNull()) { | 277 if (!cls.IsNull()) { |
287 Error& err = Error::Handle(); | 278 Error& err = Error::Handle(); |
288 err ^= cls.EnsureIsFinalized(Thread::Current()); | 279 err ^= cls.EnsureIsFinalized(Thread::Current()); |
289 ASSERT(err.IsNull()); | 280 ASSERT(err.IsNull()); |
290 } else { | 281 } else { |
291 ASSERT(IsSignatureFunction()); | 282 ASSERT(IsSignatureFunction()); |
292 } | 283 } |
293 JSONObject jsobj(stream); | 284 JSONObject jsobj(stream); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 jsobj.AddProperty("_field", field); | 335 jsobj.AddProperty("_field", field); |
345 } | 336 } |
346 } | 337 } |
347 | 338 |
348 const Script& script = Script::Handle(this->script()); | 339 const Script& script = Script::Handle(this->script()); |
349 if (!script.IsNull()) { | 340 if (!script.IsNull()) { |
350 jsobj.AddLocation(script, token_pos(), end_token_pos()); | 341 jsobj.AddLocation(script, token_pos(), end_token_pos()); |
351 } | 342 } |
352 } | 343 } |
353 | 344 |
354 | |
355 void RedirectionData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 345 void RedirectionData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
356 Object::PrintJSONImpl(stream, ref); | 346 Object::PrintJSONImpl(stream, ref); |
357 } | 347 } |
358 | 348 |
359 | |
360 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 349 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
361 JSONObject jsobj(stream); | 350 JSONObject jsobj(stream); |
362 Class& cls = Class::Handle(Owner()); | 351 Class& cls = Class::Handle(Owner()); |
363 String& field_name = String::Handle(name()); | 352 String& field_name = String::Handle(name()); |
364 const char* encoded_field_name = String::EncodeIRI(field_name); | 353 const char* encoded_field_name = String::EncodeIRI(field_name); |
365 AddCommonObjectProperties(&jsobj, "Field", ref); | 354 AddCommonObjectProperties(&jsobj, "Field", ref); |
366 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", cls.id(), | 355 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", cls.id(), |
367 encoded_field_name); | 356 encoded_field_name); |
368 | 357 |
369 const String& user_name = String::Handle(UserVisibleName()); | 358 const String& user_name = String::Handle(UserVisibleName()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 jsobj.AddProperty("_guardLength", "variable"); | 395 jsobj.AddProperty("_guardLength", "variable"); |
407 } else { | 396 } else { |
408 jsobj.AddProperty("_guardLength", guarded_list_length()); | 397 jsobj.AddProperty("_guardLength", guarded_list_length()); |
409 } | 398 } |
410 const class Script& script = Script::Handle(Script()); | 399 const class Script& script = Script::Handle(Script()); |
411 if (!script.IsNull()) { | 400 if (!script.IsNull()) { |
412 jsobj.AddLocation(script, token_pos()); | 401 jsobj.AddLocation(script, token_pos()); |
413 } | 402 } |
414 } | 403 } |
415 | 404 |
416 | |
417 void LiteralToken::PrintJSONImpl(JSONStream* stream, bool ref) const { | 405 void LiteralToken::PrintJSONImpl(JSONStream* stream, bool ref) const { |
418 Object::PrintJSONImpl(stream, ref); | 406 Object::PrintJSONImpl(stream, ref); |
419 } | 407 } |
420 | 408 |
421 | |
422 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { | 409 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { |
423 JSONObject jsobj(stream); | 410 JSONObject jsobj(stream); |
424 AddCommonObjectProperties(&jsobj, "Object", ref); | 411 AddCommonObjectProperties(&jsobj, "Object", ref); |
425 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off | 412 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off |
426 // a Script object but do not have a back reference to generate a stable id. | 413 // a Script object but do not have a back reference to generate a stable id. |
427 jsobj.AddServiceId(*this); | 414 jsobj.AddServiceId(*this); |
428 if (ref) { | 415 if (ref) { |
429 return; | 416 return; |
430 } | 417 } |
431 const String& private_key = String::Handle(PrivateKey()); | 418 const String& private_key = String::Handle(PrivateKey()); |
432 jsobj.AddProperty("privateKey", private_key); | 419 jsobj.AddProperty("privateKey", private_key); |
433 // TODO(johnmccutchan): Add support for printing LiteralTokens and add | 420 // TODO(johnmccutchan): Add support for printing LiteralTokens and add |
434 // them to members array. | 421 // them to members array. |
435 JSONArray members(&jsobj, "members"); | 422 JSONArray members(&jsobj, "members"); |
436 } | 423 } |
437 | 424 |
438 | |
439 // See also Dart_ScriptGetTokenInfo. | 425 // See also Dart_ScriptGetTokenInfo. |
440 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { | 426 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { |
441 JSONObject jsobj(stream); | 427 JSONObject jsobj(stream); |
442 AddCommonObjectProperties(&jsobj, "Script", ref); | 428 AddCommonObjectProperties(&jsobj, "Script", ref); |
443 const String& uri = String::Handle(url()); | 429 const String& uri = String::Handle(url()); |
444 ASSERT(!uri.IsNull()); | 430 ASSERT(!uri.IsNull()); |
445 const char* encoded_uri = String::EncodeIRI(uri); | 431 const char* encoded_uri = String::EncodeIRI(uri); |
446 const Library& lib = Library::Handle(FindLibrary()); | 432 const Library& lib = Library::Handle(FindLibrary()); |
447 if (lib.IsNull()) { | 433 if (lib.IsNull()) { |
448 jsobj.AddServiceId(*this); | 434 jsobj.AddServiceId(*this); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 if (value.IsNull()) { | 476 if (value.IsNull()) { |
491 break; | 477 break; |
492 } | 478 } |
493 const Smi& smi = Smi::Cast(value); | 479 const Smi& smi = Smi::Cast(value); |
494 lineInfo.AddValue(smi.Value()); | 480 lineInfo.AddValue(smi.Value()); |
495 } | 481 } |
496 } | 482 } |
497 } | 483 } |
498 } | 484 } |
499 | 485 |
500 | |
501 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { | 486 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { |
502 const String& id = String::Handle(private_key()); | 487 const String& id = String::Handle(private_key()); |
503 JSONObject jsobj(stream); | 488 JSONObject jsobj(stream); |
504 AddCommonObjectProperties(&jsobj, "Library", ref); | 489 AddCommonObjectProperties(&jsobj, "Library", ref); |
505 jsobj.AddFixedServiceId("libraries/%s", id.ToCString()); | 490 jsobj.AddFixedServiceId("libraries/%s", id.ToCString()); |
506 const String& vm_name = String::Handle(name()); | 491 const String& vm_name = String::Handle(name()); |
507 const String& scrubbed_name = String::Handle(String::ScrubName(vm_name)); | 492 const String& scrubbed_name = String::Handle(String::ScrubName(vm_name)); |
508 AddNameProperties(&jsobj, scrubbed_name.ToCString(), vm_name.ToCString()); | 493 AddNameProperties(&jsobj, scrubbed_name.ToCString(), vm_name.ToCString()); |
509 const String& library_url = String::Handle(url()); | 494 const String& library_url = String::Handle(url()); |
510 jsobj.AddPropertyStr("uri", library_url); | 495 jsobj.AddPropertyStr("uri", library_url); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 JSONArray jsarr(&jsobj, "scripts"); | 602 JSONArray jsarr(&jsobj, "scripts"); |
618 Array& scripts = Array::Handle(LoadedScripts()); | 603 Array& scripts = Array::Handle(LoadedScripts()); |
619 Script& script = Script::Handle(); | 604 Script& script = Script::Handle(); |
620 for (intptr_t i = 0; i < scripts.Length(); i++) { | 605 for (intptr_t i = 0; i < scripts.Length(); i++) { |
621 script ^= scripts.At(i); | 606 script ^= scripts.At(i); |
622 jsarr.AddValue(script); | 607 jsarr.AddValue(script); |
623 } | 608 } |
624 } | 609 } |
625 } | 610 } |
626 | 611 |
627 | |
628 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | 612 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { |
629 Object::PrintJSONImpl(stream, ref); | 613 Object::PrintJSONImpl(stream, ref); |
630 } | 614 } |
631 | 615 |
632 | |
633 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { | 616 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { |
634 Object::PrintJSONImpl(stream, ref); | 617 Object::PrintJSONImpl(stream, ref); |
635 } | 618 } |
636 | 619 |
637 | |
638 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const { | 620 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const { |
639 JSONObject jsobj(stream); | 621 JSONObject jsobj(stream); |
640 AddCommonObjectProperties(&jsobj, "Object", ref); | 622 AddCommonObjectProperties(&jsobj, "Object", ref); |
641 jsobj.AddServiceId(*this); | 623 jsobj.AddServiceId(*this); |
642 if (ref) { | 624 if (ref) { |
643 return; | 625 return; |
644 } | 626 } |
645 } | 627 } |
646 | 628 |
647 | |
648 void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const { | 629 void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const { |
649 JSONObject jsobj(stream); | 630 JSONObject jsobj(stream); |
650 AddCommonObjectProperties(&jsobj, "Object", ref); | 631 AddCommonObjectProperties(&jsobj, "Object", ref); |
651 jsobj.AddServiceId(*this); | 632 jsobj.AddServiceId(*this); |
652 jsobj.AddProperty("length", Length()); | 633 jsobj.AddProperty("length", Length()); |
653 if (ref) { | 634 if (ref) { |
654 return; | 635 return; |
655 } | 636 } |
656 | 637 |
657 { | 638 { |
(...skipping 19 matching lines...) Expand all Loading... |
677 jsentry.AddProperty("kind", "NativeEntry"); | 658 jsentry.AddProperty("kind", "NativeEntry"); |
678 jsentry.AddProperty64("value", imm); | 659 jsentry.AddProperty64("value", imm); |
679 break; | 660 break; |
680 default: | 661 default: |
681 UNREACHABLE(); | 662 UNREACHABLE(); |
682 } | 663 } |
683 } | 664 } |
684 } | 665 } |
685 } | 666 } |
686 | 667 |
687 | |
688 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | 668 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
689 AddCommonObjectProperties(jsobj, "Object", ref); | 669 AddCommonObjectProperties(jsobj, "Object", ref); |
690 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | 670 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code |
691 // object but do not have a back reference to generate an ID. | 671 // object but do not have a back reference to generate an ID. |
692 jsobj->AddServiceId(*this); | 672 jsobj->AddServiceId(*this); |
693 if (ref) { | 673 if (ref) { |
694 return; | 674 return; |
695 } | 675 } |
696 JSONArray members(jsobj, "members"); | 676 JSONArray members(jsobj, "members"); |
697 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 677 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
698 while (iter.MoveNext()) { | 678 while (iter.MoveNext()) { |
699 JSONObject descriptor(&members); | 679 JSONObject descriptor(&members); |
700 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset()); | 680 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset()); |
701 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); | 681 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); |
702 descriptor.AddProperty("deoptId", iter.DeoptId()); | 682 descriptor.AddProperty("deoptId", iter.DeoptId()); |
703 // TODO(turnidge): Use AddLocation instead. | 683 // TODO(turnidge): Use AddLocation instead. |
704 descriptor.AddProperty("tokenPos", iter.TokenPos()); | 684 descriptor.AddProperty("tokenPos", iter.TokenPos()); |
705 descriptor.AddProperty("tryIndex", iter.TryIndex()); | 685 descriptor.AddProperty("tryIndex", iter.TryIndex()); |
706 } | 686 } |
707 } | 687 } |
708 | 688 |
709 | |
710 void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { | 689 void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { |
711 JSONObject jsobj(stream); | 690 JSONObject jsobj(stream); |
712 PrintToJSONObject(&jsobj, ref); | 691 PrintToJSONObject(&jsobj, ref); |
713 } | 692 } |
714 | 693 |
715 | |
716 void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 694 void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
717 Object::PrintJSONImpl(stream, ref); | 695 Object::PrintJSONImpl(stream, ref); |
718 } | 696 } |
719 | 697 |
720 | |
721 void StackMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 698 void StackMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
722 Object::PrintJSONImpl(stream, ref); | 699 Object::PrintJSONImpl(stream, ref); |
723 } | 700 } |
724 | 701 |
725 | |
726 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { | 702 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const { |
727 JSONObject jsobj(stream); | 703 JSONObject jsobj(stream); |
728 AddCommonObjectProperties(&jsobj, "Object", ref); | 704 AddCommonObjectProperties(&jsobj, "Object", ref); |
729 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off | 705 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off |
730 // a Code object but do not have a back reference to generate an ID. | 706 // a Code object but do not have a back reference to generate an ID. |
731 jsobj.AddServiceId(*this); | 707 jsobj.AddServiceId(*this); |
732 if (ref) { | 708 if (ref) { |
733 return; | 709 return; |
734 } | 710 } |
735 JSONArray members(&jsobj, "members"); | 711 JSONArray members(&jsobj, "members"); |
736 String& var_name = String::Handle(); | 712 String& var_name = String::Handle(); |
737 for (intptr_t i = 0; i < Length(); i++) { | 713 for (intptr_t i = 0; i < Length(); i++) { |
738 RawLocalVarDescriptors::VarInfo info; | 714 RawLocalVarDescriptors::VarInfo info; |
739 var_name = GetName(i); | 715 var_name = GetName(i); |
740 GetInfo(i, &info); | 716 GetInfo(i, &info); |
741 JSONObject var(&members); | 717 JSONObject var(&members); |
742 var.AddProperty("name", var_name.ToCString()); | 718 var.AddProperty("name", var_name.ToCString()); |
743 var.AddProperty("index", static_cast<intptr_t>(info.index())); | 719 var.AddProperty("index", static_cast<intptr_t>(info.index())); |
744 var.AddProperty("declarationTokenPos", info.declaration_pos); | 720 var.AddProperty("declarationTokenPos", info.declaration_pos); |
745 var.AddProperty("scopeStartTokenPos", info.begin_pos); | 721 var.AddProperty("scopeStartTokenPos", info.begin_pos); |
746 var.AddProperty("scopeEndTokenPos", info.end_pos); | 722 var.AddProperty("scopeEndTokenPos", info.end_pos); |
747 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); | 723 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id)); |
748 var.AddProperty("kind", KindToCString(info.kind())); | 724 var.AddProperty("kind", KindToCString(info.kind())); |
749 } | 725 } |
750 } | 726 } |
751 | 727 |
752 | |
753 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, bool ref) const { | 728 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, bool ref) const { |
754 Object::PrintJSONImpl(stream, ref); | 729 Object::PrintJSONImpl(stream, ref); |
755 } | 730 } |
756 | 731 |
757 | |
758 void SingleTargetCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | 732 void SingleTargetCache::PrintJSONImpl(JSONStream* stream, bool ref) const { |
759 JSONObject jsobj(stream); | 733 JSONObject jsobj(stream); |
760 AddCommonObjectProperties(&jsobj, "Object", ref); | 734 AddCommonObjectProperties(&jsobj, "Object", ref); |
761 jsobj.AddServiceId(*this); | 735 jsobj.AddServiceId(*this); |
762 jsobj.AddProperty("_target", Code::Handle(target())); | 736 jsobj.AddProperty("_target", Code::Handle(target())); |
763 if (ref) { | 737 if (ref) { |
764 return; | 738 return; |
765 } | 739 } |
766 jsobj.AddProperty("_lowerLimit", lower_limit()); | 740 jsobj.AddProperty("_lowerLimit", lower_limit()); |
767 jsobj.AddProperty("_upperLimit", upper_limit()); | 741 jsobj.AddProperty("_upperLimit", upper_limit()); |
768 } | 742 } |
769 | 743 |
770 | |
771 void UnlinkedCall::PrintJSONImpl(JSONStream* stream, bool ref) const { | 744 void UnlinkedCall::PrintJSONImpl(JSONStream* stream, bool ref) const { |
772 JSONObject jsobj(stream); | 745 JSONObject jsobj(stream); |
773 AddCommonObjectProperties(&jsobj, "Object", ref); | 746 AddCommonObjectProperties(&jsobj, "Object", ref); |
774 jsobj.AddServiceId(*this); | 747 jsobj.AddServiceId(*this); |
775 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | 748 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); |
776 if (ref) { | 749 if (ref) { |
777 return; | 750 return; |
778 } | 751 } |
779 jsobj.AddProperty("_argumentsDescriptor", Array::Handle(args_descriptor())); | 752 jsobj.AddProperty("_argumentsDescriptor", Array::Handle(args_descriptor())); |
780 } | 753 } |
781 | 754 |
782 | |
783 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 755 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
784 JSONObject jsobj(stream); | 756 JSONObject jsobj(stream); |
785 AddCommonObjectProperties(&jsobj, "Object", ref); | 757 AddCommonObjectProperties(&jsobj, "Object", ref); |
786 jsobj.AddServiceId(*this); | 758 jsobj.AddServiceId(*this); |
787 jsobj.AddProperty("_owner", Object::Handle(Owner())); | 759 jsobj.AddProperty("_owner", Object::Handle(Owner())); |
788 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | 760 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); |
789 if (ref) { | 761 if (ref) { |
790 return; | 762 return; |
791 } | 763 } |
792 jsobj.AddProperty("_argumentsDescriptor", | 764 jsobj.AddProperty("_argumentsDescriptor", |
793 Object::Handle(arguments_descriptor())); | 765 Object::Handle(arguments_descriptor())); |
794 jsobj.AddProperty("_entries", Object::Handle(ic_data())); | 766 jsobj.AddProperty("_entries", Object::Handle(ic_data())); |
795 } | 767 } |
796 | 768 |
797 | |
798 void ICData::PrintToJSONArray(const JSONArray& jsarray, | 769 void ICData::PrintToJSONArray(const JSONArray& jsarray, |
799 TokenPosition token_pos) const { | 770 TokenPosition token_pos) const { |
800 Isolate* isolate = Isolate::Current(); | 771 Isolate* isolate = Isolate::Current(); |
801 Class& cls = Class::Handle(); | 772 Class& cls = Class::Handle(); |
802 Function& func = Function::Handle(); | 773 Function& func = Function::Handle(); |
803 | 774 |
804 JSONObject jsobj(&jsarray); | 775 JSONObject jsobj(&jsarray); |
805 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); | 776 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
806 jsobj.AddProperty("tokenPos", token_pos.value()); | 777 jsobj.AddProperty("tokenPos", token_pos.value()); |
807 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). | 778 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
808 // jsobj.AddProperty("deoptReasons", ...); | 779 // jsobj.AddProperty("deoptReasons", ...); |
809 | 780 |
810 JSONArray cache_entries(&jsobj, "cacheEntries"); | 781 JSONArray cache_entries(&jsobj, "cacheEntries"); |
811 for (intptr_t i = 0; i < NumberOfChecks(); i++) { | 782 for (intptr_t i = 0; i < NumberOfChecks(); i++) { |
812 JSONObject cache_entry(&cache_entries); | 783 JSONObject cache_entry(&cache_entries); |
813 func = GetTargetAt(i); | 784 func = GetTargetAt(i); |
814 intptr_t count = GetCountAt(i); | 785 intptr_t count = GetCountAt(i); |
815 if (!is_static_call()) { | 786 if (!is_static_call()) { |
816 intptr_t cid = GetReceiverClassIdAt(i); | 787 intptr_t cid = GetReceiverClassIdAt(i); |
817 cls ^= isolate->class_table()->At(cid); | 788 cls ^= isolate->class_table()->At(cid); |
818 cache_entry.AddProperty("receiver", cls); | 789 cache_entry.AddProperty("receiver", cls); |
819 } | 790 } |
820 cache_entry.AddProperty("target", func); | 791 cache_entry.AddProperty("target", func); |
821 cache_entry.AddProperty("count", count); | 792 cache_entry.AddProperty("count", count); |
822 } | 793 } |
823 } | 794 } |
824 | 795 |
825 | |
826 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { | 796 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { |
827 JSONObject jsobj(stream); | 797 JSONObject jsobj(stream); |
828 AddCommonObjectProperties(&jsobj, "Code", ref); | 798 AddCommonObjectProperties(&jsobj, "Code", ref); |
829 jsobj.AddFixedServiceId("code/%" Px64 "-%" Px "", compile_timestamp(), | 799 jsobj.AddFixedServiceId("code/%" Px64 "-%" Px "", compile_timestamp(), |
830 PayloadStart()); | 800 PayloadStart()); |
831 const char* qualified_name = QualifiedName(); | 801 const char* qualified_name = QualifiedName(); |
832 const char* vm_name = Name(); | 802 const char* vm_name = Name(); |
833 AddNameProperties(&jsobj, qualified_name, vm_name); | 803 AddNameProperties(&jsobj, qualified_name, vm_name); |
834 const bool is_stub = IsStubCode() || IsAllocationStubCode(); | 804 const bool is_stub = IsStubCode() || IsAllocationStubCode(); |
835 if (is_stub) { | 805 if (is_stub) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 } | 846 } |
877 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 847 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
878 if (!descriptors.IsNull()) { | 848 if (!descriptors.IsNull()) { |
879 JSONObject desc(&jsobj, "_descriptors"); | 849 JSONObject desc(&jsobj, "_descriptors"); |
880 descriptors.PrintToJSONObject(&desc, false); | 850 descriptors.PrintToJSONObject(&desc, false); |
881 } | 851 } |
882 | 852 |
883 PrintJSONInlineIntervals(&jsobj); | 853 PrintJSONInlineIntervals(&jsobj); |
884 } | 854 } |
885 | 855 |
886 | |
887 void Code::set_await_token_positions(const Array& await_token_positions) const { | 856 void Code::set_await_token_positions(const Array& await_token_positions) const { |
888 #if !defined(DART_PRECOMPILED_RUNTIME) | 857 #if !defined(DART_PRECOMPILED_RUNTIME) |
889 StorePointer(&raw_ptr()->await_token_positions_, await_token_positions.raw()); | 858 StorePointer(&raw_ptr()->await_token_positions_, await_token_positions.raw()); |
890 #endif | 859 #endif |
891 } | 860 } |
892 | 861 |
893 | |
894 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { | 862 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { |
895 JSONObject jsobj(stream); | 863 JSONObject jsobj(stream); |
896 // TODO(turnidge): Should the user level type for Context be Context | 864 // TODO(turnidge): Should the user level type for Context be Context |
897 // or Object? | 865 // or Object? |
898 AddCommonObjectProperties(&jsobj, "Context", ref); | 866 AddCommonObjectProperties(&jsobj, "Context", ref); |
899 jsobj.AddServiceId(*this); | 867 jsobj.AddServiceId(*this); |
900 | 868 |
901 jsobj.AddProperty("length", num_variables()); | 869 jsobj.AddProperty("length", num_variables()); |
902 | 870 |
903 if (ref) { | 871 if (ref) { |
904 return; | 872 return; |
905 } | 873 } |
906 | 874 |
907 const Context& parent_context = Context::Handle(parent()); | 875 const Context& parent_context = Context::Handle(parent()); |
908 if (!parent_context.IsNull()) { | 876 if (!parent_context.IsNull()) { |
909 jsobj.AddProperty("parent", parent_context); | 877 jsobj.AddProperty("parent", parent_context); |
910 } | 878 } |
911 | 879 |
912 JSONArray jsarr(&jsobj, "variables"); | 880 JSONArray jsarr(&jsobj, "variables"); |
913 Object& var = Object::Handle(); | 881 Object& var = Object::Handle(); |
914 for (intptr_t index = 0; index < num_variables(); index++) { | 882 for (intptr_t index = 0; index < num_variables(); index++) { |
915 var = At(index); | 883 var = At(index); |
916 JSONObject jselement(&jsarr); | 884 JSONObject jselement(&jsarr); |
917 jselement.AddProperty("value", var); | 885 jselement.AddProperty("value", var); |
918 } | 886 } |
919 } | 887 } |
920 | 888 |
921 | |
922 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | 889 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { |
923 Object::PrintJSONImpl(stream, ref); | 890 Object::PrintJSONImpl(stream, ref); |
924 } | 891 } |
925 | 892 |
926 | |
927 void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | 893 void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const { |
928 JSONObject jsobj(stream); | 894 JSONObject jsobj(stream); |
929 AddCommonObjectProperties(&jsobj, "Object", ref); | 895 AddCommonObjectProperties(&jsobj, "Object", ref); |
930 jsobj.AddServiceId(*this); | 896 jsobj.AddServiceId(*this); |
931 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | 897 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); |
932 if (ref) { | 898 if (ref) { |
933 return; | 899 return; |
934 } | 900 } |
935 jsobj.AddProperty("_buckets", Object::Handle(buckets())); | 901 jsobj.AddProperty("_buckets", Object::Handle(buckets())); |
936 jsobj.AddProperty("_mask", mask()); | 902 jsobj.AddProperty("_mask", mask()); |
937 jsobj.AddProperty("_argumentsDescriptor", | 903 jsobj.AddProperty("_argumentsDescriptor", |
938 Object::Handle(arguments_descriptor())); | 904 Object::Handle(arguments_descriptor())); |
939 } | 905 } |
940 | 906 |
941 | |
942 void SubtypeTestCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | 907 void SubtypeTestCache::PrintJSONImpl(JSONStream* stream, bool ref) const { |
943 JSONObject jsobj(stream); | 908 JSONObject jsobj(stream); |
944 AddCommonObjectProperties(&jsobj, "Object", ref); | 909 AddCommonObjectProperties(&jsobj, "Object", ref); |
945 jsobj.AddServiceId(*this); | 910 jsobj.AddServiceId(*this); |
946 if (ref) { | 911 if (ref) { |
947 return; | 912 return; |
948 } | 913 } |
949 jsobj.AddProperty("_cache", Array::Handle(cache())); | 914 jsobj.AddProperty("_cache", Array::Handle(cache())); |
950 } | 915 } |
951 | 916 |
952 | |
953 void Error::PrintJSONImpl(JSONStream* stream, bool ref) const { | 917 void Error::PrintJSONImpl(JSONStream* stream, bool ref) const { |
954 UNREACHABLE(); | 918 UNREACHABLE(); |
955 } | 919 } |
956 | 920 |
957 | |
958 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const { | 921 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const { |
959 JSONObject jsobj(stream); | 922 JSONObject jsobj(stream); |
960 AddCommonObjectProperties(&jsobj, "Error", ref); | 923 AddCommonObjectProperties(&jsobj, "Error", ref); |
961 jsobj.AddProperty("kind", "InternalError"); | 924 jsobj.AddProperty("kind", "InternalError"); |
962 jsobj.AddServiceId(*this); | 925 jsobj.AddServiceId(*this); |
963 jsobj.AddProperty("message", ToErrorCString()); | 926 jsobj.AddProperty("message", ToErrorCString()); |
964 } | 927 } |
965 | 928 |
966 | |
967 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const { | 929 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const { |
968 JSONObject jsobj(stream); | 930 JSONObject jsobj(stream); |
969 AddCommonObjectProperties(&jsobj, "Error", ref); | 931 AddCommonObjectProperties(&jsobj, "Error", ref); |
970 jsobj.AddProperty("kind", "LanguageError"); | 932 jsobj.AddProperty("kind", "LanguageError"); |
971 jsobj.AddServiceId(*this); | 933 jsobj.AddServiceId(*this); |
972 jsobj.AddProperty("message", ToErrorCString()); | 934 jsobj.AddProperty("message", ToErrorCString()); |
973 } | 935 } |
974 | 936 |
975 | |
976 void UnhandledException::PrintJSONImpl(JSONStream* stream, bool ref) const { | 937 void UnhandledException::PrintJSONImpl(JSONStream* stream, bool ref) const { |
977 JSONObject jsobj(stream); | 938 JSONObject jsobj(stream); |
978 AddCommonObjectProperties(&jsobj, "Error", ref); | 939 AddCommonObjectProperties(&jsobj, "Error", ref); |
979 jsobj.AddProperty("kind", "UnhandledException"); | 940 jsobj.AddProperty("kind", "UnhandledException"); |
980 jsobj.AddServiceId(*this); | 941 jsobj.AddServiceId(*this); |
981 jsobj.AddProperty("message", ToErrorCString()); | 942 jsobj.AddProperty("message", ToErrorCString()); |
982 if (ref) { | 943 if (ref) { |
983 return; | 944 return; |
984 } | 945 } |
985 Instance& instance = Instance::Handle(); | 946 Instance& instance = Instance::Handle(); |
986 instance = exception(); | 947 instance = exception(); |
987 jsobj.AddProperty("exception", instance); | 948 jsobj.AddProperty("exception", instance); |
988 instance = stacktrace(); | 949 instance = stacktrace(); |
989 jsobj.AddProperty("stacktrace", instance); | 950 jsobj.AddProperty("stacktrace", instance); |
990 } | 951 } |
991 | 952 |
992 | |
993 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const { | 953 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const { |
994 JSONObject jsobj(stream); | 954 JSONObject jsobj(stream); |
995 AddCommonObjectProperties(&jsobj, "Error", ref); | 955 AddCommonObjectProperties(&jsobj, "Error", ref); |
996 jsobj.AddProperty("kind", "TerminationError"); | 956 jsobj.AddProperty("kind", "TerminationError"); |
997 jsobj.AddServiceId(*this); | 957 jsobj.AddServiceId(*this); |
998 jsobj.AddProperty("message", ToErrorCString()); | 958 jsobj.AddProperty("message", ToErrorCString()); |
999 jsobj.AddProperty("_is_user_initiated", is_user_initiated()); | 959 jsobj.AddProperty("_is_user_initiated", is_user_initiated()); |
1000 } | 960 } |
1001 | 961 |
1002 | |
1003 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const { | 962 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const { |
1004 AddCommonObjectProperties(jsobj, "Instance", ref); | 963 AddCommonObjectProperties(jsobj, "Instance", ref); |
1005 if (ref) { | 964 if (ref) { |
1006 return; | 965 return; |
1007 } | 966 } |
1008 | 967 |
1009 // Add all fields in layout order, from superclass to subclass. | 968 // Add all fields in layout order, from superclass to subclass. |
1010 GrowableArray<Class*> classes; | 969 GrowableArray<Class*> classes; |
1011 Class& cls = Class::Handle(this->clazz()); | 970 Class& cls = Class::Handle(this->clazz()); |
1012 if (IsClosure()) { | 971 if (IsClosure()) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 JSONArray jsarr(jsobj, "_nativeFields"); | 1003 JSONArray jsarr(jsobj, "_nativeFields"); |
1045 for (intptr_t i = 0; i < NumNativeFields(); i++) { | 1004 for (intptr_t i = 0; i < NumNativeFields(); i++) { |
1046 intptr_t value = GetNativeField(i); | 1005 intptr_t value = GetNativeField(i); |
1047 JSONObject jsfield(&jsarr); | 1006 JSONObject jsfield(&jsarr); |
1048 jsfield.AddProperty("index", i); | 1007 jsfield.AddProperty("index", i); |
1049 jsfield.AddProperty("value", value); | 1008 jsfield.AddProperty("value", value); |
1050 } | 1009 } |
1051 } | 1010 } |
1052 } | 1011 } |
1053 | 1012 |
1054 | |
1055 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1013 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1056 JSONObject jsobj(stream); | 1014 JSONObject jsobj(stream); |
1057 | 1015 |
1058 // Handle certain special instance values. | 1016 // Handle certain special instance values. |
1059 if (raw() == Object::sentinel().raw()) { | 1017 if (raw() == Object::sentinel().raw()) { |
1060 jsobj.AddProperty("type", "Sentinel"); | 1018 jsobj.AddProperty("type", "Sentinel"); |
1061 jsobj.AddProperty("kind", "NotInitialized"); | 1019 jsobj.AddProperty("kind", "NotInitialized"); |
1062 jsobj.AddProperty("valueAsString", "<not initialized>"); | 1020 jsobj.AddProperty("valueAsString", "<not initialized>"); |
1063 return; | 1021 return; |
1064 } else if (raw() == Object::transition_sentinel().raw()) { | 1022 } else if (raw() == Object::transition_sentinel().raw()) { |
(...skipping 24 matching lines...) Expand all Loading... |
1089 } | 1047 } |
1090 if (IsClosure()) { | 1048 if (IsClosure()) { |
1091 Debugger* debugger = Isolate::Current()->debugger(); | 1049 Debugger* debugger = Isolate::Current()->debugger(); |
1092 Breakpoint* bpt = debugger->BreakpointAtActivation(*this); | 1050 Breakpoint* bpt = debugger->BreakpointAtActivation(*this); |
1093 if (bpt != NULL) { | 1051 if (bpt != NULL) { |
1094 jsobj.AddProperty("_activationBreakpoint", bpt); | 1052 jsobj.AddProperty("_activationBreakpoint", bpt); |
1095 } | 1053 } |
1096 } | 1054 } |
1097 } | 1055 } |
1098 | 1056 |
1099 | |
1100 void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1057 void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1101 UNREACHABLE(); | 1058 UNREACHABLE(); |
1102 } | 1059 } |
1103 | 1060 |
1104 | |
1105 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1061 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1106 // TODO(regis): Function types are not handled properly. | 1062 // TODO(regis): Function types are not handled properly. |
1107 JSONObject jsobj(stream); | 1063 JSONObject jsobj(stream); |
1108 PrintSharedInstanceJSON(&jsobj, ref); | 1064 PrintSharedInstanceJSON(&jsobj, ref); |
1109 jsobj.AddProperty("kind", "Type"); | 1065 jsobj.AddProperty("kind", "Type"); |
1110 if (HasResolvedTypeClass()) { | 1066 if (HasResolvedTypeClass()) { |
1111 const Class& type_cls = Class::Handle(type_class()); | 1067 const Class& type_cls = Class::Handle(type_class()); |
1112 if (type_cls.CanonicalType() == raw()) { | 1068 if (type_cls.CanonicalType() == raw()) { |
1113 intptr_t cid = type_cls.id(); | 1069 intptr_t cid = type_cls.id(); |
1114 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0); | 1070 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0); |
1115 } else { | 1071 } else { |
1116 jsobj.AddServiceId(*this); | 1072 jsobj.AddServiceId(*this); |
1117 } | 1073 } |
1118 jsobj.AddProperty("typeClass", type_cls); | 1074 jsobj.AddProperty("typeClass", type_cls); |
1119 } else { | 1075 } else { |
1120 jsobj.AddServiceId(*this); | 1076 jsobj.AddServiceId(*this); |
1121 } | 1077 } |
1122 const String& user_name = String::Handle(UserVisibleName()); | 1078 const String& user_name = String::Handle(UserVisibleName()); |
1123 const String& vm_name = String::Handle(Name()); | 1079 const String& vm_name = String::Handle(Name()); |
1124 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); | 1080 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); |
1125 if (ref) { | 1081 if (ref) { |
1126 return; | 1082 return; |
1127 } | 1083 } |
1128 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); | 1084 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
1129 if (!typeArgs.IsNull()) { | 1085 if (!typeArgs.IsNull()) { |
1130 jsobj.AddProperty("typeArguments", typeArgs); | 1086 jsobj.AddProperty("typeArguments", typeArgs); |
1131 } | 1087 } |
1132 } | 1088 } |
1133 | 1089 |
1134 | |
1135 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1090 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1136 JSONObject jsobj(stream); | 1091 JSONObject jsobj(stream); |
1137 PrintSharedInstanceJSON(&jsobj, ref); | 1092 PrintSharedInstanceJSON(&jsobj, ref); |
1138 jsobj.AddProperty("kind", "TypeRef"); | 1093 jsobj.AddProperty("kind", "TypeRef"); |
1139 jsobj.AddServiceId(*this); | 1094 jsobj.AddServiceId(*this); |
1140 const String& user_name = String::Handle(UserVisibleName()); | 1095 const String& user_name = String::Handle(UserVisibleName()); |
1141 const String& vm_name = String::Handle(Name()); | 1096 const String& vm_name = String::Handle(Name()); |
1142 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); | 1097 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); |
1143 if (ref) { | 1098 if (ref) { |
1144 return; | 1099 return; |
1145 } | 1100 } |
1146 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 1101 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
1147 } | 1102 } |
1148 | 1103 |
1149 | |
1150 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1104 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1151 JSONObject jsobj(stream); | 1105 JSONObject jsobj(stream); |
1152 PrintSharedInstanceJSON(&jsobj, ref); | 1106 PrintSharedInstanceJSON(&jsobj, ref); |
1153 jsobj.AddProperty("kind", "TypeParameter"); | 1107 jsobj.AddProperty("kind", "TypeParameter"); |
1154 jsobj.AddServiceId(*this); | 1108 jsobj.AddServiceId(*this); |
1155 const String& user_name = String::Handle(UserVisibleName()); | 1109 const String& user_name = String::Handle(UserVisibleName()); |
1156 const String& vm_name = String::Handle(Name()); | 1110 const String& vm_name = String::Handle(Name()); |
1157 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); | 1111 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); |
1158 const Class& param_cls = Class::Handle(parameterized_class()); | 1112 const Class& param_cls = Class::Handle(parameterized_class()); |
1159 jsobj.AddProperty("parameterizedClass", param_cls); | 1113 jsobj.AddProperty("parameterizedClass", param_cls); |
1160 if (ref) { | 1114 if (ref) { |
1161 return; | 1115 return; |
1162 } | 1116 } |
1163 jsobj.AddProperty("parameterIndex", index()); | 1117 jsobj.AddProperty("parameterIndex", index()); |
1164 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 1118 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
1165 jsobj.AddProperty("bound", upper_bound); | 1119 jsobj.AddProperty("bound", upper_bound); |
1166 } | 1120 } |
1167 | 1121 |
1168 | |
1169 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1122 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1170 JSONObject jsobj(stream); | 1123 JSONObject jsobj(stream); |
1171 PrintSharedInstanceJSON(&jsobj, ref); | 1124 PrintSharedInstanceJSON(&jsobj, ref); |
1172 jsobj.AddProperty("kind", "BoundedType"); | 1125 jsobj.AddProperty("kind", "BoundedType"); |
1173 jsobj.AddServiceId(*this); | 1126 jsobj.AddServiceId(*this); |
1174 const String& user_name = String::Handle(UserVisibleName()); | 1127 const String& user_name = String::Handle(UserVisibleName()); |
1175 const String& vm_name = String::Handle(Name()); | 1128 const String& vm_name = String::Handle(Name()); |
1176 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); | 1129 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString()); |
1177 if (ref) { | 1130 if (ref) { |
1178 return; | 1131 return; |
1179 } | 1132 } |
1180 jsobj.AddProperty("targetType", AbstractType::Handle(type())); | 1133 jsobj.AddProperty("targetType", AbstractType::Handle(type())); |
1181 jsobj.AddProperty("bound", AbstractType::Handle(bound())); | 1134 jsobj.AddProperty("bound", AbstractType::Handle(bound())); |
1182 } | 1135 } |
1183 | 1136 |
1184 | |
1185 void MixinAppType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1137 void MixinAppType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1186 UNREACHABLE(); | 1138 UNREACHABLE(); |
1187 } | 1139 } |
1188 | 1140 |
1189 | |
1190 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1141 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1191 UNREACHABLE(); | 1142 UNREACHABLE(); |
1192 } | 1143 } |
1193 | 1144 |
1194 | |
1195 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1145 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1196 JSONObject jsobj(stream); | 1146 JSONObject jsobj(stream); |
1197 PrintSharedInstanceJSON(&jsobj, ref); | 1147 PrintSharedInstanceJSON(&jsobj, ref); |
1198 jsobj.AddProperty("kind", "Int"); | 1148 jsobj.AddProperty("kind", "Int"); |
1199 jsobj.AddServiceId(*this); | 1149 jsobj.AddServiceId(*this); |
1200 jsobj.AddProperty("valueAsString", ToCString()); | 1150 jsobj.AddProperty("valueAsString", ToCString()); |
1201 } | 1151 } |
1202 | 1152 |
1203 | |
1204 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1153 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1205 JSONObject jsobj(stream); | 1154 JSONObject jsobj(stream); |
1206 PrintSharedInstanceJSON(&jsobj, ref); | 1155 PrintSharedInstanceJSON(&jsobj, ref); |
1207 jsobj.AddProperty("kind", "Int"); | 1156 jsobj.AddProperty("kind", "Int"); |
1208 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | 1157 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); |
1209 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); | 1158 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); |
1210 } | 1159 } |
1211 | 1160 |
1212 | |
1213 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1161 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1214 Integer::PrintJSONImpl(stream, ref); | 1162 Integer::PrintJSONImpl(stream, ref); |
1215 } | 1163 } |
1216 | 1164 |
1217 | |
1218 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1165 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1219 JSONObject jsobj(stream); | 1166 JSONObject jsobj(stream); |
1220 PrintSharedInstanceJSON(&jsobj, ref); | 1167 PrintSharedInstanceJSON(&jsobj, ref); |
1221 jsobj.AddProperty("kind", "Double"); | 1168 jsobj.AddProperty("kind", "Double"); |
1222 jsobj.AddServiceId(*this); | 1169 jsobj.AddServiceId(*this); |
1223 jsobj.AddProperty("valueAsString", ToCString()); | 1170 jsobj.AddProperty("valueAsString", ToCString()); |
1224 } | 1171 } |
1225 | 1172 |
1226 | |
1227 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1173 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1228 Integer::PrintJSONImpl(stream, ref); | 1174 Integer::PrintJSONImpl(stream, ref); |
1229 } | 1175 } |
1230 | 1176 |
1231 | |
1232 void String::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1177 void String::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1233 JSONObject jsobj(stream); | 1178 JSONObject jsobj(stream); |
1234 if (raw() == Symbols::OptimizedOut().raw()) { | 1179 if (raw() == Symbols::OptimizedOut().raw()) { |
1235 // TODO(turnidge): This is a hack. The user could have this | 1180 // TODO(turnidge): This is a hack. The user could have this |
1236 // special string in their program. Fixing this involves updating | 1181 // special string in their program. Fixing this involves updating |
1237 // the debugging api a bit. | 1182 // the debugging api a bit. |
1238 jsobj.AddProperty("type", "Sentinel"); | 1183 jsobj.AddProperty("type", "Sentinel"); |
1239 jsobj.AddProperty("kind", "OptimizedOut"); | 1184 jsobj.AddProperty("kind", "OptimizedOut"); |
1240 jsobj.AddProperty("valueAsString", "<optimized out>"); | 1185 jsobj.AddProperty("valueAsString", "<optimized out>"); |
1241 return; | 1186 return; |
(...skipping 17 matching lines...) Expand all Loading... |
1259 stream->ComputeOffsetAndCount(Length(), &offset, &count); | 1204 stream->ComputeOffsetAndCount(Length(), &offset, &count); |
1260 if (offset > 0) { | 1205 if (offset > 0) { |
1261 jsobj.AddProperty("offset", offset); | 1206 jsobj.AddProperty("offset", offset); |
1262 } | 1207 } |
1263 if (count < Length()) { | 1208 if (count < Length()) { |
1264 jsobj.AddProperty("count", count); | 1209 jsobj.AddProperty("count", count); |
1265 } | 1210 } |
1266 jsobj.AddPropertyStr("valueAsString", *this, offset, count); | 1211 jsobj.AddPropertyStr("valueAsString", *this, offset, count); |
1267 } | 1212 } |
1268 | 1213 |
1269 | |
1270 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1214 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1271 const char* str = ToCString(); | 1215 const char* str = ToCString(); |
1272 JSONObject jsobj(stream); | 1216 JSONObject jsobj(stream); |
1273 PrintSharedInstanceJSON(&jsobj, ref); | 1217 PrintSharedInstanceJSON(&jsobj, ref); |
1274 jsobj.AddProperty("kind", "Bool"); | 1218 jsobj.AddProperty("kind", "Bool"); |
1275 jsobj.AddFixedServiceId("objects/bool-%s", str); | 1219 jsobj.AddFixedServiceId("objects/bool-%s", str); |
1276 jsobj.AddPropertyF("valueAsString", "%s", str); | 1220 jsobj.AddPropertyF("valueAsString", "%s", str); |
1277 } | 1221 } |
1278 | 1222 |
1279 | |
1280 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1223 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1281 JSONObject jsobj(stream); | 1224 JSONObject jsobj(stream); |
1282 PrintSharedInstanceJSON(&jsobj, ref); | 1225 PrintSharedInstanceJSON(&jsobj, ref); |
1283 jsobj.AddProperty("kind", "List"); | 1226 jsobj.AddProperty("kind", "List"); |
1284 jsobj.AddServiceId(*this); | 1227 jsobj.AddServiceId(*this); |
1285 jsobj.AddProperty("length", Length()); | 1228 jsobj.AddProperty("length", Length()); |
1286 if (ref) { | 1229 if (ref) { |
1287 return; | 1230 return; |
1288 } | 1231 } |
1289 intptr_t offset; | 1232 intptr_t offset; |
(...skipping 10 matching lines...) Expand all Loading... |
1300 { | 1243 { |
1301 JSONArray jsarr(&jsobj, "elements"); | 1244 JSONArray jsarr(&jsobj, "elements"); |
1302 Object& element = Object::Handle(); | 1245 Object& element = Object::Handle(); |
1303 for (intptr_t index = offset; index < limit; index++) { | 1246 for (intptr_t index = offset; index < limit; index++) { |
1304 element = At(index); | 1247 element = At(index); |
1305 jsarr.AddValue(element); | 1248 jsarr.AddValue(element); |
1306 } | 1249 } |
1307 } | 1250 } |
1308 } | 1251 } |
1309 | 1252 |
1310 | |
1311 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1253 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1312 JSONObject jsobj(stream); | 1254 JSONObject jsobj(stream); |
1313 PrintSharedInstanceJSON(&jsobj, ref); | 1255 PrintSharedInstanceJSON(&jsobj, ref); |
1314 jsobj.AddProperty("kind", "List"); | 1256 jsobj.AddProperty("kind", "List"); |
1315 jsobj.AddServiceId(*this); | 1257 jsobj.AddServiceId(*this); |
1316 jsobj.AddProperty("length", Length()); | 1258 jsobj.AddProperty("length", Length()); |
1317 if (ref) { | 1259 if (ref) { |
1318 return; | 1260 return; |
1319 } | 1261 } |
1320 intptr_t offset; | 1262 intptr_t offset; |
(...skipping 10 matching lines...) Expand all Loading... |
1331 { | 1273 { |
1332 JSONArray jsarr(&jsobj, "elements"); | 1274 JSONArray jsarr(&jsobj, "elements"); |
1333 Object& element = Object::Handle(); | 1275 Object& element = Object::Handle(); |
1334 for (intptr_t index = offset; index < limit; index++) { | 1276 for (intptr_t index = offset; index < limit; index++) { |
1335 element = At(index); | 1277 element = At(index); |
1336 jsarr.AddValue(element); | 1278 jsarr.AddValue(element); |
1337 } | 1279 } |
1338 } | 1280 } |
1339 } | 1281 } |
1340 | 1282 |
1341 | |
1342 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1283 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1343 JSONObject jsobj(stream); | 1284 JSONObject jsobj(stream); |
1344 PrintSharedInstanceJSON(&jsobj, ref); | 1285 PrintSharedInstanceJSON(&jsobj, ref); |
1345 jsobj.AddProperty("kind", "Map"); | 1286 jsobj.AddProperty("kind", "Map"); |
1346 jsobj.AddServiceId(*this); | 1287 jsobj.AddServiceId(*this); |
1347 jsobj.AddProperty("length", Length()); | 1288 jsobj.AddProperty("length", Length()); |
1348 if (ref) { | 1289 if (ref) { |
1349 return; | 1290 return; |
1350 } | 1291 } |
1351 intptr_t offset; | 1292 intptr_t offset; |
(...skipping 18 matching lines...) Expand all Loading... |
1370 object = iterator.CurrentKey(); | 1311 object = iterator.CurrentKey(); |
1371 jsassoc.AddProperty("key", object); | 1312 jsassoc.AddProperty("key", object); |
1372 object = iterator.CurrentValue(); | 1313 object = iterator.CurrentValue(); |
1373 jsassoc.AddProperty("value", object); | 1314 jsassoc.AddProperty("value", object); |
1374 } | 1315 } |
1375 i++; | 1316 i++; |
1376 } | 1317 } |
1377 } | 1318 } |
1378 } | 1319 } |
1379 | 1320 |
1380 | |
1381 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1321 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1382 JSONObject jsobj(stream); | 1322 JSONObject jsobj(stream); |
1383 PrintSharedInstanceJSON(&jsobj, ref); | 1323 PrintSharedInstanceJSON(&jsobj, ref); |
1384 jsobj.AddProperty("kind", "Float32x4"); | 1324 jsobj.AddProperty("kind", "Float32x4"); |
1385 jsobj.AddServiceId(*this); | 1325 jsobj.AddServiceId(*this); |
1386 jsobj.AddProperty("valueAsString", ToCString()); | 1326 jsobj.AddProperty("valueAsString", ToCString()); |
1387 } | 1327 } |
1388 | 1328 |
1389 | |
1390 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1329 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1391 JSONObject jsobj(stream); | 1330 JSONObject jsobj(stream); |
1392 PrintSharedInstanceJSON(&jsobj, ref); | 1331 PrintSharedInstanceJSON(&jsobj, ref); |
1393 jsobj.AddProperty("kind", "Int32x4"); | 1332 jsobj.AddProperty("kind", "Int32x4"); |
1394 jsobj.AddServiceId(*this); | 1333 jsobj.AddServiceId(*this); |
1395 jsobj.AddProperty("valueAsString", ToCString()); | 1334 jsobj.AddProperty("valueAsString", ToCString()); |
1396 } | 1335 } |
1397 | 1336 |
1398 | |
1399 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1337 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1400 JSONObject jsobj(stream); | 1338 JSONObject jsobj(stream); |
1401 PrintSharedInstanceJSON(&jsobj, ref); | 1339 PrintSharedInstanceJSON(&jsobj, ref); |
1402 jsobj.AddProperty("kind", "Float64x2"); | 1340 jsobj.AddProperty("kind", "Float64x2"); |
1403 jsobj.AddServiceId(*this); | 1341 jsobj.AddServiceId(*this); |
1404 jsobj.AddProperty("valueAsString", ToCString()); | 1342 jsobj.AddProperty("valueAsString", ToCString()); |
1405 } | 1343 } |
1406 | 1344 |
1407 | |
1408 void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1345 void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1409 JSONObject jsobj(stream); | 1346 JSONObject jsobj(stream); |
1410 PrintSharedInstanceJSON(&jsobj, ref); | 1347 PrintSharedInstanceJSON(&jsobj, ref); |
1411 const Class& cls = Class::Handle(clazz()); | 1348 const Class& cls = Class::Handle(clazz()); |
1412 const String& kind = String::Handle(cls.UserVisibleName()); | 1349 const String& kind = String::Handle(cls.UserVisibleName()); |
1413 jsobj.AddProperty("kind", kind.ToCString()); | 1350 jsobj.AddProperty("kind", kind.ToCString()); |
1414 jsobj.AddServiceId(*this); | 1351 jsobj.AddServiceId(*this); |
1415 jsobj.AddProperty("length", Length()); | 1352 jsobj.AddProperty("length", Length()); |
1416 if (ref) { | 1353 if (ref) { |
1417 return; | 1354 return; |
1418 } | 1355 } |
1419 intptr_t offset; | 1356 intptr_t offset; |
1420 intptr_t count; | 1357 intptr_t count; |
1421 stream->ComputeOffsetAndCount(Length(), &offset, &count); | 1358 stream->ComputeOffsetAndCount(Length(), &offset, &count); |
1422 if (offset > 0) { | 1359 if (offset > 0) { |
1423 jsobj.AddProperty("offset", offset); | 1360 jsobj.AddProperty("offset", offset); |
1424 } | 1361 } |
1425 if (count < Length()) { | 1362 if (count < Length()) { |
1426 jsobj.AddProperty("count", count); | 1363 jsobj.AddProperty("count", count); |
1427 } | 1364 } |
1428 if (count == 0) { | 1365 if (count == 0) { |
1429 jsobj.AddProperty("bytes", ""); | 1366 jsobj.AddProperty("bytes", ""); |
1430 } else { | 1367 } else { |
1431 NoSafepointScope no_safepoint; | 1368 NoSafepointScope no_safepoint; |
1432 jsobj.AddPropertyBase64("bytes", reinterpret_cast<const uint8_t*>(DataAddr( | 1369 jsobj.AddPropertyBase64("bytes", |
1433 offset * ElementSizeInBytes())), | 1370 reinterpret_cast<const uint8_t*>( |
| 1371 DataAddr(offset * ElementSizeInBytes())), |
1434 count * ElementSizeInBytes()); | 1372 count * ElementSizeInBytes()); |
1435 } | 1373 } |
1436 } | 1374 } |
1437 | 1375 |
1438 | |
1439 void ExternalTypedData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1376 void ExternalTypedData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1440 JSONObject jsobj(stream); | 1377 JSONObject jsobj(stream); |
1441 PrintSharedInstanceJSON(&jsobj, ref); | 1378 PrintSharedInstanceJSON(&jsobj, ref); |
1442 const Class& cls = Class::Handle(clazz()); | 1379 const Class& cls = Class::Handle(clazz()); |
1443 const String& kind = String::Handle(cls.UserVisibleName()); | 1380 const String& kind = String::Handle(cls.UserVisibleName()); |
1444 jsobj.AddProperty("kind", kind.ToCString()); | 1381 jsobj.AddProperty("kind", kind.ToCString()); |
1445 jsobj.AddServiceId(*this); | 1382 jsobj.AddServiceId(*this); |
1446 jsobj.AddProperty("length", Length()); | 1383 jsobj.AddProperty("length", Length()); |
1447 if (ref) { | 1384 if (ref) { |
1448 return; | 1385 return; |
1449 } | 1386 } |
1450 intptr_t offset; | 1387 intptr_t offset; |
1451 intptr_t count; | 1388 intptr_t count; |
1452 stream->ComputeOffsetAndCount(Length(), &offset, &count); | 1389 stream->ComputeOffsetAndCount(Length(), &offset, &count); |
1453 if (offset > 0) { | 1390 if (offset > 0) { |
1454 jsobj.AddProperty("offset", offset); | 1391 jsobj.AddProperty("offset", offset); |
1455 } | 1392 } |
1456 if (count < Length()) { | 1393 if (count < Length()) { |
1457 jsobj.AddProperty("count", count); | 1394 jsobj.AddProperty("count", count); |
1458 } | 1395 } |
1459 if (count == 0) { | 1396 if (count == 0) { |
1460 jsobj.AddProperty("bytes", ""); | 1397 jsobj.AddProperty("bytes", ""); |
1461 } else { | 1398 } else { |
1462 NoSafepointScope no_safepoint; | 1399 NoSafepointScope no_safepoint; |
1463 jsobj.AddPropertyBase64("bytes", reinterpret_cast<const uint8_t*>(DataAddr( | 1400 jsobj.AddPropertyBase64("bytes", |
1464 offset * ElementSizeInBytes())), | 1401 reinterpret_cast<const uint8_t*>( |
| 1402 DataAddr(offset * ElementSizeInBytes())), |
1465 count * ElementSizeInBytes()); | 1403 count * ElementSizeInBytes()); |
1466 } | 1404 } |
1467 } | 1405 } |
1468 | 1406 |
1469 | |
1470 void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1407 void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1471 Instance::PrintJSONImpl(stream, ref); | 1408 Instance::PrintJSONImpl(stream, ref); |
1472 } | 1409 } |
1473 | 1410 |
1474 | |
1475 void ReceivePort::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1411 void ReceivePort::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1476 Instance::PrintJSONImpl(stream, ref); | 1412 Instance::PrintJSONImpl(stream, ref); |
1477 } | 1413 } |
1478 | 1414 |
1479 | |
1480 void SendPort::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1415 void SendPort::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1481 Instance::PrintJSONImpl(stream, ref); | 1416 Instance::PrintJSONImpl(stream, ref); |
1482 } | 1417 } |
1483 | 1418 |
1484 | |
1485 void ClosureData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1419 void ClosureData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1486 Object::PrintJSONImpl(stream, ref); | 1420 Object::PrintJSONImpl(stream, ref); |
1487 } | 1421 } |
1488 | 1422 |
1489 | |
1490 void SignatureData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1423 void SignatureData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1491 Object::PrintJSONImpl(stream, ref); | 1424 Object::PrintJSONImpl(stream, ref); |
1492 } | 1425 } |
1493 | 1426 |
1494 | |
1495 void Closure::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1427 void Closure::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1496 Instance::PrintJSONImpl(stream, ref); | 1428 Instance::PrintJSONImpl(stream, ref); |
1497 } | 1429 } |
1498 | 1430 |
1499 | |
1500 void StackTrace::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1431 void StackTrace::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1501 JSONObject jsobj(stream); | 1432 JSONObject jsobj(stream); |
1502 PrintSharedInstanceJSON(&jsobj, ref); | 1433 PrintSharedInstanceJSON(&jsobj, ref); |
1503 jsobj.AddProperty("kind", "StackTrace"); | 1434 jsobj.AddProperty("kind", "StackTrace"); |
1504 jsobj.AddServiceId(*this); | 1435 jsobj.AddServiceId(*this); |
1505 jsobj.AddProperty("valueAsString", ToCString()); | 1436 jsobj.AddProperty("valueAsString", ToCString()); |
1506 } | 1437 } |
1507 | 1438 |
1508 | |
1509 void RegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1439 void RegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1510 JSONObject jsobj(stream); | 1440 JSONObject jsobj(stream); |
1511 PrintSharedInstanceJSON(&jsobj, ref); | 1441 PrintSharedInstanceJSON(&jsobj, ref); |
1512 jsobj.AddProperty("kind", "RegExp"); | 1442 jsobj.AddProperty("kind", "RegExp"); |
1513 jsobj.AddServiceId(*this); | 1443 jsobj.AddServiceId(*this); |
1514 | 1444 |
1515 jsobj.AddProperty("pattern", String::Handle(pattern())); | 1445 jsobj.AddProperty("pattern", String::Handle(pattern())); |
1516 | 1446 |
1517 if (ref) { | 1447 if (ref) { |
1518 return; | 1448 return; |
(...skipping 26 matching lines...) Expand all Loading... |
1545 jsobj.AddProperty("_oneByteBytecode", bc); | 1475 jsobj.AddProperty("_oneByteBytecode", bc); |
1546 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/false); | 1476 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/false); |
1547 jsobj.AddProperty("_twoByteBytecode", bc); | 1477 jsobj.AddProperty("_twoByteBytecode", bc); |
1548 bc = bytecode(/*is_one_byte=*/true, /*sticky=*/true); | 1478 bc = bytecode(/*is_one_byte=*/true, /*sticky=*/true); |
1549 jsobj.AddProperty("_oneByteBytecodeSticky", bc); | 1479 jsobj.AddProperty("_oneByteBytecodeSticky", bc); |
1550 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/true); | 1480 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/true); |
1551 jsobj.AddProperty("_twoByteBytecodeSticky", bc); | 1481 jsobj.AddProperty("_twoByteBytecodeSticky", bc); |
1552 } | 1482 } |
1553 } | 1483 } |
1554 | 1484 |
1555 | |
1556 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1485 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1557 JSONObject jsobj(stream); | 1486 JSONObject jsobj(stream); |
1558 PrintSharedInstanceJSON(&jsobj, ref); | 1487 PrintSharedInstanceJSON(&jsobj, ref); |
1559 jsobj.AddProperty("kind", "WeakProperty"); | 1488 jsobj.AddProperty("kind", "WeakProperty"); |
1560 jsobj.AddServiceId(*this); | 1489 jsobj.AddServiceId(*this); |
1561 if (ref) { | 1490 if (ref) { |
1562 return; | 1491 return; |
1563 } | 1492 } |
1564 | 1493 |
1565 const Object& key_handle = Object::Handle(key()); | 1494 const Object& key_handle = Object::Handle(key()); |
1566 jsobj.AddProperty("propertyKey", key_handle); | 1495 jsobj.AddProperty("propertyKey", key_handle); |
1567 const Object& value_handle = Object::Handle(value()); | 1496 const Object& value_handle = Object::Handle(value()); |
1568 jsobj.AddProperty("propertyValue", value_handle); | 1497 jsobj.AddProperty("propertyValue", value_handle); |
1569 } | 1498 } |
1570 | 1499 |
1571 | |
1572 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1500 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1573 JSONObject jsobj(stream); | 1501 JSONObject jsobj(stream); |
1574 PrintSharedInstanceJSON(&jsobj, ref); | 1502 PrintSharedInstanceJSON(&jsobj, ref); |
1575 jsobj.AddProperty("kind", "MirrorReference"); | 1503 jsobj.AddProperty("kind", "MirrorReference"); |
1576 jsobj.AddServiceId(*this); | 1504 jsobj.AddServiceId(*this); |
1577 | 1505 |
1578 if (ref) { | 1506 if (ref) { |
1579 return; | 1507 return; |
1580 } | 1508 } |
1581 | 1509 |
1582 const Object& referent_handle = Object::Handle(referent()); | 1510 const Object& referent_handle = Object::Handle(referent()); |
1583 jsobj.AddProperty("mirrorReferent", referent_handle); | 1511 jsobj.AddProperty("mirrorReferent", referent_handle); |
1584 } | 1512 } |
1585 | 1513 |
1586 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1514 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1587 Instance::PrintJSONImpl(stream, ref); | 1515 Instance::PrintJSONImpl(stream, ref); |
1588 } | 1516 } |
1589 | 1517 |
1590 #endif | 1518 #endif |
1591 | 1519 |
1592 } // namespace dart | 1520 } // namespace dart |
OLD | NEW |