• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <codecvt>
17 #include <iomanip>
18 #include <iostream>
19 #include <string>
20 
21 #include "ecmascript/accessor_data.h"
22 #include "ecmascript/ecma_vm.h"
23 #include "ecmascript/global_dictionary-inl.h"
24 #include "ecmascript/global_env.h"
25 #include "ecmascript/ic/ic_handler.h"
26 #include "ecmascript/ic/property_box.h"
27 #include "ecmascript/ic/proto_change_details.h"
28 #include "ecmascript/interpreter/frame_handler.h"
29 #include "ecmascript/jobs/micro_job_queue.h"
30 #include "ecmascript/jobs/pending_job.h"
31 #include "ecmascript/jspandafile/class_info_extractor.h"
32 #include "ecmascript/jspandafile/class_literal.h"
33 #include "ecmascript/jspandafile/program_object.h"
34 #include "ecmascript/js_api/js_api_arraylist.h"
35 #include "ecmascript/js_api/js_api_arraylist_iterator.h"
36 #include "ecmascript/js_api/js_api_deque.h"
37 #include "ecmascript/js_api/js_api_deque_iterator.h"
38 #include "ecmascript/js_api/js_api_hashmap.h"
39 #include "ecmascript/js_api/js_api_hashmap_iterator.h"
40 #include "ecmascript/js_api/js_api_hashset.h"
41 #include "ecmascript/js_api/js_api_hashset_iterator.h"
42 #include "ecmascript/js_api/js_api_lightweightmap.h"
43 #include "ecmascript/js_api/js_api_lightweightmap_iterator.h"
44 #include "ecmascript/js_api/js_api_lightweightset.h"
45 #include "ecmascript/js_api/js_api_lightweightset_iterator.h"
46 #include "ecmascript/js_api/js_api_linked_list.h"
47 #include "ecmascript/js_api/js_api_linked_list_iterator.h"
48 #include "ecmascript/js_api/js_api_list.h"
49 #include "ecmascript/js_api/js_api_list_iterator.h"
50 #include "ecmascript/js_api/js_api_plain_array.h"
51 #include "ecmascript/js_api/js_api_plain_array_iterator.h"
52 #include "ecmascript/js_api/js_api_queue.h"
53 #include "ecmascript/js_api/js_api_queue_iterator.h"
54 #include "ecmascript/js_api/js_api_stack.h"
55 #include "ecmascript/js_api/js_api_stack_iterator.h"
56 #include "ecmascript/js_api/js_api_tree_map.h"
57 #include "ecmascript/js_api/js_api_tree_map_iterator.h"
58 #include "ecmascript/js_api/js_api_tree_set.h"
59 #include "ecmascript/js_api/js_api_tree_set_iterator.h"
60 #include "ecmascript/js_api/js_api_vector.h"
61 #include "ecmascript/js_api/js_api_vector_iterator.h"
62 #include "ecmascript/js_array.h"
63 #include "ecmascript/js_array_iterator.h"
64 #include "ecmascript/js_arraybuffer.h"
65 #include "ecmascript/js_async_from_sync_iterator.h"
66 #include "ecmascript/js_async_function.h"
67 #include "ecmascript/js_async_generator_object.h"
68 #include "ecmascript/js_bigint.h"
69 #include "ecmascript/js_collator.h"
70 #include "ecmascript/js_dataview.h"
71 #include "ecmascript/js_date.h"
72 #include "ecmascript/js_date_time_format.h"
73 #include "ecmascript/js_for_in_iterator.h"
74 #include "ecmascript/js_finalization_registry.h"
75 #include "ecmascript/js_function.h"
76 #include "ecmascript/js_generator_object.h"
77 #include "ecmascript/js_global_object.h"
78 #include "ecmascript/js_handle.h"
79 #include "ecmascript/js_intl.h"
80 #include "ecmascript/js_locale.h"
81 #include "ecmascript/js_map.h"
82 #include "ecmascript/js_map_iterator.h"
83 #include "ecmascript/js_number_format.h"
84 #include "ecmascript/js_object-inl.h"
85 #include "ecmascript/js_plural_rules.h"
86 #include "ecmascript/js_primitive_ref.h"
87 #include "ecmascript/js_promise.h"
88 #include "ecmascript/js_realm.h"
89 #include "ecmascript/js_regexp.h"
90 #include "ecmascript/js_regexp_iterator.h"
91 #include "ecmascript/js_relative_time_format.h"
92 #include "ecmascript/js_set.h"
93 #include "ecmascript/js_set_iterator.h"
94 #include "ecmascript/js_string_iterator.h"
95 #include "ecmascript/js_tagged_number.h"
96 #include "ecmascript/js_tagged_value-inl.h"
97 #include "ecmascript/js_thread.h"
98 #include "ecmascript/js_typed_array.h"
99 #include "ecmascript/js_weak_container.h"
100 #include "ecmascript/js_weak_ref.h"
101 #include "ecmascript/layout_info-inl.h"
102 #include "ecmascript/lexical_env.h"
103 #include "ecmascript/linked_hash_table.h"
104 #include "ecmascript/mem/assert_scope.h"
105 #include "ecmascript/mem/c_containers.h"
106 #include "ecmascript/mem/machine_code.h"
107 #include "ecmascript/module/js_module_namespace.h"
108 #include "ecmascript/module/js_module_source_text.h"
109 #include "ecmascript/require/js_cjs_module.h"
110 #include "ecmascript/require/js_cjs_module_cache.h"
111 #include "ecmascript/require/js_cjs_require.h"
112 #include "ecmascript/require/js_cjs_exports.h"
113 #include "ecmascript/tagged_array.h"
114 #include "ecmascript/tagged_dictionary.h"
115 #include "ecmascript/tagged_hash_array.h"
116 #include "ecmascript/tagged_list.h"
117 #include "ecmascript/tagged_tree.h"
118 #include "ecmascript/template_map.h"
119 #include "ecmascript/transitions_dictionary.h"
120 #include "ecmascript/ts_types/ts_type.h"
121 #include "ecmascript/js_displaynames.h"
122 #include "ecmascript/js_list_format.h"
123 
124 namespace panda::ecmascript {
125 using MicroJobQueue = panda::ecmascript::job::MicroJobQueue;
126 using PendingJob = panda::ecmascript::job::PendingJob;
127 
128 static constexpr uint32_t DUMP_TYPE_OFFSET = 12;
129 static constexpr uint32_t DUMP_PROPERTY_OFFSET = 20;
130 static constexpr uint32_t DUMP_ELEMENT_OFFSET = 2;
131 
DumpJSType(JSType type)132 CString JSHClass::DumpJSType(JSType type)
133 {
134     switch (type) {
135         case JSType::HCLASS:
136             return "JSHClass";
137         case JSType::TAGGED_ARRAY:
138             return "TaggedArray";
139         case JSType::LEXICAL_ENV:
140             return "LexicalEnv";
141         case JSType::TAGGED_DICTIONARY:
142             return "TaggedDictionary";
143         case JSType::CONSTANT_POOL:
144             return "ConstantPool";
145         case JSType::COW_TAGGED_ARRAY:
146             return "COWArray";
147         case JSType::STRING:
148             return "BaseString";
149         case JSType::JS_NATIVE_POINTER:
150             return "NativePointer";
151         case JSType::JS_OBJECT:
152             return "Object";
153         case JSType::JS_FUNCTION_BASE:
154             return "Function Base";
155         case JSType::JS_FUNCTION:
156             return "Function";
157         case JSType::JS_ERROR:
158             return "Error";
159         case JSType::JS_EVAL_ERROR:
160             return "Eval Error";
161         case JSType::JS_RANGE_ERROR:
162             return "Range Error";
163         case JSType::JS_TYPE_ERROR:
164             return "Type Error";
165         case JSType::JS_AGGREGATE_ERROR:
166             return "Aggregate Error";
167         case JSType::JS_REFERENCE_ERROR:
168             return "Reference Error";
169         case JSType::JS_URI_ERROR:
170             return "Uri Error";
171         case JSType::JS_SYNTAX_ERROR:
172             return "Syntax Error";
173         case JSType::JS_OOM_ERROR:
174             return "OutOfMemory Error";
175         case JSType::JS_REG_EXP:
176             return "Regexp";
177         case JSType::JS_SET:
178             return "Set";
179         case JSType::JS_MAP:
180             return "Map";
181         case JSType::JS_WEAK_SET:
182             return "WeakSet";
183         case JSType::JS_WEAK_MAP:
184             return "WeakMap";
185         case JSType::JS_WEAK_REF:
186             return "WeakRef";
187         case JSType::JS_FINALIZATION_REGISTRY:
188             return "JSFinalizationRegistry";
189         case JSType::CELL_RECORD:
190             return "CellRecord";
191         case JSType::JS_DATE:
192             return "Date";
193         case JSType::JS_BOUND_FUNCTION:
194             return "Bound Function";
195         case JSType::JS_ARRAY:
196             return "Array";
197         case JSType::JS_TYPED_ARRAY:
198             return "Typed Array";
199         case JSType::JS_INT8_ARRAY:
200             return "Int8 Array";
201         case JSType::JS_UINT8_ARRAY:
202             return "Uint8 Array";
203         case JSType::JS_UINT8_CLAMPED_ARRAY:
204             return "Uint8 Clamped Array";
205         case JSType::JS_INT16_ARRAY:
206             return "Int16 Array";
207         case JSType::JS_UINT16_ARRAY:
208             return "Uint16 Array";
209         case JSType::JS_INT32_ARRAY:
210             return "Int32 Array";
211         case JSType::JS_UINT32_ARRAY:
212             return "Uint32 Array";
213         case JSType::BIGINT:
214             return "BigInt";
215         case JSType::JS_FLOAT32_ARRAY:
216             return "Float32 Array";
217         case JSType::JS_FLOAT64_ARRAY:
218             return "Float64 Array";
219         case JSType::JS_BIGINT64_ARRAY:
220             return "BigInt64 Array";
221         case JSType::JS_BIGUINT64_ARRAY:
222             return "BigUint64 Array";
223         case JSType::BYTE_ARRAY:
224             return "ByteArray";
225         case JSType::JS_ARGUMENTS:
226             return "Arguments";
227         case JSType::JS_PROXY:
228             return "Proxy";
229         case JSType::JS_PRIMITIVE_REF:
230             return "Primitive";
231         case JSType::JS_DATA_VIEW:
232             return "DataView";
233         case JSType::JS_ITERATOR:
234             return "Iterator";
235         case JSType::JS_ASYNCITERATOR:
236             return "AsyncIterator";
237         case JSType::JS_FORIN_ITERATOR:
238             return "ForinInterator";
239         case JSType::JS_MAP_ITERATOR:
240             return "MapIterator";
241         case JSType::JS_SET_ITERATOR:
242             return "SetIterator";
243         case JSType::JS_ARRAY_ITERATOR:
244             return "ArrayIterator";
245         case JSType::JS_STRING_ITERATOR:
246             return "StringIterator";
247         case JSType::JS_REG_EXP_ITERATOR:
248             return "RegExpIterator";
249         case JSType::JS_ARRAY_BUFFER:
250             return "ArrayBuffer";
251         case JSType::JS_SHARED_ARRAY_BUFFER:
252             return "SharedArrayBuffer";
253         case JSType::JS_PROXY_REVOC_FUNCTION:
254             return "ProxyRevocFunction";
255         case JSType::PROMISE_REACTIONS:
256             return "PromiseReaction";
257         case JSType::PROMISE_CAPABILITY:
258             return "PromiseCapability";
259         case JSType::PROMISE_ITERATOR_RECORD:
260             return "PromiseIteratorRecord";
261         case JSType::PROMISE_RECORD:
262             return "PromiseRecord";
263         case JSType::RESOLVING_FUNCTIONS_RECORD:
264             return "ResolvingFunctionsRecord";
265         case JSType::ASYNC_GENERATOR_REQUEST:
266             return "AsyncGeneratorRequest";
267         case JSType::ASYNC_ITERATOR_RECORD:
268             return "AsyncIteratorRecord";
269         case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
270             return "AsyncFromSyncIterator";
271         case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
272             return "AsyncFromSyncIterUnwarpFunction";
273         case JSType::JS_PROMISE:
274             return "Promise";
275         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
276             return "PromiseReactionsFunction";
277         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
278             return "PromiseExecutorFunction";
279         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
280             return "PromiseAllResolveElementFunction";
281         case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
282             return "PromiseAnyRejectElementFunction";
283         case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
284             return "PromiseAllSettledElementFunction";
285         case JSType::JS_PROMISE_FINALLY_FUNCTION:
286             return "PromiseFinallyFunction";
287         case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
288             return "PromiseValueThunkOrThrowerFunction";
289         case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
290             return "AsyncGeneratorResumeNextReturnProcessorRstFtn";
291         case JSType::MICRO_JOB_QUEUE:
292             return "MicroJobQueue";
293         case JSType::PENDING_JOB:
294             return "PendingJob";
295         case JSType::COMPLETION_RECORD:
296             return "CompletionRecord";
297         case JSType::GLOBAL_ENV:
298             return "GlobalEnv";
299         case JSType::ACCESSOR_DATA:
300             return "AccessorData";
301         case JSType::INTERNAL_ACCESSOR:
302             return "InternalAccessor";
303         case JSType::SYMBOL:
304             return "Symbol";
305         case JSType::PROPERTY_BOX:
306             return "PropertyBox";
307         case JSType::JS_ASYNC_FUNCTION:
308             return "AsyncFunction";
309         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
310             return "AsyncAwaitStatusFunction";
311         case JSType::JS_ASYNC_FUNC_OBJECT:
312             return "AsyncFunctionObject";
313         case JSType::JS_REALM:
314             return "Realm";
315         case JSType::JS_GLOBAL_OBJECT:
316             return "GlobalObject";
317         case JSType::JS_INTL:
318             return "JSIntl";
319         case JSType::JS_LOCALE:
320             return "JSLocale";
321         case JSType::JS_DATE_TIME_FORMAT:
322             return "JSDateTimeFormat";
323         case JSType::JS_RELATIVE_TIME_FORMAT:
324             return "JSRelativeTimeFormat";
325         case JSType::JS_NUMBER_FORMAT:
326             return "JSNumberFormat";
327         case JSType::JS_COLLATOR:
328             return "JSCollator";
329         case JSType::JS_PLURAL_RULES:
330             return "JSPluralRules";
331         case JSType::JS_DISPLAYNAMES:
332             return "JSDisplayNames";
333         case JSType::JS_LIST_FORMAT:
334             return "JSListFormat";
335         case JSType::JS_GENERATOR_OBJECT:
336             return "JSGeneratorObject";
337         case JSType::JS_ASYNC_GENERATOR_OBJECT:
338             return "JSAsyncGeneratorObject";
339         case JSType::JS_GENERATOR_CONTEXT:
340             return "JSGeneratorContext";
341         case JSType::PROTO_CHANGE_MARKER:
342             return "ProtoChangeMarker";
343         case JSType::PROTOTYPE_INFO:
344             return "PrototypeInfo";
345         case JSType::PROGRAM:
346             return "program";
347         case JSType::MACHINE_CODE_OBJECT:
348             return "MachineCode";
349         case JSType::CLASS_INFO_EXTRACTOR:
350             return "ClassInfoExtractor";
351         case JSType::JS_API_ARRAY_LIST:
352             return "ArrayList";
353         case JSType::TS_OBJECT_TYPE:
354             return "TSObjectType";
355         case JSType::TS_CLASS_TYPE:
356             return "TSClassType";
357         case JSType::TS_INTERFACE_TYPE:
358             return "TSInterfaceType";
359         case JSType::TS_CLASS_INSTANCE_TYPE:
360             return "TSClassInstanceType";
361         case JSType::TS_UNION_TYPE:
362             return "TSUnionType";
363         case JSType::TS_FUNCTION_TYPE:
364             return "TSFunctionType";
365         case JSType::TS_ARRAY_TYPE:
366             return "TSArrayType";
367         case JSType::TS_ITERATOR_INSTANCE_TYPE:
368             return "TSIteratorInstanceType";
369         case JSType::JS_API_ARRAYLIST_ITERATOR:
370             return "JSArraylistIterator";
371         case JSType::LINKED_NODE:
372             return "LinkedNode";
373         case JSType::RB_TREENODE:
374              return "RBTreeNode";
375         case JSType::JS_API_HASH_MAP:
376             return "HashMap";
377         case JSType::JS_API_HASH_SET:
378              return "HashSet";
379         case JSType::JS_API_HASHMAP_ITERATOR:
380              return "HashMapIterator";
381         case JSType::JS_API_HASHSET_ITERATOR:
382              return "HashSetIterator";
383         case JSType::JS_API_LIGHT_WEIGHT_MAP:
384             return "LightWeightMap";
385         case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
386             return "LightWeightMapIterator";
387         case JSType::JS_API_LIGHT_WEIGHT_SET:
388             return "LightWeightSet";
389         case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
390             return "LightWeightSetIterator";
391         case JSType::JS_API_TREE_MAP:
392             return "TreeMap";
393         case JSType::JS_API_TREE_SET:
394             return "TreeSet";
395         case JSType::JS_API_TREEMAP_ITERATOR:
396             return "TreeMapIterator";
397         case JSType::JS_API_TREESET_ITERATOR:
398             return "TreeSetIterator";
399         case JSType::JS_API_VECTOR:
400             return "Vector";
401         case JSType::JS_API_VECTOR_ITERATOR:
402             return "VectorIterator";
403         case JSType::JS_API_QUEUE:
404             return "Queue";
405         case JSType::JS_API_QUEUE_ITERATOR:
406             return "QueueIterator";
407         case JSType::JS_API_PLAIN_ARRAY:
408             return "PlainArray";
409         case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
410             return "PlainArrayIterator";
411         case JSType::JS_API_DEQUE:
412             return "Deque";
413         case JSType::JS_API_DEQUE_ITERATOR:
414             return "DequeIterator";
415         case JSType::JS_API_STACK:
416             return "Stack";
417         case JSType::JS_API_STACK_ITERATOR:
418             return "StackIterator";
419         case JSType::JS_API_LIST:
420             return "List";
421         case JSType::JS_API_LIST_ITERATOR:
422             return "ListIterator";
423         case JSType::JS_API_LINKED_LIST:
424             return "LinkedList";
425         case JSType::JS_API_LINKED_LIST_ITERATOR:
426             return "LinkedListIterator";
427         case JSType::JS_CJS_EXPORTS:
428             return "CommonJSExports";
429         case JSType::JS_CJS_MODULE:
430             return "CommonJSModule";
431         case JSType::JS_CJS_REQUIRE:
432             return "CommonJSRequire";
433         case JSType::METHOD:
434             return "Method";
435         case JSType::AOT_LITERAL_INFO:
436             return "AOTLiteralInfo";
437         case JSType::CLASS_LITERAL:
438             return "ClassLiteral";
439         default: {
440             CString ret = "unknown type ";
441             return ret + static_cast<char>(type);
442         }
443     }
444 }
445 
DumpArrayClass(const TaggedArray * arr,std::ostream & os)446 static void DumpArrayClass(const TaggedArray *arr, std::ostream &os)
447 {
448     DISALLOW_GARBAGE_COLLECTION;
449     uint32_t len = arr->GetLength();
450     os << " <TaggedArray[" << std::dec << len << "]>\n";
451     for (uint32_t i = 0; i < len; i++) {
452         JSTaggedValue val(arr->Get(i));
453         if (!val.IsHole()) {
454             os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
455             val.DumpTaggedValue(os);
456             os << "\n";
457         }
458     }
459 }
460 
DumpConstantPoolClass(const ConstantPool * pool,std::ostream & os)461 static void DumpConstantPoolClass(const ConstantPool *pool, std::ostream &os)
462 {
463     DISALLOW_GARBAGE_COLLECTION;
464     uint32_t len = pool->GetCacheLength();
465     os << " <ConstantPool[" << std::dec << len << "]>\n";
466     for (uint32_t i = 0; i < len; i++) {
467         JSTaggedValue val(pool->GetObjectFromCache(i));
468         if (!val.IsHole()) {
469             os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
470             val.DumpTaggedValue(os);
471             os << "\n";
472         }
473     }
474 }
475 
DumpStringClass(const EcmaString * str,std::ostream & os)476 static void DumpStringClass(const EcmaString *str, std::ostream &os)
477 {
478     DISALLOW_GARBAGE_COLLECTION;
479     CString string = ConvertToString(str);
480     os << string;
481 }
482 
DumpPropertyKey(JSTaggedValue key,std::ostream & os)483 static void DumpPropertyKey(JSTaggedValue key, std::ostream &os)
484 {
485     if (key.IsString()) {
486         DumpStringClass(EcmaString::Cast(key.GetTaggedObject()), os);
487     } else if (key.IsSymbol()) {
488         JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
489         DumpStringClass(EcmaString::Cast(sym->GetDescription().GetTaggedObject()), os);
490     } else {
491         UNREACHABLE();
492     }
493 }
494 
DumpHClass(const JSHClass * jshclass,std::ostream & os,bool withDetail)495 static void DumpHClass(const JSHClass *jshclass, std::ostream &os, bool withDetail)
496 {
497     DISALLOW_GARBAGE_COLLECTION;
498     os << "JSHClass :" << std::setw(DUMP_TYPE_OFFSET);
499     os << "Type :" << JSHClass::DumpJSType(jshclass->GetObjectType()) << "\n";
500 
501     os << " - Prototype :" << std::setw(DUMP_TYPE_OFFSET);
502     jshclass->GetPrototype().DumpTaggedValue(os);
503     os << "\n";
504     os << " - PropertyDescriptors :" << std::setw(DUMP_TYPE_OFFSET);
505     JSTaggedValue attrs = jshclass->GetLayout();
506     attrs.DumpTaggedValue(os);
507     os << "\n";
508     if (withDetail && !attrs.IsNull()) {
509         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
510         layoutInfo->Dump(os);
511     }
512     os << " - Transitions :" << std::setw(DUMP_TYPE_OFFSET);
513     JSTaggedValue transtions = jshclass->GetTransitions();
514     transtions.DumpTaggedValue(os);
515     os << "\n";
516     if (withDetail && !transtions.IsNull()) {
517         transtions.Dump(os);
518     }
519 
520     os << " - Flags : " << std::setw(DUMP_TYPE_OFFSET);
521     os << "IsCtor :" << std::boolalpha << jshclass->IsConstructor();
522     os << "| IsCallable :" << std::boolalpha << jshclass->IsCallable();
523     os << "| IsExtensible :" << std::boolalpha << jshclass->IsExtensible();
524     os << "| ElementRepresentation :" << static_cast<int>(jshclass->GetElementRepresentation());
525     os << "| NumberOfProps :" << std::dec << jshclass->NumberOfProps();
526     os << "| InlinedProperties :" << std::dec << jshclass->GetInlinedProperties();
527     os << "| IsTS :" << std::boolalpha << jshclass->IsTS();
528     os << "\n";
529 }
530 
DumpClass(TaggedObject * obj,std::ostream & os)531 static void DumpClass(TaggedObject *obj, std::ostream &os)
532 {
533     JSHClass *hclass = obj->GetClass();
534     os << "JSHClass :" << std::setw(DUMP_TYPE_OFFSET) << " klass_(" << std::hex << hclass << ")\n";
535     DumpHClass(hclass, os, true);
536 }
537 
DumpAttr(const PropertyAttributes & attr,bool fastMode,std::ostream & os)538 static void DumpAttr(const PropertyAttributes &attr, bool fastMode, std::ostream &os)
539 {
540     if (attr.IsAccessor()) {
541         os << "(Accessor) ";
542     }
543 
544     os << "Attr(";
545     if (attr.IsNoneAttributes()) {
546         os << "NONE";
547     }
548     if (attr.IsWritable()) {
549         os << "W";
550     }
551     if (attr.IsEnumerable()) {
552         os << "E";
553     }
554     if (attr.IsConfigurable()) {
555         os << "C";
556     }
557     os << ")";
558 
559     os << " InlinedProps: " << attr.IsInlinedProps();
560 
561     if (fastMode) {
562         os << " Order: " << std::dec << attr.GetOffset();
563         os << " SortedIndex: " << std::dec << attr.GetSortedIndex();
564     } else {
565         os << " Order: " << std::dec << attr.GetDictionaryOrder();
566     }
567 }
568 
DumpObject(TaggedObject * obj,std::ostream & os)569 static void DumpObject(TaggedObject *obj, std::ostream &os)
570 {
571     DISALLOW_GARBAGE_COLLECTION;
572     auto jsHclass = obj->GetClass();
573     JSType type = jsHclass->GetObjectType();
574 
575     switch (type) {
576         case JSType::HCLASS:
577             return DumpClass(obj, os);
578         case JSType::TAGGED_ARRAY:
579         case JSType::TAGGED_DICTIONARY:
580         case JSType::TEMPLATE_MAP:
581         case JSType::LEXICAL_ENV:
582         case JSType::COW_TAGGED_ARRAY:
583             DumpArrayClass(TaggedArray::Cast(obj), os);
584             break;
585         case JSType::CONSTANT_POOL:
586             DumpConstantPoolClass(ConstantPool::Cast(obj), os);
587             break;
588         case JSType::STRING:
589             DumpStringClass(EcmaString::Cast(obj), os);
590             os << "\n";
591             break;
592         case JSType::JS_NATIVE_POINTER:
593             break;
594         case JSType::JS_OBJECT:
595         case JSType::JS_GLOBAL_OBJECT:
596         case JSType::JS_ERROR:
597         case JSType::JS_EVAL_ERROR:
598         case JSType::JS_RANGE_ERROR:
599         case JSType::JS_TYPE_ERROR:
600         case JSType::JS_AGGREGATE_ERROR:
601         case JSType::JS_REFERENCE_ERROR:
602         case JSType::JS_URI_ERROR:
603         case JSType::JS_SYNTAX_ERROR:
604         case JSType::JS_OOM_ERROR:
605         case JSType::JS_ARGUMENTS:
606             JSObject::Cast(obj)->Dump(os);
607             break;
608         case JSType::JS_FUNCTION_BASE:
609             JSFunctionBase::Cast(obj)->Dump(os);
610             break;
611         case JSType::GLOBAL_ENV:
612             GlobalEnv::Cast(obj)->Dump(os);
613             break;
614         case JSType::ACCESSOR_DATA:
615             break;
616         case JSType::JS_FUNCTION:
617             JSFunction::Cast(obj)->Dump(os);
618             break;
619         case JSType::JS_BOUND_FUNCTION:
620             JSBoundFunction::Cast(obj)->Dump(os);
621             break;
622         case JSType::JS_SET:
623             JSSet::Cast(obj)->Dump(os);
624             break;
625         case JSType::JS_MAP:
626             JSMap::Cast(obj)->Dump(os);
627             break;
628         case JSType::JS_WEAK_SET:
629             JSWeakSet::Cast(obj)->Dump(os);
630             break;
631         case JSType::JS_WEAK_MAP:
632             JSWeakMap::Cast(obj)->Dump(os);
633             break;
634         case JSType::JS_WEAK_REF:
635             JSWeakRef::Cast(obj)->Dump(os);
636             break;
637         case JSType::JS_FINALIZATION_REGISTRY:
638             JSFinalizationRegistry::Cast(obj)->Dump(os);
639             break;
640         case JSType::CELL_RECORD:
641             CellRecord::Cast(obj)->Dump(os);
642             break;
643         case JSType::JS_REG_EXP:
644             JSRegExp::Cast(obj)->Dump(os);
645             break;
646         case JSType::JS_DATE:
647             JSDate::Cast(obj)->Dump(os);
648             break;
649         case JSType::JS_ARRAY:
650             JSArray::Cast(obj)->Dump(os);
651             break;
652         case JSType::JS_TYPED_ARRAY:
653         case JSType::JS_INT8_ARRAY:
654         case JSType::JS_UINT8_ARRAY:
655         case JSType::JS_UINT8_CLAMPED_ARRAY:
656         case JSType::JS_INT16_ARRAY:
657         case JSType::JS_UINT16_ARRAY:
658         case JSType::JS_INT32_ARRAY:
659         case JSType::JS_UINT32_ARRAY:
660         case JSType::JS_FLOAT32_ARRAY:
661         case JSType::JS_FLOAT64_ARRAY:
662         case JSType::JS_BIGINT64_ARRAY:
663         case JSType::JS_BIGUINT64_ARRAY:
664             JSTypedArray::Cast(obj)->Dump(os);
665             break;
666         case JSType::BIGINT:
667             BigInt::Cast(obj)->Dump(os);
668             break;
669         case JSType::BYTE_ARRAY:
670             ByteArray::Cast(obj)->Dump(os);
671             break;
672         case JSType::JS_PROXY:
673             JSProxy::Cast(obj)->Dump(os);
674             break;
675         case JSType::JS_PRIMITIVE_REF:
676             JSPrimitiveRef::Cast(obj)->Dump(os);
677             break;
678         case JSType::SYMBOL:
679             JSSymbol::Cast(obj)->Dump(os);
680             break;
681         case JSType::JS_DATA_VIEW:
682             JSDataView::Cast(obj)->Dump(os);
683             break;
684         case JSType::JS_ARRAY_BUFFER:
685             JSArrayBuffer::Cast(obj)->Dump(os);
686             break;
687         case JSType::JS_SHARED_ARRAY_BUFFER:
688             JSArrayBuffer::Cast(obj)->Dump(os);
689             break;
690         case JSType::PROMISE_REACTIONS:
691             PromiseReaction::Cast(obj)->Dump(os);
692             break;
693         case JSType::PROMISE_CAPABILITY:
694             PromiseCapability::Cast(obj)->Dump(os);
695             break;
696         case JSType::PROMISE_ITERATOR_RECORD:
697             PromiseIteratorRecord::Cast(obj)->Dump(os);
698             break;
699         case JSType::PROMISE_RECORD:
700             PromiseRecord::Cast(obj)->Dump(os);
701             break;
702         case JSType::RESOLVING_FUNCTIONS_RECORD:
703             ResolvingFunctionsRecord::Cast(obj)->Dump(os);
704             break;
705         case JSType::JS_PROMISE:
706             JSPromise::Cast(obj)->Dump(os);
707             break;
708         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
709             JSPromiseReactionsFunction::Cast(obj)->Dump(os);
710             break;
711         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
712             JSPromiseExecutorFunction::Cast(obj)->Dump(os);
713             break;
714         case JSType::ASYNC_GENERATOR_REQUEST:
715             AsyncGeneratorRequest::Cast(obj)->Dump(os);
716             break;
717         case JSType::ASYNC_ITERATOR_RECORD:
718             AsyncIteratorRecord::Cast(obj)->Dump(os);
719             break;
720         case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
721             JSAsyncFromSyncIterator::Cast(obj)->Dump(os);
722             break;
723         case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
724             JSAsyncFromSyncIterUnwarpFunction::Cast(obj)->Dump(os);
725             break;
726         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
727             JSPromiseAllResolveElementFunction::Cast(obj)->Dump(os);
728             break;
729         case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
730             JSPromiseAnyRejectElementFunction::Cast(obj)->Dump(os);
731             break;
732         case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
733             JSPromiseAllSettledElementFunction::Cast(obj)->Dump(os);
734             break;
735         case JSType::JS_PROMISE_FINALLY_FUNCTION:
736             JSPromiseFinallyFunction::Cast(obj)->Dump(os);
737             break;
738         case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
739             JSPromiseValueThunkOrThrowerFunction::Cast(obj)->Dump(os);
740             break;
741         case JSType::MICRO_JOB_QUEUE:
742             MicroJobQueue::Cast(obj)->Dump(os);
743             break;
744         case JSType::PENDING_JOB:
745             PendingJob::Cast(obj)->Dump(os);
746             break;
747         case JSType::COMPLETION_RECORD:
748             CompletionRecord::Cast(obj)->Dump(os);
749             break;
750         case JSType::JS_PROXY_REVOC_FUNCTION:
751             JSProxyRevocFunction::Cast(obj)->Dump(os);
752             break;
753         case JSType::JS_ASYNC_FUNCTION:
754             JSAsyncFunction::Cast(obj)->Dump(os);
755             break;
756         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
757             JSAsyncAwaitStatusFunction::Cast(obj)->Dump(os);
758             break;
759         case JSType::JS_GENERATOR_FUNCTION:
760             JSGeneratorFunction::Cast(obj)->Dump(os);
761             break;
762         case JSType::JS_ASYNC_GENERATOR_FUNCTION:
763             JSAsyncGeneratorFunction::Cast(obj)->Dump(os);
764             break;
765         case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
766             JSAsyncGeneratorResNextRetProRstFtn::Cast(obj)->Dump(os);
767             break;
768         case JSType::JS_INTL_BOUND_FUNCTION:
769             JSIntlBoundFunction::Cast(obj)->Dump(os);
770             break;
771         case JSType::JS_ITERATOR:
772             break;
773         case JSType::JS_ASYNCITERATOR:
774             break;
775         case JSType::JS_FORIN_ITERATOR:
776             JSForInIterator::Cast(obj)->Dump(os);
777             break;
778         case JSType::JS_MAP_ITERATOR:
779             JSMapIterator::Cast(obj)->Dump(os);
780             break;
781         case JSType::JS_SET_ITERATOR:
782             JSSetIterator::Cast(obj)->Dump(os);
783             break;
784         case JSType::JS_REG_EXP_ITERATOR:
785             JSRegExpIterator::Cast(obj)->Dump(os);
786             break;
787         case JSType::JS_ARRAY_ITERATOR:
788             JSArrayIterator::Cast(obj)->Dump(os);
789             break;
790         case JSType::JS_STRING_ITERATOR:
791             JSStringIterator::Cast(obj)->Dump(os);
792             break;
793         case JSType::PROTOTYPE_HANDLER:
794             PrototypeHandler::Cast(obj)->Dump(os);
795             break;
796         case JSType::TRANSITION_HANDLER:
797             TransitionHandler::Cast(obj)->Dump(os);
798             break;
799         case JSType::TRANS_WITH_PROTO_HANDLER:
800             TransWithProtoHandler::Cast(obj)->Dump(os);
801             break;
802         case JSType::STORE_TS_HANDLER:
803             StoreTSHandler::Cast(obj)->Dump(os);
804             break;
805         case JSType::PROPERTY_BOX:
806             PropertyBox::Cast(obj)->Dump(os);
807             break;
808         case JSType::JS_REALM:
809             JSRealm::Cast(obj)->Dump(os);
810             break;
811         case JSType::JS_INTL:
812             JSIntl::Cast(obj)->Dump(os);
813             break;
814         case JSType::JS_LOCALE:
815             JSLocale::Cast(obj)->Dump(os);
816             break;
817         case JSType::JS_DATE_TIME_FORMAT:
818             JSDateTimeFormat::Cast(obj)->Dump(os);
819             break;
820         case JSType::JS_RELATIVE_TIME_FORMAT:
821             JSRelativeTimeFormat::Cast(obj)->Dump(os);
822             break;
823         case JSType::JS_NUMBER_FORMAT:
824             JSNumberFormat::Cast(obj)->Dump(os);
825             break;
826         case JSType::JS_COLLATOR:
827             JSCollator::Cast(obj)->Dump(os);
828             break;
829         case JSType::JS_PLURAL_RULES:
830             JSPluralRules::Cast(obj)->Dump(os);
831             break;
832         case JSType::JS_DISPLAYNAMES:
833             JSDisplayNames::Cast(obj)->Dump(os);
834             break;
835         case JSType::JS_LIST_FORMAT:
836             JSListFormat::Cast(obj)->Dump(os);
837             break;
838         case JSType::JS_GENERATOR_OBJECT:
839             JSGeneratorObject::Cast(obj)->Dump(os);
840             break;
841         case JSType::JS_ASYNC_GENERATOR_OBJECT:
842             JSAsyncGeneratorObject::Cast(obj)->Dump(os);
843             break;
844         case JSType::JS_ASYNC_FUNC_OBJECT:
845             JSAsyncFuncObject::Cast(obj)->Dump(os);
846             break;
847         case JSType::JS_GENERATOR_CONTEXT:
848             GeneratorContext::Cast(obj)->Dump(os);
849             break;
850         case JSType::PROTOTYPE_INFO:
851             ProtoChangeDetails::Cast(obj)->Dump(os);
852             break;
853         case JSType::PROTO_CHANGE_MARKER:
854             ProtoChangeMarker::Cast(obj)->Dump(os);
855             break;
856         case JSType::PROGRAM:
857             Program::Cast(obj)->Dump(os);
858             break;
859         case JSType::MACHINE_CODE_OBJECT:
860             MachineCode::Cast(obj)->Dump(os);
861             break;
862         case JSType::CLASS_INFO_EXTRACTOR:
863             ClassInfoExtractor::Cast(obj)->Dump(os);
864             break;
865         case JSType::JS_API_ARRAY_LIST:
866             JSAPIArrayList::Cast(obj)->Dump(os);
867             break;
868         case JSType::JS_API_ARRAYLIST_ITERATOR:
869             JSAPIArrayListIterator::Cast(obj)->Dump(os);
870             break;
871         case JSType::JS_API_LIGHT_WEIGHT_MAP:
872             JSAPILightWeightMap::Cast(obj)->Dump(os);
873             break;
874         case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
875             JSAPILightWeightMapIterator::Cast(obj)->Dump(os);
876             break;
877         case JSType::JS_API_LIGHT_WEIGHT_SET:
878             JSAPILightWeightSet::Cast(obj)->Dump(os);
879             break;
880         case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
881             JSAPILightWeightSetIterator::Cast(obj)->Dump(os);
882             break;
883         case JSType::TS_OBJECT_TYPE:
884             TSObjectType::Cast(obj)->Dump(os);
885             break;
886         case JSType::TS_CLASS_TYPE:
887             TSClassType::Cast(obj)->Dump(os);
888             break;
889         case JSType::TS_INTERFACE_TYPE:
890             TSInterfaceType::Cast(obj)->Dump(os);
891             break;
892         case JSType::TS_CLASS_INSTANCE_TYPE:
893             TSClassInstanceType::Cast(obj)->Dump(os);
894             break;
895         case JSType::TS_UNION_TYPE:
896             TSUnionType::Cast(obj)->Dump(os);
897             break;
898         case JSType::TS_FUNCTION_TYPE:
899             TSFunctionType::Cast(obj)->Dump(os);
900             break;
901         case JSType::TS_ARRAY_TYPE:
902             TSArrayType::Cast(obj)->Dump(os);
903             break;
904         case JSType::TS_ITERATOR_INSTANCE_TYPE:
905             TSIteratorInstanceType::Cast(obj)->Dump(os);
906             break;
907         case JSType::LINKED_NODE:
908         case JSType::RB_TREENODE:
909             break;
910         case JSType::JS_API_HASH_MAP:
911             JSAPIHashMap::Cast(obj)->Dump(os);
912             break;
913         case JSType::JS_API_HASH_SET:
914             JSAPIHashSet::Cast(obj)->Dump(os);
915             break;
916         case JSType::JS_API_HASHMAP_ITERATOR:
917             JSAPIHashMapIterator::Cast(obj)->Dump(os);
918             break;
919         case JSType::JS_API_HASHSET_ITERATOR:
920             JSAPIHashSetIterator::Cast(obj)->Dump(os);
921             break;
922         case JSType::JS_API_TREE_MAP:
923             JSAPITreeMap::Cast(obj)->Dump(os);
924             break;
925         case JSType::JS_API_TREE_SET:
926             JSAPITreeSet::Cast(obj)->Dump(os);
927             break;
928         case JSType::JS_API_TREEMAP_ITERATOR:
929             JSAPITreeMapIterator::Cast(obj)->Dump(os);
930             break;
931         case JSType::JS_API_TREESET_ITERATOR:
932             JSAPITreeSetIterator::Cast(obj)->Dump(os);
933             break;
934         case JSType::JS_API_VECTOR:
935             JSAPIVector::Cast(obj)->Dump(os);
936             break;
937         case JSType::JS_API_VECTOR_ITERATOR:
938             JSAPIVectorIterator::Cast(obj)->Dump(os);
939             break;
940         case JSType::JS_API_QUEUE:
941             JSAPIQueue::Cast(obj)->Dump(os);
942             break;
943         case JSType::JS_API_QUEUE_ITERATOR:
944             JSAPIQueueIterator::Cast(obj)->Dump(os);
945             break;
946         case JSType::JS_API_DEQUE:
947             JSAPIDeque::Cast(obj)->Dump(os);
948             break;
949         case JSType::JS_API_DEQUE_ITERATOR:
950             JSAPIDequeIterator::Cast(obj)->Dump(os);
951             break;
952         case JSType::JS_API_STACK:
953             JSAPIStack::Cast(obj)->Dump(os);
954             break;
955         case JSType::JS_API_STACK_ITERATOR:
956             JSAPIStackIterator::Cast(obj)->Dump(os);
957             break;
958         case JSType::JS_API_LIST:
959             JSAPIList::Cast(obj)->Dump(os);
960             break;
961         case JSType::JS_API_LIST_ITERATOR:
962             JSAPIListIterator::Cast(obj)->Dump(os);
963             break;
964         case JSType::JS_API_LINKED_LIST:
965             JSAPILinkedList::Cast(obj)->Dump(os);
966             break;
967         case JSType::JS_API_LINKED_LIST_ITERATOR:
968             JSAPILinkedListIterator::Cast(obj)->Dump(os);
969             break;
970         case JSType::SOURCE_TEXT_MODULE_RECORD:
971             SourceTextModule::Cast(obj)->Dump(os);
972             break;
973         case JSType::IMPORTENTRY_RECORD:
974             ImportEntry::Cast(obj)->Dump(os);
975             break;
976         case JSType::LOCAL_EXPORTENTRY_RECORD:
977             LocalExportEntry::Cast(obj)->Dump(os);
978             break;
979         case JSType::INDIRECT_EXPORTENTRY_RECORD:
980             IndirectExportEntry::Cast(obj)->Dump(os);
981             break;
982         case JSType::STAR_EXPORTENTRY_RECORD:
983             StarExportEntry::Cast(obj)->Dump(os);
984             break;
985         case JSType::RESOLVEDBINDING_RECORD:
986             ResolvedBinding::Cast(obj)->Dump(os);
987             break;
988         case JSType::RESOLVEDINDEXBINDING_RECORD:
989             ResolvedIndexBinding::Cast(obj)->Dump(os);
990             break;
991         case JSType::JS_MODULE_NAMESPACE:
992             ModuleNamespace::Cast(obj)->Dump(os);
993             break;
994         case JSType::JS_API_PLAIN_ARRAY:
995             JSAPIPlainArray::Cast(obj)->Dump(os);
996             break;
997         case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
998             JSAPIPlainArrayIterator::Cast(obj)->Dump(os);
999             break;
1000         case JSType::JS_CJS_MODULE:
1001             CjsModule::Cast(obj)->Dump(os);
1002             break;
1003         case JSType::JS_CJS_REQUIRE:
1004             CjsRequire::Cast(obj)->Dump(os);
1005             break;
1006         case JSType::JS_CJS_EXPORTS:
1007             CjsExports::Cast(obj)->Dump(os);
1008             break;
1009         case JSType::METHOD:
1010             Method::Cast(obj)->Dump(os);
1011             break;
1012         case JSType::CLASS_LITERAL:
1013             ClassLiteral::Cast(obj)->Dump(os);
1014             break;
1015         default:
1016             UNREACHABLE();
1017             break;
1018     }
1019 
1020     DumpHClass(jsHclass, os, false);
1021 }
1022 
DumpSpecialValue(std::ostream & os) const1023 void JSTaggedValue::DumpSpecialValue(std::ostream &os) const
1024 {
1025     ASSERT(IsSpecial());
1026     os << "[Special Value] : ";
1027     switch (GetRawData()) {
1028         case VALUE_HOLE:
1029             os << "Hole";
1030             break;
1031         case VALUE_NULL:
1032             os << "Null";
1033             break;
1034         case VALUE_FALSE:
1035             os << "False";
1036             break;
1037         case VALUE_TRUE:
1038             os << "True";
1039             break;
1040         case VALUE_UNDEFINED:
1041             os << "Undefined";
1042             break;
1043         case VALUE_EXCEPTION:
1044             os << "Exception";
1045             break;
1046         default:
1047             UNREACHABLE();
1048             break;
1049     }
1050 }
1051 
DumpHeapObjectType(std::ostream & os) const1052 void JSTaggedValue::DumpHeapObjectType(std::ostream &os) const
1053 {
1054     ASSERT(IsWeak() || IsHeapObject());
1055     bool isWeak = IsWeak();
1056     TaggedObject *obj = isWeak ? GetTaggedWeakRef() : GetTaggedObject();
1057     if (isWeak) {
1058         os << "----------Dump Weak Referent----------"
1059            << "\n";
1060     }
1061 
1062     JSType type = obj->GetClass()->GetObjectType();
1063     if (type == JSType::STRING) {
1064         CString string = ConvertToString(EcmaString::Cast(obj));
1065         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + string + "]";
1066     } else if (type == JSType::METHOD) {
1067         std::ostringstream address;
1068         address << obj;
1069         CString addrStr = CString(address.str());
1070         Method *method = Method::Cast(obj);
1071 
1072         os << std::left << std::setw(DUMP_TYPE_OFFSET)
1073                         << "[" + JSHClass::DumpJSType(type) + "(" + addrStr + "-" + method->GetMethodName() + ")]";
1074     } else {
1075         std::ostringstream address;
1076         address << obj;
1077         CString addrStr = CString(address.str());
1078 
1079         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + JSHClass::DumpJSType(type) + "(" + addrStr + ")]";
1080     }
1081 }
1082 
DumpTaggedValue(std::ostream & os) const1083 void JSTaggedValue::DumpTaggedValue(std::ostream &os) const
1084 {
1085     if (IsInt()) {
1086         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Int] : " << std::hex << "0x" << GetInt() << std::dec << " ("
1087            << GetInt() << ")";
1088     } else if (IsDouble()) {
1089         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Double] : " << GetDouble();
1090     } else if (IsSpecial()) {
1091         DumpSpecialValue(os);
1092     } else {
1093         DumpHeapObjectType(os);
1094     }
1095 }
1096 
Dump(std::ostream & os) const1097 void JSTaggedValue::Dump(std::ostream &os) const
1098 {
1099     DumpTaggedValue(os);
1100     os << "\n";
1101 
1102     if (IsHeapObject()) {
1103         TaggedObject *obj = IsWeak() ? GetTaggedWeakRef() : GetTaggedObject();
1104         DumpObject(obj, os);
1105     }
1106 }
1107 
D() const1108 void JSTaggedValue::D() const
1109 {
1110     Dump(std::cout);
1111 }
1112 
DV(JSTaggedType val)1113 void JSTaggedValue::DV(JSTaggedType val)
1114 {
1115     JSTaggedValue(val).D();
1116 }
1117 
DumpStack()1118 void JSThread::DumpStack()
1119 {
1120     FrameHandler handler(this);
1121     handler.DumpStack(std::cout);
1122 }
1123 
Dump(std::ostream & os) const1124 void NumberDictionary::Dump(std::ostream &os) const
1125 {
1126     DISALLOW_GARBAGE_COLLECTION;
1127     int size = Size();
1128     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1129         JSTaggedValue key(GetKey(hashIndex));
1130         if (!key.IsUndefined() && !key.IsHole()) {
1131             JSTaggedValue val(GetValue(hashIndex));
1132             os << std::right << std::setw(DUMP_PROPERTY_OFFSET)
1133                << static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()) << ": ";
1134             val.DumpTaggedValue(os);
1135             os << " ";
1136             DumpAttr(GetAttributes(hashIndex), false, os);
1137             os << "\n";
1138         }
1139     }
1140 }
1141 
Dump(std::ostream & os) const1142 void NameDictionary::Dump(std::ostream &os) const
1143 {
1144     DISALLOW_GARBAGE_COLLECTION;
1145     int size = Size();
1146     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1147         JSTaggedValue key(GetKey(hashIndex));
1148         if (!key.IsUndefined() && !key.IsHole()) {
1149             JSTaggedValue val(GetValue(hashIndex));
1150             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1151             DumpPropertyKey(key, os);
1152             os << ": ";
1153             val.DumpTaggedValue(os);
1154             os << " ";
1155             DumpAttr(GetAttributes(hashIndex), false, os);
1156             os << "\n";
1157         }
1158     }
1159 }
1160 
Dump(std::ostream & os) const1161 void GlobalDictionary::Dump(std::ostream &os) const
1162 {
1163     DISALLOW_GARBAGE_COLLECTION;
1164     int size = Size();
1165     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1166         JSTaggedValue key(GetKey(hashIndex));
1167         if (!key.IsUndefined() && !key.IsHole()) {
1168             JSTaggedValue val(GetValue(hashIndex));
1169             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1170             DumpPropertyKey(key, os);
1171             os << " : ";
1172             val.DumpTaggedValue(os);
1173             os << " ";
1174             DumpAttr(GetAttributes(hashIndex), false, os);
1175             os << "\n";
1176         }
1177     }
1178 }
1179 
Dump(std::ostream & os) const1180 void LayoutInfo::Dump(std::ostream &os) const
1181 {
1182     DISALLOW_GARBAGE_COLLECTION;
1183     int num = NumberOfElements();
1184     for (int i = 0; i < num; i++) {
1185         JSTaggedValue key = GetKey(i);
1186         PropertyAttributes attr = GetAttr(i);
1187         os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1188         os << "[" << i << "]: ";
1189         DumpPropertyKey(key, os);
1190         os << " : ";
1191         DumpAttr(attr, true, os);
1192         os << "\n";
1193     }
1194 }
1195 
Dump(std::ostream & os) const1196 void TransitionsDictionary::Dump(std::ostream &os) const
1197 {
1198     DISALLOW_GARBAGE_COLLECTION;
1199     int size = Size();
1200     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1201         JSTaggedValue key(GetKey(hashIndex));
1202         if (!key.IsUndefined() && !key.IsHole()) {
1203             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1204             DumpPropertyKey(key, os);
1205             os << " : ";
1206             GetValue(hashIndex).DumpTaggedValue(os);
1207             os << " : ";
1208             GetAttributes(hashIndex).DumpTaggedValue(os);
1209             os << "\n";
1210         }
1211     }
1212 }
1213 
Dump(std::ostream & os) const1214 void LinkedHashSet::Dump(std::ostream &os) const
1215 {
1216     DISALLOW_GARBAGE_COLLECTION;
1217     int capacity = NumberOfElements() + NumberOfDeletedElements();
1218     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
1219         JSTaggedValue key(GetKey(hashIndex));
1220         if (!key.IsUndefined() && !key.IsHole()) {
1221             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1222             key.DumpTaggedValue(os);
1223             os << "\n";
1224         }
1225     }
1226 }
1227 
Dump(std::ostream & os) const1228 void LinkedHashMap::Dump(std::ostream &os) const
1229 {
1230     DISALLOW_GARBAGE_COLLECTION;
1231     int capacity = NumberOfElements() + NumberOfDeletedElements();
1232     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
1233         JSTaggedValue key(GetKey(hashIndex));
1234         if (!key.IsUndefined() && !key.IsHole()) {
1235             JSTaggedValue val(GetValue(hashIndex));
1236             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1237             key.DumpTaggedValue(os);
1238             os << ": ";
1239             val.DumpTaggedValue(os);
1240             os << "\n";
1241         }
1242     }
1243 }
1244 
Dump(std::ostream & os) const1245 void TaggedDoubleList::Dump(std::ostream &os) const
1246 {
1247     DISALLOW_GARBAGE_COLLECTION;
1248     int capacity = NumberOfNodes();
1249     os << " - node num: " << std::dec << capacity << "\n";
1250     os << " - delete node num: " << std::dec << NumberOfDeletedNodes() << "\n";
1251     os << "head-next: ";
1252     // 5 : 5 first element next ptr
1253     GetElement(5).D();
1254     os << "head-pre: ";
1255     // 6 : 6 first element per ptr
1256     GetElement(6).D();
1257     os << "\n";
1258     int i = 0;
1259     int next = GetElement(5).GetInt();
1260     while (capacity > i) {
1261         os << " value: ";
1262         GetElement(next).DumpTaggedValue(os);
1263         os << " next: ";
1264         // 1 : 1 current element next ptr offset
1265         GetElement(next + 1).D();
1266         os << " pre: ";
1267         // 2 : 2 current element pre ptr offset
1268         GetElement(next + 2).D();
1269         os << "\n";
1270         next = GetElement(next + 1).GetInt();
1271         i++;
1272     }
1273 }
1274 
Dump(std::ostream & os) const1275 void TaggedSingleList::Dump(std::ostream &os) const
1276 {
1277     DISALLOW_GARBAGE_COLLECTION;
1278     int capacity = NumberOfNodes();
1279     os << "head-next: ";
1280     // 5 : 5 first element next ptr
1281     GetElement(5).D();
1282     os << "\n";
1283     int i = 0;
1284     int next = GetElement(5).GetInt();
1285     while (capacity > i) {
1286         os << " value: ";
1287         GetElement(next).DumpTaggedValue(os);
1288         os << " next: ";
1289         // 1 : 1 current element next ptr offset
1290         GetElement(next + 1).D();
1291         os << "\n";
1292         next = GetElement(next + 1).GetInt();
1293         i++;
1294     }
1295 }
1296 
Dump(std::ostream & os) const1297 void JSObject::Dump(std::ostream &os) const
1298 {
1299     DISALLOW_GARBAGE_COLLECTION;
1300     JSHClass *jshclass = GetJSHClass();
1301     os << " - hclass: " << std::hex << jshclass << "\n";
1302     os << " - prototype: ";
1303     jshclass->GetPrototype().DumpTaggedValue(os);
1304     os << "\n";
1305 
1306     TaggedArray *elements = TaggedArray::Cast(GetElements().GetTaggedObject());
1307     os << " - elements: " << std::hex << elements;
1308     if (elements->GetLength() == 0) {
1309         os << " NONE\n";
1310     } else if (!elements->IsDictionaryMode()) {
1311         DumpArrayClass(elements, os);
1312     } else {
1313         NumberDictionary *dict = NumberDictionary::Cast(elements);
1314         os << " <NumberDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1315         dict->Dump(os);
1316     }
1317 
1318     TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
1319     os << " - properties: " << std::hex << properties;
1320     if (IsJSGlobalObject()) {
1321         GlobalDictionary *dict = GlobalDictionary::Cast(properties);
1322         os << " <GlobalDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1323         dict->Dump(os);
1324         return;
1325     }
1326 
1327     if (!properties->IsDictionaryMode()) {
1328         JSTaggedValue attrs = jshclass->GetLayout();
1329         if (attrs.IsNull()) {
1330             return;
1331         }
1332 
1333         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
1334         int propNumber = static_cast<int>(jshclass->NumberOfProps());
1335         os << " <LayoutInfo[" << std::dec << propNumber << "]>\n";
1336         for (int i = 0; i < propNumber; i++) {
1337             JSTaggedValue key = layoutInfo->GetKey(i);
1338             PropertyAttributes attr = layoutInfo->GetAttr(i);
1339             ASSERT(i == static_cast<int>(attr.GetOffset()));
1340             os << "     " << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1341             DumpPropertyKey(key, os);
1342             os << ": (";
1343             JSTaggedValue val;
1344             if (attr.IsInlinedProps()) {
1345                 val = GetPropertyInlinedProps(i);
1346             } else {
1347                 val = properties->Get(i - static_cast<int>(jshclass->GetInlinedProperties()));
1348             }
1349             val.DumpTaggedValue(os);
1350             os << ") ";
1351             DumpAttr(attr, true, os);
1352             os << "\n";
1353         }
1354     } else {
1355         NameDictionary *dict = NameDictionary::Cast(properties);
1356         os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1357         dict->Dump(os);
1358     }
1359 }
1360 
Dump(std::ostream & os) const1361 void TaggedArray::Dump(std::ostream &os) const
1362 {
1363     DumpArrayClass(this, os);
1364 }
1365 
Dump(std::ostream & os) const1366 void AccessorData::Dump(std::ostream &os) const
1367 {
1368     auto *hclass = GetClass();
1369     if (hclass->GetObjectType() == JSType::INTERNAL_ACCESSOR) {
1370         os << " - Getter: " << reinterpret_cast<void *>(GetGetter().GetTaggedObject()) << "\n";
1371         os << " - Setter: " << reinterpret_cast<void *>(GetSetter().GetTaggedObject()) << "\n";
1372         return;
1373     }
1374 
1375     os << " - Getter: ";
1376     GetGetter().DumpTaggedValue(os);
1377     os << "\n";
1378 
1379     os << " - Setter: ";
1380     GetSetter().DumpTaggedValue(os);
1381     os << "\n";
1382 }
1383 
Dump(std::ostream & os) const1384 void Program::Dump(std::ostream &os) const
1385 {
1386     os << " - MainFunction: ";
1387     GetMainFunction().Dump(os);
1388     os << "\n";
1389 }
1390 
Dump(std::ostream & os) const1391 void ConstantPool::Dump(std::ostream &os) const
1392 {
1393     DumpArrayClass(this, os);
1394 }
1395 
Dump(std::ostream & os) const1396 void JSFunction::Dump(std::ostream &os) const
1397 {
1398     os << " - ProtoOrHClass: ";
1399     GetProtoOrHClass().Dump(os);
1400     os << "\n";
1401     os << " - LexicalEnv: ";
1402     GetLexicalEnv().Dump(os);
1403     os << "\n";
1404     os << " - HomeObject: ";
1405     GetHomeObject().Dump(os);
1406     os << "\n";
1407     os << " - FunctionExtraInfo: ";
1408     GetFunctionExtraInfo().Dump(os);
1409     os << "\n";
1410     os << " - Module: ";
1411     GetModule().Dump(os);
1412     os << "\n";
1413     os << " - Method: ";
1414     GetMethod().Dump(os);
1415     os << "\n";
1416     JSObject::Dump(os);
1417 }
1418 
Dump(std::ostream & os) const1419 void JSHClass::Dump(std::ostream &os) const
1420 {
1421     DumpHClass(this, os, true);
1422 }
1423 
Dump(std::ostream & os) const1424 void JSBoundFunction::Dump(std::ostream &os) const
1425 {
1426     os << " - BoundTarget: ";
1427     GetBoundTarget().DumpTaggedValue(os);
1428     os << "\n";
1429 
1430     os << " - BoundThis: ";
1431     GetBoundThis().DumpTaggedValue(os);
1432     os << "\n";
1433 
1434     os << " - BoundArguments: ";
1435     GetBoundArguments().DumpTaggedValue(os);
1436     os << "\n";
1437 
1438     JSObject::Dump(os);
1439 }
1440 
Dump(std::ostream & os) const1441 void JSPrimitiveRef::Dump(std::ostream &os) const
1442 {
1443     os << " - SubValue : ";
1444     GetValue().DumpTaggedValue(os);
1445     os << "\n";
1446     JSObject::Dump(os);
1447 }
1448 
Dump(std::ostream & os) const1449 void BigInt::Dump(std::ostream &os) const
1450 {
1451     os << " - length : " << GetLength() << "\n";
1452     os << " - Sign : " << GetSign() << "\n";
1453     os << " - value : " << ToStdString(DECIMAL) << "\n";
1454 }
1455 
Dump(std::ostream & os) const1456 void JSDate::Dump(std::ostream &os) const
1457 {
1458     os << " - time: " << GetTime().GetDouble() << "\n";
1459     os << " - localOffset: " << GetLocalOffset().GetDouble() << "\n";
1460     JSObject::Dump(os);
1461 }
1462 
Dump(std::ostream & os) const1463 void JSMap::Dump(std::ostream &os) const
1464 {
1465     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
1466     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1467     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1468     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1469     JSObject::Dump(os);
1470 
1471     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1472     map->Dump(os);
1473 }
1474 
Dump(std::ostream & os) const1475 void JSAPITreeMap::Dump(std::ostream &os) const
1476 {
1477     TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap().GetTaggedObject());
1478     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1479     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1480     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1481     JSObject::Dump(os);
1482 
1483     os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1484     map->Dump(os);
1485 }
1486 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1487 void JSAPITreeMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1488 {
1489     TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap().GetTaggedObject());
1490     map->DumpForSnapshot(vec);
1491 
1492     JSObject::DumpForSnapshot(vec);
1493 }
1494 
Dump(std::ostream & os) const1495 void JSAPITreeMapIterator::Dump(std::ostream &os) const
1496 {
1497     TaggedTreeMap *map =
1498         TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap().GetTaggedObject())->GetTreeMap().GetTaggedObject());
1499     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1500     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1501     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1502     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1503     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1504     JSObject::Dump(os);
1505 
1506     os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1507     map->Dump(os);
1508 }
1509 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1510 void JSAPITreeMapIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1511 {
1512     TaggedTreeMap *map =
1513         TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap().GetTaggedObject())->GetTreeMap().GetTaggedObject());
1514     map->DumpForSnapshot(vec);
1515     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
1516     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
1517     JSObject::DumpForSnapshot(vec);
1518 }
1519 
1520 template <typename T>
DumpTaggedTreeEntry(T tree,std::ostream & os,int index,bool isMap=false)1521 void DumpTaggedTreeEntry(T tree, std::ostream &os, int index, bool isMap = false)
1522 {
1523     DISALLOW_GARBAGE_COLLECTION;
1524     JSTaggedValue parent(tree->GetParent(index));
1525     JSTaggedValue val(tree->GetValue(index));
1526     JSTaggedValue color(static_cast<int>(tree->GetColor(index)));
1527     JSTaggedValue left = tree->GetLeftChild(index);
1528     JSTaggedValue right = tree->GetRightChild(index);
1529     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1530     os << "\n";
1531     if (isMap) {
1532         os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [key]:    {";
1533         JSTaggedValue key(tree->GetKey(index));
1534         key.DumpTaggedValue(os);
1535         os << std::right << "};";
1536         os << "\n";
1537     }
1538     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "   [value]:  {";
1539     val.DumpTaggedValue(os);
1540     os << std::right << "};";
1541     os << "\n";
1542     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [parent]: {";
1543     parent.DumpTaggedValue(os);
1544     os << std::right << "};";
1545     os << "\n";
1546     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "   [color]:  {";
1547     color.DumpTaggedValue(os);
1548     os << std::right << "};";
1549     os << "\n";
1550     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [left]:   {";
1551     left.DumpTaggedValue(os);
1552     os << std::right << "}; ";
1553     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "  [right]: {";
1554     right.DumpTaggedValue(os);
1555     os << std::right << "};";
1556     os << "\n";
1557 }
Dump(std::ostream & os) const1558 void TaggedTreeMap::Dump(std::ostream &os) const
1559 {
1560     DISALLOW_GARBAGE_COLLECTION;
1561     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
1562     JSTaggedValue node = TaggedArray::Get(0);
1563     node.DumpTaggedValue(os);
1564     os << std::right << "}" << "\n";
1565     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]:   {";
1566     node = TaggedArray::Get(1);
1567     node.DumpTaggedValue(os);
1568     os << std::right << "}" << "\n";
1569     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
1570     node = TaggedArray::Get(2); // 2 means the three element
1571     node.DumpTaggedValue(os);
1572     os << std::right << "}" << "\n";
1573     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
1574     node = TaggedArray::Get(3); // 3 means the three element
1575     node.DumpTaggedValue(os);
1576     os << std::right << "}" << "\n";
1577 
1578     int capacity = NumberOfElements() + NumberOfDeletedElements();
1579     for (int index = 0; index < capacity; index++) {
1580         if (GetKey(index).IsHole()) {
1581             os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1582             GetKey(index).DumpTaggedValue(os);
1583             os << "\n";
1584         } else {
1585             DumpTaggedTreeEntry(const_cast<TaggedTreeMap *>(this), os, index, true);
1586         }
1587     }
1588 }
1589 
Dump(std::ostream & os) const1590 void JSAPITreeSet::Dump(std::ostream &os) const
1591 {
1592     TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet().GetTaggedObject());
1593     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1594     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1595     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1596     JSObject::Dump(os);
1597 
1598     os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
1599     set->Dump(os);
1600 }
1601 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1602 void JSAPITreeSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1603 {
1604     TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet().GetTaggedObject());
1605     set->DumpForSnapshot(vec);
1606 
1607     JSObject::DumpForSnapshot(vec);
1608 }
1609 
Dump(std::ostream & os) const1610 void JSAPITreeSetIterator::Dump(std::ostream &os) const
1611 {
1612     TaggedTreeSet *set =
1613         TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet().GetTaggedObject())->GetTreeSet().GetTaggedObject());
1614     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1615     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1616     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1617     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1618     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1619     JSObject::Dump(os);
1620 
1621     os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
1622     set->Dump(os);
1623 }
1624 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1625 void JSAPITreeSetIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1626 {
1627     TaggedTreeSet *set =
1628         TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet().GetTaggedObject())->GetTreeSet().GetTaggedObject());
1629     set->DumpForSnapshot(vec);
1630     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
1631     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
1632     JSObject::DumpForSnapshot(vec);
1633 }
1634 
Dump(std::ostream & os) const1635 void TaggedTreeSet::Dump(std::ostream &os) const
1636 {
1637     DISALLOW_GARBAGE_COLLECTION;
1638     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
1639     JSTaggedValue node = TaggedArray::Get(0);
1640     node.DumpTaggedValue(os);
1641     os << std::right << "}" << "\n";
1642     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]:   {";
1643     node = TaggedArray::Get(1);
1644     node.DumpTaggedValue(os);
1645     os << std::right << "}" << "\n";
1646     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
1647     node = TaggedArray::Get(2); // 2 means the three element
1648     node.DumpTaggedValue(os);
1649     os << std::right << "}" << "\n";
1650     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
1651     node = TaggedArray::Get(3); // 3 means the three element
1652     node.DumpTaggedValue(os);
1653     os << std::right << "}" << "\n";
1654 
1655     int capacity = NumberOfElements() + NumberOfDeletedElements();
1656     for (int index = 0; index < capacity; index++) {
1657         if (GetKey(index).IsHole()) {
1658             os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1659             GetKey(index).DumpTaggedValue(os);
1660             os << "\n";
1661         } else {
1662             DumpTaggedTreeEntry(const_cast<TaggedTreeSet *>(this), os, index);
1663         }
1664     }
1665 }
1666 
Dump(std::ostream & os) const1667 void JSAPIPlainArray::Dump(std::ostream &os) const
1668 {
1669     TaggedArray *keys = TaggedArray::Cast(GetKeys().GetTaggedObject());
1670     TaggedArray *values = TaggedArray::Cast(GetValues().GetTaggedObject());
1671     uint32_t len = static_cast<uint32_t>(GetLength());
1672     for (uint32_t i = 0; i < len; i++) {
1673         os << " - keys: ";
1674         keys->Get(i).DumpTaggedValue(os);
1675         os << "\n";
1676         os << " - values: ";
1677         values->Get(i).DumpTaggedValue(os);
1678         os << "\n";
1679     }
1680     os << " - length: " << std::dec << len << "\n";
1681     JSObject::Dump(os);
1682 }
1683 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1684 void JSAPIPlainArray::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1685 {
1686     JSObject::DumpForSnapshot(vec);
1687 }
1688 
Dump(std::ostream & os) const1689 void JSAPIPlainArrayIterator::Dump(std::ostream &os) const
1690 {
1691     JSAPIPlainArray *array = JSAPIPlainArray::Cast(GetIteratedPlainArray().GetTaggedObject());
1692     os << " - length: " << std::dec << array->GetSize() << "\n";
1693     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1694     JSObject::Dump(os);
1695 }
1696 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1697 void JSAPIPlainArrayIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1698 {
1699     JSAPIPlainArray *array = JSAPIPlainArray::Cast(GetIteratedPlainArray().GetTaggedObject());
1700     array->DumpForSnapshot(vec);
1701     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
1702     JSObject::DumpForSnapshot(vec);
1703 }
1704 
Dump(std::ostream & os) const1705 void JSForInIterator::Dump(std::ostream &os) const
1706 {
1707     os << " - Object : ";
1708     GetObject().DumpTaggedValue(os);
1709     os << "\n";
1710     os << " - WasVisited : " << GetWasVisited();
1711     os << "\n";
1712     os << " - VisitedKeys : ";
1713     GetVisitedKeys().DumpTaggedValue(os);
1714     os << "\n";
1715     os << " - RemainingKeys : ";
1716     GetRemainingKeys().DumpTaggedValue(os);
1717     os << "\n";
1718     JSObject::Dump(os);
1719 }
1720 
Dump(std::ostream & os) const1721 void JSMapIterator::Dump(std::ostream &os) const
1722 {
1723     LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap().GetTaggedObject());
1724     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1725     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1726     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1727     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1728     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1729     JSObject::Dump(os);
1730 
1731     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1732     map->Dump(os);
1733 }
1734 
Dump(std::ostream & os) const1735 void JSSet::Dump(std::ostream &os) const
1736 {
1737     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
1738     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1739     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1740     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1741     JSObject::Dump(os);
1742 
1743     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1744     set->Dump(os);
1745 }
1746 
Dump(std::ostream & os) const1747 void JSWeakMap::Dump(std::ostream &os) const
1748 {
1749     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
1750     os << " - length: " << std::dec << GetSize() << "\n";
1751     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1752     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1753     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1754     JSObject::Dump(os);
1755 
1756     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1757     map->Dump(os);
1758 }
1759 
Dump(std::ostream & os) const1760 void JSWeakSet::Dump(std::ostream &os) const
1761 {
1762     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
1763     os << " - size: " << std::dec << GetSize() << "\n";
1764     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1765     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1766     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1767     JSObject::Dump(os);
1768 
1769     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1770     set->Dump(os);
1771 }
1772 
Dump(std::ostream & os) const1773 void JSWeakRef::Dump(std::ostream &os) const
1774 {
1775     os << " - WeakObject : ";
1776     GetWeakObject().DumpTaggedValue(os);
1777     os << "\n";
1778     JSObject::Dump(os);
1779 }
1780 
Dump(std::ostream & os) const1781 void JSFinalizationRegistry::Dump(std::ostream &os) const
1782 {
1783     os << " - CleanupCallback : ";
1784     GetCleanupCallback().DumpTaggedValue(os);
1785     os << "\n";
1786     os << " - NoUnregister : ";
1787     GetNoUnregister().D();
1788     os << "\n";
1789     os << " - MaybeUnregister : ";
1790     LinkedHashMap *map = LinkedHashMap::Cast(GetMaybeUnregister().GetTaggedObject());
1791     os << "   -   elements: " << std::dec << map->NumberOfElements() << "\n";
1792     os << "   -   deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1793     os << "   -   capacity: " << std::dec << map->Capacity() << "\n";
1794     JSObject::Dump(os);
1795 }
1796 
Dump(std::ostream & os) const1797 void CellRecord::Dump(std::ostream &os) const
1798 {
1799     os << " - WeakRefTarget : ";
1800     GetFromWeakRefTarget().DumpTaggedValue(os);
1801     os << "\n";
1802     os << " - HeldValue : ";
1803     GetHeldValue().DumpTaggedValue(os);
1804     os << "\n";
1805 }
1806 
Dump(std::ostream & os) const1807 void JSSetIterator::Dump(std::ostream &os) const
1808 {
1809     LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet().GetTaggedObject());
1810     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1811     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1812     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1813     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1814     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1815     JSObject::Dump(os);
1816 
1817     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1818     set->Dump(os);
1819 }
1820 
Dump(std::ostream & os) const1821 void JSRegExpIterator::Dump(std::ostream &os) const
1822 {
1823     os << " - IteratingRegExp: ";
1824     GetIteratingRegExp().D();
1825     os << "\n";
1826     os << " - IteratedString: ";
1827     GetIteratedString().D();
1828     os << "\n";
1829     os << " - Global: " << std::dec << GetGlobal() << "\n";
1830     os << " - Unicode: " << std::dec << GetUnicode() << "\n";
1831     os << " - Done: " << std::dec << GetDone() << "\n";
1832     JSObject::Dump(os);
1833 }
1834 
Dump(std::ostream & os) const1835 void JSArray::Dump(std::ostream &os) const
1836 {
1837     os << " - length: " << std::dec << GetArrayLength() << "\n";
1838     JSObject::Dump(os);
1839 }
1840 
Dump(std::ostream & os) const1841 void JSArrayIterator::Dump(std::ostream &os) const
1842 {
1843     JSArray *array = JSArray::Cast(GetIteratedArray().GetTaggedObject());
1844     os << " - length: " << std::dec << array->GetArrayLength() << "\n";
1845     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1846     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1847     JSObject::Dump(os);
1848 }
1849 
Dump(std::ostream & os) const1850 void JSAPIArrayList::Dump(std::ostream &os) const
1851 {
1852     os << " - length: " << std::dec << GetSize() << "\n";
1853     JSObject::Dump(os);
1854 }
1855 
Dump(std::ostream & os) const1856 void JSAPIArrayListIterator::Dump(std::ostream &os) const
1857 {
1858     JSAPIArrayList *arrayList = JSAPIArrayList::Cast(GetIteratedArrayList().GetTaggedObject());
1859     os << " - length: " << std::dec << arrayList->GetSize() << "\n";
1860     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1861     JSObject::Dump(os);
1862 }
1863 
Dump(std::ostream & os) const1864 void JSAPIDeque::Dump(std::ostream &os) const
1865 {
1866     os << " - first: " << std::dec << GetFirst() << "\n";
1867     os << " - last: " << std::dec << GetLast() << "\n";
1868     JSObject::Dump(os);
1869 }
1870 
Dump(std::ostream & os) const1871 void JSAPIDequeIterator::Dump(std::ostream &os) const
1872 {
1873     JSAPIDeque *deque = JSAPIDeque::Cast(GetIteratedDeque().GetTaggedObject());
1874     os << " - length: " << std::dec << deque->GetSize() << "\n";
1875     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1876     JSObject::Dump(os);
1877 }
1878 
Dump(std::ostream & os) const1879 void JSAPILightWeightMap::Dump(std::ostream &os) const
1880 {
1881     int capacity = GetSize();
1882     os << " - length: " << std::dec << capacity << "\n";
1883     int i = 0;
1884     TaggedArray *hashArray = TaggedArray::Cast(GetHashes().GetTaggedObject());
1885     TaggedArray *keyArray = TaggedArray::Cast(GetKeys().GetTaggedObject());
1886     TaggedArray *valueArray = TaggedArray::Cast(GetValues().GetTaggedObject());
1887     while (capacity > i) {
1888         os << " hash: ";
1889         hashArray->Get(i).DumpTaggedValue(os);
1890         os << " key: ";
1891         keyArray->Get(i).DumpTaggedValue(os);
1892         os << " value: ";
1893         valueArray->Get(i).DumpTaggedValue(os);
1894         os << "\n";
1895         i++;
1896     }
1897     JSObject::Dump(os);
1898 }
1899 
Dump(std::ostream & os) const1900 void JSAPILightWeightMapIterator::Dump(std::ostream &os) const
1901 {
1902     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1903     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1904     JSObject::Dump(os);
1905 }
1906 
Dump(std::ostream & os) const1907 void JSAPIHashMap::Dump(std::ostream &os) const
1908 {
1909     TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
1910     os << " - elements: " << std::dec << GetSize() << "\n";
1911     os << " - table capacity: " << std::dec << static_cast<int>(hashArray->GetLength()) << "\n";
1912     JSObject::Dump(os);
1913 }
1914 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1915 void JSAPIHashMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1916 {
1917     JSObject::DumpForSnapshot(vec);
1918 }
1919 
Dump(std::ostream & os) const1920 void JSAPIHashSet::Dump(std::ostream &os) const
1921 {
1922     TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable().GetTaggedObject());
1923     os << " - elements: " << std::dec << GetSize() << "\n";
1924     os << " - table capacity: " << std::dec << static_cast<int>(hashArray->GetLength()) << "\n";
1925     JSObject::Dump(os);
1926 }
1927 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1928 void JSAPIHashSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1929 {
1930     JSObject::DumpForSnapshot(vec);
1931 }
1932 
Dump(std::ostream & os) const1933 void JSAPIHashMapIterator::Dump(std::ostream &os) const
1934 {
1935     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1936     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1937     JSObject::Dump(os);
1938 }
1939 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1940 void JSAPIHashMapIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1941 {
1942     JSObject::DumpForSnapshot(vec);
1943 }
1944 
Dump(std::ostream & os) const1945 void JSAPIHashSetIterator::Dump(std::ostream &os) const
1946 {
1947     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1948     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1949     JSObject::Dump(os);
1950 }
1951 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1952 void JSAPIHashSetIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1953 {
1954     JSObject::DumpForSnapshot(vec);
1955 }
1956 
Dump(std::ostream & os) const1957 void JSAPILightWeightSet::Dump(std::ostream &os) const
1958 {
1959     TaggedArray *keys = TaggedArray::Cast(GetHashes().GetTaggedObject());
1960     TaggedArray *values = TaggedArray::Cast(GetValues().GetTaggedObject());
1961     uint32_t len = GetLength();
1962     for (uint32_t i = 0; i < len; i++) {
1963         os << " - keys: ";
1964         keys->Get(i).DumpTaggedValue(os);
1965         os << "\n";
1966         os << " - values: ";
1967         values->Get(i).DumpTaggedValue(os);
1968         os << "\n";
1969     }
1970     os << " - length: " << std::dec << len << "\n";
1971     JSObject::Dump(os);
1972 }
1973 
Dump(std::ostream & os) const1974 void JSAPILightWeightSetIterator::Dump(std::ostream &os) const
1975 {
1976     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1977     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1978     JSObject::Dump(os);
1979 }
1980 
Dump(std::ostream & os) const1981 void JSAPIList::Dump(std::ostream &os) const
1982 {
1983     TaggedSingleList *list = TaggedSingleList::Cast(GetSingleList().GetTaggedObject());
1984     os << " - length: " << std::dec << list->GetCapacityFromTaggedArray() << "\n";
1985     os << " - node num: " << std::dec << list->NumberOfNodes() << "\n";
1986     os << " - delete node num: " << std::dec << list->NumberOfDeletedNodes() << "\n";
1987     JSObject::Dump(os);
1988     list->Dump(os);
1989 }
1990 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const1991 void JSAPIList::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1992 {
1993     TaggedSingleList *map = TaggedSingleList::Cast(GetSingleList().GetTaggedObject());
1994     map->DumpForSnapshot(vec);
1995 
1996     JSObject::DumpForSnapshot(vec);
1997 }
1998 
Dump(std::ostream & os) const1999 void JSAPIListIterator::Dump(std::ostream &os) const
2000 {
2001     TaggedSingleList *list = TaggedSingleList::Cast(GetIteratedList().GetTaggedObject());
2002     os << " - length: " << std::dec << list->GetCapacityFromTaggedArray() << "\n";
2003     os << " - node num: " << std::dec << list->NumberOfNodes() << "\n";
2004     os << " - delete node num: " << std::dec << list->NumberOfDeletedNodes() << "\n";
2005     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2006     JSObject::Dump(os);
2007     list->Dump(os);
2008 }
2009 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const2010 void JSAPIListIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2011 {
2012     TaggedSingleList *list = TaggedSingleList::Cast(GetIteratedList().GetTaggedObject());
2013     list->DumpForSnapshot(vec);
2014     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
2015     JSObject::DumpForSnapshot(vec);
2016 }
2017 
Dump(std::ostream & os) const2018 void JSAPILinkedList::Dump(std::ostream &os) const
2019 {
2020     TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetDoubleList().GetTaggedObject());
2021     os << " - length: " << std::dec << linkedList->GetCapacityFromTaggedArray() << "\n";
2022     os << " - node num: " << std::dec << linkedList->NumberOfNodes() << "\n";
2023     os << " - delete node num: " << std::dec << linkedList->NumberOfDeletedNodes() << "\n";
2024     JSObject::Dump(os);
2025     linkedList->Dump(os);
2026 }
2027 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const2028 void JSAPILinkedList::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2029 {
2030     TaggedDoubleList *map = TaggedDoubleList::Cast(GetDoubleList().GetTaggedObject());
2031     map->DumpForSnapshot(vec);
2032 
2033     JSObject::DumpForSnapshot(vec);
2034 }
2035 
Dump(std::ostream & os) const2036 void JSAPILinkedListIterator::Dump(std::ostream &os) const
2037 {
2038     TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetIteratedLinkedList().GetTaggedObject());
2039     os << " - length: " << std::dec << linkedList->GetCapacityFromTaggedArray() << "\n";
2040     os << " - node num: " << std::dec << linkedList->NumberOfNodes() << "\n";
2041     os << " - delete node num: " << std::dec << linkedList->NumberOfDeletedNodes() << "\n";
2042     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2043     JSObject::Dump(os);
2044     linkedList->Dump(os);
2045 }
2046 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const2047 void JSAPILinkedListIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2048 {
2049     TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetIteratedLinkedList().GetTaggedObject());
2050     linkedList->DumpForSnapshot(vec);
2051     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
2052     JSObject::DumpForSnapshot(vec);
2053 }
2054 
Dump(std::ostream & os) const2055 void JSAPIQueue::Dump(std::ostream &os) const
2056 {
2057     os << " - length: " << std::dec << GetSize() << "\n";
2058     os << " - front: " << std::dec << GetFront() << "\n";
2059     os << " - tail: " << std::dec << GetTail() << "\n";
2060     JSObject::Dump(os);
2061 }
2062 
Dump(std::ostream & os) const2063 void JSAPIQueueIterator::Dump(std::ostream &os) const
2064 {
2065     JSAPIQueue *queue = JSAPIQueue::Cast(GetIteratedQueue().GetTaggedObject());
2066     os << " - length: " << std::dec << queue->GetSize() << "\n";
2067     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2068     JSObject::Dump(os);
2069 }
2070 
Dump(std::ostream & os) const2071 void JSAPIStack::Dump(std::ostream &os) const
2072 {
2073     os << " - top: " << std::dec << GetTop() << "\n";
2074     JSObject::Dump(os);
2075 }
2076 
Dump(std::ostream & os) const2077 void JSAPIStackIterator::Dump(std::ostream &os) const
2078 {
2079     JSAPIStack *stack = JSAPIStack::Cast(GetIteratedStack().GetTaggedObject());
2080     os << " - length: " << std::dec << stack->GetSize() << "\n";
2081     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2082     JSObject::Dump(os);
2083 }
2084 
Dump(std::ostream & os) const2085 void JSAPIVector::Dump(std::ostream &os) const
2086 {
2087     os << " - length: " << std::dec << GetSize() << "\n";
2088     JSObject::Dump(os);
2089 }
2090 
Dump(std::ostream & os) const2091 void JSAPIVectorIterator::Dump(std::ostream &os) const
2092 {
2093     JSAPIVector *vector = JSAPIVector::Cast(GetIteratedVector().GetTaggedObject());
2094     os << " - length: " << std::dec << vector->GetSize() << "\n";
2095     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2096     JSObject::Dump(os);
2097 }
2098 
Dump(std::ostream & os) const2099 void JSStringIterator::Dump(std::ostream &os) const
2100 {
2101     EcmaString *str = EcmaString::Cast(GetIteratedString().GetTaggedObject());
2102     os << " - IteratedString: " << EcmaStringAccessor(str).ToCString() << "\n";
2103     os << " - StringIteratorNextIndex: " << std::dec << GetStringIteratorNextIndex() << "\n";
2104     JSObject::Dump(os);
2105 }
Dump(std::ostream & os) const2106 void JSTypedArray::Dump(std::ostream &os) const
2107 {
2108     os << " - viewed-array-buffer: ";
2109     GetViewedArrayBuffer().Dump(os);
2110     os << " - typed-array-name: ";
2111     GetTypedArrayName().Dump(os);
2112     os << " - byte-length: " << GetByteLength();
2113     os << " - byte-offset: " << GetByteOffset();
2114     os << " - array-length: " << GetArrayLength();
2115     JSObject::Dump(os);
2116 }
2117 
Dump(std::ostream & os) const2118 void ByteArray::Dump(std::ostream &os) const
2119 {
2120     os << " - length: " << GetLength();
2121     os << " - size: " << GetSize();
2122 }
2123 
Dump(std::ostream & os) const2124 void JSRegExp::Dump(std::ostream &os) const
2125 {
2126     os << "\n";
2127     os << " - ByteCodeBuffer: ";
2128     GetByteCodeBuffer().D();
2129     os << "\n";
2130     os << " - OriginalSource: ";
2131     GetOriginalSource().D();
2132     os << "\n";
2133     os << " - OriginalFlags: ";
2134     GetOriginalFlags().D();
2135     os << "\n";
2136     os << " - GroupName: ";
2137     GetGroupName().D();
2138     os << "\n";
2139     os << " - Length: " << GetLength();
2140     os << "\n";
2141     JSObject::Dump(os);
2142 }
2143 
Dump(std::ostream & os) const2144 void JSProxy::Dump(std::ostream &os) const
2145 {
2146     os << " - Target: ";
2147     os << "\n";
2148     JSObject::Cast(GetTarget().GetTaggedObject())->Dump(os);
2149     os << " - Handler: ";
2150     os << "\n";
2151     JSObject::Cast(GetHandler().GetTaggedObject())->Dump(os);
2152     os << "\n";
2153 }
2154 
Dump(std::ostream & os) const2155 void JSSymbol::Dump(std::ostream &os) const
2156 {
2157     os << " - hash-field: " << GetHashField();
2158     os << "\n - flags: " << GetFlags();
2159     os << "\n - description: ";
2160     JSTaggedValue description = GetDescription();
2161     description.Dump(os);
2162 }
2163 
Dump(std::ostream & os) const2164 void LexicalEnv::Dump(std::ostream &os) const
2165 {
2166     DumpArrayClass(this, os);
2167 }
2168 
Dump(std::ostream & os) const2169 void COWTaggedArray::Dump(std::ostream &os) const
2170 {
2171     DumpArrayClass(this, os);
2172 }
2173 
2174 // NOLINTNEXTLINE(readability-function-size)
Dump(std::ostream & os) const2175 void GlobalEnv::Dump(std::ostream &os) const
2176 {
2177     auto globalConst = GetJSThread()->GlobalConstants();
2178     os << " - ObjectFunction: ";
2179     GetObjectFunction().GetTaggedValue().Dump(os);
2180     os << " - FunctionFunction: ";
2181     GetFunctionFunction().GetTaggedValue().Dump(os);
2182     os << " - NumberFunction: ";
2183     GetNumberFunction().GetTaggedValue().Dump(os);
2184     os << " - BigIntFunction: ";
2185     GetBigIntFunction().GetTaggedValue().Dump(os);
2186     os << " - DateFunction: ";
2187     GetDateFunction().GetTaggedValue().Dump(os);
2188     os << " - BooleanFunction: ";
2189     GetBooleanFunction().GetTaggedValue().Dump(os);
2190     os << " - ErrorFunction: ";
2191     GetErrorFunction().GetTaggedValue().Dump(os);
2192     os << " - ArrayFunction: ";
2193     GetArrayFunction().GetTaggedValue().Dump(os);
2194     os << " - TypedArrayFunction: ";
2195     GetTypedArrayFunction().GetTaggedValue().Dump(os);
2196     os << " - Int8ArrayFunction: ";
2197     GetInt8ArrayFunction().GetTaggedValue().Dump(os);
2198     os << " - Uint8ArrayFunction: ";
2199     GetUint8ArrayFunction().GetTaggedValue().Dump(os);
2200     os << " - Uint8ClampedArrayFunction: ";
2201     GetUint8ClampedArrayFunction().GetTaggedValue().Dump(os);
2202     os << " - Int16ArrayFunction: ";
2203     GetInt16ArrayFunction().GetTaggedValue().Dump(os);
2204     os << " - ArrayBufferFunction: ";
2205     GetArrayBufferFunction().GetTaggedValue().Dump(os);
2206     os << " - SharedArrayBufferFunction: ";
2207     GetSharedArrayBufferFunction().GetTaggedValue().Dump(os);
2208     os << " - SymbolFunction: ";
2209     GetSymbolFunction().GetTaggedValue().Dump(os);
2210     os << " - RangeErrorFunction: ";
2211     GetRangeErrorFunction().GetTaggedValue().Dump(os);
2212     os << " - ReferenceErrorFunction: ";
2213     GetReferenceErrorFunction().GetTaggedValue().Dump(os);
2214     os << " - TypeErrorFunction: ";
2215     GetTypeErrorFunction().GetTaggedValue().Dump(os);
2216     os << " - AggregateErrorFunction: ";
2217     GetAggregateErrorFunction().GetTaggedValue().Dump(os);
2218     os << " - URIErrorFunction: ";
2219     GetURIErrorFunction().GetTaggedValue().Dump(os);
2220     os << " - SyntaxErrorFunction: ";
2221     GetSyntaxErrorFunction().GetTaggedValue().Dump(os);
2222     os << " - EvalErrorFunction: ";
2223     GetEvalErrorFunction().GetTaggedValue().Dump(os);
2224     os << " - OOMErrorFunction: ";
2225     GetOOMErrorFunction().GetTaggedValue().Dump(os);
2226     os << " - RegExpFunction: ";
2227     GetRegExpFunction().GetTaggedValue().Dump(os);
2228     os << " - BuiltinsSetFunction: ";
2229     GetBuiltinsSetFunction().GetTaggedValue().Dump(os);
2230     os << " - BuiltinsMapFunction: ";
2231     GetBuiltinsMapFunction().GetTaggedValue().Dump(os);
2232     os << " - BuiltinsWeakSetFunction: ";
2233     GetBuiltinsWeakSetFunction().GetTaggedValue().Dump(os);
2234     os << " - BuiltinsWeakMapFunction: ";
2235     GetBuiltinsWeakMapFunction().GetTaggedValue().Dump(os);
2236     os << " - BuiltinsWeakRefFunction: ";
2237     GetBuiltinsWeakRefFunction().GetTaggedValue().Dump(os);
2238     os << " - BuiltinsFinalizationRegistryFunction: ";
2239     GetBuiltinsFinalizationRegistryFunction().GetTaggedValue().Dump(os);
2240     os << " - MathFunction: ";
2241     GetMathFunction().GetTaggedValue().Dump(os);
2242     os << " - AtomicsFunction: ";
2243     GetAtomicsFunction().GetTaggedValue().Dump(os);
2244     os << " - JsonFunction: ";
2245     GetJsonFunction().GetTaggedValue().Dump(os);
2246     os << " - StringFunction: ";
2247     GetStringFunction().GetTaggedValue().Dump(os);
2248     os << " - ProxyFunction: ";
2249     GetProxyFunction().GetTaggedValue().Dump(os);
2250     os << " - ReflectFunction: ";
2251     GetReflectFunction().GetTaggedValue().Dump(os);
2252     os << " - AsyncFunction: ";
2253     GetAsyncFunction().GetTaggedValue().Dump(os);
2254     os << " - AsyncFunctionPrototype: ";
2255     GetAsyncFunctionPrototype().GetTaggedValue().Dump(os);
2256     os << " - JSGlobalObject: ";
2257     GetJSGlobalObject().GetTaggedValue().Dump(os);
2258     os << " - GlobalPatch: ";
2259     GetGlobalPatch().GetTaggedValue().Dump(os);
2260     os << " - EmptyArray: ";
2261     globalConst->GetEmptyArray().Dump(os);
2262     os << " - EmptyString ";
2263     globalConst->GetEmptyString().Dump(os);
2264     os << " - EmptyTaggedQueue: ";
2265     globalConst->GetEmptyTaggedQueue().Dump(os);
2266     os << " - PrototypeString: ";
2267     globalConst->GetPrototypeString().Dump(os);
2268     os << " - HasInstanceSymbol: ";
2269     GetHasInstanceSymbol().GetTaggedValue().Dump(os);
2270     os << " - IsConcatSpreadableSymbol: ";
2271     GetIsConcatSpreadableSymbol().GetTaggedValue().Dump(os);
2272     os << " - ToStringTagSymbol: ";
2273     GetToStringTagSymbol().GetTaggedValue().Dump(os);
2274     os << " - IteratorSymbol: ";
2275     GetIteratorSymbol().GetTaggedValue().Dump(os);
2276     os << " - AsyncIteratorSymbol: ";
2277     GetAsyncIteratorSymbol().GetTaggedValue().Dump(os);
2278     os << " - MatchSymbol: ";
2279     GetMatchSymbol().GetTaggedValue().Dump(os);
2280     os << " - MatchAllSymbol: ";
2281     GetMatchAllSymbol().GetTaggedValue().Dump(os);
2282     os << " - ReplaceSymbol: ";
2283     GetReplaceSymbol().GetTaggedValue().Dump(os);
2284     os << " - SearchSymbol: ";
2285     GetSearchSymbol().GetTaggedValue().Dump(os);
2286     os << " - SpeciesSymbol: ";
2287     GetSpeciesSymbol().GetTaggedValue().Dump(os);
2288     os << " - SplitSymbol: ";
2289     GetSplitSymbol().GetTaggedValue().Dump(os);
2290     os << " - ToPrimitiveSymbol: ";
2291     GetToPrimitiveSymbol().GetTaggedValue().Dump(os);
2292     os << " - UnscopablesSymbol: ";
2293     GetUnscopablesSymbol().GetTaggedValue().Dump(os);
2294     os << " - HoleySymbol: ";
2295     GetHoleySymbol().GetTaggedValue().Dump(os);
2296     os << " - AttachSymbol: ";
2297     GetAttachSymbol().GetTaggedValue().Dump(os);
2298     os << " - DetachSymbol: ";
2299     GetDetachSymbol().GetTaggedValue().Dump(os);
2300     os << " - ConstructorString: ";
2301     globalConst->GetConstructorString().Dump(os);
2302     os << " - IteratorPrototype: ";
2303     GetIteratorPrototype().GetTaggedValue().Dump(os);
2304     os << " - ForinIteratorPrototype: ";
2305     GetForinIteratorPrototype().GetTaggedValue().Dump(os);
2306     os << " - StringIterator: ";
2307     GetStringIterator().GetTaggedValue().Dump(os);
2308     os << " - MapIteratorPrototype: ";
2309     GetMapIteratorPrototype().GetTaggedValue().Dump(os);
2310     os << " - SetIteratorPrototype: ";
2311     GetSetIteratorPrototype().GetTaggedValue().Dump(os);
2312     os << " - RegExpIteratorPrototype: ";
2313     GetRegExpIteratorPrototype().GetTaggedValue().Dump(os);
2314     os << " - ArrayIteratorPrototype: ";
2315     GetArrayIteratorPrototype().GetTaggedValue().Dump(os);
2316     os << " - StringIteratorPrototype: ";
2317     GetStringIteratorPrototype().GetTaggedValue().Dump(os);
2318     os << " - LengthString: ";
2319     globalConst->GetLengthString().Dump(os);
2320     os << " - ValueString: ";
2321     globalConst->GetValueString().Dump(os);
2322     os << " - WritableString: ";
2323     globalConst->GetWritableString().Dump(os);
2324     os << " - GetString: ";
2325     globalConst->GetGetString().Dump(os);
2326     os << " - SetString: ";
2327     globalConst->GetSetString().Dump(os);
2328     os << " - EnumerableString: ";
2329     globalConst->GetEnumerableString().Dump(os);
2330     os << " - ConfigurableString: ";
2331     globalConst->GetConfigurableString().Dump(os);
2332     os << " - NameString: ";
2333     globalConst->GetNameString().Dump(os);
2334     os << " - ValueOfString: ";
2335     globalConst->GetValueOfString().Dump(os);
2336     os << " - ToStringString: ";
2337     globalConst->GetToStringString().Dump(os);
2338     os << " - ToLocaleStringString: ";
2339     globalConst->GetToLocaleStringString().Dump(os);
2340     os << " - UndefinedString: ";
2341     globalConst->GetUndefinedString().Dump(os);
2342     os << " - NullString: ";
2343     globalConst->GetNullString().Dump(os);
2344     os << " - TrueString: ";
2345     globalConst->GetTrueString().Dump(os);
2346     os << " - FalseString: ";
2347     globalConst->GetFalseString().Dump(os);
2348     os << " - RegisterSymbols: ";
2349     GetRegisterSymbols().GetTaggedValue().Dump(os);
2350     os << " - ThrowTypeError: ";
2351     GetThrowTypeError().GetTaggedValue().Dump(os);
2352     os << " - GetPrototypeOfString: ";
2353     globalConst->GetGetPrototypeOfString().Dump(os);
2354     os << " - SetPrototypeOfString: ";
2355     globalConst->GetSetPrototypeOfString().Dump(os);
2356     os << " - IsExtensibleString: ";
2357     globalConst->GetIsExtensibleString().Dump(os);
2358     os << " - PreventExtensionsString: ";
2359     globalConst->GetPreventExtensionsString().Dump(os);
2360     os << " - GetOwnPropertyDescriptorString: ";
2361     globalConst->GetGetOwnPropertyDescriptorString().Dump(os);
2362     os << " - DefinePropertyString: ";
2363     globalConst->GetDefinePropertyString().Dump(os);
2364     os << " - HasString: ";
2365     globalConst->GetHasString().Dump(os);
2366     os << " - DeletePropertyString: ";
2367     globalConst->GetDeletePropertyString().Dump(os);
2368     os << " - EnumerateString: ";
2369     globalConst->GetEnumerateString().Dump(os);
2370     os << " - OwnKeysString: ";
2371     globalConst->GetOwnKeysString().Dump(os);
2372     os << " - ApplyString: ";
2373     globalConst->GetApplyString().Dump(os);
2374     os << " - ProxyString: ";
2375     globalConst->GetProxyString().Dump(os);
2376     os << " - RevokeString: ";
2377     globalConst->GetRevokeString().Dump(os);
2378     os << " - ProxyConstructString: ";
2379     globalConst->GetProxyConstructString().Dump(os);
2380     os << " - ProxyCallString: ";
2381     globalConst->GetProxyCallString().Dump(os);
2382     os << " - DoneString: ";
2383     globalConst->GetDoneString().Dump(os);
2384     os << " - NegativeZeroString: ";
2385     globalConst->GetNegativeZeroString().Dump(os);
2386     os << " - NextString: ";
2387     globalConst->GetNextString().Dump(os);
2388     os << " - PromiseThenString: ";
2389     globalConst->GetPromiseThenString().Dump(os);
2390     os << " - PromiseFunction: ";
2391     GetPromiseFunction().GetTaggedValue().Dump(os);
2392     os << " - PromiseReactionJob: ";
2393     GetPromiseReactionJob().GetTaggedValue().Dump(os);
2394     os << " - PromiseResolveThenableJob: ";
2395     GetPromiseResolveThenableJob().GetTaggedValue().Dump(os);
2396     os << " - DynamicImportJob: ";
2397     GetDynamicImportJob().GetTaggedValue().Dump(os);
2398     os << " - ScriptJobString: ";
2399     globalConst->GetScriptJobString().Dump(os);
2400     os << " - PromiseString: ";
2401     globalConst->GetPromiseString().Dump(os);
2402     os << " - IdentityString: ";
2403     globalConst->GetIdentityString().Dump(os);
2404     os << " - AsyncFunctionString: ";
2405     globalConst->GetAsyncFunctionString().Dump(os);
2406     os << " - ThrowerString: ";
2407     globalConst->GetThrowerString().Dump(os);
2408     os << " - Undefined: ";
2409     globalConst->GetUndefined().Dump(os);
2410 }
2411 
Dump(std::ostream & os) const2412 void JSDataView::Dump(std::ostream &os) const
2413 {
2414     os << " - data-view: ";
2415     GetDataView().Dump(os);
2416     os << " - buffer: ";
2417     GetViewedArrayBuffer().Dump(os);
2418     os << "- byte-length: " << GetByteLength();
2419     os << "\n - byte-offset: " << GetByteOffset();
2420 }
2421 
Dump(std::ostream & os) const2422 void JSArrayBuffer::Dump(std::ostream &os) const
2423 {
2424     os << " - byte-length: " << GetArrayBufferByteLength();
2425     os << " - buffer-data: ";
2426     GetArrayBufferData().Dump(os);
2427     os << " - Shared: " << GetShared();
2428 }
2429 
Dump(std::ostream & os) const2430 void PromiseReaction::Dump(std::ostream &os) const
2431 {
2432     os << " - promise-capability: ";
2433     GetPromiseCapability().Dump(os);
2434     os << " - type: " << static_cast<int>(GetType());
2435     os << " - handler: ";
2436     GetHandler().Dump(os);
2437 }
2438 
Dump(std::ostream & os) const2439 void PromiseCapability::Dump(std::ostream &os) const
2440 {
2441     os << " - promise: ";
2442     GetPromise().Dump(os);
2443     os << " - resolve: ";
2444     GetResolve().Dump(os);
2445     os << " - reject: ";
2446     GetReject().Dump(os);
2447 }
2448 
Dump(std::ostream & os) const2449 void PromiseIteratorRecord::Dump(std::ostream &os) const
2450 {
2451     os << " - iterator: ";
2452     GetIterator().Dump(os);
2453     os << " - done: " << GetDone();
2454 }
2455 
Dump(std::ostream & os) const2456 void PromiseRecord::Dump(std::ostream &os) const
2457 {
2458     os << " - value: ";
2459     GetValue().Dump(os);
2460 }
2461 
Dump(std::ostream & os) const2462 void ResolvingFunctionsRecord::Dump(std::ostream &os) const
2463 {
2464     os << " - resolve-function: ";
2465     GetResolveFunction().Dump(os);
2466     os << " - reject-function: ";
2467     GetRejectFunction().Dump(os);
2468 }
2469 
Dump(std::ostream & os) const2470 void AsyncGeneratorRequest::Dump(std::ostream &os) const
2471 {
2472     os << " - completion: ";
2473     GetCompletion().Dump(os);
2474     os << " - capability: ";
2475     GetCapability().Dump(os);
2476 }
2477 
Dump(std::ostream & os) const2478 void AsyncIteratorRecord::Dump(std::ostream &os) const
2479 {
2480     os << " - completion: ";
2481     GetIterator().Dump(os);
2482     os << " - nextmethod: ";
2483     GetNextMethod().Dump(os);
2484     os << " - done: " << GetDone();
2485 }
2486 
Dump(std::ostream & os) const2487 void JSAsyncFromSyncIterator::Dump(std::ostream &os) const
2488 {
2489     os << " - sync-iterator-record: ";
2490     GetSyncIteratorRecord().Dump(os);
2491     JSObject::Dump(os);
2492 }
2493 
Dump(std::ostream & os) const2494 void JSAsyncFromSyncIterUnwarpFunction::Dump(std::ostream &os) const
2495 {
2496     os << " - done: " ;
2497     GetDone().Dump(os);
2498     JSObject::Dump(os);
2499 }
2500 
Dump(std::ostream & os) const2501 void JSPromise::Dump(std::ostream &os) const
2502 {
2503     os << " - promise-state: " << static_cast<int>(GetPromiseState());
2504     os << "\n - promise-result: ";
2505     GetPromiseResult().Dump(os);
2506     os << " - promise-fulfill-reactions: ";
2507     GetPromiseFulfillReactions().Dump(os);
2508     os << " - promise-reject-reactions: ";
2509     GetPromiseRejectReactions().Dump(os);
2510     os << " - promise-is-handled: " << GetPromiseIsHandled();
2511     JSObject::Dump(os);
2512 }
2513 
Dump(std::ostream & os) const2514 void JSPromiseReactionsFunction::Dump(std::ostream &os) const
2515 {
2516     os << " - promise: ";
2517     GetPromise().Dump(os);
2518     os << " - already-resolved: ";
2519     GetAlreadyResolved().Dump(os);
2520     JSObject::Dump(os);
2521 }
2522 
Dump(std::ostream & os) const2523 void JSPromiseExecutorFunction::Dump(std::ostream &os) const
2524 {
2525     os << " - capability: ";
2526     GetCapability().Dump(os);
2527     JSObject::Dump(os);
2528 }
2529 
Dump(std::ostream & os) const2530 void JSPromiseAllResolveElementFunction::Dump(std::ostream &os) const
2531 {
2532     os << " - index: ";
2533     GetIndex().Dump(os);
2534     os << " - values: ";
2535     GetValues().Dump(os);
2536     os << " - capability: ";
2537     GetCapabilities().Dump(os);
2538     os << " - remaining-elements: ";
2539     GetRemainingElements().Dump(os);
2540     os << " - already-called: ";
2541     GetAlreadyCalled().Dump(os);
2542     JSObject::Dump(os);
2543 }
2544 
Dump(std::ostream & os) const2545 void JSPromiseAnyRejectElementFunction::Dump(std::ostream &os) const
2546 {
2547     os << " - index: ";
2548     JSTaggedValue(GetIndex()).Dump(os);
2549     os << " - errors: ";
2550     GetErrors().Dump(os);
2551     os << " - capability: ";
2552     GetCapability().Dump(os);
2553     os << " - remaining-elements: ";
2554     GetRemainingElements().Dump(os);
2555     os << " - already-called: ";
2556     GetAlreadyCalled().Dump(os);
2557     JSObject::Dump(os);
2558 }
2559 
Dump(std::ostream & os) const2560 void JSPromiseAllSettledElementFunction::Dump(std::ostream &os) const
2561 {
2562     os << " - already-called: ";
2563     GetAlreadyCalled().Dump(os);
2564     os << " - index: ";
2565     JSTaggedValue(GetIndex()).Dump(os);
2566     os << " - values: ";
2567     GetValues().Dump(os);
2568     os << " - capability: ";
2569     GetCapability().Dump(os);
2570     os << " - remaining-elements: ";
2571     GetRemainingElements().Dump(os);
2572     JSObject::Dump(os);
2573 }
2574 
Dump(std::ostream & os) const2575 void JSPromiseFinallyFunction::Dump(std::ostream &os) const
2576 {
2577     os << " - constructor: ";
2578     GetConstructor().Dump(os);
2579     os << " - onFinally: ";
2580     GetOnFinally().Dump(os);
2581     JSObject::Dump(os);
2582 }
2583 
Dump(std::ostream & os) const2584 void JSPromiseValueThunkOrThrowerFunction::Dump(std::ostream &os) const
2585 {
2586     os << " - result: ";
2587     GetResult().Dump(os);
2588     JSObject::Dump(os);
2589 }
2590 
Dump(std::ostream & os) const2591 void JSAsyncGeneratorResNextRetProRstFtn::Dump(std::ostream &os) const
2592 {
2593     os << " - AsyncGeneratorObject";
2594     GetAsyncGeneratorObject().Dump(os);
2595     JSObject::Dump(os);
2596 }
2597 
Dump(std::ostream & os) const2598 void MicroJobQueue::Dump(std::ostream &os) const
2599 {
2600     os << " - promise-job-queue: ";
2601     GetPromiseJobQueue().Dump(os);
2602     os << " - script-job-queue: ";
2603     GetScriptJobQueue().Dump(os);
2604 }
2605 
Dump(std::ostream & os) const2606 void PendingJob::Dump(std::ostream &os) const
2607 {
2608     os << " - job: ";
2609     GetJob().Dump(os);
2610     os << "\n";
2611     os << " - arguments: ";
2612     GetArguments().Dump(os);
2613 #if defined(ENABLE_HITRACE)
2614     os << "\n";
2615     os << " - chainId: " << GetChainId();
2616     os << "\n";
2617     os << " - spanId: " << GetSpanId();
2618     os << "\n";
2619     os << " - parentSpanId: " << GetParentSpanId();
2620     os << "\n";
2621     os << " - flags: " << GetFlags();
2622     os << "\n";
2623 #endif
2624 }
2625 
Dump(std::ostream & os) const2626 void CompletionRecord::Dump(std::ostream &os) const
2627 {
2628     os << " - type: " << static_cast<int>(GetType());
2629     os << " - value: ";
2630     GetValue().Dump(os);
2631 }
2632 
Dump(std::ostream & os) const2633 void JSProxyRevocFunction::Dump(std::ostream &os) const
2634 {
2635     os << " - RevocableProxy: ";
2636     os << "\n";
2637     GetRevocableProxy().Dump(os);
2638     os << "\n";
2639 }
2640 
Dump(std::ostream & os) const2641 void JSAsyncFunction::Dump(std::ostream &os) const
2642 {
2643     JSFunction::Dump(os);
2644 }
2645 
Dump(std::ostream & os) const2646 void JSAsyncAwaitStatusFunction::Dump(std::ostream &os) const
2647 {
2648     os << " - AsyncContext: ";
2649     os << "\n";
2650     GetAsyncContext().Dump(os);
2651     os << "\n";
2652 }
2653 
Dump(std::ostream & os) const2654 void JSGeneratorFunction::Dump(std::ostream &os) const
2655 {
2656     JSFunction::Dump(os);
2657 }
2658 
Dump(std::ostream & os) const2659 void JSAsyncGeneratorFunction::Dump(std::ostream &os) const
2660 {
2661     JSFunction::Dump(os);
2662 }
2663 
Dump(std::ostream & os) const2664 void JSIntlBoundFunction::Dump(std::ostream &os) const
2665 {
2666     os << " - NumberFormat: ";
2667     GetNumberFormat().Dump(os);
2668     os << "\n";
2669     os << " - DateTimeFormat: ";
2670     GetDateTimeFormat().Dump(os);
2671     os << "\n";
2672     os << " - Collator: ";
2673     GetCollator().Dump(os);
2674     os << "\n";
2675     JSObject::Dump(os);
2676 }
2677 
Dump(std::ostream & os) const2678 void PropertyBox::Dump(std::ostream &os) const
2679 {
2680     os << " - Value: ";
2681     GetValue().Dump(os);
2682     os << "\n";
2683 }
2684 
Dump(std::ostream & os) const2685 void PrototypeHandler::Dump(std::ostream &os) const
2686 {
2687     os << " - HandlerInfo: ";
2688     GetHandlerInfo().Dump(os);
2689     os << "\n";
2690     os << " - ProtoCell: ";
2691     GetHandlerInfo().Dump(os);
2692     os << "\n";
2693     os << " - Holder: ";
2694     GetHandlerInfo().Dump(os);
2695     os << "\n";
2696 }
2697 
Dump(std::ostream & os) const2698 void TransitionHandler::Dump(std::ostream &os) const
2699 {
2700     os << " - HandlerInfo: ";
2701     GetHandlerInfo().Dump(os);
2702     os << "\n";
2703     os << " - TransitionHClass: ";
2704     GetTransitionHClass().Dump(os);
2705     os << "\n";
2706 }
2707 
Dump(std::ostream & os) const2708 void TransWithProtoHandler::Dump(std::ostream &os) const
2709 {
2710     os << " - HandlerInfo: ";
2711     GetHandlerInfo().Dump(os);
2712     os << "\n";
2713     os << " - TransitionHClass: ";
2714     GetTransitionHClass().Dump(os);
2715     os << "\n";
2716     os << " - Holder: ";
2717     GetHandlerInfo().Dump(os);
2718     os << "\n";
2719 }
2720 
Dump(std::ostream & os) const2721 void StoreTSHandler::Dump(std::ostream &os) const
2722 {
2723     os << " - HandlerInfo: ";
2724     GetHandlerInfo().Dump(os);
2725     os << "\n";
2726     os << " - ProtoCell: ";
2727     GetHandlerInfo().Dump(os);
2728     os << "\n";
2729     os << " - Holder: ";
2730     GetHandlerInfo().Dump(os);
2731     os << "\n";
2732 }
2733 
Dump(std::ostream & os) const2734 void JSRealm::Dump(std::ostream &os) const
2735 {
2736     os << " - Value: ";
2737     GetValue().Dump(os);
2738     os << "\n";
2739     os << " - GlobalEnv: ";
2740     GetGlobalEnv().Dump(os);
2741     os << "\n";
2742     JSObject::Dump(os);
2743 }
2744 
Dump(std::ostream & os) const2745 void JSIntl::Dump(std::ostream &os) const
2746 {
2747     os << " - FallbackSymbol: ";
2748     GetFallbackSymbol().Dump(os);
2749     os << "\n";
2750     JSObject::Dump(os);
2751 }
2752 
Dump(std::ostream & os) const2753 void JSLocale::Dump(std::ostream &os) const
2754 {
2755     os << " - IcuField: ";
2756     GetIcuField().Dump(os);
2757     os << "\n";
2758     JSObject::Dump(os);
2759 }
2760 
Dump(std::ostream & os) const2761 void JSDateTimeFormat::Dump(std::ostream &os) const
2762 {
2763     os << " - Locale: ";
2764     GetLocale().Dump(os);
2765     os << "\n";
2766     os << " - Calendar: ";
2767     GetCalendar().Dump(os);
2768     os << "\n";
2769     os << " - NumberingSystem: ";
2770     GetNumberingSystem().Dump(os);
2771     os << "\n";
2772     os << " - TimeZone: ";
2773     GetTimeZone().Dump(os);
2774     os << "\n";
2775     os << " - HourCycle: " << static_cast<int>(GetHourCycle());
2776     os << "\n";
2777     os << " - LocaleIcu: ";
2778     GetLocaleIcu().Dump(os);
2779     os << "\n";
2780     os << " - SimpleDateTimeFormatIcu: ";
2781     GetSimpleDateTimeFormatIcu().Dump(os);
2782     os << "\n";
2783     os << " - Iso8601: ";
2784     GetIso8601().Dump(os);
2785     os << "\n";
2786     os << " - DateStyle: " << static_cast<int>(GetDateStyle());
2787     os << "\n";
2788     os << " - TimeStyle: " << static_cast<int>(GetTimeStyle());
2789     os << "\n";
2790     os << " - BoundFormat: ";
2791     GetBoundFormat().Dump(os);
2792     os << "\n";
2793     JSObject::Dump(os);
2794 }
2795 
Dump(std::ostream & os) const2796 void JSRelativeTimeFormat::Dump(std::ostream &os) const
2797 {
2798     os << " - Locale: ";
2799     GetLocale().Dump(os);
2800     os << "\n";
2801     os << " - NumberingSystem: ";
2802     GetNumberingSystem().Dump(os);
2803     os << "\n";
2804     os << " - Style: " << static_cast<int>(GetStyle());
2805     os << "\n";
2806     os << " - Numeric: " << static_cast<int>(GetNumeric());
2807     os << "\n";
2808     os << " - IcuField: ";
2809     GetIcuField().Dump(os);
2810     os << "\n";
2811     JSObject::Dump(os);
2812 }
2813 
Dump(std::ostream & os) const2814 void JSNumberFormat::Dump(std::ostream &os) const
2815 {
2816     os << " - Locale: ";
2817     GetLocale().Dump(os);
2818     os << "\n" << " - NumberingSystem: ";
2819     GetNumberingSystem().Dump(os);
2820     os << "\n" << " - Style: " << static_cast<int>(GetStyle());
2821     os << "\n" << " - Currency: ";
2822     GetCurrency().Dump(os);
2823     os << "\n" << " - CurrencyDisplay: " << static_cast<int>(GetCurrencyDisplay());
2824     os << "\n" << " - CurrencySign: " << static_cast<int>(GetCurrencySign());
2825     os << "\n" << " - Unit: ";
2826     GetUnit().Dump(os);
2827     os << "\n" << " - UnitDisplay: " << static_cast<int>(GetUnitDisplay());
2828     os << "\n" << " - MinimumIntegerDigits: ";
2829     GetMinimumIntegerDigits().Dump(os);
2830     os << "\n" << " - MinimumFractionDigits: ";
2831     GetMinimumFractionDigits().Dump(os);
2832     os << "\n" << " - MaximumFractionDigits: ";
2833     GetMaximumFractionDigits().Dump(os);
2834     os << "\n" << " - MinimumSignificantDigits: ";
2835     GetMinimumSignificantDigits().Dump(os);
2836     os << "\n" << " - MaximumSignificantDigits: ";
2837     GetMaximumSignificantDigits().Dump(os);
2838     os << "\n" << " - UseGrouping: ";
2839     GetUseGrouping().Dump(os);
2840     os << "\n" << " - RoundingType: " << static_cast<int>(GetRoundingType());
2841     os << "\n" << " - Notation: " << static_cast<int>(GetNotation());
2842     os << "\n" << " - CompactDisplay: " << static_cast<int>(GetCompactDisplay());
2843     os << "\n" << " - SignDisplay: " << static_cast<int>(GetSignDisplay());
2844     os << "\n" << " - BoundFormat: ";
2845     GetBoundFormat().Dump(os);
2846     os << "\n" << " - IcuField: ";
2847     GetIcuField().Dump(os);
2848     os << "\n";
2849     JSObject::Dump(os);
2850 }
2851 
Dump(std::ostream & os) const2852 void JSCollator::Dump(std::ostream &os) const
2853 {
2854     os << " - IcuField: ";
2855     GetIcuField().Dump(os);
2856     os << "\n - Locale: ";
2857     GetLocale().Dump(os);
2858     os << "\n - Usage: " << static_cast<int>(GetUsage());
2859     os << "\n - Sensitivity: " << static_cast<int>(GetSensitivity());
2860     os << "\n - IgnorePunctuation: " << GetIgnorePunctuation();
2861     os << "\n - Collation: ";
2862     GetCollation().Dump(os);
2863     os << "\n - Numeric: " << GetNumeric();
2864     os << "\n - CaseFirst: " << static_cast<int>(GetCaseFirst());
2865     os << "\n - BoundCompare: ";
2866     GetBoundCompare().Dump(os);
2867     os << "\n";
2868     JSObject::Dump(os);
2869 }
2870 
Dump(std::ostream & os) const2871 void JSPluralRules::Dump(std::ostream &os) const
2872 {
2873     os << " - Locale: ";
2874     GetLocale().Dump(os);
2875     os << "\n";
2876     os << " - Type: " << static_cast<int>(GetType());
2877     os << "\n";
2878     os << " - MinimumIntegerDigits: ";
2879     GetMinimumIntegerDigits().Dump(os);
2880     os << "\n";
2881     os << " - MinimumFractionDigits: ";
2882     GetMinimumFractionDigits().Dump(os);
2883     os << "\n";
2884     os << " - MaximumFractionDigits: ";
2885     GetMaximumFractionDigits().Dump(os);
2886     os << "\n";
2887     os << " - MinimumSignificantDigits: ";
2888     GetMinimumSignificantDigits().Dump(os);
2889     os << "\n";
2890     os << " - MaximumSignificantDigits: ";
2891     GetMaximumSignificantDigits().Dump(os);
2892     os << "\n";
2893     os << " - RoundingType: " << static_cast<int>(GetRoundingType());
2894     os << "\n";
2895     os << " - IcuPR: ";
2896     GetIcuPR().Dump(os);
2897     os << "\n";
2898     os << " - IcuNF: ";
2899     GetIcuNF().Dump(os);
2900     os << "\n";
2901     JSObject::Dump(os);
2902 }
2903 
Dump(std::ostream & os) const2904 void JSDisplayNames::Dump(std::ostream &os) const
2905 {
2906     os << " - Locale: ";
2907     GetLocale().Dump(os);
2908     os << "\n";
2909     os << " - Type: "<< static_cast<int>(GetType());
2910     os << "\n";
2911     os << " - Style: "<< static_cast<int>(GetStyle());
2912     os << "\n";
2913     os << " - Fallback: "<< static_cast<int>(GetFallback());
2914     os << "\n";
2915     os << " - IcuLDN: ";
2916     GetIcuLDN().Dump(os);
2917     os << "\n";
2918     JSObject::Dump(os);
2919 }
2920 
Dump(std::ostream & os) const2921 void JSListFormat::Dump(std::ostream &os) const
2922 {
2923     os << " - Locale: ";
2924     GetLocale().Dump(os);
2925     os << "\n";
2926     os << " - Type: "<< static_cast<int>(GetType());
2927     os << "\n";
2928     os << " - Style: "<< static_cast<int>(GetStyle());
2929     os << "\n";
2930     os << " - IcuLF: ";
2931     GetIcuLF().Dump(os);
2932     os << "\n";
2933     JSObject::Dump(os);
2934 }
2935 
Dump(std::ostream & os) const2936 void JSGeneratorObject::Dump(std::ostream &os) const
2937 {
2938     os << " - GeneratorContext: ";
2939     GetGeneratorContext().Dump(os);
2940     os << "\n";
2941     os << " - ResumeResult: ";
2942     GetResumeResult().Dump(os);
2943     os << "\n";
2944     os << " - GeneratorState: " << static_cast<uint8_t>(GetGeneratorState());
2945     os << "\n";
2946     os << " - ResumeMode: " << static_cast<uint8_t>(GetResumeMode());
2947     os << "\n";
2948     JSObject::Dump(os);
2949 }
2950 
Dump(std::ostream & os) const2951 void JSAsyncGeneratorObject::Dump(std::ostream &os) const
2952 {
2953     os << " - GeneratorContext: ";
2954     GetGeneratorContext().Dump(os);
2955     os << "\n";
2956     os << " - AsyncGeneratorQueue: ";
2957     GetAsyncGeneratorQueue().Dump(os);
2958     os << "\n";
2959     os << " - GeneratorBrand: ";
2960     GetGeneratorBrand().Dump(os);
2961     os << "\n";
2962     os << " - ResumeResult: ";
2963     GetResumeResult().Dump(os);
2964     os << "\n";
2965     os << " - AsyncGeneratorState: " << static_cast<uint8_t>(GetAsyncGeneratorState());
2966     os << "\n";
2967     os << " - ResumeMode: " << static_cast<uint8_t>(GetResumeMode());
2968     os << "\n";
2969     JSObject::Dump(os);
2970 }
2971 
Dump(std::ostream & os) const2972 void JSAsyncFuncObject::Dump(std::ostream &os) const
2973 {
2974     os << " - Promise: ";
2975     GetPromise().Dump(os);
2976     os << "\n";
2977 }
2978 
Dump(std::ostream & os) const2979 void GeneratorContext::Dump(std::ostream &os) const
2980 {
2981     os << " - RegsArray: ";
2982     GetRegsArray().Dump(os);
2983     os << "\n";
2984     os << " - Method: ";
2985     GetMethod().Dump(os);
2986     os << "\n";
2987     os << " - This: ";
2988     GetThis().Dump(os);
2989     os << "\n";
2990     os << " - Acc: ";
2991     GetAcc().Dump(os);
2992     os << "\n";
2993     os << " - GeneratorObject: ";
2994     GetGeneratorObject().Dump(os);
2995     os << "\n";
2996     os << " - LexicalEnv: ";
2997     GetLexicalEnv().Dump(os);
2998     os << "\n";
2999     os << " - NRegs: " << GetNRegs();
3000     os << "\n";
3001     os << " - BCOffset: " << GetBCOffset();
3002     os << "\n";
3003 }
3004 
Dump(std::ostream & os) const3005 void ProtoChangeMarker::Dump(std::ostream &os) const
3006 {
3007     os << " - HasChanged: " << GetHasChanged() << "\n";
3008 }
3009 
Dump(std::ostream & os) const3010 void ProtoChangeDetails::Dump(std::ostream &os) const
3011 {
3012     os << " - ChangeListener: ";
3013     GetChangeListener().Dump(os);
3014     os << "\n";
3015     os << " - RegisterIndex: " << GetRegisterIndex();
3016     os << "\n";
3017 }
3018 
Dump(std::ostream & os) const3019 void MachineCode::Dump(std::ostream &os) const
3020 {
3021     os << " - InstructionSizeInBytes: " << GetInstructionSizeInBytes();
3022     os << "\n";
3023 }
3024 
Dump(std::ostream & os) const3025 void ClassInfoExtractor::Dump(std::ostream &os) const
3026 {
3027     os << " - NonStaticKeys: ";
3028     GetNonStaticKeys().Dump(os);
3029     os << "\n";
3030     os << " - NonStaticProperties: ";
3031     GetNonStaticProperties().Dump(os);
3032     os << "\n";
3033     os << " - NonStaticElements: ";
3034     GetNonStaticElements().Dump(os);
3035     os << "\n";
3036     os << " - StaticKeys: ";
3037     GetStaticKeys().Dump(os);
3038     os << "\n";
3039     os << " - StaticProperties: ";
3040     GetStaticProperties().Dump(os);
3041     os << "\n";
3042     os << " - StaticElements: ";
3043     GetStaticElements().Dump(os);
3044     os << "\n";
3045 }
3046 
Dump(std::ostream & os) const3047 void TSObjectType::Dump(std::ostream &os) const
3048 {
3049     os << " - TSObjectType globalTSTypeRef: ";
3050     GlobalTSTypeRef gt = GetGT();
3051     uint64_t globalTSTypeRef = gt.GetType();
3052     os << globalTSTypeRef;
3053     os << "\n";
3054     os << " - TSObjectType moduleId: ";
3055     uint32_t moduleId = gt.GetModuleId();
3056     os << moduleId;
3057     os << "\n";
3058     os << " - TSObjectType localTypeId: ";
3059     uint32_t localTypeId = gt.GetLocalId();
3060     os << localTypeId;
3061     os << "\n";
3062     os << "  - ObjLayoutInfo: ";
3063     DumpArrayClass(TaggedArray::Cast(GetObjLayoutInfo().GetTaggedObject()), os);
3064     os << "  - HClass: ";
3065     GetHClass().Dump(os);
3066 }
3067 
Dump(std::ostream & os) const3068 void TSClassType::Dump(std::ostream &os) const
3069 {
3070     os << " - Dump TSClassType - " << "\n";
3071     os << " - TSClassType globalTSTypeRef: ";
3072     GlobalTSTypeRef gt = GetGT();
3073     uint64_t globalTSTypeRef = gt.GetType();
3074     os << globalTSTypeRef;
3075     os << "\n";
3076     os << " - TSClassType moduleId: ";
3077     uint32_t moduleId = gt.GetModuleId();
3078     os << moduleId;
3079     os << "\n";
3080     os << " - TSClassType localTypeId: ";
3081     uint32_t localTypeId = gt.GetLocalId();
3082     os << localTypeId;
3083     os << "\n";
3084     os << " - ExtensionTypeGT: ";
3085     GlobalTSTypeRef extensionGT = GetExtensionGT();
3086     if (extensionGT.IsDefault()) {
3087         os << " (base class type) ";
3088     } else {
3089         os << extensionGT.GetType();
3090     }
3091     os << "\n";
3092 
3093     CString hasLinked = GetHasLinked() ? "true" : "false";
3094     os << " - HasLinked: " << hasLinked  << "\n";
3095 
3096     os << " - InstanceType: " << "\n";
3097     if (GetInstanceType().IsTSObjectType()) {
3098         TSObjectType *instanceType = TSObjectType::Cast(GetInstanceType().GetTaggedObject());
3099         instanceType->Dump(os);
3100         os << "\n";
3101     }
3102 
3103     os << " - ConstructorType: " << "\n";
3104     if (GetConstructorType().IsTSObjectType()) {
3105         TSObjectType *constructorType = TSObjectType::Cast(GetConstructorType().GetTaggedObject());
3106         constructorType->Dump(os);
3107         os << "\n";
3108     }
3109 
3110     os << " - PrototypeType: " << "\n";
3111     if (GetPrototypeType().IsTSObjectType()) {
3112         TSObjectType *prototypeType = TSObjectType::Cast(GetPrototypeType().GetTaggedObject());
3113         prototypeType->Dump(os);
3114         os << "\n";
3115     }
3116 }
3117 
Dump(std::ostream & os) const3118 void TSInterfaceType::Dump(std::ostream &os) const
3119 {
3120     os << " - Dump Interface Type - " << "\n";
3121     os << " - TSInterfaceType globalTSTypeRef: ";
3122     GlobalTSTypeRef gt = GetGT();
3123     uint64_t globalTSTypeRef = gt.GetType();
3124     os << globalTSTypeRef;
3125     os << "\n";
3126     os << " - TSInterfaceType moduleId: ";
3127     uint32_t moduleId = gt.GetModuleId();
3128     os << moduleId;
3129     os << "\n";
3130     os << " - TSInterfaceType localTypeId: ";
3131     uint32_t localTypeId = gt.GetLocalId();
3132     os << localTypeId;
3133     os << "\n";
3134     os << " - Extends TypeId: " << "\n";
3135     if (TaggedArray::Cast(GetExtends().GetTaggedObject())->GetLength() == 0) {
3136         os << " (base interface type) "<< "\n";
3137     }
3138     DumpArrayClass(TaggedArray::Cast(GetExtends().GetTaggedObject()), os);
3139 
3140     os << " - Fields: " << "\n";
3141     if (GetFields().IsTSObjectType()) {
3142         TSObjectType *fieldsType = TSObjectType::Cast(GetFields().GetTaggedObject());
3143         fieldsType->Dump(os);
3144         os << "\n";
3145     }
3146 }
3147 
Dump(std::ostream & os) const3148 void TSClassInstanceType::Dump(std::ostream &os) const
3149 {
3150     os << " - Dump ClassInstance Type - " << "\n";
3151     os << " - TSClassInstanceType globalTSTypeRef: ";
3152     GlobalTSTypeRef gt = GetGT();
3153     uint64_t globalTSTypeRef = gt.GetType();
3154     os << globalTSTypeRef;
3155     os << "\n";
3156     os << " - TSClassInstanceType moduleId: ";
3157     uint32_t moduleId = gt.GetModuleId();
3158     os << moduleId;
3159     os << "\n";
3160     os << " - TSClassInstanceType localTypeId: ";
3161     uint32_t localTypeId = gt.GetLocalId();
3162     os << localTypeId;
3163     os << "\n";
3164 
3165     os << " - createClassType GT: ";
3166     GlobalTSTypeRef createClassTypeGT = GetClassGT();
3167     os << createClassTypeGT.GetType();
3168     os << "\n";
3169 }
3170 
Dump(std::ostream & os) const3171 void TSUnionType::Dump(std::ostream &os) const
3172 {
3173     os << " - Dump UnionType Type - " << "\n";
3174     os << " - TSUnionType globalTSTypeRef: ";
3175     GlobalTSTypeRef gt = GetGT();
3176     uint64_t globalTSTypeRef = gt.GetType();
3177     os << globalTSTypeRef;
3178     os << "\n";
3179     os << " - TSUnionType moduleId: ";
3180     uint32_t moduleId = gt.GetModuleId();
3181     os << moduleId;
3182     os << "\n";
3183     os << " - TSUnionType localTypeId: ";
3184     uint32_t localTypeId = gt.GetLocalId();
3185     os << localTypeId;
3186     os << "\n";
3187     os << " - TSUnionType TypeId: " << "\n";
3188     DumpArrayClass(TaggedArray::Cast(GetComponents().GetTaggedObject()), os);
3189 }
3190 
Dump(std::ostream & os) const3191 void TSFunctionType::Dump(std::ostream &os) const
3192 {
3193     os << " - Dump TSFunctionType - " << "\n";
3194     os << " - TSFunctionType globalTSTypeRef: ";
3195     GlobalTSTypeRef gt = GetGT();
3196     uint64_t globalTSTypeRef = gt.GetType();
3197     os << globalTSTypeRef;
3198     os << "\n";
3199     os << " - TSFunctionType moduleId: ";
3200     uint32_t moduleId = gt.GetModuleId();
3201     os << moduleId;
3202     os << "\n";
3203     os << " - TSFunctionType localTypeId: ";
3204     uint32_t localTypeId = gt.GetLocalId();
3205     os << localTypeId;
3206     os << "\n";
3207     os << " - TSFunctionType Name: ";
3208     JSTaggedValue name = GetName();
3209     if (name.IsString()) {
3210         os << ConvertToString(EcmaString::Cast(name.GetTaggedObject()));
3211     }
3212     os << "\n";
3213     os << " - TSFunctionType ParameterTypeIds: " << "\n";
3214     DumpArrayClass(TaggedArray::Cast(GetParameterTypes().GetTaggedObject()), os);
3215     os << " - TSFunctionType ReturnType: " << GetReturnGT().GetType() << "\n";
3216     os << " - TSFunctionType ThisType: " << GetThisGT().GetType() << "\n";
3217     TSFunctionType::Visibility visibility = GetVisibility();
3218     switch (visibility) {
3219         case TSFunctionType::Visibility::PUBLIC:
3220             os << " - Visibility: public";
3221             break;
3222         case TSFunctionType::Visibility::PRIVATE:
3223             os << " - Visibility: private";
3224             break;
3225         case TSFunctionType::Visibility::PROTECTED:
3226             os << " - Visibility: protected";
3227             break;
3228     }
3229     os << " | IsStatic: " << std::boolalpha << GetStatic();
3230     os << " | IsAsync: " << std::boolalpha << GetAsync();
3231     os << " | IsGenerator: " << std::boolalpha << GetGenerator();
3232     os << " | IsGetterSetter: " << std::boolalpha << GetIsGetterSetter();
3233     os << "\n";
3234 }
3235 
Dump(std::ostream & os) const3236 void TSArrayType::Dump(std::ostream &os) const
3237 {
3238     os << " - Dump TSArrayType - " << "\n";
3239     os << " - TSArrayType globalTSTypeRef: ";
3240     GlobalTSTypeRef gt = GetGT();
3241     os << gt.GetType();
3242     os << "\n";
3243     os << " - TSArrayType ElementGT: ";
3244     os <<  GetElementGT().GetType();
3245     os << "\n";
3246 }
3247 
Dump(std::ostream & os) const3248 void TSIteratorInstanceType::Dump(std::ostream &os) const
3249 {
3250     os << " - Dump IteratorInstance Type - " << "\n";
3251     os << " - TSIteratorInstanceType globalTSTypeRef: ";
3252     GlobalTSTypeRef gt = GetGT();
3253     uint64_t globalTSTypeRef = gt.GetType();
3254     os << globalTSTypeRef;
3255     os << "\n";
3256     os << " - TSIteratorInstanceType moduleId: ";
3257     uint32_t moduleId = gt.GetModuleId();
3258     os << moduleId;
3259     os << "\n";
3260     os << " - TSIteratorInstanceType localTypeId: ";
3261     uint32_t localTypeId = gt.GetLocalId();
3262     os << localTypeId;
3263     os << "\n";
3264 
3265     os << " - TSIteratorInstanceType KindGT: ";
3266     os << GetKindGT().GetType();
3267     os << "\n";
3268 
3269     os << " - TSIteratorInstanceType ElementGT: ";
3270     os << GetElementGT().GetType();
3271     os << "\n";
3272 }
3273 
Dump(std::ostream & os) const3274 void SourceTextModule::Dump(std::ostream &os) const
3275 {
3276     os << " - Environment: ";
3277     GetEnvironment().Dump(os);
3278     os << "\n";
3279     os << " - Namespace: ";
3280     GetNamespace().Dump(os);
3281     os << "\n";
3282     os << " - EcmaModuleFilename: ";
3283     GetEcmaModuleFilename().Dump(os);
3284     os << "\n";
3285     os << " - EcmaModuleRecordName: ";
3286     GetEcmaModuleRecordName().Dump(os);
3287     os << "\n";
3288     os << " - RequestedModules: ";
3289     GetRequestedModules().Dump(os);
3290     os << "\n";
3291     os << " - ImportEntries: ";
3292     GetImportEntries().Dump(os);
3293     os << "\n";
3294     os << " - LocalExportEntries: ";
3295     GetLocalExportEntries().Dump(os);
3296     os << "\n";
3297     os << " - IndirectExportEntries: ";
3298     GetIndirectExportEntries().Dump(os);
3299     os << "\n";
3300     os << " - StarExportEntries: ";
3301     GetStarExportEntries().Dump(os);
3302     os << "\n";
3303     os << " - Status: ";
3304     os << static_cast<int32_t>(GetStatus());
3305     os << "\n";
3306     os << " - EvaluationError: ";
3307     os << GetEvaluationError();
3308     os << "\n";
3309     os << " - DFSIndex: ";
3310     os << GetDFSIndex();
3311     os << "\n";
3312     os << " - DFSAncestorIndex: ";
3313     os << GetDFSAncestorIndex();
3314     os << "\n";
3315     os << " - NameDictionary: ";
3316     GetNameDictionary().Dump(os);
3317     os << "\n";
3318 }
3319 
Dump(std::ostream & os) const3320 void ImportEntry::Dump(std::ostream &os) const
3321 {
3322     os << " - ModuleRequest: ";
3323     GetModuleRequest().Dump(os);
3324     os << "\n";
3325     os << " - ImportName: ";
3326     GetImportName().Dump(os);
3327     os << "\n";
3328     os << " - LocalName: ";
3329     GetLocalName().Dump(os);
3330     os << "\n";
3331 }
3332 
Dump(std::ostream & os) const3333 void LocalExportEntry::Dump(std::ostream &os) const
3334 {
3335     os << " - ExportName: ";
3336     GetExportName().Dump(os);
3337     os << "\n";
3338     os << " - LocalName: ";
3339     GetLocalName().Dump(os);
3340     os << "\n";
3341 }
3342 
Dump(std::ostream & os) const3343 void IndirectExportEntry::Dump(std::ostream &os) const
3344 {
3345     os << " - ExportName: ";
3346     GetExportName().Dump(os);
3347     os << "\n";
3348     os << " - ModuleRequest: ";
3349     GetModuleRequest().Dump(os);
3350     os << "\n";
3351     os << " - ImportName: ";
3352     GetImportName().Dump(os);
3353     os << "\n";
3354 }
3355 
Dump(std::ostream & os) const3356 void StarExportEntry::Dump(std::ostream &os) const
3357 {
3358     os << " - ModuleRequest: ";
3359     GetModuleRequest().Dump(os);
3360     os << "\n";
3361 }
3362 
Dump(std::ostream & os) const3363 void ResolvedBinding::Dump(std::ostream &os) const
3364 {
3365     os << " - Module: ";
3366     GetModule().Dump(os);
3367     os << "\n";
3368     os << " - BindingName: ";
3369     GetBindingName().Dump(os);
3370     os << "\n";
3371 }
3372 
Dump(std::ostream & os) const3373 void ResolvedIndexBinding::Dump(std::ostream &os) const
3374 {
3375     os << " - Module: ";
3376     GetModule().Dump(os);
3377     os << "\n";
3378     os << " - Index: ";
3379     GetIndex();
3380     os << "\n";
3381 }
3382 
Dump(std::ostream & os) const3383 void ModuleNamespace::Dump(std::ostream &os) const
3384 {
3385     os << " - Exports: ";
3386     GetExports().Dump(os);
3387     os << "\n";
3388 }
3389 
Dump(std::ostream & os) const3390 void CjsModule::Dump(std::ostream &os) const
3391 {
3392     os << " - current module path: ";
3393     GetPath().Dump(os);
3394     os << "\n";
3395     os << " - current module filename: ";
3396     GetFilename().Dump(os);
3397     os << "\n";
3398 }
3399 
Dump(std::ostream & os) const3400 void CjsRequire::Dump(std::ostream &os) const
3401 {
3402     os << " --- CjsRequire is JSFunction: ";
3403     os << "\n";
3404 }
3405 
Dump(std::ostream & os) const3406 void CjsExports::Dump(std::ostream &os) const
3407 {
3408     DISALLOW_GARBAGE_COLLECTION;
3409     JSHClass *jshclass = GetJSHClass();
3410     os << " - hclass: " << std::hex << jshclass << "\n";
3411     os << " - prototype: ";
3412     jshclass->GetPrototype().DumpTaggedValue(os);
3413     os << "\n";
3414 
3415     TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
3416     os << " - properties: " << std::hex << properties;
3417 
3418     if (!properties->IsDictionaryMode()) {
3419         JSTaggedValue attrs = jshclass->GetLayout();
3420         if (attrs.IsNull()) {
3421             return;
3422         }
3423 
3424         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
3425         int propNumber = static_cast<int>(jshclass->NumberOfProps());
3426         os << " <LayoutInfo[" << std::dec << propNumber << "]>\n";
3427         for (int i = 0; i < propNumber; i++) {
3428             JSTaggedValue key = layoutInfo->GetKey(i);
3429             PropertyAttributes attr = layoutInfo->GetAttr(i);
3430             ASSERT(i == static_cast<int>(attr.GetOffset()));
3431             os << "     " << std::right << std::setw(DUMP_PROPERTY_OFFSET);
3432             DumpPropertyKey(key, os);
3433             os << ": (";
3434             JSTaggedValue val;
3435             if (attr.IsInlinedProps()) {
3436                 val = GetPropertyInlinedProps(i);
3437             } else {
3438                 val = properties->Get(i - static_cast<int>(jshclass->GetInlinedProperties()));
3439             }
3440             val.DumpTaggedValue(os);
3441             os << ") ";
3442             DumpAttr(attr, true, os);
3443             os << "\n";
3444         }
3445     } else {
3446         NameDictionary *dict = NameDictionary::Cast(properties);
3447         os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
3448         dict->Dump(os);
3449     }
3450 }
3451 
Dump(std::ostream & os) const3452 void JSFunctionBase::Dump(std::ostream &os) const
3453 {
3454     os << " - Method: ";
3455     GetMethod().Dump(os);
3456     os << "\n";
3457 }
3458 
Dump(std::ostream & os) const3459 void Method::Dump(std::ostream &os) const
3460 {
3461     os << " - MethodName: ";
3462     os << GetMethodName();
3463     os << "\n";
3464     os << " - ConstantPool: ";
3465     GetConstantPool().Dump(os);
3466     os << "\n";
3467     os << " - ProfileTypeInfo: ";
3468     GetProfileTypeInfo().Dump(os);
3469     os << "\n";
3470     os << " - FunctionKind: " << static_cast<int>(GetFunctionKind());
3471     os << "\n";
3472     os << " - CodeEntryOrLiteral: " << std::hex << GetCodeEntryOrLiteral() << "\n";
3473     os << "\n";
3474 }
3475 
Dump(std::ostream & os) const3476 void ClassLiteral::Dump(std::ostream &os) const
3477 {
3478     os << " - ClassLiteral: ";
3479     os << "\n";
3480     os << " - IsAOTUsed: " << std::boolalpha << GetIsAOTUsed();
3481     os << "\n";
3482     os << " - Array: ";
3483     GetArray().Dump(os);
3484     os << "\n";
3485 }
3486 
3487 // ########################################################################################
3488 // Dump for Snapshot
3489 // ########################################################################################
DumpArrayClass(const TaggedArray * arr,std::vector<std::pair<CString,JSTaggedValue>> & vec)3490 static void DumpArrayClass(const TaggedArray *arr,
3491                            std::vector<std::pair<CString, JSTaggedValue>> &vec)
3492 {
3493     DISALLOW_GARBAGE_COLLECTION;
3494     uint32_t len = arr->GetLength();
3495     vec.reserve(vec.size() + len);
3496     for (uint32_t i = 0; i < len; i++) {
3497         JSTaggedValue val(arr->Get(i));
3498         CString str = ToCString(i);
3499         vec.emplace_back(str, val);
3500     }
3501 }
3502 
DumpConstantPoolClass(const ConstantPool * arr,std::vector<std::pair<CString,JSTaggedValue>> & vec)3503 static void DumpConstantPoolClass(const ConstantPool *arr,
3504                                   std::vector<std::pair<CString, JSTaggedValue>> &vec)
3505 {
3506     DISALLOW_GARBAGE_COLLECTION;
3507     uint32_t len = arr->GetCacheLength();
3508     vec.reserve(vec.size() + len);
3509     for (uint32_t i = 0; i < len; i++) {
3510         JSTaggedValue val(arr->GetObjectFromCache(i));
3511         CString str = ToCString(i);
3512         vec.emplace_back(str, val);
3513     }
3514 }
3515 
DumpStringClass(const EcmaString * str,std::vector<std::pair<CString,JSTaggedValue>> & vec)3516 static void DumpStringClass(const EcmaString *str,
3517                             std::vector<std::pair<CString, JSTaggedValue>> &vec)
3518 {
3519     vec.emplace_back("string", JSTaggedValue(str));
3520 }
3521 
DumpClass(TaggedObject * obj,std::vector<std::pair<CString,JSTaggedValue>> & vec)3522 static void DumpClass(TaggedObject *obj,
3523                          std::vector<std::pair<CString, JSTaggedValue>> &vec)
3524 {
3525     JSHClass *jshclass = obj->GetClass();
3526     vec.emplace_back("__proto__", jshclass->GetPrototype());
3527 }
3528 
DumpObject(TaggedObject * obj,std::vector<std::pair<CString,JSTaggedValue>> & vec,bool isVmMode)3529 static void DumpObject(TaggedObject *obj,
3530                        std::vector<std::pair<CString, JSTaggedValue>> &vec, bool isVmMode)
3531 {
3532     DISALLOW_GARBAGE_COLLECTION;
3533     auto jsHclass = obj->GetClass();
3534     JSType type = jsHclass->GetObjectType();
3535 
3536     switch (type) {
3537         case JSType::HCLASS:
3538             DumpClass(obj, vec);
3539             return;
3540         case JSType::TAGGED_ARRAY:
3541         case JSType::TAGGED_DICTIONARY:
3542         case JSType::LEXICAL_ENV:
3543         case JSType::COW_TAGGED_ARRAY:
3544             DumpArrayClass(TaggedArray::Cast(obj), vec);
3545             return;
3546         case JSType::CONSTANT_POOL:
3547             DumpConstantPoolClass(ConstantPool::Cast(obj), vec);
3548             return;
3549         case JSType::STRING:
3550             DumpStringClass(EcmaString::Cast(obj), vec);
3551             return;
3552         case JSType::JS_NATIVE_POINTER:
3553             return;
3554         case JSType::JS_OBJECT:
3555         case JSType::JS_ERROR:
3556         case JSType::JS_EVAL_ERROR:
3557         case JSType::JS_RANGE_ERROR:
3558         case JSType::JS_TYPE_ERROR:
3559         case JSType::JS_AGGREGATE_ERROR:
3560         case JSType::JS_REFERENCE_ERROR:
3561         case JSType::JS_URI_ERROR:
3562         case JSType::JS_SYNTAX_ERROR:
3563         case JSType::JS_OOM_ERROR:
3564         case JSType::JS_ARGUMENTS:
3565         case JSType::JS_GLOBAL_OBJECT:
3566             JSObject::Cast(obj)->DumpForSnapshot(vec);
3567             return;
3568         case JSType::JS_FUNCTION_BASE:
3569         case JSType::JS_FUNCTION:
3570             JSFunction::Cast(obj)->DumpForSnapshot(vec);
3571             return;
3572         case JSType::JS_BOUND_FUNCTION:
3573             JSBoundFunction::Cast(obj)->DumpForSnapshot(vec);
3574             return;
3575         case JSType::JS_SET:
3576             JSSet::Cast(obj)->DumpForSnapshot(vec);
3577             return;
3578         case JSType::JS_MAP:
3579             JSMap::Cast(obj)->DumpForSnapshot(vec);
3580             return;
3581         case JSType::JS_WEAK_SET:
3582             JSWeakSet::Cast(obj)->DumpForSnapshot(vec);
3583             return;
3584         case JSType::JS_WEAK_MAP:
3585             JSWeakMap::Cast(obj)->DumpForSnapshot(vec);
3586             return;
3587         case JSType::JS_WEAK_REF:
3588             JSWeakRef::Cast(obj)->DumpForSnapshot(vec);
3589             return;
3590         case JSType::JS_FINALIZATION_REGISTRY:
3591             JSFinalizationRegistry::Cast(obj)->DumpForSnapshot(vec);
3592             return;
3593         case JSType::CELL_RECORD:
3594             CellRecord::Cast(obj)->DumpForSnapshot(vec);
3595             return;
3596         case JSType::JS_REG_EXP:
3597             JSRegExp::Cast(obj)->DumpForSnapshot(vec);
3598             return;
3599         case JSType::JS_DATE:
3600             JSDate::Cast(obj)->DumpForSnapshot(vec);
3601             return;
3602         case JSType::JS_ARRAY:
3603             JSArray::Cast(obj)->DumpForSnapshot(vec);
3604             return;
3605         case JSType::JS_TYPED_ARRAY:
3606         case JSType::JS_INT8_ARRAY:
3607         case JSType::JS_UINT8_ARRAY:
3608         case JSType::JS_UINT8_CLAMPED_ARRAY:
3609         case JSType::JS_INT16_ARRAY:
3610         case JSType::JS_UINT16_ARRAY:
3611         case JSType::JS_INT32_ARRAY:
3612         case JSType::JS_UINT32_ARRAY:
3613         case JSType::JS_FLOAT32_ARRAY:
3614         case JSType::JS_FLOAT64_ARRAY:
3615         case JSType::JS_BIGINT64_ARRAY:
3616         case JSType::JS_BIGUINT64_ARRAY:
3617             JSTypedArray::Cast(obj)->DumpForSnapshot(vec);
3618             return;
3619         case JSType::BIGINT:
3620             BigInt::Cast(obj)->DumpForSnapshot(vec);
3621             return;
3622         case JSType::BYTE_ARRAY:
3623             ByteArray::Cast(obj)->DumpForSnapshot(vec);
3624             return;
3625         case JSType::JS_PROXY:
3626             JSProxy::Cast(obj)->DumpForSnapshot(vec);
3627             return;
3628         case JSType::JS_PRIMITIVE_REF:
3629             JSPrimitiveRef::Cast(obj)->DumpForSnapshot(vec);
3630             return;
3631         case JSType::SYMBOL:
3632             JSSymbol::Cast(obj)->DumpForSnapshot(vec);
3633             return;
3634         case JSType::ACCESSOR_DATA:
3635         case JSType::INTERNAL_ACCESSOR:
3636             AccessorData::Cast(obj)->DumpForSnapshot(vec);
3637             return;
3638         case JSType::JS_DATA_VIEW:
3639             JSDataView::Cast(obj)->DumpForSnapshot(vec);
3640             return;
3641         case JSType::PROMISE_REACTIONS:
3642             PromiseReaction::Cast(obj)->DumpForSnapshot(vec);
3643             return;
3644         case JSType::PROMISE_CAPABILITY:
3645             PromiseCapability::Cast(obj)->DumpForSnapshot(vec);
3646             return;
3647         case JSType::PROMISE_ITERATOR_RECORD:
3648             PromiseIteratorRecord::Cast(obj)->DumpForSnapshot(vec);
3649             return;
3650         case JSType::PROMISE_RECORD:
3651             PromiseRecord::Cast(obj)->DumpForSnapshot(vec);
3652             return;
3653         case JSType::RESOLVING_FUNCTIONS_RECORD:
3654             ResolvingFunctionsRecord::Cast(obj)->DumpForSnapshot(vec);
3655             return;
3656         case JSType::JS_PROMISE:
3657             JSPromise::Cast(obj)->DumpForSnapshot(vec);
3658             return;
3659         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
3660             JSPromiseReactionsFunction::Cast(obj)->DumpForSnapshot(vec);
3661             return;
3662         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
3663             JSPromiseExecutorFunction::Cast(obj)->DumpForSnapshot(vec);
3664             return;
3665         case JSType::ASYNC_GENERATOR_REQUEST:
3666             AsyncGeneratorRequest::Cast(obj)->DumpForSnapshot(vec);
3667             return;
3668         case JSType::ASYNC_ITERATOR_RECORD:
3669             AsyncIteratorRecord::Cast(obj)->DumpForSnapshot(vec);
3670             return;
3671         case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
3672             JSAsyncFromSyncIterator::Cast(obj)->DumpForSnapshot(vec);
3673             return;
3674         case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
3675             JSAsyncFromSyncIterUnwarpFunction::Cast(obj)->DumpForSnapshot(vec);
3676             return;
3677         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
3678             JSPromiseAllResolveElementFunction::Cast(obj)->DumpForSnapshot(vec);
3679             return;
3680         case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
3681             JSPromiseAnyRejectElementFunction::Cast(obj)->DumpForSnapshot(vec);
3682             return;
3683         case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
3684             JSPromiseAllSettledElementFunction::Cast(obj)->DumpForSnapshot(vec);
3685             return;
3686         case JSType::JS_PROMISE_FINALLY_FUNCTION:
3687             JSPromiseFinallyFunction::Cast(obj)->DumpForSnapshot(vec);
3688             return;
3689         case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
3690             JSPromiseValueThunkOrThrowerFunction::Cast(obj)->DumpForSnapshot(vec);
3691             return;
3692         case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
3693             JSAsyncGeneratorResNextRetProRstFtn::Cast(obj)->DumpForSnapshot(vec);
3694             return;
3695         case JSType::MICRO_JOB_QUEUE:
3696             MicroJobQueue::Cast(obj)->DumpForSnapshot(vec);
3697             return;
3698         case JSType::PENDING_JOB:
3699             PendingJob::Cast(obj)->DumpForSnapshot(vec);
3700             return;
3701         case JSType::COMPLETION_RECORD:
3702             CompletionRecord::Cast(obj)->DumpForSnapshot(vec);
3703             return;
3704         case JSType::JS_ITERATOR:
3705         case JSType::JS_ASYNCITERATOR:
3706         case JSType::JS_FORIN_ITERATOR:
3707         case JSType::JS_MAP_ITERATOR:
3708         case JSType::JS_SET_ITERATOR:
3709         case JSType::JS_ARRAY_ITERATOR:
3710         case JSType::JS_STRING_ITERATOR:
3711         case JSType::JS_REG_EXP_ITERATOR:
3712         case JSType::JS_ARRAY_BUFFER:
3713             JSArrayBuffer::Cast(obj)->DumpForSnapshot(vec);
3714             return;
3715         case JSType::JS_SHARED_ARRAY_BUFFER:
3716             JSArrayBuffer::Cast(obj)->DumpForSnapshot(vec);
3717             return;
3718         case JSType::JS_PROXY_REVOC_FUNCTION:
3719             JSProxyRevocFunction::Cast(obj)->DumpForSnapshot(vec);
3720             return;
3721         case JSType::JS_ASYNC_FUNCTION:
3722             JSAsyncFunction::Cast(obj)->DumpForSnapshot(vec);
3723             return;
3724         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
3725             JSAsyncAwaitStatusFunction::Cast(obj)->DumpForSnapshot(vec);
3726             return;
3727         case JSType::JS_GENERATOR_FUNCTION:
3728             JSGeneratorFunction::Cast(obj)->DumpForSnapshot(vec);
3729             return;
3730         case JSType::JS_ASYNC_GENERATOR_FUNCTION:
3731             JSAsyncGeneratorFunction::Cast(obj)->DumpForSnapshot(vec);
3732             return;
3733         case JSType::JS_INTL_BOUND_FUNCTION:
3734             JSIntlBoundFunction::Cast(obj)->DumpForSnapshot(vec);
3735             return;
3736         case JSType::JS_REALM:
3737             JSRealm::Cast(obj)->DumpForSnapshot(vec);
3738             return;
3739         case JSType::JS_INTL:
3740             JSIntl::Cast(obj)->DumpForSnapshot(vec);
3741             return;
3742         case JSType::JS_LOCALE:
3743             JSLocale::Cast(obj)->DumpForSnapshot(vec);
3744             return;
3745         case JSType::JS_DATE_TIME_FORMAT:
3746             JSDateTimeFormat::Cast(obj)->DumpForSnapshot(vec);
3747             return;
3748         case JSType::JS_RELATIVE_TIME_FORMAT:
3749             JSRelativeTimeFormat::Cast(obj)->DumpForSnapshot(vec);
3750             return;
3751         case JSType::JS_NUMBER_FORMAT:
3752             JSNumberFormat::Cast(obj)->DumpForSnapshot(vec);
3753             return;
3754         case JSType::JS_CJS_MODULE:
3755             CjsModule::Cast(obj)->DumpForSnapshot(vec);
3756             return;
3757         case JSType::JS_CJS_EXPORTS:
3758             CjsExports::Cast(obj)->DumpForSnapshot(vec);
3759             return;
3760         case JSType::JS_CJS_REQUIRE:
3761             CjsRequire::Cast(obj)->DumpForSnapshot(vec);
3762             return;
3763         case JSType::JS_COLLATOR:
3764             JSCollator::Cast(obj)->DumpForSnapshot(vec);
3765             return;
3766         case JSType::JS_PLURAL_RULES:
3767             JSPluralRules::Cast(obj)->DumpForSnapshot(vec);
3768             return;
3769         case JSType::JS_DISPLAYNAMES:
3770             JSDisplayNames::Cast(obj)->DumpForSnapshot(vec);
3771             return;
3772         case JSType::JS_LIST_FORMAT:
3773             JSListFormat::Cast(obj)->DumpForSnapshot(vec);
3774             return;
3775         case JSType::JS_GENERATOR_OBJECT:
3776             JSGeneratorObject::Cast(obj)->DumpForSnapshot(vec);
3777             return;
3778         case JSType::JS_ASYNC_GENERATOR_OBJECT:
3779             JSAsyncGeneratorObject::Cast(obj)->DumpForSnapshot(vec);
3780             return;
3781         case JSType::JS_ASYNC_FUNC_OBJECT:
3782             JSAsyncFuncObject::Cast(obj)->DumpForSnapshot(vec);
3783             return;
3784         case JSType::JS_GENERATOR_CONTEXT:
3785             GeneratorContext::Cast(obj)->DumpForSnapshot(vec);
3786             return;
3787         case JSType::JS_API_ARRAY_LIST:
3788             JSAPIArrayList::Cast(obj)->DumpForSnapshot(vec);
3789             return;
3790         case JSType::JS_API_ARRAYLIST_ITERATOR:
3791             JSAPIArrayListIterator::Cast(obj)->DumpForSnapshot(vec);
3792             return;
3793         case JSType::LINKED_NODE:
3794         case JSType::RB_TREENODE:
3795             return;
3796         case JSType::JS_API_HASH_MAP:
3797             JSAPIHashMap::Cast(obj)->DumpForSnapshot(vec);
3798             return;
3799         case JSType::JS_API_HASH_SET:
3800             JSAPIHashSet::Cast(obj)->DumpForSnapshot(vec);
3801             return;
3802         case JSType::JS_API_HASHMAP_ITERATOR:
3803             JSAPIHashMapIterator::Cast(obj)->DumpForSnapshot(vec);
3804             return;
3805         case JSType::JS_API_HASHSET_ITERATOR:
3806             JSAPIHashSetIterator::Cast(obj)->DumpForSnapshot(vec);
3807             return;
3808         case JSType::JS_API_LIGHT_WEIGHT_MAP:
3809             JSAPILightWeightMap::Cast(obj)->DumpForSnapshot(vec);
3810             return;
3811         case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
3812             JSAPILightWeightMapIterator::Cast(obj)->DumpForSnapshot(vec);
3813             return;
3814         case JSType::JS_API_LIGHT_WEIGHT_SET:
3815             JSAPILightWeightSet::Cast(obj)->DumpForSnapshot(vec);
3816             return;
3817         case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
3818             JSAPILightWeightSetIterator::Cast(obj)->DumpForSnapshot(vec);
3819             return;
3820         case JSType::JS_API_TREE_MAP:
3821             JSAPITreeMap::Cast(obj)->DumpForSnapshot(vec);
3822             return;
3823         case JSType::JS_API_TREE_SET:
3824             JSAPITreeSet::Cast(obj)->DumpForSnapshot(vec);
3825             return;
3826         case JSType::JS_API_TREEMAP_ITERATOR:
3827             JSAPITreeMapIterator::Cast(obj)->DumpForSnapshot(vec);
3828             return;
3829         case JSType::JS_API_TREESET_ITERATOR:
3830             JSAPITreeSetIterator::Cast(obj)->DumpForSnapshot(vec);
3831             return;
3832         case JSType::JS_API_VECTOR:
3833             JSAPIVector::Cast(obj)->DumpForSnapshot(vec);
3834             return;
3835         case JSType::JS_API_VECTOR_ITERATOR:
3836             JSAPIVectorIterator::Cast(obj)->DumpForSnapshot(vec);
3837             return;
3838         case JSType::JS_API_QUEUE:
3839             JSAPIQueue::Cast(obj)->DumpForSnapshot(vec);
3840             return;
3841         case JSType::JS_API_QUEUE_ITERATOR:
3842             JSAPIQueueIterator::Cast(obj)->DumpForSnapshot(vec);
3843             return;
3844         case JSType::JS_API_DEQUE:
3845             JSAPIDeque::Cast(obj)->DumpForSnapshot(vec);
3846             return;
3847         case JSType::JS_API_DEQUE_ITERATOR:
3848             JSAPIDequeIterator::Cast(obj)->DumpForSnapshot(vec);
3849             return;
3850         case JSType::JS_API_STACK:
3851             JSAPIStack::Cast(obj)->DumpForSnapshot(vec);
3852             return;
3853         case JSType::JS_API_STACK_ITERATOR:
3854             JSAPIStackIterator::Cast(obj)->DumpForSnapshot(vec);
3855             return;
3856         case JSType::JS_API_LIST:
3857             JSAPIList::Cast(obj)->DumpForSnapshot(vec);
3858             return;
3859         case JSType::JS_API_LINKED_LIST:
3860             JSAPILinkedList::Cast(obj)->DumpForSnapshot(vec);
3861             return;
3862         case JSType::JS_API_LIST_ITERATOR:
3863             JSAPIListIterator::Cast(obj)->DumpForSnapshot(vec);
3864             return;
3865         case JSType::JS_API_LINKED_LIST_ITERATOR:
3866             JSAPILinkedListIterator::Cast(obj)->DumpForSnapshot(vec);
3867             return;
3868         case JSType::SOURCE_TEXT_MODULE_RECORD:
3869             SourceTextModule::Cast(obj)->DumpForSnapshot(vec);
3870             return;
3871         case JSType::IMPORTENTRY_RECORD:
3872             ImportEntry::Cast(obj)->DumpForSnapshot(vec);
3873             return;
3874         case JSType::LOCAL_EXPORTENTRY_RECORD:
3875             LocalExportEntry::Cast(obj)->DumpForSnapshot(vec);
3876             return;
3877         case JSType::INDIRECT_EXPORTENTRY_RECORD:
3878             IndirectExportEntry::Cast(obj)->DumpForSnapshot(vec);
3879             return;
3880         case JSType::STAR_EXPORTENTRY_RECORD:
3881             StarExportEntry::Cast(obj)->DumpForSnapshot(vec);
3882             return;
3883         case JSType::RESOLVEDBINDING_RECORD:
3884             ResolvedBinding::Cast(obj)->DumpForSnapshot(vec);
3885             return;
3886         case JSType::RESOLVEDINDEXBINDING_RECORD:
3887             ResolvedIndexBinding::Cast(obj)->DumpForSnapshot(vec);
3888             return;
3889         case JSType::JS_MODULE_NAMESPACE:
3890             ModuleNamespace::Cast(obj)->DumpForSnapshot(vec);
3891             return;
3892         case JSType::JS_API_PLAIN_ARRAY:
3893             JSAPIPlainArray::Cast(obj)->DumpForSnapshot(vec);
3894             return;
3895         case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
3896             JSAPIPlainArrayIterator::Cast(obj)->DumpForSnapshot(vec);
3897             return;
3898         default:
3899             break;
3900     }
3901     if (isVmMode) {
3902         switch (type) {
3903             case JSType::PROPERTY_BOX:
3904                 PropertyBox::Cast(obj)->DumpForSnapshot(vec);
3905                 return;
3906             case JSType::TEMPLATE_MAP:
3907                 DumpArrayClass(TaggedArray::Cast(obj), vec);
3908                 return;
3909             case JSType::GLOBAL_ENV:
3910                 GlobalEnv::Cast(obj)->DumpForSnapshot(vec);
3911                 return;
3912             case JSType::PROTO_CHANGE_MARKER:
3913                 ProtoChangeMarker::Cast(obj)->DumpForSnapshot(vec);
3914                 return;
3915             case JSType::PROTOTYPE_INFO:
3916                 ProtoChangeDetails::Cast(obj)->DumpForSnapshot(vec);
3917                 return;
3918             case JSType::PROGRAM:
3919                 Program::Cast(obj)->DumpForSnapshot(vec);
3920                 return;
3921             case JSType::MACHINE_CODE_OBJECT:
3922                 MachineCode::Cast(obj)->DumpForSnapshot(vec);
3923                 return;
3924             case JSType::TRANSITION_HANDLER:
3925                 TransitionHandler::Cast(obj)->DumpForSnapshot(vec);
3926                 return;
3927             case JSType::TRANS_WITH_PROTO_HANDLER:
3928                 TransWithProtoHandler::Cast(obj)->DumpForSnapshot(vec);
3929                 return;
3930             case JSType::STORE_TS_HANDLER:
3931                 StoreTSHandler::Cast(obj)->DumpForSnapshot(vec);
3932                 return;
3933             case JSType::PROTOTYPE_HANDLER:
3934                 PrototypeHandler::Cast(obj)->DumpForSnapshot(vec);
3935                 return;
3936             case JSType::CLASS_INFO_EXTRACTOR:
3937                 ClassInfoExtractor::Cast(obj)->DumpForSnapshot(vec);
3938                 return;
3939             case JSType::TS_OBJECT_TYPE:
3940                 TSObjectType::Cast(obj)->DumpForSnapshot(vec);
3941                 return;
3942             case JSType::TS_CLASS_TYPE:
3943                 TSClassType::Cast(obj)->DumpForSnapshot(vec);
3944                 return;
3945             case JSType::TS_INTERFACE_TYPE:
3946                 TSInterfaceType::Cast(obj)->DumpForSnapshot(vec);
3947                 return;
3948             case JSType::TS_CLASS_INSTANCE_TYPE:
3949                 TSClassInstanceType::Cast(obj)->DumpForSnapshot(vec);
3950                 return;
3951             case JSType::TS_UNION_TYPE:
3952                 TSUnionType::Cast(obj)->DumpForSnapshot(vec);
3953                 return;
3954             case JSType::TS_FUNCTION_TYPE:
3955                 TSFunctionType::Cast(obj)->DumpForSnapshot(vec);
3956                 return;
3957             case JSType::TS_ARRAY_TYPE:
3958                 TSArrayType::Cast(obj)->DumpForSnapshot(vec);
3959                 return;
3960             case JSType::TS_ITERATOR_INSTANCE_TYPE:
3961                 TSIteratorInstanceType::Cast(obj)->DumpForSnapshot(vec);
3962                 return;
3963             case JSType::METHOD:
3964                 Method::Cast(obj)->DumpForSnapshot(vec);
3965                 return;
3966             case JSType::CLASS_LITERAL:
3967                 ClassLiteral::Cast(obj)->DumpForSnapshot(vec);
3968                 return;
3969             default:
3970                 UNREACHABLE();
3971                 break;
3972         }
3973     }
3974 }
3975 
EcmaStringToStd(CString & res,EcmaString * str)3976 static inline void EcmaStringToStd(CString &res, EcmaString *str)
3977 {
3978     if (EcmaStringAccessor(str).GetLength() == 0) {
3979         CString emptyStr = "EmptyString";
3980         res.append(emptyStr);
3981     }
3982 
3983     CString string = ConvertToString(str);
3984     res.append(string);
3985 }
3986 
KeyToStd(CString & res,JSTaggedValue key)3987 static void KeyToStd(CString &res, JSTaggedValue key)
3988 {
3989     if (key.IsInt()) {
3990         res = std::to_string(key.GetInt());
3991     } else if (key.IsDouble()) {
3992         res = std::to_string(key.GetDouble());
3993     } else if (key.IsBoolean()) {
3994         res = key.IsTrue() ? "true" : "false";
3995     } else if (key.IsHeapObject()) {
3996         if (key.IsWeak()) {
3997             key.RemoveWeakTag();
3998         }
3999         if (key.IsString()) {
4000             EcmaStringToStd(res, EcmaString::Cast(key.GetTaggedObject()));
4001         } else if (key.IsSymbol()) {
4002             JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
4003             JSTaggedValue desc = sym->GetDescription();
4004             if (desc.IsString()) {
4005                 EcmaStringToStd(res, EcmaString::Cast(desc.GetTaggedObject()));
4006             }
4007         }
4008     }
4009 }
4010 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec,bool isVmMode) const4011 void JSTaggedValue::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec, bool isVmMode) const
4012 {
4013     if (IsHeapObject()) {
4014         return DumpObject(GetTaggedObject(), vec, isVmMode);
4015     }
4016 
4017     UNREACHABLE();
4018 }
4019 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4020 void NumberDictionary::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4021 {
4022     DISALLOW_GARBAGE_COLLECTION;
4023     int size = Size();
4024     vec.reserve(vec.size() + size);
4025     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4026         JSTaggedValue key(GetKey(hashIndex));
4027         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4028             JSTaggedValue val(GetValue(hashIndex));
4029             CString str = ToCString(static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()));
4030             vec.emplace_back(str, val);
4031         }
4032     }
4033 }
4034 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4035 void NameDictionary::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4036 {
4037     DISALLOW_GARBAGE_COLLECTION;
4038     int size = Size();
4039     vec.reserve(vec.size() + size);
4040     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4041         JSTaggedValue key(GetKey(hashIndex));
4042         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4043             JSTaggedValue val(GetValue(hashIndex));
4044             CString str;
4045             KeyToStd(str, key);
4046             vec.emplace_back(str, val);
4047         }
4048     }
4049 }
4050 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4051 void GlobalDictionary::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4052 {
4053     DISALLOW_GARBAGE_COLLECTION;
4054     int size = Size();
4055     vec.reserve(vec.size() + size);
4056     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4057         JSTaggedValue key(GetKey(hashIndex));
4058         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4059             CString str;
4060             KeyToStd(str, key);
4061             JSTaggedValue val = GetValue(hashIndex);
4062             vec.emplace_back(str, val);
4063         }
4064     }
4065 }
4066 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4067 void LinkedHashSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4068 {
4069     DISALLOW_GARBAGE_COLLECTION;
4070     int capacity = NumberOfElements() + NumberOfDeletedElements();
4071     vec.reserve(vec.size() + capacity);
4072     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
4073         JSTaggedValue key(GetKey(hashIndex));
4074         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4075             CString str;
4076             KeyToStd(str, key);
4077             vec.emplace_back(str, JSTaggedValue::Hole());
4078         }
4079     }
4080 }
4081 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4082 void LinkedHashMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4083 {
4084     DISALLOW_GARBAGE_COLLECTION;
4085     int capacity = NumberOfElements() + NumberOfDeletedElements();
4086     vec.reserve(vec.size() + capacity);
4087     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
4088         JSTaggedValue key(GetKey(hashIndex));
4089         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4090             JSTaggedValue val = GetValue(hashIndex);
4091             CString str;
4092             KeyToStd(str, key);
4093             vec.emplace_back(str, val);
4094         }
4095     }
4096 }
4097 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4098 void TaggedTreeMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4099 {
4100     DISALLOW_GARBAGE_COLLECTION;
4101     int capacity = NumberOfElements() + NumberOfDeletedElements();
4102     vec.reserve(vec.size() + capacity);
4103     for (int index = 0; index < capacity; index++) {
4104         JSTaggedValue key(GetKey(index));
4105         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4106             JSTaggedValue val = GetValue(index);
4107             CString str;
4108             KeyToStd(str, key);
4109             vec.emplace_back(str, val);
4110         }
4111     }
4112 }
4113 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4114 void TaggedTreeSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4115 {
4116     DISALLOW_GARBAGE_COLLECTION;
4117     int capacity = NumberOfElements() + NumberOfDeletedElements();
4118     vec.reserve(vec.size() + capacity);
4119     for (int index = 0; index < capacity; index++) {
4120         JSTaggedValue key(GetKey(index));
4121         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4122             CString str;
4123             KeyToStd(str, key);
4124             vec.emplace_back(str, JSTaggedValue::Hole());
4125         }
4126     }
4127 }
4128 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4129 void TaggedDoubleList::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4130 {
4131     DISALLOW_GARBAGE_COLLECTION;
4132     int capacity = NumberOfNodes();
4133     vec.reserve(vec.size() + capacity);
4134     for (int index = 0; index < capacity; index++) {
4135         JSTaggedValue val = GetElement(index);
4136         CString str;
4137         KeyToStd(str, JSTaggedValue(index));
4138         vec.emplace_back(str, val);
4139     }
4140 }
4141 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4142 void TaggedSingleList::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4143 {
4144     DISALLOW_GARBAGE_COLLECTION;
4145     int capacity = NumberOfNodes();
4146     vec.reserve(vec.size() + capacity);
4147     for (int index = 0; index < capacity; index++) {
4148         JSTaggedValue val = GetElement(index);
4149         CString str;
4150         KeyToStd(str, JSTaggedValue(index));
4151         vec.emplace_back(str, val);
4152     }
4153 }
4154 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4155 void JSObject::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4156 {
4157     DISALLOW_GARBAGE_COLLECTION;
4158     JSHClass *jshclass = GetJSHClass();
4159     vec.emplace_back("__proto__", jshclass->GetPrototype());
4160 
4161     TaggedArray *elements = TaggedArray::Cast(GetElements().GetTaggedObject());
4162     if (elements->GetLength() == 0) {
4163     } else if (!elements->IsDictionaryMode()) {
4164         DumpArrayClass(elements, vec);
4165     } else {
4166         NumberDictionary *dict = NumberDictionary::Cast(elements);
4167         dict->DumpForSnapshot(vec);
4168     }
4169 
4170     TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
4171     if (IsJSGlobalObject()) {
4172         GlobalDictionary *dict = GlobalDictionary::Cast(properties);
4173         dict->DumpForSnapshot(vec);
4174         return;
4175     }
4176 
4177     if (!properties->IsDictionaryMode()) {
4178         JSTaggedValue attrs = jshclass->GetLayout();
4179         if (attrs.IsNull()) {
4180             return;
4181         }
4182 
4183         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
4184         int propNumber = static_cast<int>(jshclass->NumberOfProps());
4185         vec.reserve(vec.size() + propNumber);
4186         for (int i = 0; i < propNumber; i++) {
4187             JSTaggedValue key = layoutInfo->GetKey(i);
4188             PropertyAttributes attr = layoutInfo->GetAttr(i);
4189             ASSERT(i == static_cast<int>(attr.GetOffset()));
4190             JSTaggedValue val;
4191             if (attr.IsInlinedProps()) {
4192                 val = GetPropertyInlinedProps(i);
4193             } else {
4194                 val = properties->Get(i - static_cast<int>(jshclass->GetInlinedProperties()));
4195             }
4196 
4197             CString str;
4198             KeyToStd(str, key);
4199             vec.emplace_back(str, val);
4200         }
4201     } else {
4202         NameDictionary *dict = NameDictionary::Cast(properties);
4203         dict->DumpForSnapshot(vec);
4204     }
4205 }
4206 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4207 void JSHClass::DumpForSnapshot([[maybe_unused]] std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4208 {
4209 }
4210 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4211 void JSFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4212 {
4213     vec.emplace_back("ProtoOrHClass", GetProtoOrHClass());
4214     vec.emplace_back("LexicalEnv", GetLexicalEnv());
4215     vec.emplace_back("HomeObject", GetHomeObject());
4216     vec.emplace_back("FunctionKind", JSTaggedValue(static_cast<int>(GetFunctionKind())));
4217     vec.emplace_back("FunctionExtraInfo", GetFunctionExtraInfo());
4218     JSObject::DumpForSnapshot(vec);
4219 }
4220 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4221 void Method::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4222 {
4223     vec.emplace_back("ConstantPool", GetConstantPool());
4224     vec.emplace_back("ProfileTypeInfo", GetProfileTypeInfo());
4225 }
4226 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4227 void Program::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4228 {
4229     vec.emplace_back("MainFunction", GetMainFunction());
4230 }
4231 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4232 void ConstantPool::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4233 {
4234     DumpArrayClass(this, vec);
4235 }
4236 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4237 void COWTaggedArray::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4238 {
4239     DumpArrayClass(this, vec);
4240 }
4241 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4242 void JSBoundFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4243 {
4244     JSObject::DumpForSnapshot(vec);
4245 
4246     vec.emplace_back("BoundTarget", GetBoundTarget());
4247     vec.emplace_back("BoundThis", GetBoundThis());
4248     vec.emplace_back("BoundArguments", GetBoundArguments());
4249 }
4250 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4251 void JSPrimitiveRef::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4252 {
4253     vec.emplace_back("subValue", GetValue());
4254     JSObject::DumpForSnapshot(vec);
4255 }
4256 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4257 void BigInt::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4258 {
4259     vec.emplace_back("Length", JSTaggedValue(GetLength()));
4260     vec.emplace_back("Sign", JSTaggedValue(GetSign()));
4261 }
4262 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4263 void JSDate::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4264 {
4265     vec.emplace_back("time", GetTime());
4266     vec.emplace_back("localOffset", GetLocalOffset());
4267 
4268     JSObject::DumpForSnapshot(vec);
4269 }
4270 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4271 void JSMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4272 {
4273     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
4274     map->DumpForSnapshot(vec);
4275 
4276     JSObject::DumpForSnapshot(vec);
4277 }
4278 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4279 void JSForInIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4280 {
4281     vec.emplace_back("Object", GetObject());
4282     vec.emplace_back("WasVisited", JSTaggedValue(GetWasVisited()));
4283     vec.emplace_back("VisitedKeys", GetVisitedKeys());
4284     vec.emplace_back("RemainingKeys", GetRemainingKeys());
4285     JSObject::DumpForSnapshot(vec);
4286 }
4287 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4288 void JSMapIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4289 {
4290     LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap().GetTaggedObject());
4291     map->DumpForSnapshot(vec);
4292     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4293     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
4294     JSObject::DumpForSnapshot(vec);
4295 }
4296 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4297 void JSSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4298 {
4299     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
4300     set->DumpForSnapshot(vec);
4301 
4302     JSObject::DumpForSnapshot(vec);
4303 }
4304 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4305 void JSWeakMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4306 {
4307     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
4308     map->DumpForSnapshot(vec);
4309 
4310     JSObject::DumpForSnapshot(vec);
4311 }
4312 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4313 void JSWeakSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4314 {
4315     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
4316     set->DumpForSnapshot(vec);
4317 
4318     JSObject::DumpForSnapshot(vec);
4319 }
4320 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4321 void JSWeakRef::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4322 {
4323     vec.emplace_back("WeakObject", GetWeakObject());
4324     JSObject::DumpForSnapshot(vec);
4325 }
4326 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4327 void JSFinalizationRegistry::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4328 {
4329     vec.emplace_back("CleanupCallback", GetCleanupCallback());
4330     LinkedHashMap *map = LinkedHashMap::Cast(GetMaybeUnregister().GetTaggedObject());
4331     map->DumpForSnapshot(vec);
4332     vec.emplace_back("MaybeUnregister", GetMaybeUnregister());
4333     JSObject::DumpForSnapshot(vec);
4334 }
4335 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4336 void CellRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4337 {
4338     vec.emplace_back("WeakRefTarget", GetWeakRefTarget());
4339     vec.emplace_back("HeldValue", GetHeldValue());
4340 }
4341 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4342 void JSSetIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4343 {
4344     LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet().GetTaggedObject());
4345     set->DumpForSnapshot(vec);
4346     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4347     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
4348     JSObject::DumpForSnapshot(vec);
4349 }
4350 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4351 void JSArray::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4352 {
4353     JSObject::DumpForSnapshot(vec);
4354 }
4355 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4356 void JSAPIArrayList::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4357 {
4358     JSObject::DumpForSnapshot(vec);
4359 }
4360 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4361 void JSAPIArrayListIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4362 {
4363     JSAPIArrayList *arraylist = JSAPIArrayList::Cast(GetIteratedArrayList().GetTaggedObject());
4364     arraylist->DumpForSnapshot(vec);
4365     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4366     JSObject::DumpForSnapshot(vec);
4367 }
4368 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4369 void JSAPILightWeightMap::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4370 {
4371     JSObject::DumpForSnapshot(vec);
4372 }
4373 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4374 void JSAPILightWeightMapIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4375 {
4376     JSAPILightWeightMap *map =
4377         JSAPILightWeightMap::Cast(GetIteratedLightWeightMap().GetTaggedObject());
4378     map->DumpForSnapshot(vec);
4379     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4380     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
4381     JSObject::DumpForSnapshot(vec);
4382 }
4383 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4384 void JSAPIQueue::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4385 {
4386     JSObject::DumpForSnapshot(vec);
4387 }
4388 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4389 void JSAPIQueueIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4390 {
4391     JSAPIQueue *queue = JSAPIQueue::Cast(GetIteratedQueue().GetTaggedObject());
4392     queue->DumpForSnapshot(vec);
4393     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4394     JSObject::DumpForSnapshot(vec);
4395 }
4396 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4397 void JSAPIDeque::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4398 {
4399     JSObject::DumpForSnapshot(vec);
4400 }
4401 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4402 void JSAPIDequeIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4403 {
4404     JSAPIDeque *deque = JSAPIDeque::Cast(GetIteratedDeque().GetTaggedObject());
4405     deque->DumpForSnapshot(vec);
4406     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4407     JSObject::DumpForSnapshot(vec);
4408 }
4409 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4410 void JSAPILightWeightSet::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4411 {
4412     JSObject::DumpForSnapshot(vec);
4413 }
4414 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4415 void JSAPILightWeightSetIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4416 {
4417     JSAPILightWeightSet *set =
4418         JSAPILightWeightSet::Cast(GetIteratedLightWeightSet().GetTaggedObject());
4419     set->DumpForSnapshot(vec);
4420     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4421     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
4422     JSObject::DumpForSnapshot(vec);
4423 }
4424 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4425 void JSAPIStack::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4426 {
4427     JSObject::DumpForSnapshot(vec);
4428 }
4429 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4430 void JSAPIStackIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4431 {
4432     JSAPIStack *stack = JSAPIStack::Cast(GetIteratedStack().GetTaggedObject());
4433     stack->DumpForSnapshot(vec);
4434     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4435     JSObject::DumpForSnapshot(vec);
4436 }
4437 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4438 void JSArrayIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4439 {
4440     JSArray *array = JSArray::Cast(GetIteratedArray().GetTaggedObject());
4441     array->DumpForSnapshot(vec);
4442     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4443     vec.emplace_back("IterationKind", JSTaggedValue(static_cast<int>(GetIterationKind())));
4444     JSObject::DumpForSnapshot(vec);
4445 }
4446 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4447 void JSAPIVector::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4448 {
4449     JSObject::DumpForSnapshot(vec);
4450 }
4451 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4452 void JSAPIVectorIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4453 {
4454     JSAPIVector *vector = JSAPIVector::Cast(GetIteratedVector().GetTaggedObject());
4455     vector->DumpForSnapshot(vec);
4456     vec.emplace_back("NextIndex", JSTaggedValue(GetNextIndex()));
4457     JSObject::DumpForSnapshot(vec);
4458 }
4459 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4460 void JSStringIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4461 {
4462     vec.emplace_back("IteratedString", GetIteratedString());
4463     vec.emplace_back("StringIteratorNextIndex", JSTaggedValue(GetStringIteratorNextIndex()));
4464     JSObject::DumpForSnapshot(vec);
4465 }
4466 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4467 void JSTypedArray::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4468 {
4469     // please update the NUM_OF_ITEMS if you change the items below
4470     constexpr int16_t NUM_OF_ITEMS = 5;
4471     vec.reserve(vec.size() + NUM_OF_ITEMS);
4472     vec.emplace_back("viewed-array-buffer", GetViewedArrayBuffer());
4473     vec.emplace_back("typed-array-name", GetTypedArrayName());
4474     vec.emplace_back("byte-length", JSTaggedValue(GetByteLength()));
4475     vec.emplace_back("byte-offset", JSTaggedValue(GetByteOffset()));
4476     vec.emplace_back("array-length", JSTaggedValue(GetArrayLength()));
4477 }
4478 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4479 void ByteArray::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4480 {
4481     vec.emplace_back("length", JSTaggedValue(GetLength()));
4482     vec.emplace_back("size", JSTaggedValue(GetSize()));
4483 }
4484 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4485 void JSRegExp::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4486 {
4487     vec.emplace_back("originalSource", GetOriginalSource());
4488     vec.emplace_back("originalFlags", GetOriginalFlags());
4489     vec.emplace_back("groupName", GetGroupName());
4490     JSObject::DumpForSnapshot(vec);
4491 }
4492 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4493 void JSRegExpIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4494 {
4495     vec.emplace_back("IteratingRegExp", GetIteratingRegExp());
4496     vec.emplace_back("IteratedString", GetIteratedString());
4497     vec.emplace_back("Global", JSTaggedValue(GetGlobal()));
4498     vec.emplace_back("Unicode", JSTaggedValue(GetUnicode()));
4499     vec.emplace_back("Done", JSTaggedValue(GetDone()));
4500     JSObject::DumpForSnapshot(vec);
4501 }
4502 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4503 void JSProxy::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4504 {
4505     vec.emplace_back("target", GetTarget());
4506     vec.emplace_back("handler", GetHandler());
4507 }
4508 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4509 void JSSymbol::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4510 {
4511     vec.emplace_back("hash-field", JSTaggedValue(GetHashField()));
4512     vec.emplace_back("flags", JSTaggedValue(GetFlags()));
4513     vec.emplace_back("description", GetDescription());
4514 }
4515 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4516 void AccessorData::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4517 {
4518     vec.emplace_back("getter", GetGetter());
4519     vec.emplace_back("setter", GetSetter());
4520 }
4521 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4522 void LexicalEnv::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4523 {
4524     DumpArrayClass(this, vec);
4525 }
4526 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4527 void GlobalEnv::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4528 {
4529     auto globalConst = GetJSThread()->GlobalConstants();
4530     // please update the NUM_OF_ITEMS if you change the items below
4531     constexpr int16_t NUM_OF_ITEMS = 137;
4532     vec.reserve(vec.size() + NUM_OF_ITEMS);
4533     vec.emplace_back("ObjectFunction", GetObjectFunction().GetTaggedValue());
4534     vec.emplace_back("FunctionFunction", GetFunctionFunction().GetTaggedValue());
4535     vec.emplace_back("NumberFunction", GetNumberFunction().GetTaggedValue());
4536     vec.emplace_back("BigIntFunction", GetBigIntFunction().GetTaggedValue());
4537     vec.emplace_back("DateFunction", GetDateFunction().GetTaggedValue());
4538     vec.emplace_back("BooleanFunction", GetBooleanFunction().GetTaggedValue());
4539     vec.emplace_back("ErrorFunction", GetErrorFunction().GetTaggedValue());
4540     vec.emplace_back("ArrayFunction", GetArrayFunction().GetTaggedValue());
4541     vec.emplace_back("TypedArrayFunction", GetTypedArrayFunction().GetTaggedValue());
4542     vec.emplace_back("Int8ArrayFunction", GetInt8ArrayFunction().GetTaggedValue());
4543     vec.emplace_back("Uint8ArrayFunction", GetUint8ArrayFunction().GetTaggedValue());
4544     vec.emplace_back("Uint8ClampedArrayFunction", GetUint8ClampedArrayFunction().GetTaggedValue());
4545     vec.emplace_back("Int16ArrayFunction", GetInt16ArrayFunction().GetTaggedValue());
4546     vec.emplace_back("Uint16ArrayFunction", GetUint16ArrayFunction().GetTaggedValue());
4547     vec.emplace_back("Int32ArrayFunction", GetInt32ArrayFunction().GetTaggedValue());
4548     vec.emplace_back("Uint32ArrayFunction", GetUint32ArrayFunction().GetTaggedValue());
4549     vec.emplace_back("Float32ArrayFunction", GetFloat32ArrayFunction().GetTaggedValue());
4550     vec.emplace_back("Float64ArrayFunction", GetFloat64ArrayFunction().GetTaggedValue());
4551     vec.emplace_back("ArrayBufferFunction", GetArrayBufferFunction().GetTaggedValue());
4552     vec.emplace_back("SharedArrayBufferFunction", GetSharedArrayBufferFunction().GetTaggedValue());
4553     vec.emplace_back("SymbolFunction", GetSymbolFunction().GetTaggedValue());
4554     vec.emplace_back("RangeErrorFunction", GetRangeErrorFunction().GetTaggedValue());
4555     vec.emplace_back("ReferenceErrorFunction", GetReferenceErrorFunction().GetTaggedValue());
4556     vec.emplace_back("TypeErrorFunction", GetTypeErrorFunction().GetTaggedValue());
4557     vec.emplace_back("AggregateErrorFunction", GetAggregateErrorFunction().GetTaggedValue());
4558     vec.emplace_back("URIErrorFunction", GetURIErrorFunction().GetTaggedValue());
4559     vec.emplace_back("SyntaxErrorFunction", GetSyntaxErrorFunction().GetTaggedValue());
4560     vec.emplace_back("EvalErrorFunction", GetEvalErrorFunction().GetTaggedValue());
4561     vec.emplace_back("OOMErrorFunction", GetOOMErrorFunction().GetTaggedValue());
4562     vec.emplace_back("RegExpFunction", GetRegExpFunction().GetTaggedValue());
4563     vec.emplace_back("BuiltinsSetFunction", GetBuiltinsSetFunction().GetTaggedValue());
4564     vec.emplace_back("BuiltinsMapFunction", GetBuiltinsMapFunction().GetTaggedValue());
4565     vec.emplace_back("BuiltinsWeakSetFunction", GetBuiltinsWeakSetFunction().GetTaggedValue());
4566     vec.emplace_back("BuiltinsWeakMapFunction", GetBuiltinsWeakMapFunction().GetTaggedValue());
4567     vec.emplace_back("BuiltinsWeakRefFunction", GetBuiltinsWeakRefFunction().GetTaggedValue());
4568     vec.emplace_back("BuiltinsFinalizationRegistryFunction",
4569         GetBuiltinsFinalizationRegistryFunction().GetTaggedValue());
4570     vec.emplace_back("MathFunction", GetMathFunction().GetTaggedValue());
4571     vec.emplace_back("AtomicsFunction", GetAtomicsFunction().GetTaggedValue());
4572     vec.emplace_back("JsonFunction", GetJsonFunction().GetTaggedValue());
4573     vec.emplace_back("StringFunction", GetStringFunction().GetTaggedValue());
4574     vec.emplace_back("ProxyFunction", GetProxyFunction().GetTaggedValue());
4575     vec.emplace_back("ReflectFunction", GetReflectFunction().GetTaggedValue());
4576     vec.emplace_back("AsyncFunction", GetAsyncFunction().GetTaggedValue());
4577     vec.emplace_back("AsyncFunctionPrototype", GetAsyncFunctionPrototype().GetTaggedValue());
4578     vec.emplace_back("JSGlobalObject", GetJSGlobalObject().GetTaggedValue());
4579     vec.emplace_back("EmptyArray", globalConst->GetEmptyArray());
4580     vec.emplace_back("EmptyString", globalConst->GetEmptyString());
4581     vec.emplace_back("EmptyTaggedQueue", globalConst->GetEmptyTaggedQueue());
4582     vec.emplace_back("PrototypeString", globalConst->GetPrototypeString());
4583     vec.emplace_back("HasInstanceSymbol", GetHasInstanceSymbol().GetTaggedValue());
4584     vec.emplace_back("IsConcatSpreadableSymbol", GetIsConcatSpreadableSymbol().GetTaggedValue());
4585     vec.emplace_back("ToStringTagSymbol", GetToStringTagSymbol().GetTaggedValue());
4586     vec.emplace_back("IteratorSymbol", GetIteratorSymbol().GetTaggedValue());
4587     vec.emplace_back("AsyncIteratorSymbol", GetAsyncIteratorSymbol().GetTaggedValue());
4588     vec.emplace_back("MatchSymbol", GetMatchSymbol().GetTaggedValue());
4589     vec.emplace_back("MatchAllSymbol", GetMatchAllSymbol().GetTaggedValue());
4590     vec.emplace_back("ReplaceSymbol", GetReplaceSymbol().GetTaggedValue());
4591     vec.emplace_back("SearchSymbol", GetSearchSymbol().GetTaggedValue());
4592     vec.emplace_back("SpeciesSymbol", GetSpeciesSymbol().GetTaggedValue());
4593     vec.emplace_back("SplitSymbol", GetSplitSymbol().GetTaggedValue());
4594     vec.emplace_back("ToPrimitiveSymbol", GetToPrimitiveSymbol().GetTaggedValue());
4595     vec.emplace_back("UnscopablesSymbol", GetUnscopablesSymbol().GetTaggedValue());
4596     vec.emplace_back("HoleySymbol", GetHoleySymbol().GetTaggedValue());
4597     vec.emplace_back("AttachSymbol", GetAttachSymbol().GetTaggedValue());
4598     vec.emplace_back("DetachSymbol", GetDetachSymbol().GetTaggedValue());
4599     vec.emplace_back("ConstructorString", globalConst->GetConstructorString());
4600     vec.emplace_back("IteratorPrototype", GetIteratorPrototype().GetTaggedValue());
4601     vec.emplace_back("ForinIteratorPrototype", GetForinIteratorPrototype().GetTaggedValue());
4602     vec.emplace_back("StringIterator", GetStringIterator().GetTaggedValue());
4603     vec.emplace_back("MapIteratorPrototype", GetMapIteratorPrototype().GetTaggedValue());
4604     vec.emplace_back("SetIteratorPrototype", GetSetIteratorPrototype().GetTaggedValue());
4605     vec.emplace_back("RegExpIteratorPrototype", GetRegExpIteratorPrototype().GetTaggedValue());
4606     vec.emplace_back("ArrayIteratorPrototype", GetArrayIteratorPrototype().GetTaggedValue());
4607     vec.emplace_back("StringIteratorPrototype", GetStringIteratorPrototype().GetTaggedValue());
4608     vec.emplace_back("LengthString", globalConst->GetLengthString());
4609     vec.emplace_back("ValueString", globalConst->GetValueString());
4610     vec.emplace_back("WritableString", globalConst->GetWritableString());
4611     vec.emplace_back("GetString", globalConst->GetGetString());
4612     vec.emplace_back("SetString", globalConst->GetSetString());
4613     vec.emplace_back("EnumerableString", globalConst->GetEnumerableString());
4614     vec.emplace_back("ConfigurableString", globalConst->GetConfigurableString());
4615     vec.emplace_back("NameString", globalConst->GetNameString());
4616     vec.emplace_back("ValueOfString", globalConst->GetValueOfString());
4617     vec.emplace_back("ToStringString", globalConst->GetToStringString());
4618     vec.emplace_back("ToLocaleStringString", globalConst->GetToLocaleStringString());
4619     vec.emplace_back("UndefinedString", globalConst->GetUndefinedString());
4620     vec.emplace_back("NullString", globalConst->GetNullString());
4621     vec.emplace_back("TrueString", globalConst->GetTrueString());
4622     vec.emplace_back("FalseString", globalConst->GetFalseString());
4623     vec.emplace_back("RegisterSymbols", GetRegisterSymbols().GetTaggedValue());
4624     vec.emplace_back("ThrowTypeError", GetThrowTypeError().GetTaggedValue());
4625     vec.emplace_back("GetPrototypeOfString", globalConst->GetGetPrototypeOfString());
4626     vec.emplace_back("SetPrototypeOfString", globalConst->GetSetPrototypeOfString());
4627     vec.emplace_back("IsExtensibleString", globalConst->GetIsExtensibleString());
4628     vec.emplace_back("PreventExtensionsString", globalConst->GetPreventExtensionsString());
4629     vec.emplace_back("GetOwnPropertyDescriptorString", globalConst->GetGetOwnPropertyDescriptorString());
4630     vec.emplace_back("DefinePropertyString", globalConst->GetDefinePropertyString());
4631     vec.emplace_back("HasString", globalConst->GetHasString());
4632     vec.emplace_back("DeletePropertyString", globalConst->GetDeletePropertyString());
4633     vec.emplace_back("EnumerateString", globalConst->GetEnumerateString());
4634     vec.emplace_back("OwnKeysString", globalConst->GetOwnKeysString());
4635     vec.emplace_back("ApplyString", globalConst->GetApplyString());
4636     vec.emplace_back("ProxyString", globalConst->GetProxyString());
4637     vec.emplace_back("RevokeString", globalConst->GetRevokeString());
4638     vec.emplace_back("ProxyConstructString", globalConst->GetProxyConstructString());
4639     vec.emplace_back("ProxyCallString", globalConst->GetProxyCallString());
4640     vec.emplace_back("DoneString", globalConst->GetDoneString());
4641     vec.emplace_back("NegativeZeroString", globalConst->GetNegativeZeroString());
4642     vec.emplace_back("NextString", globalConst->GetNextString());
4643     vec.emplace_back("PromiseThenString", globalConst->GetPromiseThenString());
4644     vec.emplace_back("PromiseFunction", GetPromiseFunction().GetTaggedValue());
4645     vec.emplace_back("PromiseReactionJob", GetPromiseReactionJob().GetTaggedValue());
4646     vec.emplace_back("PromiseResolveThenableJob", GetPromiseResolveThenableJob().GetTaggedValue());
4647     vec.emplace_back("DynamicImportJob", GetDynamicImportJob().GetTaggedValue());
4648     vec.emplace_back("ScriptJobString", globalConst->GetScriptJobString());
4649     vec.emplace_back("PromiseString", globalConst->GetPromiseString());
4650     vec.emplace_back("IdentityString", globalConst->GetIdentityString());
4651     vec.emplace_back("AsyncFunctionString", globalConst->GetAsyncFunctionString());
4652     vec.emplace_back("ThrowerString", globalConst->GetThrowerString());
4653     vec.emplace_back("Undefined", globalConst->GetUndefined());
4654     vec.emplace_back("ArrayListFunction", globalConst->GetArrayListFunction());
4655     vec.emplace_back("ArrayListIteratorPrototype", globalConst->GetArrayListIteratorPrototype());
4656     vec.emplace_back("HashMapIteratorPrototype", globalConst->GetHashMapIteratorPrototype());
4657     vec.emplace_back("HashSetIteratorPrototype", globalConst->GetHashSetIteratorPrototype());
4658     vec.emplace_back("LightWeightMapIteratorPrototype", globalConst->GetLightWeightMapIteratorPrototype());
4659     vec.emplace_back("LightWeightSetIteratorPrototype", globalConst->GetLightWeightSetIteratorPrototype());
4660     vec.emplace_back("TreeMapIteratorPrototype", globalConst->GetTreeMapIteratorPrototype());
4661     vec.emplace_back("TreeSetIteratorPrototype", globalConst->GetTreeSetIteratorPrototype());
4662     vec.emplace_back("VectorFunction", globalConst->GetVectorFunction());
4663     vec.emplace_back("VectorIteratorPrototype", globalConst->GetVectorIteratorPrototype());
4664     vec.emplace_back("QueueIteratorPrototype", globalConst->GetQueueIteratorPrototype());
4665     vec.emplace_back("PlainArrayIteratorPrototype", globalConst->GetPlainArrayIteratorPrototype());
4666     vec.emplace_back("DequeIteratorPrototype", globalConst->GetDequeIteratorPrototype());
4667     vec.emplace_back("StackIteratorPrototype", globalConst->GetStackIteratorPrototype());
4668     vec.emplace_back("LinkedListIteratorPrototype", globalConst->GetLinkedListIteratorPrototype());
4669     vec.emplace_back("ListIteratorPrototype", globalConst->GetListIteratorPrototype());
4670     vec.emplace_back("GlobalPatch", GetGlobalPatch().GetTaggedValue());
4671 }
4672 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4673 void JSDataView::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4674 {
4675     vec.emplace_back("data-view", GetDataView());
4676     vec.emplace_back("buffer", GetViewedArrayBuffer());
4677     vec.emplace_back("byte-length", JSTaggedValue(GetByteLength()));
4678     vec.emplace_back("byte-offset", JSTaggedValue(GetByteOffset()));
4679 }
4680 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4681 void JSArrayBuffer::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4682 {
4683     vec.emplace_back("buffer-data", GetArrayBufferData());
4684     vec.emplace_back("byte-length", JSTaggedValue(GetArrayBufferByteLength()));
4685     vec.emplace_back("shared", JSTaggedValue(GetShared()));
4686 }
4687 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4688 void PromiseReaction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4689 {
4690     vec.emplace_back("promise-capability", GetPromiseCapability());
4691     vec.emplace_back("handler", GetHandler());
4692     vec.emplace_back("type", JSTaggedValue(static_cast<int>(GetType())));
4693 }
4694 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4695 void PromiseCapability::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4696 {
4697     vec.emplace_back("promise", GetPromise());
4698     vec.emplace_back("resolve", GetResolve());
4699     vec.emplace_back("reject", GetReject());
4700 }
4701 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4702 void PromiseIteratorRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4703 {
4704     vec.emplace_back("iterator", GetIterator());
4705     vec.emplace_back("done", JSTaggedValue(GetDone()));
4706 }
4707 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4708 void PromiseRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4709 {
4710     vec.emplace_back("value", GetValue());
4711 }
4712 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4713 void ResolvingFunctionsRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4714 {
4715     vec.emplace_back("resolve-function", GetResolveFunction());
4716     vec.emplace_back("reject-function", GetRejectFunction());
4717 }
4718 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4719 void AsyncGeneratorRequest::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4720 {
4721     vec.emplace_back("completion", GetCompletion());
4722     vec.emplace_back("capability", GetCapability());
4723 }
4724 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4725 void AsyncIteratorRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4726 {
4727     vec.emplace_back("iterator", GetIterator());
4728     vec.emplace_back("nextmethod", GetNextMethod());
4729     vec.emplace_back("done", JSTaggedValue(GetDone()));
4730 }
4731 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4732 void JSAsyncFromSyncIterator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4733 {
4734     vec.emplace_back("synciteratorrecord", GetSyncIteratorRecord());
4735 }
4736 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4737 void JSAsyncFromSyncIterUnwarpFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4738 {
4739     vec.emplace_back("done", JSTaggedValue(GetDone()));
4740 }
4741 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4742 void JSPromise::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4743 {
4744     vec.emplace_back("promise-state", JSTaggedValue(static_cast<int>(GetPromiseState())));
4745     vec.emplace_back("promise-result", GetPromiseResult());
4746     vec.emplace_back("promise-fulfill-reactions", GetPromiseFulfillReactions());
4747     vec.emplace_back("promise-reject-reactions", GetPromiseRejectReactions());
4748     vec.emplace_back("promise-is-handled", JSTaggedValue(GetPromiseIsHandled()));
4749     JSObject::DumpForSnapshot(vec);
4750 }
4751 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4752 void JSPromiseReactionsFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4753 {
4754     vec.emplace_back("promise", GetPromise());
4755     vec.emplace_back("already-resolved", GetAlreadyResolved());
4756     JSObject::DumpForSnapshot(vec);
4757 }
4758 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4759 void JSAsyncGeneratorResNextRetProRstFtn::DumpForSnapshot(std::vector<std::pair<CString,
4760                                                           JSTaggedValue>> &vec) const
4761 {
4762     vec.emplace_back("async-generator-object", GetAsyncGeneratorObject());
4763     JSObject::DumpForSnapshot(vec);
4764 }
4765 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4766 void JSPromiseExecutorFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4767 {
4768     vec.emplace_back("capability", GetCapability());
4769     JSObject::DumpForSnapshot(vec);
4770 }
4771 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4772 void JSPromiseAllResolveElementFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4773 {
4774     vec.emplace_back("index", GetIndex());
4775     vec.emplace_back("values", GetValues());
4776     vec.emplace_back("capabilities", GetCapabilities());
4777     vec.emplace_back("remaining-elements", GetRemainingElements());
4778     vec.emplace_back("already-called", GetAlreadyCalled());
4779     JSObject::DumpForSnapshot(vec);
4780 }
4781 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4782 void JSPromiseAnyRejectElementFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4783 {
4784     vec.emplace_back("index", JSTaggedValue(GetIndex()));
4785     vec.emplace_back("errors", GetErrors());
4786     vec.emplace_back("capability", GetCapability());
4787     vec.emplace_back("remaining-elements", GetRemainingElements());
4788     vec.emplace_back("already-called", GetAlreadyCalled());
4789     JSObject::DumpForSnapshot(vec);
4790 }
4791 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4792 void JSPromiseAllSettledElementFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4793 {
4794     vec.emplace_back("already-called", GetAlreadyCalled());
4795     vec.emplace_back("index", JSTaggedValue(GetIndex()));
4796     vec.emplace_back("values", GetValues());
4797     vec.emplace_back("capability", GetCapability());
4798     vec.emplace_back("remaining-elements", GetRemainingElements());
4799     JSObject::DumpForSnapshot(vec);
4800 }
4801 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4802 void JSPromiseFinallyFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4803 {
4804     vec.emplace_back("constructor", GetConstructor());
4805     vec.emplace_back("onFinally", GetOnFinally());
4806     JSObject::DumpForSnapshot(vec);
4807 }
4808 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4809 void JSPromiseValueThunkOrThrowerFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4810 {
4811     vec.emplace_back("result", GetResult());
4812     JSObject::DumpForSnapshot(vec);
4813 }
4814 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4815 void MicroJobQueue::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4816 {
4817     vec.emplace_back("promise-job-queue", GetPromiseJobQueue());
4818     vec.emplace_back("script-job-queue", GetScriptJobQueue());
4819 }
4820 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4821 void PendingJob::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4822 {
4823     vec.emplace_back("job", GetJob());
4824     vec.emplace_back("arguments", GetArguments());
4825 }
4826 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4827 void CompletionRecord::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4828 {
4829     vec.emplace_back("value", GetValue());
4830     vec.emplace_back("type", JSTaggedValue(static_cast<int>(GetType())));
4831 }
4832 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4833 void JSProxyRevocFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4834 {
4835     vec.emplace_back("RevocableProxy", GetRevocableProxy());
4836 }
4837 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4838 void JSAsyncFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4839 {
4840     JSFunction::DumpForSnapshot(vec);
4841 }
4842 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4843 void JSAsyncAwaitStatusFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4844 {
4845     vec.emplace_back("AsyncContext", GetAsyncContext());
4846 }
4847 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4848 void JSGeneratorFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4849 {
4850     JSFunction::DumpForSnapshot(vec);
4851 }
4852 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4853 void JSAsyncGeneratorFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4854 {
4855     JSFunction::DumpForSnapshot(vec);
4856 }
4857 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4858 void JSIntlBoundFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4859 {
4860     vec.emplace_back("NumberFormat", GetNumberFormat());
4861     vec.emplace_back("DateTimeFormat", GetDateTimeFormat());
4862     vec.emplace_back("Collator", GetCollator());
4863     JSObject::DumpForSnapshot(vec);
4864 }
4865 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4866 void PropertyBox::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4867 {
4868     vec.emplace_back("Value", GetValue());
4869 }
4870 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4871 void PrototypeHandler::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4872 {
4873     vec.emplace_back("HandlerInfo", GetHandlerInfo());
4874     vec.emplace_back("ProtoCell", GetProtoCell());
4875     vec.emplace_back("Holder", GetHolder());
4876 }
4877 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4878 void TransitionHandler::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4879 {
4880     vec.emplace_back("HandlerInfo", GetHandlerInfo());
4881     vec.emplace_back("TransitionHClass", GetTransitionHClass());
4882 }
4883 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4884 void TransWithProtoHandler::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4885 {
4886     vec.emplace_back("HandlerInfo", GetHandlerInfo());
4887     vec.emplace_back("TransitionHClass", GetTransitionHClass());
4888     vec.emplace_back("ProtoCell", GetProtoCell());
4889 }
4890 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4891 void StoreTSHandler::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4892 {
4893     vec.emplace_back("HandlerInfo", GetHandlerInfo());
4894     vec.emplace_back("ProtoCell", GetProtoCell());
4895     vec.emplace_back("Holder", GetHolder());
4896 }
4897 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4898 void JSRealm::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4899 {
4900     vec.emplace_back("Value", GetValue());
4901     vec.emplace_back("GLobalEnv", GetGlobalEnv());
4902     JSObject::DumpForSnapshot(vec);
4903 }
4904 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4905 void JSIntl::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4906 {
4907     vec.emplace_back("FallbackSymbol", GetFallbackSymbol());
4908     JSObject::DumpForSnapshot(vec);
4909 }
4910 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4911 void JSLocale::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4912 {
4913     vec.emplace_back("IcuField", GetIcuField());
4914     JSObject::DumpForSnapshot(vec);
4915 }
4916 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4917 void JSDateTimeFormat::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4918 {
4919     // please update the NUM_OF_ITEMS if you change the items below
4920     constexpr int16_t NUM_OF_ITEMS = 11;
4921     vec.reserve(vec.size() + NUM_OF_ITEMS);
4922     vec.emplace_back("Locale", GetLocale());
4923     vec.emplace_back("Calendar", GetCalendar());
4924     vec.emplace_back("NumberingSystem", GetNumberingSystem());
4925     vec.emplace_back("TimeZone", GetTimeZone());
4926     vec.emplace_back("HourCycle", JSTaggedValue(static_cast<int>(GetHourCycle())));
4927     vec.emplace_back("LocaleIcu", GetLocaleIcu());
4928     vec.emplace_back("SimpleDateTimeFormatIcu", GetSimpleDateTimeFormatIcu());
4929     vec.emplace_back("Iso8601", GetIso8601());
4930     vec.emplace_back("DateStyle", JSTaggedValue(static_cast<int>(GetDateStyle())));
4931     vec.emplace_back("TimeStyle", JSTaggedValue(static_cast<int>(GetTimeStyle())));
4932     vec.emplace_back("BoundFormat", GetBoundFormat());
4933     JSObject::DumpForSnapshot(vec);
4934 }
4935 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4936 void JSRelativeTimeFormat::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4937 {
4938     vec.emplace_back("Locale", GetLocale());
4939     vec.emplace_back("NumberingSystem", GetNumberingSystem());
4940     vec.emplace_back("Style", JSTaggedValue(static_cast<int>(GetStyle())));
4941     vec.emplace_back("Numeric", JSTaggedValue(static_cast<int>(GetNumeric())));
4942     vec.emplace_back("IcuField", GetIcuField());
4943     JSObject::DumpForSnapshot(vec);
4944 }
4945 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4946 void JSNumberFormat::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4947 {
4948     // please update the NUM_OF_ITEMS if you change the items below
4949     constexpr int16_t NUM_OF_ITEMS = 20;
4950     vec.reserve(vec.size() + NUM_OF_ITEMS);
4951     vec.emplace_back("Locale", GetLocale());
4952     vec.emplace_back("NumberingSystem", GetNumberingSystem());
4953     vec.emplace_back("Style", JSTaggedValue(static_cast<int>(GetStyle())));
4954     vec.emplace_back("Currency", GetCurrency());
4955     vec.emplace_back("CurrencyDisplay", JSTaggedValue(static_cast<int>(GetCurrencyDisplay())));
4956     vec.emplace_back("CurrencySign", JSTaggedValue(static_cast<int>(GetCurrencySign())));
4957     vec.emplace_back("Unit", GetUnit());
4958     vec.emplace_back("UnitDisplay", JSTaggedValue(static_cast<int>(GetUnitDisplay())));
4959     vec.emplace_back("MinimumIntegerDigits", GetMinimumIntegerDigits());
4960     vec.emplace_back("MinimumFractionDigits", GetMinimumFractionDigits());
4961     vec.emplace_back("MaximumFractionDigits", GetMaximumFractionDigits());
4962     vec.emplace_back("MinimumSignificantDigits", GetMinimumSignificantDigits());
4963     vec.emplace_back("MaximumSignificantDigits", GetMaximumSignificantDigits());
4964     vec.emplace_back("UseGrouping", GetUseGrouping());
4965     vec.emplace_back("RoundingType", JSTaggedValue(static_cast<int>(GetRoundingType())));
4966     vec.emplace_back("Notation", JSTaggedValue(static_cast<int>(GetNotation())));
4967     vec.emplace_back("CompactDisplay", JSTaggedValue(static_cast<int>(GetCompactDisplay())));
4968     vec.emplace_back("SignDisplay", JSTaggedValue(static_cast<int>(GetSignDisplay())));
4969     vec.emplace_back("BoundFormat", GetBoundFormat());
4970     vec.emplace_back("IcuField", GetIcuField());
4971     JSObject::DumpForSnapshot(vec);
4972 }
4973 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4974 void JSCollator::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4975 {
4976     // please update the NUM_OF_ITEMS if you change the items below
4977     constexpr int16_t NUM_OF_ITEMS = 9;
4978     vec.reserve(vec.size() + NUM_OF_ITEMS);
4979     vec.emplace_back("IcuField", GetIcuField());
4980     vec.emplace_back("Locale", GetLocale());
4981     vec.emplace_back("Collation", GetCollation());
4982     vec.emplace_back("BoundCompare", GetBoundCompare());
4983     vec.emplace_back("CaseFirst", JSTaggedValue(static_cast<int>(GetCaseFirst())));
4984     vec.emplace_back("Usage", JSTaggedValue(static_cast<int>(GetUsage())));
4985     vec.emplace_back("Sensitivity", JSTaggedValue(static_cast<int>(GetSensitivity())));
4986     vec.emplace_back("IgnorePunctuation", JSTaggedValue(GetIgnorePunctuation()));
4987     vec.emplace_back("Numeric", JSTaggedValue(GetNumeric()));
4988     JSObject::DumpForSnapshot(vec);
4989 }
4990 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const4991 void JSPluralRules::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
4992 {
4993     // please update the NUM_OF_ITEMS if you change the items below
4994     constexpr int16_t NUM_OF_ITEMS = 10;
4995     vec.reserve(vec.size() + NUM_OF_ITEMS);
4996     vec.emplace_back("Locale", GetLocale());
4997     vec.emplace_back("MinimumIntegerDigits", GetMinimumIntegerDigits());
4998     vec.emplace_back("MinimumFractionDigits", GetMinimumFractionDigits());
4999     vec.emplace_back("MaximumFractionDigits", GetMaximumFractionDigits());
5000     vec.emplace_back("MinimumSignificantDigits", GetMinimumSignificantDigits());
5001     vec.emplace_back("MaximumSignificantDigits", GetMaximumSignificantDigits());
5002     vec.emplace_back("RoundingType", JSTaggedValue(static_cast<int>(GetRoundingType())));
5003     vec.emplace_back("IcuPR", GetIcuPR());
5004     vec.emplace_back("IcuNF", GetIcuNF());
5005     vec.emplace_back("Type", JSTaggedValue(static_cast<int>(GetType())));
5006     JSObject::DumpForSnapshot(vec);
5007 }
5008 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5009 void JSDisplayNames::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5010 {
5011     vec.emplace_back("Locale", GetLocale());
5012     vec.emplace_back("Type", JSTaggedValue(static_cast<int>(GetType())));
5013     vec.emplace_back("Style", JSTaggedValue(static_cast<int>(GetStyle())));
5014     vec.emplace_back("Fallback", JSTaggedValue(static_cast<int>(GetFallback())));
5015     vec.emplace_back("IcuLDN", GetIcuLDN());
5016     JSObject::DumpForSnapshot(vec);
5017 }
5018 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5019 void JSListFormat::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5020 {
5021     vec.emplace_back("Locale", GetLocale());
5022     vec.emplace_back("Type", JSTaggedValue(static_cast<int>(GetType())));
5023     vec.emplace_back("Style", JSTaggedValue(static_cast<int>(GetStyle())));
5024     vec.emplace_back("IcuLF", GetIcuLF());
5025     JSObject::DumpForSnapshot(vec);
5026 }
5027 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5028 void JSGeneratorObject::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5029 {
5030     vec.emplace_back("GeneratorContext", GetGeneratorContext());
5031     vec.emplace_back("ResumeResult", GetResumeResult());
5032     vec.emplace_back("GeneratorState", JSTaggedValue(static_cast<int>(GetGeneratorState())));
5033     vec.emplace_back("ResumeMode", JSTaggedValue(static_cast<int>(GetResumeMode())));
5034     JSObject::DumpForSnapshot(vec);
5035 }
5036 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5037 void JSAsyncGeneratorObject::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5038 {
5039     vec.emplace_back("GeneratorContext", GetGeneratorContext());
5040     vec.emplace_back("AsyncGeneratorQueue", GetAsyncGeneratorQueue());
5041     vec.emplace_back("GeneratorBrand", GetGeneratorBrand());
5042     vec.emplace_back("ResumeResult", GetResumeResult());
5043     vec.emplace_back("AsyncGeneratorState", JSTaggedValue(static_cast<int>(GetAsyncGeneratorState())));
5044     vec.emplace_back("ResumeMode", JSTaggedValue(static_cast<int>(GetResumeMode())));
5045     JSObject::DumpForSnapshot(vec);
5046 }
5047 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5048 void JSAsyncFuncObject::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5049 {
5050     vec.emplace_back("Promise", GetPromise());
5051 }
5052 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5053 void GeneratorContext::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5054 {
5055     // please update the NUM_OF_ITEMS if you change the items below
5056     constexpr int16_t NUM_OF_ITEMS = 8;
5057     vec.reserve(vec.size() + NUM_OF_ITEMS);
5058     vec.emplace_back("RegsArray", GetRegsArray());
5059     vec.emplace_back("Method", GetMethod());
5060     vec.emplace_back("This", GetThis());
5061     vec.emplace_back("Acc", GetAcc());
5062     vec.emplace_back("GeneratorObject", GetGeneratorObject());
5063     vec.emplace_back("LexicalEnv", GetLexicalEnv());
5064     vec.emplace_back("NRegs",  JSTaggedValue(GetNRegs()));
5065     vec.emplace_back("BCOffset",  JSTaggedValue(GetBCOffset()));
5066 }
5067 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5068 void ProtoChangeMarker::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5069 {
5070     vec.emplace_back("Promise", JSTaggedValue(GetHasChanged()));
5071 }
5072 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5073 void ProtoChangeDetails::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5074 {
5075     vec.emplace_back("ChangeListener", GetChangeListener());
5076     vec.emplace_back("RegisterIndex", JSTaggedValue(GetRegisterIndex()));
5077 }
5078 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5079 void MachineCode::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5080 {
5081     vec.emplace_back("InstructionSizeInBytes", JSTaggedValue(GetInstructionSizeInBytes()));
5082 }
5083 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5084 void ClassInfoExtractor::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5085 {
5086     // please update the NUM_OF_ITEMS if you change the items below
5087     constexpr int16_t NUM_OF_ITEMS = 6;
5088     vec.reserve(vec.size() + NUM_OF_ITEMS);
5089     vec.emplace_back("NonStaticKeys", GetNonStaticKeys());
5090     vec.emplace_back("NonStaticProperties", GetNonStaticProperties());
5091     vec.emplace_back("NonStaticElements", GetNonStaticElements());
5092     vec.emplace_back("StaticKeys", GetStaticKeys());
5093     vec.emplace_back("StaticProperties", GetStaticProperties());
5094     vec.emplace_back("StaticElements", GetStaticElements());
5095 }
5096 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5097 void TSObjectType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5098 {
5099     vec.emplace_back("ObjLayoutInfo", GetObjLayoutInfo());
5100     vec.emplace_back("HClass", GetHClass());
5101 }
5102 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5103 void TSClassType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5104 {
5105     // please update the NUM_OF_ITEMS if you change the items below
5106     constexpr int16_t NUM_OF_ITEMS = 5;
5107     vec.reserve(vec.size() + NUM_OF_ITEMS);
5108     vec.emplace_back("InstanceType", GetInstanceType());
5109     vec.emplace_back("ConstructorType", GetConstructorType());
5110     vec.emplace_back("PrototypeType", GetPrototypeType());
5111     vec.emplace_back("ExtensionGT", JSTaggedValue(GetExtensionGT().GetType()));
5112     vec.emplace_back("HasLinked", JSTaggedValue(GetHasLinked()));
5113 }
5114 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5115 void TSInterfaceType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5116 {
5117     vec.emplace_back("Fields", GetFields());
5118     vec.emplace_back("Extends", GetExtends());
5119 }
5120 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5121 void TSClassInstanceType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5122 {
5123     vec.emplace_back("ClassGT", JSTaggedValue(GetClassGT().GetType()));
5124 }
5125 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5126 void TSUnionType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5127 {
5128     vec.emplace_back("ComponentTypes", GetComponents());
5129 }
5130 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5131 void TSFunctionType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5132 {
5133     // please update the NUM_OF_ITEMS if you change the items below
5134     constexpr int16_t NUM_OF_ITEMS = 5;
5135     vec.reserve(vec.size() + NUM_OF_ITEMS);
5136     vec.emplace_back("Name", GetName());
5137     vec.emplace_back("ParameterTypes", GetParameterTypes());
5138     vec.emplace_back("ReturnGT", JSTaggedValue(GetReturnGT().GetType()));
5139     vec.emplace_back("ThisGT", JSTaggedValue(GetThisGT().GetType()));
5140     vec.emplace_back("BitFiled", JSTaggedValue(GetBitField()));
5141 }
5142 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5143 void TSArrayType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5144 {
5145     vec.emplace_back("ParameterTypeRef", JSTaggedValue(GetElementGT().GetType()));
5146 }
5147 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5148 void TSIteratorInstanceType::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5149 {
5150     vec.emplace_back("kindGT", JSTaggedValue(GetKindGT().GetType()));
5151     vec.emplace_back("elementGT", JSTaggedValue(GetElementGT().GetType()));
5152 }
5153 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5154 void SourceTextModule::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5155 {
5156     // please update the NUM_OF_ITEMS if you change the items below
5157     constexpr int16_t NUM_OF_ITEMS = 14;
5158     vec.reserve(vec.size() + NUM_OF_ITEMS);
5159     vec.emplace_back("Environment", GetEnvironment());
5160     vec.emplace_back("Namespace", GetNamespace());
5161     vec.emplace_back("EcmaModuleFilename", GetEcmaModuleFilename());
5162     vec.emplace_back("EcmaModuleRecordName", GetEcmaModuleRecordName());
5163     vec.emplace_back("RequestedModules", GetRequestedModules());
5164     vec.emplace_back("ImportEntries", GetImportEntries());
5165     vec.emplace_back("LocalExportEntries", GetLocalExportEntries());
5166     vec.emplace_back("IndirectExportEntries", GetIndirectExportEntries());
5167     vec.emplace_back("StarExportEntries", GetStarExportEntries());
5168     vec.emplace_back("Status", JSTaggedValue(static_cast<int32_t>(GetStatus())));
5169     vec.emplace_back("EvaluationError", JSTaggedValue(GetEvaluationError()));
5170     vec.emplace_back("DFSIndex", JSTaggedValue(GetDFSIndex()));
5171     vec.emplace_back("DFSAncestorIndex", JSTaggedValue(GetDFSAncestorIndex()));
5172     vec.emplace_back("NameDictionary", GetNameDictionary());
5173 }
5174 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5175 void ImportEntry::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5176 {
5177     vec.emplace_back("ModuleRequest", GetModuleRequest());
5178     vec.emplace_back("ImportName", GetImportName());
5179     vec.emplace_back("LocalName", GetLocalName());
5180 }
5181 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5182 void LocalExportEntry::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5183 {
5184     vec.emplace_back("ExportName", GetExportName());
5185     vec.emplace_back("LocalName", GetLocalName());
5186 }
5187 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5188 void IndirectExportEntry::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5189 {
5190     vec.emplace_back("ExportName", GetExportName());
5191     vec.emplace_back("ModuleRequest", GetModuleRequest());
5192     vec.emplace_back("ImportName", GetImportName());
5193 }
5194 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5195 void StarExportEntry::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5196 {
5197     vec.emplace_back("ModuleRequest", GetModuleRequest());
5198 }
5199 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5200 void ResolvedBinding::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5201 {
5202     vec.emplace_back("Module", GetModule());
5203     vec.emplace_back("BindingName", GetBindingName());
5204 }
5205 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5206 void ResolvedIndexBinding::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5207 {
5208     vec.emplace_back("Module", GetModule());
5209     vec.emplace_back("Index", JSTaggedValue(GetIndex()));
5210 }
5211 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5212 void ModuleNamespace::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5213 {
5214     vec.emplace_back("Module", GetModule());
5215     vec.emplace_back("Exports", GetExports());
5216 }
5217 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5218 void CjsModule::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5219 {
5220     vec.emplace_back("Id", GetId());
5221     vec.emplace_back("Path", GetPath());
5222     vec.emplace_back("Exports", GetExports());
5223     vec.emplace_back("Filename", GetFilename());
5224 }
5225 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5226 void CjsExports::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5227 {
5228     vec.emplace_back("Exports", GetExports());
5229 }
5230 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5231 void CjsRequire::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5232 {
5233     vec.emplace_back("Cache", GetCache());
5234     vec.emplace_back("Parent", GetParent());
5235 }
5236 
DumpForSnapshot(std::vector<std::pair<CString,JSTaggedValue>> & vec) const5237 void ClassLiteral::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
5238 {
5239     vec.emplace_back("Array", GetArray());
5240     vec.emplace_back("IsAOTUsed", GetIsAOTUsed());
5241 }
5242 }  // namespace panda::ecmascript
5243