Flutter Engine
The Flutter Engine
object_service.cc
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
8#include "vm/debugger.h"
9#include "vm/object.h"
10#include "vm/object_graph.h"
11#include "vm/object_store.h"
12#include "vm/resolver.h"
13#include "vm/stub_code.h"
14#include "vm/symbols.h"
15
16namespace dart {
17
18#ifndef PRODUCT
19
20static void AddNameProperties(JSONObject* jsobj,
21 const char* name,
22 const char* vm_name) {
23 jsobj->AddProperty("name", name);
24 if (strcmp(name, vm_name) != 0) {
25 jsobj->AddProperty("_vmName", vm_name);
26 }
27}
28
30 const char* protocol_type,
31 bool ref) const {
32 const char* vm_type = JSONType();
33 bool same_type = (strcmp(protocol_type, vm_type) == 0);
34 if (ref) {
35 jsobj->AddPropertyF("type", "@%s", protocol_type);
36 } else {
37 jsobj->AddProperty("type", protocol_type);
38 }
39 if (!same_type) {
40 jsobj->AddProperty("_vmType", vm_type);
41 }
42 if (!ref || IsInstance() || IsNull()) {
43 // TODO(turnidge): Provide the type arguments here too?
44 const Class& cls = Class::Handle(this->clazz());
45 jsobj->AddProperty("class", cls);
46 }
47 if (!ref) {
48 if (ptr()->IsHeapObject()) {
49 jsobj->AddProperty("size", ptr()->untag()->HeapSize());
50 } else {
51 jsobj->AddProperty("size", (intptr_t)0);
52 }
53 }
54}
55
56void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
57 JSONObject jsobj(stream);
58 AddCommonObjectProperties(&jsobj, "Object", ref);
59 jsobj.AddServiceId(*this);
60 if (ref) {
61 return;
62 }
63}
64
65void Object::PrintJSON(JSONStream* stream, bool ref) const {
66 if (IsNull()) {
67 JSONObject jsobj(stream);
68 AddCommonObjectProperties(&jsobj, "Instance", ref);
69 jsobj.AddProperty("kind", "Null");
70 jsobj.AddFixedServiceId("objects/null");
71 jsobj.AddProperty("valueAsString", "null");
72 } else {
74 }
75}
76
78 const JSONArray& jsarr_fields) const {
80}
81
83 JSONObject jsobj(stream);
84 jsobj.AddProperty("type", "ImplementationFields");
85 JSONArray jsarr_fields(&jsobj, "fields");
86 if (!IsNull()) {
88 }
89}
90
91void Class::PrintJSONImpl(JSONStream* stream, bool ref) const {
92 Isolate* isolate = Isolate::Current();
93 JSONObject jsobj(stream);
94 if ((ptr() == Class::null()) || (id() == kFreeListElement)) {
95 // TODO(turnidge): This is weird and needs to be changed.
96 jsobj.AddProperty("type", "null");
97 return;
98 }
99 AddCommonObjectProperties(&jsobj, "Class", ref);
100 jsobj.AddFixedServiceId("classes/%" Pd "", id());
101 const String& scrubbed_name = String::Handle(ScrubbedName());
102 const String& vm_name = String::Handle(Name());
103 AddNameProperties(&jsobj, scrubbed_name.ToCString(), vm_name.ToCString());
104 const Script& script = Script::Handle(this->script());
105 if (!script.IsNull()) {
106 jsobj.AddLocation(script, token_pos(), end_token_pos());
107 }
108
109 jsobj.AddProperty("library", Object::Handle(library()));
110
111 const intptr_t num_type_params = NumTypeParameters();
112 if (num_type_params > 0) {
113 JSONArray jsarr(&jsobj, "typeParameters");
114 TypeParameter& type_param = TypeParameter::Handle();
115 for (intptr_t i = 0; i < num_type_params; ++i) {
116 type_param = TypeParameterAt(i);
117 jsarr.AddValue(type_param);
118 }
119 }
120 if (ref) {
121 return;
122 }
123
124 const Error& err = Error::Handle(EnsureIsFinalized(Thread::Current()));
125 if (!err.IsNull()) {
126 jsobj.AddProperty("error", err);
127 }
128 jsobj.AddProperty("abstract", is_abstract());
129 jsobj.AddProperty("const", is_const());
130 jsobj.AddProperty("isSealed", is_sealed());
131 jsobj.AddProperty("isMixinClass", is_mixin_class());
132 jsobj.AddProperty("isBaseClass", is_base_class());
133 jsobj.AddProperty("isInterfaceClass", is_interface_class());
134 jsobj.AddProperty("isFinal", is_final());
135 jsobj.AddProperty("_finalized", is_finalized());
136 jsobj.AddProperty("_implemented", is_implemented());
137 jsobj.AddProperty("_patch", false);
138 jsobj.AddProperty("traceAllocations", TraceAllocation(isolate->group()));
139
140 const Class& superClass = Class::Handle(SuperClass());
141 if (!superClass.IsNull()) {
142 jsobj.AddProperty("super", superClass);
143 }
144 const AbstractType& superType = AbstractType::Handle(super_type());
145 if (!superType.IsNull()) {
146 jsobj.AddProperty("superType", superType);
147 }
148 const Array& interface_array = Array::Handle(interfaces());
150 Type& mix = Type::Handle();
151 mix ^= interface_array.At(interface_array.Length() - 1);
152 jsobj.AddProperty("mixin", mix);
153 }
154 {
155 JSONArray interfaces_array(&jsobj, "interfaces");
156 Type& interface_type = Type::Handle();
157 if (!interface_array.IsNull()) {
158 for (intptr_t i = 0; i < interface_array.Length(); ++i) {
159 interface_type ^= interface_array.At(i);
160 interfaces_array.AddValue(interface_type);
161 }
162 }
163 }
164 {
165 JSONArray fields_array(&jsobj, "fields");
166 const Array& field_array = Array::Handle(fields());
167 Field& field = Field::Handle();
168 if (!field_array.IsNull()) {
169 for (intptr_t i = 0; i < field_array.Length(); ++i) {
170 field ^= field_array.At(i);
171 fields_array.AddValue(field);
172 }
173 }
174 }
175 {
176 JSONArray functions_array(&jsobj, "functions");
177 const Array& function_array = Array::Handle(current_functions());
178 Function& function = Function::Handle();
179 if (!function_array.IsNull()) {
180 for (intptr_t i = 0; i < function_array.Length(); i++) {
181 function ^= function_array.At(i);
182 functions_array.AddValue(function);
183 }
184 }
185 }
186 {
187 JSONArray subclasses_array(&jsobj, "subclasses");
188 const GrowableObjectArray& subclasses =
190 if (!subclasses.IsNull()) {
191 Class& subclass = Class::Handle();
192 for (intptr_t i = 0; i < subclasses.Length(); ++i) {
193 // TODO(turnidge): Use the Type directly once regis has added
194 // types to the vmservice.
195 subclass ^= subclasses.At(i);
196 subclasses_array.AddValue(subclass);
197 }
198 }
199 }
200}
201
202void Class::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {
203}
204
205void TypeParameters::PrintJSONImpl(JSONStream* stream, bool ref) const {
206 JSONObject jsobj(stream);
207 AddCommonObjectProperties(&jsobj, "TypeParameters", ref);
208 jsobj.AddServiceId(*this);
209 if (ref) {
210 return;
211 }
212 jsobj.AddProperty("flags", Array::Handle(flags()));
213 jsobj.AddProperty("names", Array::Handle(names()));
214 jsobj.AddProperty("bounds", TypeArguments::Handle(bounds()));
215 jsobj.AddProperty("defaults", TypeArguments::Handle(defaults()));
216}
217
219 const JSONArray& jsarr_fields) const {}
220
221void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
222 JSONObject jsobj(stream);
223 // The index in the canonical_type_arguments table cannot be used as part of
224 // the object id (as in typearguments/id), because the indices are not
225 // preserved when the table grows and the entries get rehashed. Use the ring.
226 Thread* thread = Thread::Current();
227 Zone* zone = thread->zone();
228 auto object_store = thread->isolate_group()->object_store();
229 CanonicalTypeArgumentsSet typeargs_table(
230 zone, object_store->canonical_type_arguments());
231 const Array& table =
232 Array::Handle(HashTables::ToArray(typeargs_table, false));
233 typeargs_table.Release();
234 ASSERT(table.Length() > 0);
235 AddCommonObjectProperties(&jsobj, "TypeArguments", ref);
236 jsobj.AddServiceId(*this);
237 const String& user_name = String::Handle(UserVisibleName());
238 const String& vm_name = String::Handle(Name());
239 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString());
240 if (ref) {
241 return;
242 }
243 {
244 JSONArray jsarr(&jsobj, "types");
246 for (intptr_t i = 0; i < Length(); i++) {
247 type_arg = TypeAt(i);
248 jsarr.AddValue(type_arg);
249 }
250 }
251 if (!IsInstantiated()) {
252 JSONArray jsarr(&jsobj, "_instantiations");
253 Array& prior_instantiations = Array::Handle(zone, instantiations());
254 TypeArguments& type_args = TypeArguments::Handle(zone);
255 InstantiationsCacheTable table(prior_instantiations);
256 for (const auto& tuple : table) {
257 // Skip unoccupied entries.
258 if (tuple.Get<Cache::kSentinelIndex>() == Cache::Sentinel()) continue;
259 JSONObject instantiation(&jsarr);
260 type_args ^= tuple.Get<Cache::kInstantiatorTypeArgsIndex>();
261 instantiation.AddProperty("instantiatorTypeArguments", type_args, true);
262 type_args = tuple.Get<Cache::kFunctionTypeArgsIndex>();
263 instantiation.AddProperty("functionTypeArguments", type_args, true);
264 type_args = tuple.Get<Cache::kInstantiatedTypeArgsIndex>();
265 instantiation.AddProperty("instantiated", type_args, true);
266 }
267 }
268}
269
271 const JSONArray& jsarr_fields) const {}
272
273void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const {
275}
276
278 const JSONArray& jsarr_fields) const {}
279
281 Class& cls = Class::Handle(Owner());
282 // Special kinds of functions use indices in their respective lists.
283 intptr_t id = -1;
284 const char* selector = nullptr;
285 // Regular functions known to their owner use their name (percent-encoded).
286 String& name = String::Handle(this->name());
287
290 selector = "closures";
291 } else if (IsImplicitClosureFunction()) {
292 id = cls.FindImplicitClosureFunctionIndex(*this);
293 selector = "implicit_closures";
296 selector = "dispatchers";
297 } else if (IsFieldInitializer()) {
299 const char* encoded_field_name = String::EncodeIRI(name);
300 if (cls.IsTopLevel()) {
301 const auto& library = Library::Handle(cls.library());
302 const auto& private_key = String::Handle(library.private_key());
303 jsobj.AddFixedServiceId("libraries/%s/field_inits/%s",
304 private_key.ToCString(), encoded_field_name);
305 } else {
306 jsobj.AddFixedServiceId("classes/%" Pd "/field_inits/%s", cls.id(),
307 encoded_field_name);
308 }
309 return;
310 }
311 if (id != -1) {
312 ASSERT(selector != nullptr);
313 if (cls.IsTopLevel()) {
314 const auto& library = Library::Handle(cls.library());
315 const auto& private_key = String::Handle(library.private_key());
316 jsobj.AddFixedServiceId("libraries/%s/%s/%" Pd "",
317 private_key.ToCString(), selector, id);
318 } else {
319 jsobj.AddFixedServiceId("classes/%" Pd "/%s/%" Pd "", cls.id(), selector,
320 id);
321 }
322 return;
323 }
324 Thread* thread = Thread::Current();
325 if (Resolver::ResolveFunction(thread->zone(), cls, name) == ptr()) {
326 const char* encoded_name = String::EncodeIRI(name);
327 if (cls.IsTopLevel()) {
328 const auto& library = Library::Handle(cls.library());
329 const auto& private_key = String::Handle(library.private_key());
330 jsobj.AddFixedServiceId("libraries/%s/functions/%s",
331 private_key.ToCString(), encoded_name);
332 } else {
333 jsobj.AddFixedServiceId("classes/%" Pd "/functions/%s", cls.id(),
334 encoded_name);
335 }
336 return;
337 }
338 // Oddball functions (not known to their owner) fall back to use the object
339 // id ring. Current known examples are signature functions of closures
340 // and stubs like 'megamorphic_call_miss'.
341 jsobj.AddServiceId(*this);
342}
343
344void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
345 Class& cls = Class::Handle(Owner());
346 ASSERT(!cls.IsNull());
347 Error& err = Error::Handle();
349 ASSERT(err.IsNull());
350 JSONObject jsobj(stream);
351 AddCommonObjectProperties(&jsobj, "Function", ref);
353 const char* user_name = UserVisibleNameCString();
354 const String& vm_name = String::Handle(name());
355 AddNameProperties(&jsobj, user_name, vm_name.ToCString());
356 const Function& parent = Function::Handle(parent_function());
357 if (!parent.IsNull()) {
358 jsobj.AddProperty("owner", parent);
359 } else if (!cls.IsNull()) {
360 if (cls.IsTopLevel()) {
361 const Library& library = Library::Handle(cls.library());
362 jsobj.AddProperty("owner", library);
363 } else {
364 jsobj.AddProperty("owner", cls);
365 }
366 }
367
368 const char* kind_string = Function::KindToCString(kind());
369 jsobj.AddProperty("_kind", kind_string);
370 jsobj.AddProperty("static", is_static());
371 jsobj.AddProperty("const", is_const());
372 jsobj.AddProperty("implicit", IsImplicitGetterOrSetter());
373 jsobj.AddProperty("abstract", is_abstract());
374 jsobj.AddProperty("_intrinsic", is_intrinsic());
375 jsobj.AddProperty("_native", is_native());
376 jsobj.AddProperty("isGetter", kind() == UntaggedFunction::kGetterFunction);
377 jsobj.AddProperty("isSetter", kind() == UntaggedFunction::kSetterFunction);
378
379 const Script& script = Script::Handle(this->script());
380 if (!script.IsNull()) {
381#if defined(DART_PRECOMPILED_RUNTIME)
382 // Token position information is stripped in AOT snapshots, but the line
383 // number is still included.
384 jsobj.AddLocationLine(script, line());
385#else
386 jsobj.AddLocation(script, token_pos(), end_token_pos());
387#endif // defined(DART_PRECOMPILED_RUNTIME)
388 }
389
390 if (ref) {
391 return;
392 }
393 const FunctionType& sig = FunctionType::Handle(signature());
394 jsobj.AddProperty("signature", sig);
395
396 Code& code = Code::Handle(CurrentCode());
397 if (!code.IsNull()) {
398 jsobj.AddProperty("code", code);
399 }
400 Array& ics = Array::Handle(ic_data_array());
401 if (!ics.IsNull()) {
402 jsobj.AddProperty("_icDataArray", ics);
403 }
404 jsobj.AddProperty("_optimizable", is_optimizable());
405 jsobj.AddProperty("_inlinable", is_inlinable());
406 jsobj.AddProperty("_recognized", IsRecognized());
408 if (!code.IsNull()) {
409 jsobj.AddProperty("_unoptimizedCode", code);
410 }
411 jsobj.AddProperty("_usageCounter", usage_counter());
412 jsobj.AddProperty("_optimizedCallSiteCount", optimized_call_site_count());
413 jsobj.AddProperty("_deoptimizations",
414 static_cast<intptr_t>(deoptimization_counter()));
415 if ((kind() == UntaggedFunction::kImplicitGetter) ||
416 (kind() == UntaggedFunction::kImplicitSetter) ||
417 (kind() == UntaggedFunction::kImplicitStaticGetter) ||
418 (kind() == UntaggedFunction::kFieldInitializer)) {
419 const Field& field = Field::Handle(accessor_field());
420 if (!field.IsNull()) {
421 jsobj.AddProperty("_field", field);
422 }
423 }
424}
425
427 const JSONArray& jsarr_fields) const {}
428
429void FfiTrampolineData::PrintJSONImpl(JSONStream* stream, bool ref) const {
431}
432
434 const JSONArray& jsarr_fields) const {}
435
436void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
437 JSONObject jsobj(stream);
438 Class& cls = Class::Handle(Owner());
439 String& field_name = String::Handle(name());
440 const char* encoded_field_name = String::EncodeIRI(field_name);
441 AddCommonObjectProperties(&jsobj, "Field", ref);
442 if (cls.IsTopLevel()) {
443 const auto& library = Library::Handle(cls.library());
444 const auto& private_key = String::Handle(library.private_key());
445 jsobj.AddFixedServiceId("libraries/%s/fields/%s", private_key.ToCString(),
446 encoded_field_name);
447 } else {
448 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%s", cls.id(),
449 encoded_field_name);
450 }
451
452 const char* user_name = UserVisibleNameCString();
453 const String& vm_name = String::Handle(name());
454 AddNameProperties(&jsobj, user_name, vm_name.ToCString());
455 if (cls.IsTopLevel()) {
456 const Library& library = Library::Handle(cls.library());
457 jsobj.AddProperty("owner", library);
458 } else {
459 jsobj.AddProperty("owner", cls);
460 }
461
462 AbstractType& declared_type = AbstractType::Handle(type());
463 jsobj.AddProperty("declaredType", declared_type);
464 jsobj.AddProperty("static", is_static());
465 jsobj.AddProperty("final", is_final());
466 jsobj.AddProperty("const", is_const());
467
468 const class Script& script = Script::Handle(Script());
469 if (!script.IsNull()) {
470 jsobj.AddLocation(script, token_pos(), end_token_pos());
471 }
472
473 if (ref) {
474 return;
475 }
476 if (is_static()) {
477 const Object& valueObj = Object::Handle(StaticValue());
478 jsobj.AddProperty("staticValue", valueObj);
479 }
480
481 jsobj.AddProperty("_guardNullable", is_nullable());
482 if (guarded_cid() == kIllegalCid) {
483 jsobj.AddProperty("_guardClass", "unknown");
484 } else if (guarded_cid() == kDynamicCid) {
485 jsobj.AddProperty("_guardClass", "dynamic");
486 } else {
487 ClassTable* table = IsolateGroup::Current()->class_table();
488 ASSERT(table->IsValidIndex(guarded_cid()));
489 cls = table->At(guarded_cid());
490 jsobj.AddProperty("_guardClass", cls);
491 }
493 jsobj.AddProperty("_guardLength", "unknown");
494 } else if (guarded_list_length() == kNoFixedLength) {
495 jsobj.AddProperty("_guardLength", "variable");
496 } else {
497 jsobj.AddPropertyF("_guardLength", "%" Pd, guarded_list_length());
498 }
499}
500
501void Field::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {
502}
503
504// See also Dart_ScriptGetTokenInfo.
505void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
506 JSONObject jsobj(stream);
507 AddCommonObjectProperties(&jsobj, "Script", ref);
508 const String& uri = String::Handle(url());
509 ASSERT(!uri.IsNull());
510 const char* encoded_uri = String::EncodeIRI(uri);
511 const Library& lib = Library::Handle(FindLibrary());
512 if (lib.IsNull()) {
513 jsobj.AddServiceId(*this);
514 } else {
515 const String& lib_id = String::Handle(lib.private_key());
516 jsobj.AddFixedServiceId("libraries/%s/scripts/%s/%" Px64 "",
517 lib_id.ToCString(), encoded_uri, load_timestamp());
518 }
519 jsobj.AddPropertyStr("uri", uri);
520 jsobj.AddProperty("_kind", "kernel");
521 if (ref) {
522 return;
523 }
524 jsobj.AddPropertyTimeMillis("_loadTime", load_timestamp());
525 if (!lib.IsNull()) {
526 jsobj.AddProperty("library", lib);
527 }
528 const String& source = String::Handle(Source());
529 jsobj.AddProperty("lineOffset", line_offset());
530 jsobj.AddProperty("columnOffset", col_offset());
531 if (!source.IsNull()) {
532 jsobj.AddPropertyStr("source", source);
533 }
534
535 // Print the line number table
536 const GrowableObjectArray& lineNumberArray =
538 if (!lineNumberArray.IsNull() && (lineNumberArray.Length() > 0)) {
539 JSONArray tokenPosTable(&jsobj, "tokenPosTable");
540
542 intptr_t pos = 0;
543
544 // Skip leading null.
545 ASSERT(lineNumberArray.Length() > 0);
546 value = lineNumberArray.At(pos);
547 ASSERT(value.IsNull());
548 pos++;
549
550 while (pos < lineNumberArray.Length()) {
551 JSONArray lineInfo(&tokenPosTable);
552 while (pos < lineNumberArray.Length()) {
553 value = lineNumberArray.At(pos);
554 pos++;
555 if (value.IsNull()) {
556 break;
557 }
558 const Smi& smi = Smi::Cast(value);
559 lineInfo.AddValue(smi.Value());
560 }
561 }
562 }
563}
564
566 const JSONArray& jsarr_fields) const {}
567
568static void PrintShowHideNamesToJSON(JSONObject* jsobj, const Namespace& ns) {
569 Array& arr = Array::Handle();
571 arr ^= ns.show_names();
572 if (!arr.IsNull()) {
573 JSONArray jsarr(jsobj, "shows");
574 for (intptr_t i = 0; i < arr.Length(); ++i) {
575 name ^= arr.At(i);
576 jsarr.AddValue(name.ToCString());
577 }
578 }
579 arr ^= ns.hide_names();
580 if (!arr.IsNull()) {
581 JSONArray jsarr(jsobj, "hides");
582 for (intptr_t i = 0; i < arr.Length(); ++i) {
583 name ^= arr.At(i);
584 jsarr.AddValue(name.ToCString());
585 }
586 }
587}
588
589void Library::PrintJSONImpl(JSONStream* stream, bool ref) const {
590 const String& id = String::Handle(private_key());
591 JSONObject jsobj(stream);
592 AddCommonObjectProperties(&jsobj, "Library", ref);
593 jsobj.AddFixedServiceId("libraries/%s", id.ToCString());
594 const String& vm_name = String::Handle(name());
595 const char* scrubbed_name = String::ScrubName(vm_name);
596 AddNameProperties(&jsobj, scrubbed_name, vm_name.ToCString());
597 const String& library_url = String::Handle(url());
598 jsobj.AddPropertyStr("uri", library_url);
599 if (ref) {
600 return;
601 }
602 jsobj.AddProperty("debuggable", IsDebuggable());
603 {
604 JSONArray jsarr(&jsobj, "classes");
605 ClassDictionaryIterator class_iter(*this);
606 Class& klass = Class::Handle();
607 while (class_iter.HasNext()) {
608 klass = class_iter.GetNextClass();
609 jsarr.AddValue(klass);
610 }
611 }
612 {
613 JSONArray jsarr(&jsobj, "dependencies");
614
616 Library& target = Library::Handle();
617
618 // Unprefixed imports.
619 Array& imports = Array::Handle(this->imports());
620 for (intptr_t i = 0; i < imports.Length(); i++) {
621 ns ^= imports.At(i);
622 if (ns.IsNull()) continue;
623
624 JSONObject jsdep(&jsarr);
625 jsdep.AddProperty("isDeferred", false);
626 jsdep.AddProperty("isExport", false);
627 jsdep.AddProperty("isImport", true);
628 target = ns.target();
629 jsdep.AddProperty("target", target);
630 PrintShowHideNamesToJSON(&jsdep, ns);
631 }
632
633 // Exports.
634 const Array& exports = Array::Handle(this->exports());
635 for (intptr_t i = 0; i < exports.Length(); i++) {
636 ns ^= exports.At(i);
637 if (ns.IsNull()) continue;
638
639 JSONObject jsdep(&jsarr);
640 jsdep.AddProperty("isDeferred", false);
641 jsdep.AddProperty("isExport", true);
642 jsdep.AddProperty("isImport", false);
643 target = ns.target();
644 jsdep.AddProperty("target", target);
645 PrintShowHideNamesToJSON(&jsdep, ns);
646 }
647
648 // Prefixed imports.
649 DictionaryIterator entries(*this);
650 Object& entry = Object::Handle();
651 LibraryPrefix& prefix = LibraryPrefix::Handle();
652 String& prefix_name = String::Handle();
653 while (entries.HasNext()) {
654 entry = entries.GetNext();
655 if (entry.IsLibraryPrefix()) {
656 prefix ^= entry.ptr();
657 imports = prefix.imports();
658 if (!imports.IsNull()) {
659 for (intptr_t i = 0; i < imports.Length(); i++) {
660 ns ^= imports.At(i);
661 if (ns.IsNull()) continue;
662
663 JSONObject jsdep(&jsarr);
664 jsdep.AddProperty("isDeferred", prefix.is_deferred_load());
665 jsdep.AddProperty("isExport", false);
666 jsdep.AddProperty("isImport", true);
667 prefix_name = prefix.name();
668 ASSERT(!prefix_name.IsNull());
669 jsdep.AddProperty("prefix", prefix_name.ToCString());
670 target = ns.target();
671 jsdep.AddProperty("target", target);
672 PrintShowHideNamesToJSON(&jsdep, ns);
673 }
674 }
675 }
676 }
677 }
678 {
679 JSONArray jsarr(&jsobj, "variables");
680 DictionaryIterator entries(*this);
681 Object& entry = Object::Handle();
682 while (entries.HasNext()) {
683 entry = entries.GetNext();
684 if (entry.IsField()) {
685 jsarr.AddValue(entry);
686 }
687 }
688 }
689 {
690 JSONArray jsarr(&jsobj, "functions");
691 DictionaryIterator entries(*this);
692 Object& entry = Object::Handle();
693 while (entries.HasNext()) {
694 entry = entries.GetNext();
695 if (entry.IsFunction()) {
696 const Function& func = Function::Cast(entry);
697 if (func.kind() == UntaggedFunction::kRegularFunction ||
698 func.kind() == UntaggedFunction::kGetterFunction ||
699 func.kind() == UntaggedFunction::kSetterFunction) {
700 jsarr.AddValue(func);
701 }
702 }
703 }
704 }
705 {
706 JSONArray jsarr(&jsobj, "scripts");
708 Script& script = Script::Handle();
709 for (intptr_t i = 0; i < scripts.Length(); i++) {
710 script ^= scripts.At(i);
711 jsarr.AddValue(script);
712 }
713 }
714}
715
717 const JSONArray& jsarr_fields) const {}
718
719void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const {
721}
722
724 const JSONArray& jsarr_fields) const {}
725
726void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const {
728}
729
731 const JSONArray& jsarr_fields) const {}
732
733void KernelProgramInfo::PrintJSONImpl(JSONStream* stream, bool ref) const {
735}
736
738 const JSONArray& jsarr_fields) const {}
739
740void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const {
742}
743
745 const JSONArray& jsarr_fields) const {}
746
747void InstructionsSection::PrintJSONImpl(JSONStream* stream, bool ref) const {
749}
750
752 const JSONArray& jsarr_fields) const {}
753
754void InstructionsTable::PrintJSONImpl(JSONStream* stream, bool ref) const {
756}
757
759 const JSONArray& jsarr_fields) const {}
760
762 bool ref) const {
763 JSONObject jsobj(stream);
764 AddCommonObjectProperties(&jsobj, "Object", ref);
765 jsobj.AddServiceId(*this);
766 if (ref) return;
767 auto& obj = Object::Handle(target());
768 jsobj.AddProperty("target", obj);
769}
770
772 const JSONArray& jsarr_fields) const {}
773
774void WeakArray::PrintJSONImpl(JSONStream* stream, bool ref) const {
775 JSONObject jsobj(stream);
776 AddCommonObjectProperties(&jsobj, "Object", ref);
777 jsobj.AddServiceId(*this);
778 jsobj.AddProperty("length", Length());
779 if (ref) {
780 return;
781 }
782 intptr_t offset;
783 intptr_t count;
784 stream->ComputeOffsetAndCount(Length(), &offset, &count);
785 if (offset > 0) {
786 jsobj.AddProperty("offset", offset);
787 }
788 if (count < Length()) {
789 jsobj.AddProperty("count", count);
790 }
791 intptr_t limit = offset + count;
792 ASSERT(limit <= Length());
793 {
794 JSONArray jsarr(&jsobj, "elements");
795 Object& element = Object::Handle();
796 for (intptr_t index = offset; index < limit; index++) {
797 element = At(index);
798 jsarr.AddValue(element);
799 }
800 }
801}
802
804 const JSONArray& jsarr_fields) const {}
805
806void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const {
807 JSONObject jsobj(stream);
808 AddCommonObjectProperties(&jsobj, "Object", ref);
809 jsobj.AddServiceId(*this);
810 jsobj.AddProperty("length", Length());
811 if (ref) {
812 return;
813 }
814
815 {
816 JSONArray jsarr(&jsobj, "_entries");
817 uword imm;
818 Object& obj = Object::Handle();
819 for (intptr_t i = 0; i < Length(); i++) {
820 JSONObject jsentry(stream);
821 jsentry.AddProperty("offset", OffsetFromIndex(i));
822 switch (TypeAt(i)) {
823 case ObjectPool::EntryType::kTaggedObject:
824 obj = ObjectAt(i);
825 jsentry.AddProperty("kind", "Object");
826 jsentry.AddProperty("value", obj);
827 break;
828 case ObjectPool::EntryType::kImmediate:
829 imm = RawValueAt(i);
830 jsentry.AddProperty("kind", "Immediate");
831 jsentry.AddPropertyF("value", "0x%" Px, imm);
832 break;
833 case ObjectPool::EntryType::kNativeFunction:
834 imm = RawValueAt(i);
835 jsentry.AddProperty("kind", "NativeFunction");
836 jsentry.AddPropertyF("value", "0x%" Px, imm);
837 break;
838 default:
839 UNREACHABLE();
840 }
841 }
842 }
843}
844
846 const JSONArray& jsarr_fields) const {}
847
848void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
849 AddCommonObjectProperties(jsobj, "Object", ref);
850 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
851 // object but do not have a back reference to generate an ID.
852 jsobj->AddServiceId(*this);
853 if (ref) {
854 return;
855 }
856 JSONArray members(jsobj, "members");
857 Iterator iter(*this, UntaggedPcDescriptors::kAnyKind);
858 while (iter.MoveNext()) {
859 JSONObject descriptor(&members);
860 descriptor.AddPropertyF("pcOffset", "%" Px "", iter.PcOffset());
861 descriptor.AddProperty("kind", KindAsStr(iter.Kind()));
862 descriptor.AddProperty("deoptId", iter.DeoptId());
863 // TODO(turnidge): Use AddLocation instead.
864 descriptor.AddProperty("tokenPos", iter.TokenPos());
865 descriptor.AddProperty("tryIndex", iter.TryIndex());
866 }
867}
868
869void PcDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const {
870 JSONObject jsobj(stream);
871 PrintToJSONObject(&jsobj, ref);
872}
873
875 const JSONArray& jsarr_fields) const {}
876
877void CodeSourceMap::PrintJSONImpl(JSONStream* stream, bool ref) const {
879}
880
882 const JSONArray& jsarr_fields) const {}
883
884void CompressedStackMaps::PrintJSONImpl(JSONStream* stream, bool ref) const {
886}
887
889 const JSONArray& jsarr_fields) const {}
890
891void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, bool ref) const {
892 JSONObject jsobj(stream);
893 AddCommonObjectProperties(&jsobj, "Object", ref);
894 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off
895 // a Code object but do not have a back reference to generate an ID.
896 jsobj.AddServiceId(*this);
897 if (ref) {
898 return;
899 }
900 JSONArray members(&jsobj, "members");
901 String& var_name = String::Handle();
902 for (intptr_t i = 0; i < Length(); i++) {
903 UntaggedLocalVarDescriptors::VarInfo info;
904 var_name = GetName(i);
905 GetInfo(i, &info);
906 JSONObject var(&members);
907 var.AddProperty("name", var_name.ToCString());
908 var.AddProperty("index", static_cast<intptr_t>(info.index()));
909 var.AddProperty("declarationTokenPos", info.declaration_pos);
910 var.AddProperty("scopeStartTokenPos", info.begin_pos);
911 var.AddProperty("scopeEndTokenPos", info.end_pos);
912 var.AddProperty("scopeId", static_cast<intptr_t>(info.scope_id));
913 var.AddProperty("kind", KindToCString(info.kind()));
914 }
915}
916
918 const JSONArray& jsarr_fields) const {}
919
920void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, bool ref) const {
922}
923
925 const JSONArray& jsarr_fields) const {}
926
927void SingleTargetCache::PrintJSONImpl(JSONStream* stream, bool ref) const {
928 JSONObject jsobj(stream);
929 AddCommonObjectProperties(&jsobj, "Object", ref);
930 jsobj.AddServiceId(*this);
931 jsobj.AddProperty("_target", Code::Handle(target()));
932 if (ref) {
933 return;
934 }
935 jsobj.AddProperty("_lowerLimit", lower_limit());
936 jsobj.AddProperty("_upperLimit", upper_limit());
937}
938
940 const JSONArray& jsarr_fields) const {}
941
942void UnlinkedCall::PrintJSONImpl(JSONStream* stream, bool ref) const {
943 JSONObject jsobj(stream);
944 AddCommonObjectProperties(&jsobj, "Object", ref);
945 jsobj.AddServiceId(*this);
946 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString());
947 if (ref) {
948 return;
949 }
950 jsobj.AddProperty("_argumentsDescriptor",
952}
953
955 const JSONArray& jsarr_fields) const {}
956
957void MonomorphicSmiableCall::PrintJSONImpl(JSONStream* stream, bool ref) const {
958 JSONObject jsobj(stream);
959 AddCommonObjectProperties(&jsobj, "Object", ref);
960 jsobj.AddServiceId(*this);
961 jsobj.AddProperty("_expectedClassId", Smi::Handle(Smi::New(expected_cid())));
962 if (ref) {
963 return;
964 }
965}
966
968 const JSONArray& jsarr_fields) const {}
969
970void CallSiteData::PrintJSONImpl(JSONStream* stream, bool ref) const {
971 UNREACHABLE();
972}
973
975 const JSONArray& jsarr_fields) const {
976 UNREACHABLE();
977}
978
979void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const {
980 JSONObject jsobj(stream);
981 AddCommonObjectProperties(&jsobj, "Object", ref);
982 jsobj.AddServiceId(*this);
983 jsobj.AddProperty("_owner", Object::Handle(Owner()));
984 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString());
985 if (ref) {
986 return;
987 }
988 jsobj.AddProperty("_argumentsDescriptor",
990 jsobj.AddProperty("_entries", Object::Handle(entries()));
991}
992
994 TokenPosition token_pos) const {
995 auto class_table = IsolateGroup::Current()->class_table();
996 Class& cls = Class::Handle();
997 Function& func = Function::Handle();
998
999 JSONObject jsobj(&jsarray);
1000 jsobj.AddProperty("name", String::Handle(target_name()).ToCString());
1001 jsobj.AddProperty("tokenPos", static_cast<intptr_t>(token_pos.Serialize()));
1002 // TODO(rmacnak): Figure out how to stringify DeoptReasons().
1003 // jsobj.AddProperty("deoptReasons", ...);
1004
1005 JSONArray cache_entries(&jsobj, "cacheEntries");
1006 for (intptr_t i = 0; i < NumberOfChecks(); i++) {
1007 JSONObject cache_entry(&cache_entries);
1008 func = GetTargetAt(i);
1009 intptr_t count = GetCountAt(i);
1010 if (!is_static_call()) {
1011 intptr_t cid = GetReceiverClassIdAt(i);
1012 cls = class_table->At(cid);
1013 cache_entry.AddProperty("receiver", cls);
1014 }
1015 cache_entry.AddProperty("target", func);
1016 cache_entry.AddProperty("count", count);
1017 }
1018}
1019
1021 const JSONArray& jsarr_fields) const {}
1022
1023void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
1024 JSONObject jsobj(stream);
1025 AddCommonObjectProperties(&jsobj, "Code", ref);
1026 jsobj.AddFixedServiceId("code/%" Px64 "-%" Px "", compile_timestamp(),
1027 PayloadStart());
1028 const char* qualified_name = QualifiedName(
1029 NameFormattingParams(kUserVisibleName, NameDisambiguation::kNo));
1030 const char* vm_name = Name();
1031 AddNameProperties(&jsobj, qualified_name, vm_name);
1032 const bool is_stub =
1034 if (is_stub) {
1035 jsobj.AddProperty("kind", "Stub");
1036 } else {
1037 jsobj.AddProperty("kind", "Dart");
1038 }
1039 jsobj.AddProperty("_optimized", is_optimized());
1040 const Object& obj = Object::Handle(owner());
1041 if (obj.IsFunction()) {
1042 const Function& func = Function::Cast(obj);
1043 jsobj.AddProperty("_intrinsic", func.is_intrinsic());
1044 jsobj.AddProperty("_native", func.is_native());
1045 } else {
1046 jsobj.AddProperty("_intrinsic", false);
1047 jsobj.AddProperty("_native", false);
1048 }
1049 if (obj.IsFunction()) {
1050 jsobj.AddProperty("function", obj);
1051 } else {
1052 // Generate a fake function reference.
1053 JSONObject func(&jsobj, "function");
1054 func.AddProperty("type", "@Function");
1055 func.AddProperty("_kind", "Stub");
1056 ASSERT(strcmp(qualified_name, vm_name) == 0);
1057 func.AddProperty("name", vm_name);
1059 }
1060 if (ref) {
1061 return;
1062 }
1063 jsobj.AddPropertyF("_startAddress", "%" Px "", PayloadStart());
1064 jsobj.AddPropertyF("_endAddress", "%" Px "", PayloadStart() + Size());
1065 jsobj.AddProperty("_alive", is_alive());
1066 const ObjectPool& object_pool = ObjectPool::Handle(GetObjectPool());
1067 jsobj.AddProperty("_objectPool", object_pool);
1068 {
1069 JSONArray jsarr(&jsobj, "_disassembly");
1070 if (is_alive()) {
1071 // Only disassemble alive code objects.
1072 DisassembleToJSONStream formatter(jsarr);
1073 Disassemble(&formatter);
1074 }
1075 }
1076 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
1077 if (!descriptors.IsNull()) {
1078 JSONObject desc(&jsobj, "_descriptors");
1079 descriptors.PrintToJSONObject(&desc, false);
1080 }
1081
1082 PrintJSONInlineIntervals(&jsobj);
1083}
1084
1085void Code::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1086
1087void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
1088 JSONObject jsobj(stream);
1089 // TODO(turnidge): Should the user level type for Context be Context
1090 // or Object?
1091 AddCommonObjectProperties(&jsobj, "Context", ref);
1092 jsobj.AddServiceId(*this);
1093
1094 jsobj.AddProperty("length", num_variables());
1095
1096 if (ref) {
1097 return;
1098 }
1099
1100 const Context& parent_context = Context::Handle(parent());
1101 if (!parent_context.IsNull()) {
1102 jsobj.AddProperty("parent", parent_context);
1103 }
1104
1105 JSONArray jsarr(&jsobj, "variables");
1106 Object& var = Object::Handle();
1107 for (intptr_t index = 0; index < num_variables(); index++) {
1108 var = At(index);
1109 JSONObject jselement(&jsarr);
1110 jselement.AddProperty("value", var);
1111 }
1112}
1113
1115 const JSONArray& jsarr_fields) const {}
1116
1117void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const {
1119}
1120
1122 const JSONArray& jsarr_fields) const {}
1123
1124void Sentinel::PrintJSONImpl(JSONStream* stream, bool ref) const {
1125 // Handle certain special sentinel values.
1126 if (ptr() == Object::sentinel().ptr()) {
1127 JSONObject jsobj(stream);
1128 jsobj.AddProperty("type", "Sentinel");
1129 jsobj.AddProperty("kind", "NotInitialized");
1130 jsobj.AddProperty("valueAsString", "<not initialized>");
1131 return;
1132 } else if (ptr() == Object::transition_sentinel().ptr()) {
1133 JSONObject jsobj(stream);
1134 jsobj.AddProperty("type", "Sentinel");
1135 jsobj.AddProperty("kind", "BeingInitialized");
1136 jsobj.AddProperty("valueAsString", "<being initialized>");
1137 return;
1138 } else if (ptr() == Object::optimized_out().ptr()) {
1139 JSONObject jsobj(stream);
1140 jsobj.AddProperty("type", "Sentinel");
1141 jsobj.AddProperty("kind", "OptimizedOut");
1142 jsobj.AddProperty("valueAsString", "<optimized out>");
1143 return;
1144 }
1145
1147}
1148
1150 const JSONArray& jsarr_fields) const {}
1151
1152void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const {
1153 JSONObject jsobj(stream);
1154 AddCommonObjectProperties(&jsobj, "Object", ref);
1155 jsobj.AddServiceId(*this);
1156 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString());
1157 if (ref) {
1158 return;
1159 }
1160 jsobj.AddProperty("_buckets", Object::Handle(buckets()));
1161 jsobj.AddProperty("_mask", mask());
1162 jsobj.AddProperty("_argumentsDescriptor",
1164}
1165
1167 const JSONArray& jsarr_fields) const {}
1168
1169void SubtypeTestCache::PrintJSONImpl(JSONStream* stream, bool ref) const {
1170 JSONObject jsobj(stream);
1171 AddCommonObjectProperties(&jsobj, "Object", ref);
1172 jsobj.AddServiceId(*this);
1173 if (ref) {
1174 return;
1175 }
1176 jsobj.AddProperty("_cache", Array::Handle(cache()));
1177}
1178
1180 const JSONArray& jsarr_fields) const {}
1181
1182void LoadingUnit::PrintJSONImpl(JSONStream* stream, bool ref) const {
1183 JSONObject jsobj(stream);
1184 AddCommonObjectProperties(&jsobj, "Object", ref);
1185 jsobj.AddServiceId(*this);
1186 if (ref) {
1187 return;
1188 }
1189 jsobj.AddProperty("_parent", LoadingUnit::Handle(parent()));
1190 jsobj.AddProperty("_baseObjects", Array::Handle(base_objects()));
1191 jsobj.AddProperty("_id", static_cast<intptr_t>(id()));
1192 jsobj.AddProperty("_loaded", loaded());
1193 jsobj.AddProperty("_loadOutstanding", load_outstanding());
1194}
1195
1197 const JSONArray& jsarr_fields) const {}
1198
1199void Error::PrintJSONImpl(JSONStream* stream, bool ref) const {
1200 UNREACHABLE();
1201}
1202
1203void Error::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {
1204 UNREACHABLE();
1205}
1206
1207void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const {
1208 JSONObject jsobj(stream);
1209 AddCommonObjectProperties(&jsobj, "Error", ref);
1210 jsobj.AddProperty("kind", "InternalError");
1211 jsobj.AddServiceId(*this);
1212 jsobj.AddProperty("message", ToErrorCString());
1213}
1214
1216 const JSONArray& jsarr_fields) const {}
1217
1218void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const {
1219 JSONObject jsobj(stream);
1220 AddCommonObjectProperties(&jsobj, "Error", ref);
1221 jsobj.AddProperty("kind", "LanguageError");
1222 jsobj.AddServiceId(*this);
1223 jsobj.AddProperty("message", ToErrorCString());
1224}
1225
1227 const JSONArray& jsarr_fields) const {}
1228
1229void UnhandledException::PrintJSONImpl(JSONStream* stream, bool ref) const {
1230 JSONObject jsobj(stream);
1231 AddCommonObjectProperties(&jsobj, "Error", ref);
1232 jsobj.AddProperty("kind", "UnhandledException");
1233 jsobj.AddServiceId(*this);
1234 jsobj.AddProperty("message", ToErrorCString());
1235 if (ref) {
1236 return;
1237 }
1238 Instance& instance = Instance::Handle();
1239 instance = exception();
1240 jsobj.AddProperty("exception", instance);
1241 instance = stacktrace();
1242 jsobj.AddProperty("stacktrace", instance);
1243}
1244
1246 const JSONArray& jsarr_fields) const {}
1247
1248void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
1249 JSONObject jsobj(stream);
1250 AddCommonObjectProperties(&jsobj, "Error", ref);
1251 jsobj.AddProperty("kind", "TerminationError");
1252 jsobj.AddServiceId(*this);
1253 jsobj.AddProperty("message", ToErrorCString());
1254 jsobj.AddProperty("_is_user_initiated", is_user_initiated());
1255}
1256
1258 const JSONArray& jsarr_fields) const {}
1259
1261 bool ref,
1262 bool include_id) const {
1263 AddCommonObjectProperties(jsobj, "Instance", ref);
1264 {
1265 NoSafepointScope safepoint_scope;
1266 uint32_t hash_code = HeapSnapshotWriter::GetHeapSnapshotIdentityHash(
1267 Thread::Current(), ptr());
1268 jsobj->AddProperty64("identityHashCode", hash_code);
1269 }
1270 if (include_id) {
1271 jsobj->AddServiceId(*this);
1272 }
1273 if (ref) {
1274 return;
1275 }
1276
1277 // Add all fields in layout order, from superclass to subclass.
1278 GrowableArray<Class*> classes;
1279 Class& cls = Class::Handle(this->clazz());
1280 if (IsClosure()) {
1281 // Closure fields are not instances. Skip them.
1282 cls = cls.SuperClass();
1283 }
1284 do {
1285 classes.Add(&Class::Handle(cls.ptr()));
1286 cls = cls.SuperClass();
1287 } while (!cls.IsNull());
1288
1289 Array& field_array = Array::Handle();
1290 Field& field = Field::Handle();
1291 Object& field_value = Object::Handle();
1292 {
1293 JSONArray jsarr(jsobj, "fields");
1294 for (intptr_t i = classes.length() - 1; i >= 0; i--) {
1295 field_array = classes[i]->fields();
1296 if (!field_array.IsNull()) {
1297 for (intptr_t j = 0; j < field_array.Length(); j++) {
1298 field ^= field_array.At(j);
1299 if (!field.is_static()) {
1300 field_value = GetField(field);
1301 JSONObject jsfield(&jsarr);
1302 jsfield.AddProperty("decl", field);
1303 jsfield.AddProperty("name", field.UserVisibleNameCString());
1304 jsfield.AddProperty("value", field_value);
1305 }
1306 }
1307 }
1308 }
1309 }
1310
1311 if (NumNativeFields() > 0) {
1312 JSONArray jsarr(jsobj, "_nativeFields");
1313 for (intptr_t i = 0; i < NumNativeFields(); i++) {
1314 intptr_t value = GetNativeField(i);
1315 JSONObject jsfield(&jsarr);
1316 jsfield.AddProperty("index", i);
1317 jsfield.AddProperty("value", value);
1318 }
1319 }
1320}
1321
1322void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
1323 JSONObject jsobj(stream);
1324 PrintSharedInstanceJSON(&jsobj, ref);
1325 jsobj.AddProperty("kind", "PlainInstance");
1326
1327 GrowableArray<Class*> classes;
1328 Array& field_array = Array::Handle();
1329 Field& field = Field::Handle();
1330 Class& cls = Class::Handle(this->clazz());
1331 if (IsClosure()) {
1332 // Closure fields are not instances. Skip them.
1333 cls = cls.SuperClass();
1334 }
1335 do {
1336 classes.Add(&Class::Handle(cls.ptr()));
1337 cls = cls.SuperClass();
1338 } while (!cls.IsNull());
1339
1340 intptr_t num_fields = 0;
1341 for (intptr_t i = classes.length() - 1; i >= 0; --i) {
1342 field_array ^= classes[i]->fields();
1343 if (!field_array.IsNull()) {
1344 for (intptr_t j = 0; j < field_array.Length(); ++j) {
1345 field ^= field_array.At(j);
1346 if (!field.is_static()) {
1347 ++num_fields;
1348 }
1349 }
1350 }
1351 }
1352 jsobj.AddProperty("length", num_fields);
1353}
1354
1356 const JSONArray& jsarr_fields) const {}
1357
1358void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const {
1359 UNREACHABLE();
1360}
1361
1363 const JSONArray& jsarr_fields) const {
1364 UNREACHABLE();
1365}
1366
1367void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
1368 JSONObject jsobj(stream);
1369 PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
1370 jsobj.AddProperty("kind", "Type");
1371 const Class& type_cls = Class::Handle(type_class());
1372 if (type_cls.DeclarationType() == ptr()) {
1373 intptr_t cid = type_cls.id();
1374 jsobj.AddFixedServiceId("classes/%" Pd "/types/%d", cid, 0);
1375 } else {
1376 jsobj.AddServiceId(*this);
1377 }
1378 jsobj.AddProperty("typeClass", type_cls);
1379 const String& user_name = String::Handle(UserVisibleName());
1380 const String& vm_name = String::Handle(Name());
1381 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString());
1382 if (ref) {
1383 return;
1384 }
1385 const TypeArguments& typeArgs = TypeArguments::Handle(arguments());
1386 if (!typeArgs.IsNull()) {
1387 jsobj.AddProperty("typeArguments", typeArgs);
1388 }
1389}
1390
1391void Type::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1392
1393void FunctionType::PrintJSONImpl(JSONStream* stream, bool ref) const {
1394 JSONObject jsobj(stream);
1395 PrintSharedInstanceJSON(&jsobj, ref);
1396 jsobj.AddProperty("kind", "FunctionType");
1397 AbstractType& type = AbstractType::Handle(result_type());
1398 jsobj.AddProperty("returnType", type);
1399
1400 const int type_params_count = NumTypeParameters();
1401 if (type_params_count > 0) {
1402 JSONArray arr(&jsobj, "typeParameters");
1403 TypeParameter& type_param = TypeParameter::Handle();
1404 for (intptr_t i = 0; i < type_params_count; ++i) {
1405 type_param = TypeParameterAt(i);
1406 arr.AddValue(type_param);
1407 }
1408 }
1409
1410 {
1411 JSONArray jsarr(&jsobj, "parameters");
1412 String& name = String::Handle();
1413 const intptr_t param_count = NumParameters();
1414 const intptr_t fixed_param_count = num_fixed_parameters();
1415 const bool has_named = HasOptionalNamedParameters();
1416 for (intptr_t i = 0; i < param_count; ++i) {
1417 JSONObject param(&jsarr);
1419 param.AddProperty("parameterType", type);
1420 bool fixed = i < fixed_param_count;
1421 param.AddProperty("fixed", fixed);
1422 if (!fixed && has_named) {
1424 param.AddProperty("name", name.ToCString());
1425 param.AddProperty("required", IsRequiredAt(i));
1426 }
1427 }
1428 }
1429}
1430
1432 const JSONArray& jsarr_fields) const {}
1433
1434void RecordType::PrintJSONImpl(JSONStream* stream, bool ref) const {
1435 JSONObject jsobj(stream);
1436 PrintSharedInstanceJSON(&jsobj, ref);
1437 jsobj.AddProperty("kind", "RecordType");
1438 if (ref) {
1439 return;
1440 }
1441
1442 {
1443 JSONArray jsarr(&jsobj, "fields");
1444 String& name = String::Handle();
1445 AbstractType& type = AbstractType::Handle();
1446 const intptr_t num_fields = NumFields();
1447 const Array& field_names = Array::Handle(GetFieldNames(Thread::Current()));
1448 const intptr_t num_positional_fields = num_fields - field_names.Length();
1449 for (intptr_t index = 0; index < num_fields; ++index) {
1450 JSONObject jsfield(&jsarr);
1451 if (index < num_positional_fields) {
1452 jsfield.AddProperty("name", index + 1);
1453 } else {
1454 name ^= field_names.At(index - num_positional_fields);
1455 jsfield.AddProperty("name", name.ToCString());
1456 }
1457 type = FieldTypeAt(index);
1458 jsfield.AddProperty("value", type);
1459 }
1460 }
1461}
1462
1464 const JSONArray& jsarr_fields) const {}
1465
1466void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
1467 JSONObject jsobj(stream);
1468 PrintSharedInstanceJSON(&jsobj, ref);
1469 jsobj.AddProperty("kind", "TypeParameter");
1470 const String& user_name = String::Handle(UserVisibleName());
1471 const String& vm_name = String::Handle(Name());
1472 AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString());
1473 // TODO(regis): parameterizedClass is meaningless and always null.
1474 jsobj.AddProperty("parameterizedClass", Object::null_class());
1475 if (ref) {
1476 return;
1477 }
1478 jsobj.AddProperty("parameterIndex", index());
1479 const AbstractType& upper_bound = AbstractType::Handle(bound());
1480 jsobj.AddProperty("bound", upper_bound);
1481}
1482
1484 const JSONArray& jsarr_fields) const {}
1485
1486void Number::PrintJSONImpl(JSONStream* stream, bool ref) const {
1487 UNREACHABLE();
1488}
1489
1491 const JSONArray& jsarr_fields) const {
1492 UNREACHABLE();
1493}
1494
1495void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
1496 JSONObject jsobj(stream);
1497 PrintSharedInstanceJSON(&jsobj, ref);
1498 jsobj.AddProperty("kind", "Int");
1499 jsobj.AddProperty("valueAsString", ToCString());
1500}
1501
1503 const JSONArray& jsarr_fields) const {}
1504
1505void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
1506 JSONObject jsobj(stream);
1507 PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
1508 jsobj.AddProperty("kind", "Int");
1509 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value());
1510 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
1511}
1512
1513void Smi::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1514
1515void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const {
1517}
1518
1519void Mint::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1520
1521void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
1522 JSONObject jsobj(stream);
1523 PrintSharedInstanceJSON(&jsobj, ref);
1524 jsobj.AddProperty("kind", "Double");
1525 jsobj.AddProperty("valueAsString", ToCString());
1526}
1527
1529 const JSONArray& jsarr_fields) const {}
1530
1531void String::PrintJSONImpl(JSONStream* stream, bool ref) const {
1532 JSONObject jsobj(stream);
1533 PrintSharedInstanceJSON(&jsobj, ref);
1534 jsobj.AddProperty("kind", "String");
1535 jsobj.AddProperty("length", Length());
1536 if (ref) {
1537 // String refs always truncate to a fixed count;
1538 const intptr_t kFixedCount = 128;
1539 if (jsobj.AddPropertyStr("valueAsString", *this, 0, kFixedCount)) {
1540 jsobj.AddProperty("count", kFixedCount);
1541 jsobj.AddProperty("valueAsStringIsTruncated", true);
1542 }
1543 return;
1544 }
1545
1546 intptr_t offset;
1547 intptr_t count;
1548 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1549 if (offset > 0) {
1550 jsobj.AddProperty("offset", offset);
1551 }
1552 if (count < Length()) {
1553 jsobj.AddProperty("count", count);
1554 }
1555 jsobj.AddPropertyStr("valueAsString", *this, offset, count);
1556}
1557
1559 const JSONArray& jsarr_fields) const {}
1560
1561void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const {
1562 const char* str = ToCString();
1563 JSONObject jsobj(stream);
1564 PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
1565 jsobj.AddProperty("kind", "Bool");
1566 jsobj.AddFixedServiceId("objects/bool-%s", str);
1567 jsobj.AddPropertyF("valueAsString", "%s", str);
1568}
1569
1570void Bool::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1571
1572void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
1573 JSONObject jsobj(stream);
1574 PrintSharedInstanceJSON(&jsobj, ref);
1575 jsobj.AddProperty("kind", "List");
1576 jsobj.AddProperty("length", Length());
1577 if (ref) {
1578 return;
1579 }
1580 intptr_t offset;
1581 intptr_t count;
1582 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1583 if (offset > 0) {
1584 jsobj.AddProperty("offset", offset);
1585 }
1586 if (count < Length()) {
1587 jsobj.AddProperty("count", count);
1588 }
1589 intptr_t limit = offset + count;
1590 ASSERT(limit <= Length());
1591 {
1592 JSONArray jsarr(&jsobj, "elements");
1593 Object& element = Object::Handle();
1594 for (intptr_t index = offset; index < limit; index++) {
1595 element = At(index);
1596 jsarr.AddValue(element);
1597 }
1598 }
1599}
1600
1601void Array::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {
1602}
1603
1604void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, bool ref) const {
1605 JSONObject jsobj(stream);
1606 PrintSharedInstanceJSON(&jsobj, ref);
1607 jsobj.AddProperty("kind", "List");
1608 jsobj.AddProperty("length", Length());
1609 if (ref) {
1610 return;
1611 }
1612 intptr_t offset;
1613 intptr_t count;
1614 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1615 if (offset > 0) {
1616 jsobj.AddProperty("offset", offset);
1617 }
1618 if (count < Length()) {
1619 jsobj.AddProperty("count", count);
1620 }
1621 intptr_t limit = offset + count;
1622 ASSERT(limit <= Length());
1623 {
1624 JSONArray jsarr(&jsobj, "elements");
1625 Object& element = Object::Handle();
1626 for (intptr_t index = offset; index < limit; index++) {
1627 element = At(index);
1628 jsarr.AddValue(element);
1629 }
1630 }
1631}
1632
1634 const JSONArray& jsarr_fields) const {}
1635
1636void Map::PrintJSONImpl(JSONStream* stream, bool ref) const {
1637 JSONObject jsobj(stream);
1638 PrintSharedInstanceJSON(&jsobj, ref);
1639 jsobj.AddProperty("kind", "Map");
1640 jsobj.AddProperty("length", Length());
1641 if (ref) {
1642 return;
1643 }
1644 intptr_t offset;
1645 intptr_t count;
1646 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1647 if (offset > 0) {
1648 jsobj.AddProperty("offset", offset);
1649 }
1650 if (count < Length()) {
1651 jsobj.AddProperty("count", count);
1652 }
1653 intptr_t limit = offset + count;
1654 ASSERT(limit <= Length());
1655 {
1656 JSONArray jsarr(&jsobj, "associations");
1657 Object& object = Object::Handle();
1658 Map::Iterator iterator(*this);
1659 int i = 0;
1660 while (iterator.MoveNext() && i < limit) {
1661 if (i >= offset) {
1662 JSONObject jsassoc(&jsarr);
1663 object = iterator.CurrentKey();
1664 jsassoc.AddProperty("key", object);
1665 object = iterator.CurrentValue();
1666 jsassoc.AddProperty("value", object);
1667 }
1668 i++;
1669 }
1670 }
1671}
1672
1673void Map::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1674
1675void Set::PrintJSONImpl(JSONStream* stream, bool ref) const {
1676 JSONObject jsobj(stream);
1677 PrintSharedInstanceJSON(&jsobj, ref);
1678 jsobj.AddProperty("kind", "Set");
1679 jsobj.AddProperty("length", Length());
1680 if (ref) {
1681 return;
1682 }
1683 intptr_t offset;
1684 intptr_t count;
1685 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1686 if (offset > 0) {
1687 jsobj.AddProperty("offset", offset);
1688 }
1689 if (count < Length()) {
1690 jsobj.AddProperty("count", count);
1691 }
1692 intptr_t limit = offset + count;
1693 ASSERT(limit <= Length());
1694 {
1695 JSONArray jsarr(&jsobj, "elements");
1696 Object& object = Object::Handle();
1697 Set::Iterator iterator(*this);
1698 int i = 0;
1699 while (iterator.MoveNext() && i < limit) {
1700 if (i >= offset) {
1701 object = iterator.CurrentKey();
1702 jsarr.AddValue(object);
1703 }
1704 i++;
1705 }
1706 }
1707}
1708
1709void Set::PrintImplementationFieldsImpl(const JSONArray& jsarr_fields) const {}
1710
1711void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
1712 JSONObject jsobj(stream);
1713 PrintSharedInstanceJSON(&jsobj, ref);
1714 jsobj.AddProperty("kind", "Float32x4");
1715 jsobj.AddProperty("valueAsString", ToCString());
1716}
1717
1719 const JSONArray& jsarr_fields) const {}
1720
1721void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
1722 JSONObject jsobj(stream);
1723 PrintSharedInstanceJSON(&jsobj, ref);
1724 jsobj.AddProperty("kind", "Int32x4");
1725 jsobj.AddProperty("valueAsString", ToCString());
1726}
1727
1729 const JSONArray& jsarr_fields) const {}
1730
1731void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const {
1732 JSONObject jsobj(stream);
1733 PrintSharedInstanceJSON(&jsobj, ref);
1734 jsobj.AddProperty("kind", "Float64x2");
1735 jsobj.AddProperty("valueAsString", ToCString());
1736}
1737
1739 const JSONArray& jsarr_fields) const {}
1740
1741void TypedDataBase::PrintJSONImpl(JSONStream* stream, bool ref) const {
1742 UNREACHABLE();
1743}
1744
1746 const JSONArray& jsarr_fields) const {
1747 UNREACHABLE();
1748}
1749
1750void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
1751 JSONObject jsobj(stream);
1752 PrintSharedInstanceJSON(&jsobj, ref);
1753 const Class& cls = Class::Handle(clazz());
1754 const char* kind = cls.UserVisibleNameCString();
1755 jsobj.AddProperty("kind", kind);
1756 jsobj.AddProperty("length", Length());
1757 if (ref) {
1758 return;
1759 }
1760 intptr_t offset;
1761 intptr_t count;
1762 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1763 if (offset > 0) {
1764 jsobj.AddProperty("offset", offset);
1765 }
1766 if (count < Length()) {
1767 jsobj.AddProperty("count", count);
1768 }
1769 if (count == 0) {
1770 jsobj.AddProperty("bytes", "");
1771 } else {
1772 NoSafepointScope no_safepoint;
1773 jsobj.AddPropertyBase64("bytes",
1774 reinterpret_cast<const uint8_t*>(
1777 }
1778}
1779
1781 const JSONArray& jsarr_fields) const {}
1782
1783void TypedDataView::PrintJSONImpl(JSONStream* stream, bool ref) const {
1785}
1786
1788 const JSONArray& jsarr_fields) const {}
1789
1790void ExternalTypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
1791 JSONObject jsobj(stream);
1792 PrintSharedInstanceJSON(&jsobj, ref);
1793 const Class& cls = Class::Handle(clazz());
1794 const char* kind = cls.UserVisibleNameCString();
1795 jsobj.AddProperty("kind", kind);
1796 jsobj.AddProperty("length", Length());
1797 if (ref) {
1798 return;
1799 }
1800 intptr_t offset;
1801 intptr_t count;
1802 stream->ComputeOffsetAndCount(Length(), &offset, &count);
1803 if (offset > 0) {
1804 jsobj.AddProperty("offset", offset);
1805 }
1806 if (count < Length()) {
1807 jsobj.AddProperty("count", count);
1808 }
1809 if (count == 0) {
1810 jsobj.AddProperty("bytes", "");
1811 } else {
1812 NoSafepointScope no_safepoint;
1813 jsobj.AddPropertyBase64("bytes",
1814 reinterpret_cast<const uint8_t*>(
1817 }
1818}
1819
1821 const JSONArray& jsarr_fields) const {}
1822
1823void Pointer::PrintJSONImpl(JSONStream* stream, bool ref) const {
1825}
1826
1828 const JSONArray& jsarr_fields) const {}
1829
1830void DynamicLibrary::PrintJSONImpl(JSONStream* stream, bool ref) const {
1832}
1833
1835 const JSONArray& jsarr_fields) const {}
1836
1837void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const {
1839}
1840
1842 const JSONArray& jsarr_fields) const {}
1843
1844void ReceivePort::PrintJSONImpl(JSONStream* stream, bool ref) const {
1845 JSONObject obj(stream);
1847 const StackTrace& allocation_location_ =
1849 const String& debug_name_ = String::Handle(debug_name());
1850 obj.AddProperty("kind", "ReceivePort");
1851 obj.AddProperty64("portId", Id());
1852 obj.AddProperty("debugName", debug_name_.ToCString());
1853 obj.AddProperty("allocationLocation", allocation_location_);
1854}
1855
1857 const JSONArray& jsarr_fields) const {}
1858
1859void SendPort::PrintJSONImpl(JSONStream* stream, bool ref) const {
1861}
1862
1864 const JSONArray& jsarr_fields) const {}
1865
1866void TransferableTypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
1868}
1869
1871 const JSONArray& jsarr_fields) const {}
1872
1873void ClosureData::PrintJSONImpl(JSONStream* stream, bool ref) const {
1875}
1876
1878 const JSONArray& jsarr_fields) const {}
1879
1880void Closure::PrintJSONImpl(JSONStream* stream, bool ref) const {
1881 JSONObject jsobj(stream);
1882 PrintSharedInstanceJSON(&jsobj, ref);
1883 jsobj.AddProperty("kind", "Closure");
1884 const auto& func = Function::Handle(function());
1885 jsobj.AddProperty("closureFunction", func);
1886 if (!func.IsImplicitClosureFunction()) {
1887 jsobj.AddProperty("closureContext", Context::Handle(GetContext()));
1888 } else {
1889 jsobj.AddProperty("closureContext", Object::null_object());
1890 }
1891 if (func.IsImplicitInstanceClosureFunction()) {
1892 jsobj.AddProperty("closureReceiver",
1894 } else {
1895 jsobj.AddProperty("closureReceiver", Object::null_object());
1896 }
1897 if (ref) {
1898 return;
1899 }
1900
1901 Debugger* debugger = Isolate::Current()->debugger();
1902 Breakpoint* bpt = debugger->BreakpointAtActivation(*this);
1903 if (bpt != nullptr) {
1904 jsobj.AddProperty("_activationBreakpoint", bpt);
1905 }
1906}
1907
1909 const JSONArray& jsarr_fields) const {}
1910
1911void Record::PrintJSONImpl(JSONStream* stream, bool ref) const {
1912 JSONObject jsobj(stream);
1913 PrintSharedInstanceJSON(&jsobj, ref);
1914 jsobj.AddProperty("kind", "Record");
1915 const intptr_t num_fields = this->num_fields();
1916 jsobj.AddProperty("length", num_fields);
1917 if (ref) {
1918 return;
1919 }
1920
1921 {
1922 JSONArray jsarr(&jsobj, "fields");
1923 String& name = String::Handle();
1925 const Array& field_names = Array::Handle(GetFieldNames(Thread::Current()));
1926 const intptr_t num_positional_fields = num_fields - field_names.Length();
1927 for (intptr_t index = 0; index < num_fields; ++index) {
1928 JSONObject jsfield(&jsarr);
1929 if (index < num_positional_fields) {
1930 jsfield.AddProperty("name", index + 1);
1931 } else {
1932 name ^= field_names.At(index - num_positional_fields);
1933 jsfield.AddProperty("name", name.ToCString());
1934 }
1935 value = FieldAt(index);
1936 jsfield.AddProperty("value", value);
1937 }
1938 }
1939}
1940
1942 const JSONArray& jsarr_fields) const {}
1943
1944void StackTrace::PrintJSONImpl(JSONStream* stream, bool ref) const {
1945 JSONObject jsobj(stream);
1946 PrintSharedInstanceJSON(&jsobj, ref);
1947 jsobj.AddProperty("kind", "StackTrace");
1948 jsobj.AddProperty("valueAsString", ToCString());
1949}
1950
1952 const JSONArray& jsarr_fields) const {}
1953
1954void RegExp::PrintJSONImpl(JSONStream* stream, bool ref) const {
1955 JSONObject jsobj(stream);
1956 PrintSharedInstanceJSON(&jsobj, ref);
1957 jsobj.AddProperty("kind", "RegExp");
1958
1959 jsobj.AddProperty("pattern", String::Handle(pattern()));
1960
1961 if (ref) {
1962 return;
1963 }
1964
1965 jsobj.AddProperty("isCaseSensitive", !flags().IgnoreCase());
1966 jsobj.AddProperty("isMultiLine", flags().IsMultiLine());
1967
1968 if (!FLAG_interpret_irregexp) {
1969 Function& func = Function::Handle();
1970 func = function(kOneByteStringCid, /*sticky=*/false);
1971 jsobj.AddProperty("_oneByteFunction", func);
1972 func = function(kTwoByteStringCid, /*sticky=*/false);
1973 jsobj.AddProperty("_twoByteFunction", func);
1974 func = function(kOneByteStringCid, /*sticky=*/true);
1975 jsobj.AddProperty("_oneByteFunctionSticky", func);
1976 func = function(kTwoByteStringCid, /*sticky=*/true);
1977 jsobj.AddProperty("_twoByteFunctionSticky", func);
1978 } else {
1979 TypedData& bc = TypedData::Handle();
1980 bc = bytecode(/*is_one_byte=*/true, /*sticky=*/false);
1981 jsobj.AddProperty("_oneByteBytecode", bc);
1982 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/false);
1983 jsobj.AddProperty("_twoByteBytecode", bc);
1984 bc = bytecode(/*is_one_byte=*/true, /*sticky=*/true);
1985 jsobj.AddProperty("_oneByteBytecodeSticky", bc);
1986 bc = bytecode(/*is_one_byte=*/false, /*sticky=*/true);
1987 jsobj.AddProperty("_twoByteBytecodeSticky", bc);
1988 }
1989}
1990
1992 const JSONArray& jsarr_fields) const {}
1993
1994void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
1995 JSONObject jsobj(stream);
1996 PrintSharedInstanceJSON(&jsobj, ref);
1997 jsobj.AddProperty("kind", "WeakProperty");
1998 if (ref) {
1999 return;
2000 }
2001
2002 const Object& key_handle = Object::Handle(key());
2003 jsobj.AddProperty("propertyKey", key_handle);
2004 const Object& value_handle = Object::Handle(value());
2005 jsobj.AddProperty("propertyValue", value_handle);
2006}
2007
2009 const JSONArray& jsarr_fields) const {}
2010
2011void WeakReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
2012 JSONObject jsobj(stream);
2013 PrintSharedInstanceJSON(&jsobj, ref);
2014 jsobj.AddProperty("kind", "WeakReference");
2015 if (ref) {
2016 return;
2017 }
2018
2019 const Object& target_handle = Object::Handle(target());
2020 jsobj.AddProperty("target", target_handle);
2021}
2022
2024 const JSONArray& jsarr_fields) const {}
2025
2026void FinalizerBase::PrintJSONImpl(JSONStream* stream, bool ref) const {
2027 UNREACHABLE();
2028}
2029
2031 const JSONArray& jsarr_fields) const {
2032 UNREACHABLE();
2033}
2034
2035void Finalizer::PrintJSONImpl(JSONStream* stream, bool ref) const {
2036 JSONObject jsobj(stream);
2037 PrintSharedInstanceJSON(&jsobj, ref);
2038 jsobj.AddProperty("kind", "Finalizer");
2039 if (ref) {
2040 return;
2041 }
2042
2043 Object& object = Object::Handle();
2044 object = callback();
2045 jsobj.AddProperty("callback", object);
2046 object = all_entries();
2047 jsobj.AddProperty("allEntries", object);
2048 object = entries_collected();
2049 jsobj.AddProperty("_entriesCollected", object);
2050}
2051
2053 const JSONArray& jsarr_fields) const {}
2054
2055void NativeFinalizer::PrintJSONImpl(JSONStream* stream, bool ref) const {
2056 JSONObject jsobj(stream);
2057 PrintSharedInstanceJSON(&jsobj, ref);
2058 jsobj.AddProperty("kind", "NativeFinalizer");
2059 if (ref) {
2060 return;
2061 }
2062
2063 Object& object = Object::Handle();
2064 object = callback();
2065 jsobj.AddProperty("callbackAddress", object);
2066 object = all_entries();
2067 jsobj.AddProperty("allEntries", object);
2068 object = entries_collected();
2069 jsobj.AddProperty("_entriesCollected", object);
2070}
2071
2073 const JSONArray& jsarr_fields) const {}
2074
2075void FinalizerEntry::PrintJSONImpl(JSONStream* stream, bool ref) const {
2076 JSONObject jsobj(stream);
2077 PrintSharedInstanceJSON(&jsobj, ref);
2078 jsobj.AddProperty("kind", "FinalizerEntry");
2079 if (ref) {
2080 return;
2081 }
2082
2083 Object& object = Object::Handle();
2084 object = value();
2085 jsobj.AddProperty("value", object);
2086 object = detach();
2087 jsobj.AddProperty("detach", object);
2088 object = token();
2089 jsobj.AddProperty("token", object);
2090 object = finalizer();
2091 jsobj.AddProperty("_finalizer", object);
2092 object = next();
2093 jsobj.AddProperty("_next", object);
2094}
2095
2097 const JSONArray& jsarr_fields) const {}
2098
2099void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
2100 JSONObject jsobj(stream);
2101 PrintSharedInstanceJSON(&jsobj, ref);
2102 jsobj.AddProperty("kind", "MirrorReference");
2103
2104 if (ref) {
2105 return;
2106 }
2107
2108 const Object& referent_handle = Object::Handle(referent());
2109 jsobj.AddProperty("mirrorReferent", referent_handle);
2110}
2111
2113 const JSONArray& jsarr_fields) const {}
2114
2115void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
2116 JSONObject jsobj(stream);
2117 PrintSharedInstanceJSON(&jsobj, ref);
2118 jsobj.AddProperty("kind", "UserTag");
2119
2120 String& tag_label = String::Handle(label());
2121 jsobj.AddProperty("label", tag_label.ToCString());
2122}
2123
2125 const JSONArray& jsarr_fields) const {}
2126
2127void FutureOr::PrintJSONImpl(JSONStream* stream, bool ref) const {
2129}
2130
2132 const JSONArray& jsarr_fields) const {}
2133
2134void SuspendState::PrintJSONImpl(JSONStream* stream, bool ref) const {
2136}
2137
2139 const JSONArray& jsarr_fields) const {}
2140
2141#endif
2142
2143} // namespace dart
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
int count
Definition: FontMgrTest.cpp:50
SkPoint pos
SI F table(const skcms_Curve *curve, F v)
#define UNREACHABLE()
Definition: assert.h:248
GLenum type
StringPtr UserVisibleName() const
Definition: object.cc:21331
StringPtr Name() const
Definition: object.cc:21320
virtual const char * ToErrorCString() const
Definition: object.cc:19820
friend class Object
Definition: object.h:11031
ObjectPtr At(intptr_t index) const
Definition: object.h:10875
intptr_t Length() const
Definition: object.h:10829
void Add(const T &value)
intptr_t length() const
StringPtr target_name() const
Definition: object.h:2372
ArrayPtr arguments_descriptor() const
Definition: object.h:2373
bool is_sealed() const
Definition: object.h:1759
bool is_base_class() const
Definition: object.h:1765
intptr_t FindImplicitClosureFunctionIndex(const Function &needle) const
Definition: object.cc:3364
intptr_t NumTypeParameters() const
Definition: object.h:1344
LibraryPtr library() const
Definition: object.h:1333
bool TraceAllocation(IsolateGroup *isolate_group) const
Definition: object.cc:4434
bool is_const() const
Definition: object.h:1745
StringPtr ScrubbedName() const
Definition: object.cc:2981
bool is_mixin_class() const
Definition: object.h:1762
TypePtr super_type() const
Definition: object.h:1431
intptr_t id() const
Definition: object.h:1233
bool is_final() const
Definition: object.h:1773
ArrayPtr interfaces() const
Definition: object.h:1447
ArrayPtr fields() const
Definition: object.h:1615
bool is_abstract() const
Definition: object.h:1696
StringPtr Name() const
Definition: object.cc:2977
TokenPosition token_pos() const
Definition: object.h:1279
ErrorPtr EnsureIsFinalized(Thread *thread) const
Definition: object.cc:4924
GrowableObjectArrayPtr direct_subclasses_unsafe() const
Definition: object.h:1542
TokenPosition end_token_pos() const
Definition: object.h:1291
ClassPtr SuperClass(ClassTable *class_table=nullptr) const
Definition: object.cc:3665
bool IsTopLevel() const
Definition: object.cc:6121
bool is_implemented() const
Definition: object.h:1692
TypeParameterPtr TypeParameterAt(intptr_t index, Nullability nullability=Nullability::kNonNullable) const
Definition: object.cc:3689
bool is_transformed_mixin_application() const
Definition: object.h:1754
friend class AbstractType
Definition: object.h:2237
bool is_interface_class() const
Definition: object.h:1768
intptr_t FindInvocationDispatcherFunctionIndex(const Function &needle) const
Definition: object.cc:3392
bool is_finalized() const
Definition: object.h:1723
ArrayPtr current_functions() const
Definition: object.h:1641
ScriptPtr script() const
Definition: object.h:1272
static intptr_t FindClosureIndex(const Function &needle)
ContextPtr GetContext() const
Definition: object.h:12360
InstancePtr GetImplicitClosureReceiver() const
Definition: object.h:12365
FunctionPtr function() const
Definition: object.h:12350
uword Size() const
Definition: object.h:6903
bool is_alive() const
Definition: object.h:6830
PcDescriptorsPtr pc_descriptors() const
Definition: object.h:6927
bool is_optimized() const
Definition: object.h:6817
ObjectPoolPtr object_pool() const
Definition: object.h:6808
const char * QualifiedName(const NameFormattingParams &params) const
Definition: object.cc:18344
bool IsStubCode() const
Definition: object.cc:18357
ObjectPtr owner() const
Definition: object.h:7135
void Disassemble(DisassemblyFormatter *formatter=nullptr) const
Definition: object.cc:17849
const char * Name() const
Definition: object.cc:18313
bool IsTypeTestStubCode() const
Definition: object.cc:18367
bool IsAllocationStubCode() const
Definition: object.cc:18363
ObjectPoolPtr GetObjectPool() const
Definition: object.cc:17723
uword PayloadStart() const
Definition: object.h:6850
int64_t compile_timestamp() const
Definition: object.h:7230
friend class Object
Definition: object.h:7469
ObjectPtr At(intptr_t context_index) const
Definition: object.h:7422
intptr_t num_variables() const
Definition: object.h:7414
ContextPtr parent() const
Definition: object.h:7406
Breakpoint * BreakpointAtActivation(const Instance &closure)
Definition: debugger.cc:2756
friend class Class
Definition: object.h:11780
bool is_final() const
Definition: object.h:4442
const char * UserVisibleNameCString() const
Definition: object.cc:12082
ClassPtr Owner() const
Definition: object.cc:11860
bool is_nullable() const
Definition: object.cc:11770
ScriptPtr Script() const
Definition: object.cc:11871
@ kUnknownFixedLength
Definition: object.h:4728
@ kNoFixedLength
Definition: object.h:4729
bool is_static() const
Definition: object.h:4440
static StringPtr NameFromInit(const String &init_name)
Definition: object.cc:11826
StringPtr name() const
Definition: object.h:4430
ObjectPtr StaticValue() const
Definition: object.h:13279
intptr_t guarded_cid() const
Definition: object.cc:11749
intptr_t guarded_list_length() const
Definition: object.cc:12101
AbstractTypePtr type() const
Definition: object.h:4550
bool is_const() const
Definition: object.h:4443
friend class Class
Definition: object.h:4924
TokenPosition end_token_pos() const
Definition: object.h:4590
TokenPosition token_pos() const
Definition: object.h:4589
FinalizerEntryPtr entries_collected() const
Definition: object.h:13055
SetPtr all_entries() const
Definition: object.h:13047
FinalizerBasePtr finalizer() const
Definition: object.h:12990
ObjectPtr token() const
Definition: object.h:12984
ObjectPtr detach() const
Definition: object.h:12976
ObjectPtr value() const
Definition: object.h:12970
FinalizerEntryPtr next() const
Definition: object.h:12996
ObjectPtr callback() const
Definition: object.h:13076
AbstractTypePtr ParameterTypeAt(intptr_t index) const
Definition: object.cc:8585
TypeParameterPtr TypeParameterAt(intptr_t index, Nullability nullability=Nullability::kNonNullable) const
Definition: object.cc:8560
StringPtr ParameterNameAt(intptr_t index) const
Definition: object.cc:8645
AbstractTypePtr result_type() const
Definition: object.h:9670
bool IsRequiredAt(intptr_t index) const
Definition: object.cc:8755
bool HasOptionalNamedParameters() const
Definition: object.h:9609
intptr_t NumParameters() const
Definition: object.h:9648
intptr_t num_fixed_parameters() const
Definition: object.h:9595
intptr_t NumTypeParameters() const
Definition: object.h:9578
bool IsRecognized() const
Definition: object.h:3624
CodePtr CurrentCode() const
Definition: object.h:3177
bool IsImplicitClosureFunction() const
Definition: object.h:3903
bool IsNoSuchMethodDispatcher() const
Definition: object.h:3288
bool IsImplicitGetterOrSetter() const
Definition: object.h:3318
bool IsFieldInitializer() const
Definition: object.h:3885
static const char * KindToCString(UntaggedFunction::Kind kind)
Definition: object.cc:8419
FunctionPtr parent_function() const
Definition: object.cc:8167
StringPtr name() const
Definition: object.h:2992
TokenPosition token_pos() const
Definition: object.h:3446
void AddFunctionServiceId(const JSONObject &obj) const
ScriptPtr script() const
Definition: object.cc:10881
bool IsInvokeFieldDispatcher() const
Definition: object.h:3296
ArrayPtr ic_data_array() const
Definition: object.cc:11272
FieldPtr accessor_field() const
Definition: object.cc:8149
bool IsNonImplicitClosureFunction() const
Definition: object.h:3911
CodePtr unoptimized_code() const
Definition: object.h:3185
bool is_optimizable() const
Definition: object.h:4200
ClassPtr Owner() const
Definition: object.cc:10841
const char * UserVisibleNameCString() const
Definition: object.cc:10990
UntaggedFunction::Kind kind() const
Definition: object.h:3349
TokenPosition end_token_pos() const
Definition: object.h:3455
intptr_t Length() const
Definition: object.h:11072
ObjectPtr At(intptr_t index) const
Definition: object.h:11085
static ArrayPtr ToArray(const Table &table, bool include_payload)
Definition: hash_table.h:653
bool is_static_call() const
Definition: object.cc:16555
intptr_t GetReceiverClassIdAt(intptr_t index) const
Definition: object.cc:17020
ArrayPtr entries() const
Definition: object.h:2783
intptr_t GetCountAt(intptr_t index) const
Definition: object.cc:17063
FunctionPtr GetTargetAt(intptr_t index) const
Definition: object.cc:17029
intptr_t NumberOfChecks() const
Definition: object.cc:16577
void PrintToJSONArray(const JSONArray &jsarray, TokenPosition token_pos) const
FunctionPtr Owner() const
Definition: object.cc:16423
intptr_t GetNativeField(int index) const
Definition: object.h:13307
uint16_t NumNativeFields() const
Definition: object.h:8280
ObjectPtr GetField(const Field &field) const
Definition: object.cc:20475
virtual void PrintSharedInstanceJSON(JSONObject *jsobj, bool ref, bool include_id=true) const
static IsolateGroup * Current()
Definition: isolate.h:539
ClassTable * class_table() const
Definition: isolate.h:496
static Isolate * Current()
Definition: isolate.h:986
Debugger * debugger() const
Definition: isolate.h:1108
IsolateGroup * group() const
Definition: isolate.h:1037
void AddValue(bool b) const
Definition: json_stream.h:494
void AddProperty64(const char *name, int64_t i) const
Definition: json_stream.h:401
void AddProperty(const char *name, bool b) const
Definition: json_stream.h:395
void AddServiceId(const Object &o) const
Definition: json_stream.h:380
void AddFixedServiceId(const char *format,...) const PRINTF_ATTRIBUTE(2
Definition: json_stream.cc:503
void AddPropertyF(const char *name, const char *format,...) const PRINTF_ATTRIBUTE(3
Definition: json_stream.cc:589
virtual const char * ToErrorCString() const
Definition: object.cc:19930
friend class Object
Definition: object.h:5440
friend class DictionaryIterator
Definition: object.h:5436
ArrayPtr LoadedScripts() const
Definition: object.cc:13940
friend class Namespace
Definition: object.h:5439
StringPtr name() const
Definition: object.h:5094
ArrayPtr exports() const
Definition: object.h:5217
bool IsDebuggable() const
Definition: object.h:5281
StringPtr private_key() const
Definition: object.h:5099
StringPtr url() const
Definition: object.h:5097
ArrayPtr imports() const
Definition: object.h:5216
friend class Class
Definition: object.h:5434
intptr_t Length() const
Definition: object.h:12056
bool loaded() const
Definition: object.h:7990
LoadingUnitPtr parent() const
Definition: object.h:7980
bool load_outstanding() const
Definition: object.h:8009
ArrayPtr base_objects() const
Definition: object.h:7982
intptr_t Length() const
Definition: object.cc:16149
static const char * KindToCString(UntaggedLocalVarDescriptors::VarInfoKind kind)
Definition: object.cc:16117
StringPtr GetName(intptr_t var_index) const
Definition: object.cc:16030
void GetInfo(intptr_t var_index, UntaggedLocalVarDescriptors::VarInfo *info) const
Definition: object.cc:16046
intptr_t mask() const
Definition: object.cc:18759
ArrayPtr buckets() const
Definition: object.cc:18748
ObjectPtr referent() const
Definition: object.h:13120
classid_t expected_cid() const
Definition: object.h:2348
ArrayPtr hide_names() const
Definition: object.h:5450
ArrayPtr show_names() const
Definition: object.h:5449
PointerPtr callback() const
Definition: object.h:13096
EntryType TypeAt(intptr_t index) const
Definition: object.h:5596
friend class Object
Definition: object.h:5702
ObjectPtr ObjectAt(intptr_t index) const
Definition: object.h:5628
intptr_t Length() const
Definition: object.h:5572
uword RawValueAt(intptr_t index) const
Definition: object.h:5640
static intptr_t OffsetFromIndex(intptr_t index)
Definition: object.h:5688
@ kUserVisibleName
Definition: object.h:645
void AddCommonObjectProperties(JSONObject *jsobj, const char *protocol_type, bool ref) const
void PrintJSON(JSONStream *stream, bool ref=true) const
static ObjectPtr null()
Definition: object.h:433
ObjectPtr ptr() const
Definition: object.h:332
virtual const char * JSONType() const
Definition: object.h:380
virtual const char * ToCString() const
Definition: object.h:366
virtual void PrintImplementationFieldsImpl(const JSONArray &jsarr_fields) const
virtual void PrintJSONImpl(JSONStream *stream, bool ref) const
bool IsNull() const
Definition: object.h:363
static Object & Handle()
Definition: object.h:407
friend class Thread
Definition: object.h:1025
void PrintImplementationFields(JSONStream *stream) const
ClassPtr clazz() const
Definition: object.h:13218
TokenPosition TokenPos() const
Definition: object.h:6156
intptr_t DeoptId() const
Definition: object.h:6155
intptr_t TryIndex() const
Definition: object.h:6159
UntaggedPcDescriptors::Kind Kind() const
Definition: object.h:6161
void PrintToJSONObject(JSONObject *jsobj, bool ref) const
StringPtr debug_name() const
Definition: object.h:12468
StackTracePtr allocation_location() const
Definition: object.h:12464
Dart_Port Id() const
Definition: object.h:12436
AbstractTypePtr FieldTypeAt(intptr_t index) const
Definition: object.cc:27380
ArrayPtr GetFieldNames(Thread *thread) const
Definition: object.cc:27401
intptr_t NumFields() const
Definition: object.h:13392
friend class Object
Definition: object.h:11500
ArrayPtr GetFieldNames(Thread *thread) const
Definition: object.h:11493
intptr_t num_fields() const
Definition: object.h:11425
ObjectPtr FieldAt(intptr_t field_index) const
Definition: object.h:11433
TypedDataPtr bytecode(bool is_one_byte, bool sticky) const
Definition: object.h:12803
StringPtr pattern() const
Definition: object.h:12797
RegExpFlags flags() const
Definition: object.h:12891
FunctionPtr function(intptr_t cid, bool sticky) const
Definition: object.h:12836
static FunctionPtr ResolveFunction(Zone *zone, const Class &receiver_class, const String &function_name)
Definition: resolver.cc:167
StringPtr Source() const
Definition: object.cc:13093
GrowableObjectArrayPtr GenerateLineNumberArray() const
Definition: object.cc:13125
intptr_t col_offset() const
Definition: object.h:4944
int64_t load_timestamp() const
Definition: object.h:4950
LibraryPtr FindLibrary() const
Definition: object.cc:13482
StringPtr url() const
Definition: object.h:4932
intptr_t line_offset() const
Definition: object.h:4943
CodePtr target() const
Definition: object.h:2315
static SmiPtr New(intptr_t value)
Definition: object.h:10006
intptr_t Value() const
Definition: object.h:9990
intptr_t Length() const
Definition: object.h:10210
static const char * ScrubName(const String &name, bool is_extension=false)
Definition: object.cc:287
static const char * EncodeIRI(const String &str)
Definition: object.cc:23918
ArrayPtr cache() const
Definition: object.cc:18938
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
int32_t Serialize() const
static SmiPtr Sentinel()
Definition: object.cc:7173
StringPtr Name() const
Definition: object.cc:6869
bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition: object.h:8707
intptr_t Length() const
Definition: object.cc:7294
StringPtr UserVisibleName() const
Definition: object.cc:6876
friend class AbstractType
Definition: object.h:9036
AbstractTypePtr TypeAt(intptr_t index) const
Definition: object.cc:7308
intptr_t index() const
Definition: object.h:9821
AbstractTypePtr bound() const
Definition: object.cc:22737
friend class TypeArguments
Definition: object.h:9507
virtual ClassPtr type_class() const
virtual TypeArgumentsPtr arguments() const
Definition: object.h:9381
friend class Class
Definition: object.h:9506
intptr_t Length() const
Definition: object.h:11518
intptr_t ElementSizeInBytes() const
Definition: object.h:11531
void * DataAddr(intptr_t byte_offset) const
Definition: object.h:11571
friend class Class
Definition: object.h:11725
virtual const char * ToErrorCString() const
Definition: object.cc:19963
InstancePtr exception() const
Definition: object.h:8146
InstancePtr stacktrace() const
Definition: object.h:8151
bool is_user_initiated() const
Definition: object.h:8179
virtual const char * ToErrorCString() const
Definition: object.cc:20022
StringPtr label() const
Definition: object.h:13168
friend class Object
Definition: object.h:6758
intptr_t Length() const
Definition: object.h:6697
ObjectPtr At(intptr_t index) const
Definition: object.h:6722
ObjectPtr value() const
Definition: object.h:12924
ObjectPtr key() const
Definition: object.h:12920
ObjectPtr target() const
Definition: object.h:12944
ObjectPtr target() const
Definition: object.h:6662
#define ASSERT(E)
VkInstance instance
Definition: main.cc:48
SkBitmap source
Definition: examples.cpp:28
uint8_t value
uint32_t * target
Dart_NativeFunction function
Definition: fuchsia.cc:51
Definition: dart_vm.cc:33
ArrayOfTuplesView< TypeArguments::Cache::Entry, std::tuple< Object, TypeArguments, TypeArguments >, TypeArguments::Cache::kHeaderSize > InstantiationsCacheTable
Definition: object.h:13566
const char *const name
UnorderedHashSet< CanonicalTypeArgumentsTraits > CanonicalTypeArgumentsSet
static void AddNameProperties(JSONObject *jsobj, const char *name, const char *vm_name)
static void PrintShowHideNamesToJSON(JSONObject *jsobj, const Namespace &ns)
@ kIllegalCid
Definition: class_id.h:214
@ kDynamicCid
Definition: class_id.h:253
@ kFreeListElement
Definition: class_id.h:224
uintptr_t uword
Definition: globals.h:501
static char * vm_name
Definition: service.cc:356
const intptr_t cid
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558
#define Px
Definition: globals.h:410
#define Px64
Definition: globals.h:418
#define Pd
Definition: globals.h:408
SeparatedVector2 offset
static float Length(float x, float y)
Definition: SkPoint.cpp:79