• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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/class_info_extractor.h"
23 #include "ecmascript/jspandafile/program_object-inl.h"
24 #include "ecmascript/ecma_module.h"
25 #include "ecmascript/ecma_vm.h"
26 #include "ecmascript/global_dictionary-inl.h"
27 #include "ecmascript/global_env.h"
28 #include "ecmascript/ic/ic_handler.h"
29 #include "ecmascript/ic/property_box.h"
30 #include "ecmascript/ic/proto_change_details.h"
31 #include "ecmascript/interpreter/frame_handler.h"
32 #include "ecmascript/jobs/micro_job_queue.h"
33 #include "ecmascript/jobs/pending_job.h"
34 #include "ecmascript/js_api_tree_map.h"
35 #include "ecmascript/js_api_tree_map_iterator.h"
36 #include "ecmascript/js_api_tree_set.h"
37 #include "ecmascript/js_api_tree_set_iterator.h"
38 #include "ecmascript/js_array.h"
39 #include "ecmascript/js_array_iterator.h"
40 #include "ecmascript/js_arraybuffer.h"
41 #include "ecmascript/js_api_arraylist.h"
42 #include "ecmascript/js_api_arraylist_iterator.h"
43 #include "ecmascript/js_async_function.h"
44 #include "ecmascript/js_bigint.h"
45 #include "ecmascript/js_collator.h"
46 #include "ecmascript/js_dataview.h"
47 #include "ecmascript/js_date.h"
48 #include "ecmascript/js_date_time_format.h"
49 #include "ecmascript/js_for_in_iterator.h"
50 #include "ecmascript/js_function.h"
51 #include "ecmascript/js_generator_object.h"
52 #include "ecmascript/js_global_object.h"
53 #include "ecmascript/js_handle.h"
54 #include "ecmascript/js_intl.h"
55 #include "ecmascript/js_locale.h"
56 #include "ecmascript/js_map.h"
57 #include "ecmascript/js_map_iterator.h"
58 #include "ecmascript/js_number_format.h"
59 #include "ecmascript/js_object-inl.h"
60 #include "ecmascript/js_plural_rules.h"
61 #include "ecmascript/js_primitive_ref.h"
62 #include "ecmascript/js_promise.h"
63 #include "ecmascript/js_realm.h"
64 #include "ecmascript/js_regexp.h"
65 #include "ecmascript/js_relative_time_format.h"
66 #include "ecmascript/js_set.h"
67 #include "ecmascript/js_set_iterator.h"
68 #include "ecmascript/js_string_iterator.h"
69 #include "ecmascript/js_tagged_number.h"
70 #include "ecmascript/js_tagged_value-inl.h"
71 #include "ecmascript/js_thread.h"
72 #include "ecmascript/js_typed_array.h"
73 #include "ecmascript/js_weak_container.h"
74 #include "ecmascript/layout_info-inl.h"
75 #include "ecmascript/lexical_env.h"
76 #include "ecmascript/linked_hash_table-inl.h"
77 #include "ecmascript/mem/assert_scope-inl.h"
78 #include "ecmascript/mem/c_containers.h"
79 #include "ecmascript/mem/machine_code.h"
80 #include "ecmascript/tagged_array.h"
81 #include "ecmascript/tagged_dictionary.h"
82 #include "ecmascript/tagged_tree-inl.h"
83 #include "ecmascript/template_map.h"
84 #include "ecmascript/transitions_dictionary.h"
85 #include "ecmascript/ts_types/ts_type.h"
86 
87 namespace panda::ecmascript {
88 using MicroJobQueue = panda::ecmascript::job::MicroJobQueue;
89 using PendingJob = panda::ecmascript::job::PendingJob;
90 
91 static constexpr uint32_t DUMP_TYPE_OFFSET = 12;
92 static constexpr uint32_t DUMP_PROPERTY_OFFSET = 20;
93 static constexpr uint32_t DUMP_ELEMENT_OFFSET = 2;
94 
DumpJSType(JSType type)95 CString JSHClass::DumpJSType(JSType type)
96 {
97     switch (type) {
98         case JSType::HCLASS:
99             return "JSHClass";
100         case JSType::TAGGED_ARRAY:
101             return "TaggedArray";
102         case JSType::TAGGED_DICTIONARY:
103             return "TaggedDictionary";
104         case JSType::STRING:
105             return "BaseString";
106         case JSType::JS_NATIVE_POINTER:
107             return "NativePointer";
108         case JSType::JS_OBJECT:
109             return "Object";
110         case JSType::JS_FUNCTION_BASE:
111             return "Function Base";
112         case JSType::JS_FUNCTION:
113             return "Function";
114         case JSType::JS_ERROR:
115             return "Error";
116         case JSType::JS_EVAL_ERROR:
117             return "Eval Error";
118         case JSType::JS_RANGE_ERROR:
119             return "Range Error";
120         case JSType::JS_TYPE_ERROR:
121             return "Type Error";
122         case JSType::JS_REFERENCE_ERROR:
123             return "Reference Error";
124         case JSType::JS_URI_ERROR:
125             return "Uri Error";
126         case JSType::JS_SYNTAX_ERROR:
127             return "Syntax Error";
128         case JSType::JS_REG_EXP:
129             return "Regexp";
130         case JSType::JS_SET:
131             return "Set";
132         case JSType::JS_MAP:
133             return "Map";
134         case JSType::JS_WEAK_SET:
135             return "WeakSet";
136         case JSType::JS_WEAK_MAP:
137             return "WeakMap";
138         case JSType::JS_DATE:
139             return "Date";
140         case JSType::JS_BOUND_FUNCTION:
141             return "Bound Function";
142         case JSType::JS_ARRAY:
143             return "Array";
144         case JSType::JS_TYPED_ARRAY:
145             return "Typed Array";
146         case JSType::JS_INT8_ARRAY:
147             return "Int8 Array";
148         case JSType::JS_UINT8_ARRAY:
149             return "Uint8 Array";
150         case JSType::JS_UINT8_CLAMPED_ARRAY:
151             return "Uint8 Clamped Array";
152         case JSType::JS_INT16_ARRAY:
153             return "Int16 Array";
154         case JSType::JS_UINT16_ARRAY:
155             return "Uint16 Array";
156         case JSType::JS_INT32_ARRAY:
157             return "Int32 Array";
158         case JSType::JS_UINT32_ARRAY:
159             return "Uint32 Array";
160         case JSType::BIGINT:
161             return "BigInt";
162         case JSType::JS_FLOAT32_ARRAY:
163             return "Float32 Array";
164         case JSType::JS_FLOAT64_ARRAY:
165             return "Float64 Array";
166         case JSType::JS_ARGUMENTS:
167             return "Arguments";
168         case JSType::JS_PROXY:
169             return "Proxy";
170         case JSType::JS_PRIMITIVE_REF:
171             return "Primitive";
172         case JSType::JS_DATA_VIEW:
173             return "DataView";
174         case JSType::JS_ITERATOR:
175             return "Iterator";
176         case JSType::JS_FORIN_ITERATOR:
177             return "ForinInterator";
178         case JSType::JS_MAP_ITERATOR:
179             return "MapIterator";
180         case JSType::JS_SET_ITERATOR:
181             return "SetIterator";
182         case JSType::JS_ARRAY_ITERATOR:
183             return "ArrayIterator";
184         case JSType::JS_STRING_ITERATOR:
185             return "StringIterator";
186         case JSType::JS_ARRAY_BUFFER:
187             return "ArrayBuffer";
188         case JSType::JS_PROXY_REVOC_FUNCTION:
189             return "ProxyRevocFunction";
190         case JSType::PROMISE_REACTIONS:
191             return "PromiseReaction";
192         case JSType::PROMISE_CAPABILITY:
193             return "PromiseCapability";
194         case JSType::PROMISE_ITERATOR_RECORD:
195             return "PromiseIteratorRecord";
196         case JSType::PROMISE_RECORD:
197             return "PromiseRecord";
198         case JSType::RESOLVING_FUNCTIONS_RECORD:
199             return "ResolvingFunctionsRecord";
200         case JSType::JS_PROMISE:
201             return "Promise";
202         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
203             return "PromiseReactionsFunction";
204         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
205             return "PromiseExecutorFunction";
206         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
207             return "PromiseAllResolveElementFunction";
208         case JSType::MICRO_JOB_QUEUE:
209             return "MicroJobQueue";
210         case JSType::PENDING_JOB:
211             return "PendingJob";
212         case JSType::COMPLETION_RECORD:
213             return "CompletionRecord";
214         case JSType::GLOBAL_ENV:
215             return "GlobalEnv";
216         case JSType::ACCESSOR_DATA:
217             return "AccessorData";
218         case JSType::INTERNAL_ACCESSOR:
219             return "InternalAccessor";
220         case JSType::SYMBOL:
221             return "Symbol";
222         case JSType::PROPERTY_BOX:
223             return "PropertyBox";
224         case JSType::JS_ASYNC_FUNCTION:
225             return "AsyncFunction";
226         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
227             return "AsyncAwaitStatusFunction";
228         case JSType::JS_ASYNC_FUNC_OBJECT:
229             return "AsyncFunctionObject";
230         case JSType::JS_REALM:
231             return "Realm";
232         case JSType::JS_GLOBAL_OBJECT:
233             return "GlobalObject";
234         case JSType::JS_INTL:
235             return "JSIntl";
236         case JSType::JS_LOCALE:
237             return "JSLocale";
238         case JSType::JS_DATE_TIME_FORMAT:
239             return "JSDateTimeFormat";
240         case JSType::JS_RELATIVE_TIME_FORMAT:
241             return "JSRelativeTimeFormat";
242         case JSType::JS_NUMBER_FORMAT:
243             return "JSNumberFormat";
244         case JSType::JS_COLLATOR:
245             return "JSCollator";
246         case JSType::JS_PLURAL_RULES:
247             return "JSPluralRules";
248         case JSType::JS_GENERATOR_OBJECT:
249             return "JSGeneratorObject";
250         case JSType::JS_GENERATOR_CONTEXT:
251             return "JSGeneratorContext";
252         case JSType::PROTO_CHANGE_MARKER:
253             return "ProtoChangeMarker";
254         case JSType::PROTOTYPE_INFO:
255             return "PrototypeInfo";
256         case JSType::PROGRAM:
257             return "program";
258         case JSType::MACHINE_CODE_OBJECT:
259             return "MachineCode";
260         case JSType::ECMA_MODULE:
261             return "EcmaModule";
262         case JSType::CLASS_INFO_EXTRACTOR:
263             return "ClassInfoExtractor";
264         case JSType::JS_API_ARRAY_LIST:
265             return "ArrayList";
266         case JSType::TS_OBJECT_TYPE:
267             return "TSObjectType";
268         case JSType::TS_CLASS_TYPE:
269             return "TSClassType";
270         case JSType::TS_INTERFACE_TYPE:
271             return "TSInterfaceType";
272         case JSType::TS_IMPORT_TYPE:
273             return "TSImportType";
274         case JSType::TS_CLASS_INSTANCE_TYPE:
275             return "TSClassInstanceType";
276         case JSType::TS_UNION_TYPE:
277             return "TSUnionType";
278         case JSType::JS_API_ARRAYLIST_ITERATOR:
279             return "JSArraylistIterator";
280         case JSType::JS_API_TREE_MAP:
281             return "TreeMap";
282         case JSType::JS_API_TREE_SET:
283             return "TreeSet";
284         case JSType::JS_API_TREEMAP_ITERATOR:
285             return "TreeMapIterator";
286         case JSType::JS_API_TREESET_ITERATOR:
287             return "TreeSetIterator";
288         default: {
289             CString ret = "unknown type ";
290             return ret + static_cast<char>(type);
291         }
292     }
293 }
294 
DumpArrayClass(JSThread * thread,const TaggedArray * arr,std::ostream & os)295 static void DumpArrayClass(JSThread *thread, const TaggedArray *arr, std::ostream &os)
296 {
297     DISALLOW_GARBAGE_COLLECTION;
298     uint32_t len = arr->GetLength();
299     os << " <TaggedArray[" << std::dec << len << "]>\n";
300     for (uint32_t i = 0; i < len; i++) {
301         JSTaggedValue val(arr->Get(i));
302         if (!val.IsHole()) {
303             os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
304             val.DumpTaggedValue(thread, os);
305             os << "\n";
306         }
307     }
308 }
309 
DumpStringClass(const EcmaString * str,std::ostream & os)310 static void DumpStringClass(const EcmaString *str, std::ostream &os)
311 {
312     DISALLOW_GARBAGE_COLLECTION;
313     CString string = ConvertToString(str);
314     os << string;
315 }
316 
DumpPropertyKey(JSTaggedValue key,std::ostream & os)317 static void DumpPropertyKey(JSTaggedValue key, std::ostream &os)
318 {
319     if (key.IsString()) {
320         DumpStringClass(EcmaString::Cast(key.GetTaggedObject()), os);
321     } else if (key.IsSymbol()) {
322         JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
323         DumpStringClass(EcmaString::Cast(sym->GetDescription().GetTaggedObject()), os);
324     } else {
325         UNREACHABLE();
326     }
327 }
328 
DumpHClass(JSThread * thread,const JSHClass * jshclass,std::ostream & os,bool withDetail)329 static void DumpHClass(JSThread *thread, const JSHClass *jshclass, std::ostream &os, bool withDetail)
330 {
331     DISALLOW_GARBAGE_COLLECTION;
332     os << "JSHClass :" << std::setw(DUMP_TYPE_OFFSET);
333     os << "Type :" << JSHClass::DumpJSType(jshclass->GetObjectType()) << "\n";
334 
335     os << " - Prototype :" << std::setw(DUMP_TYPE_OFFSET);
336     jshclass->GetPrototype().DumpTaggedValue(thread, os);
337     os << "\n";
338     os << " - PropertyDescriptors :" << std::setw(DUMP_TYPE_OFFSET);
339     JSTaggedValue attrs = jshclass->GetLayout();
340     attrs.DumpTaggedValue(thread, os);
341     os << "\n";
342     if (withDetail && !attrs.IsNull()) {
343         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
344         layoutInfo->Dump(thread, os);
345     }
346     os << " - Transitions :" << std::setw(DUMP_TYPE_OFFSET);
347     JSTaggedValue transtions = jshclass->GetTransitions();
348     transtions.DumpTaggedValue(thread, os);
349     os << "\n";
350     if (withDetail && !transtions.IsNull()) {
351         transtions.Dump(thread, os);
352     }
353 
354     os << " - Flags : " << std::setw(DUMP_TYPE_OFFSET);
355     os << "Ctor :" << jshclass->IsConstructor();
356     os << "| Callable :" << jshclass->IsCallable();
357     os << "| Extensible :" << jshclass->IsExtensible();
358     os << "| ElementRepresentation :" << static_cast<int>(jshclass->GetElementRepresentation());
359     os << "| NumberOfProps :" << std::dec << jshclass->NumberOfProps();
360     os << "| InlinedProperties :" << std::dec << jshclass->GetInlinedProperties();
361     os << "\n";
362 }
363 
DumpDynClass(JSThread * thread,TaggedObject * obj,std::ostream & os)364 static void DumpDynClass(JSThread *thread, TaggedObject *obj, std::ostream &os)
365 {
366     JSHClass *hclass = obj->GetClass();
367     os << "JSHClass :" << std::setw(DUMP_TYPE_OFFSET) << " klass_(" << std::hex << hclass << ")\n";
368     DumpHClass(thread, hclass, os, true);
369 }
370 
DumpAttr(const PropertyAttributes & attr,bool fastMode,std::ostream & os)371 static void DumpAttr(const PropertyAttributes &attr, bool fastMode, std::ostream &os)
372 {
373     if (attr.IsAccessor()) {
374         os << "(Accessor) ";
375     }
376 
377     os << "Attr(";
378     if (attr.IsNoneAttributes()) {
379         os << "NONE";
380     }
381     if (attr.IsWritable()) {
382         os << "W";
383     }
384     if (attr.IsEnumerable()) {
385         os << "E";
386     }
387     if (attr.IsConfigurable()) {
388         os << "C";
389     }
390     os << ")";
391 
392     os << " InlinedProps: " << attr.IsInlinedProps();
393 
394     if (fastMode) {
395         os << " Order: " << std::dec << attr.GetOffset();
396         os << " SortedIndex: " << std::dec << attr.GetSortedIndex();
397     } else {
398         os << " Order: " << std::dec << attr.GetDictionaryOrder();
399     }
400 }
401 
DumpObject(JSThread * thread,TaggedObject * obj,std::ostream & os)402 static void DumpObject(JSThread *thread, TaggedObject *obj, std::ostream &os)
403 {
404     DISALLOW_GARBAGE_COLLECTION;
405     auto jsHclass = obj->GetClass();
406     JSType type = jsHclass->GetObjectType();
407 
408     switch (type) {
409         case JSType::HCLASS:
410             return DumpDynClass(thread, obj, os);
411         case JSType::TAGGED_ARRAY:
412         case JSType::TAGGED_DICTIONARY:
413         case JSType::TEMPLATE_MAP:
414             DumpArrayClass(thread, TaggedArray::Cast(obj), os);
415             break;
416         case JSType::STRING:
417             DumpStringClass(EcmaString::Cast(obj), os);
418             os << "\n";
419             break;
420         case JSType::JS_NATIVE_POINTER:
421             break;
422         case JSType::JS_OBJECT:
423         case JSType::JS_GLOBAL_OBJECT:
424         case JSType::JS_ERROR:
425         case JSType::JS_EVAL_ERROR:
426         case JSType::JS_RANGE_ERROR:
427         case JSType::JS_TYPE_ERROR:
428         case JSType::JS_REFERENCE_ERROR:
429         case JSType::JS_URI_ERROR:
430         case JSType::JS_SYNTAX_ERROR:
431         case JSType::JS_ARGUMENTS:
432         case JSType::JS_FUNCTION_BASE:
433             JSObject::Cast(obj)->Dump(thread, os);
434             break;
435         case JSType::GLOBAL_ENV:
436             GlobalEnv::Cast(obj)->Dump(thread, os);
437             break;
438         case JSType::ACCESSOR_DATA:
439             break;
440         case JSType::JS_FUNCTION:
441             JSFunction::Cast(obj)->Dump(thread, os);
442             break;
443         case JSType::JS_BOUND_FUNCTION:
444             JSBoundFunction::Cast(obj)->Dump(thread, os);
445             break;
446         case JSType::JS_SET:
447             JSSet::Cast(obj)->Dump(thread, os);
448             break;
449         case JSType::JS_MAP:
450             JSMap::Cast(obj)->Dump(thread, os);
451             break;
452         case JSType::JS_WEAK_SET:
453             JSWeakSet::Cast(obj)->Dump(thread, os);
454             break;
455         case JSType::JS_WEAK_MAP:
456             JSWeakMap::Cast(obj)->Dump(thread, os);
457             break;
458         case JSType::JS_REG_EXP:
459             JSRegExp::Cast(obj)->Dump(thread, os);
460             break;
461         case JSType::JS_DATE:
462             JSDate::Cast(obj)->Dump(thread, os);
463             break;
464         case JSType::JS_ARRAY:
465             JSArray::Cast(obj)->Dump(thread, os);
466             break;
467         case JSType::JS_TYPED_ARRAY:
468         case JSType::JS_INT8_ARRAY:
469         case JSType::JS_UINT8_ARRAY:
470         case JSType::JS_UINT8_CLAMPED_ARRAY:
471         case JSType::JS_INT16_ARRAY:
472         case JSType::JS_UINT16_ARRAY:
473         case JSType::JS_INT32_ARRAY:
474         case JSType::JS_UINT32_ARRAY:
475         case JSType::JS_FLOAT32_ARRAY:
476         case JSType::JS_FLOAT64_ARRAY:
477             JSTypedArray::Cast(obj)->Dump(thread, os);
478             break;
479         case JSType::BIGINT:
480             BigInt::Cast(obj)->Dump(thread, os);
481             break;
482         case JSType::JS_PROXY:
483             JSProxy::Cast(obj)->Dump(thread, os);
484             break;
485         case JSType::JS_PRIMITIVE_REF:
486             JSPrimitiveRef::Cast(obj)->Dump(thread, os);
487             break;
488         case JSType::SYMBOL:
489             JSSymbol::Cast(obj)->Dump(thread, os);
490             break;
491         case JSType::JS_DATA_VIEW:
492             JSDataView::Cast(obj)->Dump(thread, os);
493             break;
494         case JSType::JS_ARRAY_BUFFER:
495             JSArrayBuffer::Cast(obj)->Dump(thread, os);
496             break;
497         case JSType::PROMISE_REACTIONS:
498             PromiseReaction::Cast(obj)->Dump(thread, os);
499             break;
500         case JSType::PROMISE_CAPABILITY:
501             PromiseCapability::Cast(obj)->Dump(thread, os);
502             break;
503         case JSType::PROMISE_ITERATOR_RECORD:
504             PromiseIteratorRecord::Cast(obj)->Dump(thread, os);
505             break;
506         case JSType::PROMISE_RECORD:
507             PromiseRecord::Cast(obj)->Dump(thread, os);
508             break;
509         case JSType::RESOLVING_FUNCTIONS_RECORD:
510             ResolvingFunctionsRecord::Cast(obj)->Dump(thread, os);
511             break;
512         case JSType::JS_PROMISE:
513             JSPromise::Cast(obj)->Dump(thread, os);
514             break;
515         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
516             JSPromiseReactionsFunction::Cast(obj)->Dump(thread, os);
517             break;
518         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
519             JSPromiseExecutorFunction::Cast(obj)->Dump(thread, os);
520             break;
521         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
522             JSPromiseAllResolveElementFunction::Cast(obj)->Dump(thread, os);
523             break;
524         case JSType::MICRO_JOB_QUEUE:
525             MicroJobQueue::Cast(obj)->Dump(thread, os);
526             break;
527         case JSType::PENDING_JOB:
528             PendingJob::Cast(obj)->Dump(thread, os);
529             break;
530         case JSType::COMPLETION_RECORD:
531             CompletionRecord::Cast(obj)->Dump(thread, os);
532             break;
533         case JSType::JS_PROXY_REVOC_FUNCTION:
534             JSProxyRevocFunction::Cast(obj)->Dump(thread, os);
535             break;
536         case JSType::JS_ASYNC_FUNCTION:
537             JSAsyncFunction::Cast(obj)->Dump(thread, os);
538             break;
539         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
540             JSAsyncAwaitStatusFunction::Cast(obj)->Dump(thread, os);
541             break;
542         case JSType::JS_GENERATOR_FUNCTION:
543             JSGeneratorFunction::Cast(obj)->Dump(thread, os);
544             break;
545         case JSType::JS_INTL_BOUND_FUNCTION:
546             JSIntlBoundFunction::Cast(obj)->Dump(thread, os);
547             break;
548         case JSType::JS_ITERATOR:
549             break;
550         case JSType::JS_FORIN_ITERATOR:
551             JSForInIterator::Cast(obj)->Dump(thread, os);
552             break;
553         case JSType::JS_MAP_ITERATOR:
554             JSMapIterator::Cast(obj)->Dump(thread, os);
555             break;
556         case JSType::JS_SET_ITERATOR:
557             JSSetIterator::Cast(obj)->Dump(thread, os);
558             break;
559         case JSType::JS_ARRAY_ITERATOR:
560             JSArrayIterator::Cast(obj)->Dump(thread, os);
561             break;
562         case JSType::JS_STRING_ITERATOR:
563             JSStringIterator::Cast(obj)->Dump(thread, os);
564             break;
565         case JSType::PROTOTYPE_HANDLER:
566             PrototypeHandler::Cast(obj)->Dump(thread, os);
567             break;
568         case JSType::TRANSITION_HANDLER:
569             TransitionHandler::Cast(obj)->Dump(thread, os);
570             break;
571         case JSType::PROPERTY_BOX:
572             PropertyBox::Cast(obj)->Dump(thread, os);
573             break;
574         case JSType::JS_REALM:
575             JSRealm::Cast(obj)->Dump(thread, os);
576             break;
577         case JSType::JS_INTL:
578             JSIntl::Cast(obj)->Dump(thread, os);
579             break;
580         case JSType::JS_LOCALE:
581             JSLocale::Cast(obj)->Dump(thread, os);
582             break;
583         case JSType::JS_DATE_TIME_FORMAT:
584             JSDateTimeFormat::Cast(obj)->Dump(thread, os);
585             break;
586         case JSType::JS_RELATIVE_TIME_FORMAT:
587             JSRelativeTimeFormat::Cast(obj)->Dump(thread, os);
588             break;
589         case JSType::JS_NUMBER_FORMAT:
590             JSNumberFormat::Cast(obj)->Dump(thread, os);
591             break;
592         case JSType::JS_COLLATOR:
593             JSCollator::Cast(obj)->Dump(thread, os);
594             break;
595         case JSType::JS_PLURAL_RULES:
596             JSPluralRules::Cast(obj)->Dump(thread, os);
597             break;
598         case JSType::JS_GENERATOR_OBJECT:
599             JSGeneratorObject::Cast(obj)->Dump(thread, os);
600             break;
601         case JSType::JS_ASYNC_FUNC_OBJECT:
602             JSAsyncFuncObject::Cast(obj)->Dump(thread, os);
603             break;
604         case JSType::JS_GENERATOR_CONTEXT:
605             GeneratorContext::Cast(obj)->Dump(thread, os);
606             break;
607         case JSType::PROTOTYPE_INFO:
608             ProtoChangeDetails::Cast(obj)->Dump(thread, os);
609             break;
610         case JSType::PROTO_CHANGE_MARKER:
611             ProtoChangeMarker::Cast(obj)->Dump(thread, os);
612             break;
613         case JSType::PROGRAM:
614             Program::Cast(obj)->Dump(thread, os);
615             break;
616         case JSType::MACHINE_CODE_OBJECT:
617             MachineCode::Cast(obj)->Dump(thread, os);
618             break;
619         case JSType::ECMA_MODULE:
620             EcmaModule::Cast(obj)->Dump(thread, os);
621             break;
622         case JSType::CLASS_INFO_EXTRACTOR:
623             ClassInfoExtractor::Cast(obj)->Dump(thread, os);
624             break;
625         case JSType::JS_API_ARRAY_LIST:
626             JSAPIArrayList::Cast(obj)->Dump(thread, os);
627             break;
628         case JSType::JS_API_ARRAYLIST_ITERATOR:
629             JSAPIArrayListIterator::Cast(obj)->Dump(thread, os);
630             break;
631         case JSType::TS_OBJECT_TYPE:
632             TSObjectType::Cast(obj)->Dump(thread, os);
633             break;
634         case JSType::TS_CLASS_TYPE:
635             TSClassType::Cast(obj)->Dump(thread, os);
636             break;
637         case JSType::TS_INTERFACE_TYPE:
638             TSInterfaceType::Cast(obj)->Dump(thread, os);
639             break;
640         case JSType::TS_IMPORT_TYPE:
641             TSImportType::Cast(obj)->Dump(thread, os);
642             break;
643         case JSType::TS_CLASS_INSTANCE_TYPE:
644             TSClassInstanceType::Cast(obj)->Dump(thread, os);
645             break;
646         case JSType::TS_UNION_TYPE:
647             TSUnionType::Cast(obj)->Dump(thread, os);
648             break;
649         case JSType::JS_API_TREE_MAP:
650             JSAPITreeMap::Cast(obj)->Dump(thread, os);
651             break;
652         case JSType::JS_API_TREE_SET:
653             JSAPITreeSet::Cast(obj)->Dump(thread, os);
654             break;
655         case JSType::JS_API_TREEMAP_ITERATOR:
656             JSAPITreeMapIterator::Cast(obj)->Dump(thread, os);
657             break;
658         case JSType::JS_API_TREESET_ITERATOR:
659             JSAPITreeSetIterator::Cast(obj)->Dump(thread, os);
660             break;
661         default:
662             UNREACHABLE();
663             break;
664     }
665 
666     DumpHClass(thread, jsHclass, os, false);
667 }
668 
DumpSpecialValue(JSThread * thread,std::ostream & os) const669 void JSTaggedValue::DumpSpecialValue([[maybe_unused]] JSThread *thread, std::ostream &os) const
670 {
671     ASSERT(IsSpecial());
672     os << "[Special Value] : ";
673     switch (GetRawData()) {
674         case VALUE_HOLE:
675             os << "Hole";
676             break;
677         case VALUE_NULL:
678             os << "Null";
679             break;
680         case VALUE_FALSE:
681             os << "False";
682             break;
683         case VALUE_TRUE:
684             os << "True";
685             break;
686         case VALUE_UNDEFINED:
687             os << "Undefined";
688             break;
689         case VALUE_EXCEPTION:
690             os << "Exception";
691             break;
692         default:
693             UNREACHABLE();
694             break;
695     }
696 }
697 
DumpHeapObjectType(JSThread * thread,std::ostream & os) const698 void JSTaggedValue::DumpHeapObjectType([[maybe_unused]] JSThread *thread, std::ostream &os) const
699 {
700     ASSERT(IsWeak() || IsHeapObject());
701     bool isWeak = IsWeak();
702     TaggedObject *obj = isWeak ? GetTaggedWeakRef() : GetTaggedObject();
703     if (isWeak) {
704         os << "----------Dump Weak Referent----------"
705            << "\n";
706     }
707 
708     JSType type = obj->GetClass()->GetObjectType();
709     if (type == JSType::STRING) {
710         CString string = ConvertToString(EcmaString::Cast(obj));
711         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + string + "]";
712     } else {
713         std::ostringstream address;
714         address << obj;
715         CString addrStr = CString(address.str());
716 
717         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + JSHClass::DumpJSType(type) + "(" + addrStr + ")]";
718     }
719 }
720 
DumpTaggedValue(JSThread * thread,std::ostream & os) const721 void JSTaggedValue::DumpTaggedValue(JSThread *thread, std::ostream &os) const
722 {
723     if (IsInt()) {
724         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Int] : " << std::hex << "0x" << GetInt() << std::dec << " ("
725            << GetInt() << ")";
726     } else if (IsDouble()) {
727         os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Double] : " << GetDouble();
728     } else if (IsSpecial()) {
729         DumpSpecialValue(thread, os);
730     } else {
731         DumpHeapObjectType(thread, os);
732     }
733 }
734 
Dump(JSThread * thread,std::ostream & os) const735 void JSTaggedValue::Dump(JSThread *thread, std::ostream &os) const
736 {
737     DumpTaggedValue(thread, os);
738     os << "\n";
739 
740     if (IsHeapObject()) {
741         TaggedObject *obj = GetTaggedObject();
742         if (thread == nullptr) {
743             thread = obj->GetJSThread();
744         }
745         DumpObject(thread, obj, os);
746     }
747 }
748 
D() const749 void JSTaggedValue::D() const
750 {
751     Dump(nullptr, std::cout);
752 }
753 
DV(JSTaggedType val)754 void JSTaggedValue::DV(JSTaggedType val)
755 {
756     JSTaggedValue(val).D();
757 }
758 
DumpStack()759 void JSThread::DumpStack()
760 {
761     InterpretedFrameHandler handler(this);
762     handler.DumpStack(std::cout);
763 }
764 
Dump(JSThread * thread,std::ostream & os) const765 void NumberDictionary::Dump(JSThread *thread, std::ostream &os) const
766 {
767     DISALLOW_GARBAGE_COLLECTION;
768     int size = Size();
769     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
770         JSTaggedValue key(GetKey(hashIndex));
771         if (!key.IsUndefined() && !key.IsHole()) {
772             JSTaggedValue val(GetValue(hashIndex));
773             os << std::right << std::setw(DUMP_PROPERTY_OFFSET)
774                << static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()) << ": ";
775             val.DumpTaggedValue(thread, os);
776             os << " ";
777             DumpAttr(GetAttributes(hashIndex), false, os);
778             os << "\n";
779         }
780     }
781 }
782 
Dump(JSThread * thread,std::ostream & os) const783 void NameDictionary::Dump(JSThread *thread, std::ostream &os) const
784 {
785     DISALLOW_GARBAGE_COLLECTION;
786     int size = Size();
787     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
788         JSTaggedValue key(GetKey(hashIndex));
789         if (!key.IsUndefined() && !key.IsHole()) {
790             JSTaggedValue val(GetValue(hashIndex));
791             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
792             DumpPropertyKey(key, os);
793             os << ": ";
794             val.DumpTaggedValue(thread, os);
795             os << " ";
796             DumpAttr(GetAttributes(hashIndex), false, os);
797             os << "\n";
798         }
799     }
800 }
801 
Dump(JSThread * thread,std::ostream & os) const802 void GlobalDictionary::Dump(JSThread *thread, std::ostream &os) const
803 {
804     DISALLOW_GARBAGE_COLLECTION;
805     int size = Size();
806     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
807         JSTaggedValue key(GetKey(hashIndex));
808         if (!key.IsUndefined() && !key.IsHole()) {
809             JSTaggedValue val(GetValue(hashIndex));
810             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
811             DumpPropertyKey(key, os);
812             os << " : ";
813             val.DumpTaggedValue(thread, os);
814             os << " ";
815             DumpAttr(GetAttributes(hashIndex), false, os);
816             os << "\n";
817         }
818     }
819 }
820 
Dump(JSThread * thread,std::ostream & os) const821 void LayoutInfo::Dump([[maybe_unused]] JSThread *thread, std::ostream &os) const
822 {
823     DISALLOW_GARBAGE_COLLECTION;
824     int num = NumberOfElements();
825     for (int i = 0; i < num; i++) {
826         JSTaggedValue key = GetKey(i);
827         PropertyAttributes attr = GetAttr(i);
828         os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
829         os << "[" << i << "]: ";
830         DumpPropertyKey(key, os);
831         os << " : ";
832         DumpAttr(attr, true, os);
833         os << "\n";
834     }
835 }
836 
Dump(JSThread * thread,std::ostream & os) const837 void TransitionsDictionary::Dump(JSThread *thread, std::ostream &os) const
838 {
839     DISALLOW_GARBAGE_COLLECTION;
840     int size = Size();
841     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
842         JSTaggedValue key(GetKey(hashIndex));
843         if (!key.IsUndefined() && !key.IsHole()) {
844             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
845             DumpPropertyKey(key, os);
846             os << " : ";
847             GetValue(hashIndex).DumpTaggedValue(thread, os);
848             os << " : ";
849             GetAttributes(hashIndex).DumpTaggedValue(thread, os);
850             os << "\n";
851         }
852     }
853 }
854 
Dump(JSThread * thread,std::ostream & os) const855 void LinkedHashSet::Dump(JSThread *thread, std::ostream &os) const
856 {
857     DISALLOW_GARBAGE_COLLECTION;
858     int capacity = NumberOfElements() + NumberOfDeletedElements();
859     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
860         JSTaggedValue key(GetKey(hashIndex));
861         if (!key.IsUndefined() && !key.IsHole()) {
862             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
863             key.DumpTaggedValue(thread, os);
864             os << "\n";
865         }
866     }
867 }
868 
Dump(JSThread * thread,std::ostream & os) const869 void LinkedHashMap::Dump(JSThread *thread, std::ostream &os) const
870 {
871     DISALLOW_GARBAGE_COLLECTION;
872     int capacity = NumberOfElements() + NumberOfDeletedElements();
873     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
874         JSTaggedValue key(GetKey(hashIndex));
875         if (!key.IsUndefined() && !key.IsHole()) {
876             JSTaggedValue val(GetValue(hashIndex));
877             os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
878             key.DumpTaggedValue(thread, os);
879             os << ": ";
880             val.DumpTaggedValue(thread, os);
881             os << "\n";
882         }
883     }
884 }
885 
Dump(JSThread * thread,std::ostream & os) const886 void JSObject::Dump(JSThread *thread, std::ostream &os) const
887 {
888     DISALLOW_GARBAGE_COLLECTION;
889     JSHClass *jshclass = GetJSHClass();
890     os << " - hclass: " << std::hex << jshclass << "\n";
891     os << " - prototype: ";
892     jshclass->GetPrototype().DumpTaggedValue(thread, os);
893     os << "\n";
894 
895     TaggedArray *elements = TaggedArray::Cast(GetElements().GetTaggedObject());
896     os << " - elements: " << std::hex << elements;
897     if (elements->GetLength() == 0) {
898         os << " NONE\n";
899     } else if (!elements->IsDictionaryMode()) {
900         DumpArrayClass(thread, elements, os);
901     } else {
902         NumberDictionary *dict = NumberDictionary::Cast(elements);
903         os << " <NumberDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
904         dict->Dump(thread, os);
905     }
906 
907     TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
908     os << " - properties: " << std::hex << properties;
909     if (IsJSGlobalObject()) {
910         GlobalDictionary *dict = GlobalDictionary::Cast(properties);
911         os << " <GlobalDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
912         dict->Dump(thread, os);
913         return;
914     }
915 
916     if (!properties->IsDictionaryMode()) {
917         JSTaggedValue attrs = jshclass->GetLayout();
918         if (attrs.IsNull()) {
919             return;
920         }
921 
922         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
923         int propNumber = jshclass->NumberOfProps();
924         os << " <LayoutInfo[" << std::dec << propNumber << "]>\n";
925         for (int i = 0; i < propNumber; i++) {
926             JSTaggedValue key = layoutInfo->GetKey(i);
927             PropertyAttributes attr = layoutInfo->GetAttr(i);
928             ASSERT(i == static_cast<int>(attr.GetOffset()));
929             os << "     " << std::right << std::setw(DUMP_PROPERTY_OFFSET);
930             DumpPropertyKey(key, os);
931             os << ": (";
932             JSTaggedValue val;
933             if (attr.IsInlinedProps()) {
934                 val = GetPropertyInlinedProps(i);
935             } else {
936                 val = properties->Get(i - jshclass->GetInlinedProperties());
937             }
938             val.DumpTaggedValue(thread, os);
939             os << ") ";
940             DumpAttr(attr, true, os);
941             os << "\n";
942         }
943     } else {
944         NameDictionary *dict = NameDictionary::Cast(properties);
945         os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
946         dict->Dump(thread, os);
947     }
948 }
949 
Dump(JSThread * thread,std::ostream & os) const950 void AccessorData::Dump(JSThread *thread, std::ostream &os) const
951 {
952     auto *hclass = GetClass();
953     if (hclass->GetObjectType() == JSType::INTERNAL_ACCESSOR) {
954         os << " - Getter: " << reinterpret_cast<void *>(GetGetter().GetTaggedObject()) << "\n";
955         os << " - Setter: " << reinterpret_cast<void *>(GetSetter().GetTaggedObject()) << "\n";
956         return;
957     }
958 
959     os << " - Getter: ";
960     GetGetter().DumpTaggedValue(thread, os);
961     os << "\n";
962 
963     os << " - Setter: ";
964     GetSetter().DumpTaggedValue(thread, os);
965     os << "\n";
966 }
967 
Dump(JSThread * thread,std::ostream & os) const968 void Program::Dump(JSThread *thread, std::ostream &os) const
969 {
970     os << " - MainFunction: ";
971     GetMainFunction().D();
972     os << "\n";
973 }
974 
Dump(JSThread * thread,std::ostream & os) const975 void ConstantPool::Dump(JSThread *thread, std::ostream &os) const
976 {
977     DumpArrayClass(thread, this, os);
978 }
979 
Dump(JSThread * thread,std::ostream & os) const980 void JSFunction::Dump(JSThread *thread, std::ostream &os) const
981 {
982     os << " - ProtoOrDynClass: ";
983     GetProtoOrDynClass().D();
984     os << "\n";
985     os << " - LexicalEnv: ";
986     GetLexicalEnv().D();
987     os << "\n";
988     os << " - HomeObject: ";
989     GetHomeObject().D();
990     os << "\n";
991     os << " - FunctionKind: " << static_cast<int>(GetFunctionKind());
992     os << "\n";
993     os << " - Strict: " << GetStrict();
994     os << "\n";
995     os << " - Resolved: " << GetResolved();
996     os << "\n";
997     os << " - ThisMode: " << static_cast<int>(GetThisMode());
998     os << "\n";
999     os << " - FunctionExtraInfo: ";
1000     GetFunctionExtraInfo().D();
1001     os << "\n";
1002     os << " - ConstantPool: ";
1003     GetConstantPool().D();
1004     os << "\n";
1005     os << " - ProfileTypeInfo: ";
1006     GetProfileTypeInfo().D();
1007     os << "\n";
1008     JSObject::Dump(thread, os);
1009 }
1010 
Dump(JSThread * thread,std::ostream & os) const1011 void JSHClass::Dump(JSThread *thread, std::ostream &os) const
1012 {
1013     DumpHClass(thread, this, os, true);
1014 }
1015 
Dump(JSThread * thread,std::ostream & os) const1016 void JSBoundFunction::Dump(JSThread *thread, std::ostream &os) const
1017 {
1018     os << " - BoundTarget: ";
1019     GetBoundTarget().DumpTaggedValue(thread, os);
1020     os << "\n";
1021 
1022     os << " - BoundThis: ";
1023     GetBoundThis().DumpTaggedValue(thread, os);
1024     os << "\n";
1025 
1026     os << " - BoundArguments: ";
1027     GetBoundArguments().DumpTaggedValue(thread, os);
1028     os << "\n";
1029 
1030     JSObject::Dump(thread, os);
1031 }
1032 
Dump(JSThread * thread,std::ostream & os) const1033 void JSPrimitiveRef::Dump(JSThread *thread, std::ostream &os) const
1034 {
1035     os << " - SubValue : ";
1036     GetValue().DumpTaggedValue(thread, os);
1037     os << "\n";
1038     JSObject::Dump(thread, os);
1039 }
1040 
Dump(JSThread * thread,std::ostream & os) const1041 void BigInt::Dump(JSThread *thread, std::ostream &os) const
1042 {
1043     os << " - Data : ";
1044     GetData().DumpTaggedValue(thread, os);
1045     os << "\n";
1046 
1047     os << " - Sign : ";
1048     os << GetSign();
1049     os << "\n";
1050 }
1051 
Dump(JSThread * thread,std::ostream & os) const1052 void JSDate::Dump(JSThread *thread, std::ostream &os) const
1053 {
1054     os << " - time: " << GetTime().GetDouble() << "\n";
1055     os << " - localOffset: " << GetLocalOffset().GetDouble() << "\n";
1056     JSObject::Dump(thread, os);
1057 }
1058 
Dump(JSThread * thread,std::ostream & os) const1059 void JSMap::Dump(JSThread *thread, std::ostream &os) const
1060 {
1061     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
1062     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1063     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1064     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1065     JSObject::Dump(thread, os);
1066 
1067     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1068     map->Dump(thread, os);
1069 }
1070 
Dump(JSThread * thread,std::ostream & os) const1071 void JSAPITreeMap::Dump(JSThread *thread, std::ostream &os) const
1072 {
1073     TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap().GetTaggedObject());
1074     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1075     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1076     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1077     JSObject::Dump(thread, os);
1078 
1079     os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1080     map->Dump(thread, os);
1081 }
1082 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const1083 void JSAPITreeMap::DumpForSnapshot([[maybe_unused]] JSThread *thread,
1084                                    std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1085 {
1086     TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap().GetTaggedObject());
1087     map->DumpForSnapshot(thread, vec);
1088 
1089     JSObject::DumpForSnapshot(thread, vec);
1090 }
1091 
Dump(JSThread * thread,std::ostream & os) const1092 void JSAPITreeMapIterator::Dump(JSThread *thread, std::ostream &os) const
1093 {
1094     TaggedTreeMap *map =
1095         TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap().GetTaggedObject())->GetTreeMap().GetTaggedObject());
1096     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1097     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1098     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1099     os << " - nextIndex: " << std::dec << GetNextIndex().GetInt() << "\n";
1100     os << " - IterationKind: " << std::dec << GetIterationKind().GetInt() << "\n";
1101     JSObject::Dump(thread, os);
1102 
1103     os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1104     map->Dump(thread, os);
1105 }
1106 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const1107 void JSAPITreeMapIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
1108                                            std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1109 {
1110     TaggedTreeMap *map =
1111         TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap().GetTaggedObject())->GetTreeMap().GetTaggedObject());
1112     map->DumpForSnapshot(thread, vec);
1113     vec.push_back(std::make_pair(CString("NextIndex"), GetNextIndex()));
1114     vec.push_back(std::make_pair(CString("IterationKind"), GetIterationKind()));
1115     JSObject::DumpForSnapshot(thread, vec);
1116 }
1117 
1118 template <typename T>
DumpTaggedTreeEntry(JSThread * thread,T tree,std::ostream & os,int index,bool isMap=false)1119 void DumpTaggedTreeEntry(JSThread *thread, T tree, std::ostream &os, int index, bool isMap = false)
1120 {
1121     DISALLOW_GARBAGE_COLLECTION;
1122     JSTaggedValue parent(tree->GetParent(index));
1123     JSTaggedValue val(tree->GetValue(index));
1124     JSTaggedValue color(static_cast<int>(tree->GetColor(index)));
1125     JSTaggedValue left = tree->GetLeftChild(index);
1126     JSTaggedValue right = tree->GetRightChild(index);
1127     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1128     os << "\n";
1129     if (isMap) {
1130         os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [key]:    {";
1131         JSTaggedValue key(tree->GetKey(index));
1132         key.DumpTaggedValue(thread, os);
1133         os << std::right << "};";
1134         os << "\n";
1135     }
1136     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "   [value]:  {";
1137     val.DumpTaggedValue(thread, os);
1138     os << std::right << "};";
1139     os << "\n";
1140     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [parent]: {";
1141     parent.DumpTaggedValue(thread, os);
1142     os << std::right << "};";
1143     os << "\n";
1144     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "   [color]:  {";
1145     color.DumpTaggedValue(thread, os);
1146     os << std::right << "};";
1147     os << "\n";
1148     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "   [left]:   {";
1149     left.DumpTaggedValue(thread, os);
1150     os << std::right << "}; ";
1151     os << std::left << std::setw(DUMP_TYPE_OFFSET) << "  [right]: {";
1152     right.DumpTaggedValue(thread, os);
1153     os << std::right << "};";
1154     os << "\n";
1155 }
Dump(JSThread * thread,std::ostream & os) const1156 void TaggedTreeMap::Dump(JSThread *thread, std::ostream &os) const
1157 {
1158     DISALLOW_GARBAGE_COLLECTION;
1159     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
1160     JSTaggedValue node = TaggedArray::Get(0);
1161     node.DumpTaggedValue(thread, os);
1162     os << std::right << "}" << "\n";
1163     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]:   {";
1164     node = TaggedArray::Get(1);
1165     node.DumpTaggedValue(thread, os);
1166     os << std::right << "}" << "\n";
1167     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
1168     node = TaggedArray::Get(2); // 2 means the three element
1169     node.DumpTaggedValue(thread, os);
1170     os << std::right << "}" << "\n";
1171     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
1172     node = TaggedArray::Get(3); // 3 means the three element
1173     node.DumpTaggedValue(thread, os);
1174     os << std::right << "}" << "\n";
1175 
1176     int capacity = NumberOfElements() + NumberOfDeletedElements();
1177     for (int index = 0; index < capacity; index++) {
1178         if (GetKey(index).IsHole()) {
1179             os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1180             GetKey(index).DumpTaggedValue(thread, os);
1181             os << "\n";
1182         } else {
1183             DumpTaggedTreeEntry(thread, const_cast<TaggedTreeMap *>(this), os, index, true);
1184         }
1185     }
1186 }
1187 
Dump(JSThread * thread,std::ostream & os) const1188 void JSAPITreeSet::Dump(JSThread *thread, std::ostream &os) const
1189 {
1190     TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet().GetTaggedObject());
1191     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1192     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1193     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1194     JSObject::Dump(thread, os);
1195 
1196     os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
1197     set->Dump(thread, os);
1198 }
1199 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const1200 void JSAPITreeSet::DumpForSnapshot([[maybe_unused]] JSThread *thread,
1201                                    std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1202 {
1203     TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet().GetTaggedObject());
1204     set->DumpForSnapshot(thread, vec);
1205 
1206     JSObject::DumpForSnapshot(thread, vec);
1207 }
1208 
Dump(JSThread * thread,std::ostream & os) const1209 void JSAPITreeSetIterator::Dump(JSThread *thread, std::ostream &os) const
1210 {
1211     TaggedTreeSet *set =
1212         TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet().GetTaggedObject())->GetTreeSet().GetTaggedObject());
1213     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1214     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1215     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1216     os << " - nextIndex: " << std::dec << GetNextIndex().GetInt() << "\n";
1217     os << " - IterationKind: " << std::dec << GetIterationKind().GetInt() << "\n";
1218     JSObject::Dump(thread, os);
1219 
1220     os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
1221     set->Dump(thread, os);
1222 }
1223 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const1224 void JSAPITreeSetIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
1225                                            std::vector<std::pair<CString, JSTaggedValue>> &vec) const
1226 {
1227     TaggedTreeSet *set =
1228         TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet().GetTaggedObject())->GetTreeSet().GetTaggedObject());
1229     set->DumpForSnapshot(thread, vec);
1230     vec.push_back(std::make_pair(CString("NextIndex"), GetNextIndex()));
1231     vec.push_back(std::make_pair(CString("IterationKind"), GetIterationKind()));
1232     JSObject::DumpForSnapshot(thread, vec);
1233 }
1234 
Dump(JSThread * thread,std::ostream & os) const1235 void TaggedTreeSet::Dump(JSThread *thread, std::ostream &os) const
1236 {
1237     DISALLOW_GARBAGE_COLLECTION;
1238     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
1239     JSTaggedValue node = TaggedArray::Get(0);
1240     node.DumpTaggedValue(thread, os);
1241     os << std::right << "}" << "\n";
1242     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]:   {";
1243     node = TaggedArray::Get(1);
1244     node.DumpTaggedValue(thread, os);
1245     os << std::right << "}" << "\n";
1246     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
1247     node = TaggedArray::Get(2); // 2 means the three element
1248     node.DumpTaggedValue(thread, os);
1249     os << std::right << "}" << "\n";
1250     os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
1251     node = TaggedArray::Get(3); // 3 means the three element
1252     node.DumpTaggedValue(thread, os);
1253     os << std::right << "}" << "\n";
1254 
1255     int capacity = NumberOfElements() + NumberOfDeletedElements();
1256     for (int index = 0; index < capacity; index++) {
1257         if (GetKey(index).IsHole()) {
1258             os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1259             GetKey(index).DumpTaggedValue(thread, os);
1260             os << "\n";
1261         } else {
1262             DumpTaggedTreeEntry(thread, const_cast<TaggedTreeSet *>(this), os, index);
1263         }
1264     }
1265 }
1266 
Dump(JSThread * thread,std::ostream & os) const1267 void JSForInIterator::Dump(JSThread *thread, std::ostream &os) const
1268 {
1269     os << " - Object : ";
1270     GetObject().DumpTaggedValue(thread, os);
1271     os << "\n";
1272     os << " - WasVisited : " << GetWasVisited();
1273     os << "\n";
1274     os << " - VisitedKeys : ";
1275     GetVisitedKeys().DumpTaggedValue(thread, os);
1276     os << "\n";
1277     os << " - RemainingKeys : ";
1278     GetRemainingKeys().DumpTaggedValue(thread, os);
1279     os << "\n";
1280     JSObject::Dump(thread, os);
1281 }
1282 
Dump(JSThread * thread,std::ostream & os) const1283 void JSMapIterator::Dump(JSThread *thread, std::ostream &os) const
1284 {
1285     LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap().GetTaggedObject());
1286     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1287     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1288     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1289     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1290     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1291     JSObject::Dump(thread, os);
1292 
1293     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1294     map->Dump(thread, os);
1295 }
1296 
Dump(JSThread * thread,std::ostream & os) const1297 void JSSet::Dump(JSThread *thread, std::ostream &os) const
1298 {
1299     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
1300     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1301     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1302     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1303     JSObject::Dump(thread, os);
1304 
1305     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1306     set->Dump(thread, os);
1307 }
1308 
Dump(JSThread * thread,std::ostream & os) const1309 void JSWeakMap::Dump(JSThread *thread, std::ostream &os) const
1310 {
1311     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
1312     os << " - length: " << std::dec << GetSize() << "\n";
1313     os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1314     os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1315     os << " - capacity: " << std::dec << map->Capacity() << "\n";
1316     JSObject::Dump(thread, os);
1317 
1318     os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1319     map->Dump(thread, os);
1320 }
1321 
Dump(JSThread * thread,std::ostream & os) const1322 void JSWeakSet::Dump(JSThread *thread, std::ostream &os) const
1323 {
1324     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
1325     os << " - size: " << std::dec << GetSize() << "\n";
1326     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1327     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1328     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1329     JSObject::Dump(thread, os);
1330 
1331     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1332     set->Dump(thread, os);
1333 }
1334 
Dump(JSThread * thread,std::ostream & os) const1335 void JSSetIterator::Dump(JSThread *thread, std::ostream &os) const
1336 {
1337     LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet().GetTaggedObject());
1338     os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
1339     os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
1340     os << " - capacity: " << std::dec << set->Capacity() << "\n";
1341     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1342     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1343     JSObject::Dump(thread, os);
1344 
1345     os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
1346     set->Dump(thread, os);
1347 }
1348 
Dump(JSThread * thread,std::ostream & os) const1349 void JSArray::Dump(JSThread *thread, std::ostream &os) const
1350 {
1351     os << " - length: " << std::dec << GetArrayLength() << "\n";
1352     JSObject::Dump(thread, os);
1353 }
1354 
Dump(JSThread * thread,std::ostream & os) const1355 void JSAPIArrayList::Dump(JSThread *thread, std::ostream &os) const
1356 {
1357     os << " - length: " << std::dec << GetLength().GetArrayLength() << "\n";
1358     JSObject::Dump(thread, os);
1359 }
1360 
Dump(JSThread * thread,std::ostream & os) const1361 void JSAPIArrayListIterator::Dump(JSThread *thread, std::ostream &os) const
1362 {
1363     JSAPIArrayList *arrayList = JSAPIArrayList::Cast(GetIteratedArrayList().GetTaggedObject());
1364     os << " - length: " << std::dec << arrayList->GetLength().GetArrayLength() << "\n";
1365     os << " - nextIndex: " << std::dec << GetNextIndex().GetInt() << "\n";
1366     JSObject::Dump(thread, os);
1367 }
1368 
Dump(JSThread * thread,std::ostream & os) const1369 void JSArrayIterator::Dump(JSThread *thread, std::ostream &os) const
1370 {
1371     JSArray *array = JSArray::Cast(GetIteratedArray().GetTaggedObject());
1372     os << " - length: " << std::dec << array->GetArrayLength() << "\n";
1373     os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1374     os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1375     JSObject::Dump(thread, os);
1376 }
1377 
Dump(JSThread * thread,std::ostream & os) const1378 void JSStringIterator::Dump(JSThread *thread, std::ostream &os) const
1379 {
1380     EcmaString *str = EcmaString::Cast(GetIteratedString().GetTaggedObject());
1381     os << " - IteratedString: " << str->GetCString().get() << "\n";
1382     os << " - StringIteratorNextIndex: " << std::dec << GetStringIteratorNextIndex() << "\n";
1383     JSObject::Dump(thread, os);
1384 }
Dump(JSThread * thread,std::ostream & os) const1385 void JSTypedArray::Dump(JSThread *thread, std::ostream &os) const
1386 {
1387     os << " - viewed-array-buffer: ";
1388     GetViewedArrayBuffer().D();
1389     os << " - typed-array-name: ";
1390     GetTypedArrayName().D();
1391     os << " - byte-length: ";
1392     GetByteLength().D();
1393     os << " - byte-offset: ";
1394     GetByteOffset().D();
1395     os << " - array-length: ";
1396     GetArrayLength().D();
1397     JSObject::Dump(thread, os);
1398 }
1399 
Dump(JSThread * thread,std::ostream & os) const1400 void JSRegExp::Dump(JSThread *thread, std::ostream &os) const
1401 {
1402     os << "\n";
1403     os << " - ByteCodeBuffer: ";
1404     GetByteCodeBuffer().D();
1405     os << "\n";
1406     os << " - OriginalSource: ";
1407     GetOriginalSource().D();
1408     os << "\n";
1409     os << " - OriginalFlags: ";
1410     GetOriginalFlags().D();
1411     os << "\n";
1412     os << " - Length: " << GetLength();
1413     os << "\n";
1414     JSObject::Dump(thread, os);
1415 }
1416 
Dump(JSThread * thread,std::ostream & os) const1417 void JSProxy::Dump(JSThread *thread, std::ostream &os) const
1418 {
1419     os << " - Target: ";
1420     os << "\n";
1421     JSObject::Cast(GetTarget().GetTaggedObject())->Dump(thread, os);
1422     os << " - Handler: ";
1423     os << "\n";
1424     JSObject::Cast(GetHandler().GetTaggedObject())->Dump(thread, os);
1425     os << "\n";
1426 }
1427 
Dump(JSThread * thread,std::ostream & os) const1428 void JSSymbol::Dump(JSThread *thread, std::ostream &os) const
1429 {
1430     os << " - hash-field: " << GetHashField();
1431     os << "\n - flags: " << GetFlags();
1432     os << "\n - description: ";
1433     JSTaggedValue description = GetDescription();
1434     description.D();
1435 }
1436 
Dump(JSThread * thread,std::ostream & os) const1437 void LexicalEnv::Dump(JSThread *thread, std::ostream &os) const
1438 {
1439     DumpArrayClass(thread, this, os);
1440 }
1441 
1442 // NOLINTNEXTLINE(readability-function-size)
Dump(JSThread * thread,std::ostream & os) const1443 void GlobalEnv::Dump(JSThread *thread, std::ostream &os) const
1444 {
1445     auto globalConst = thread->GlobalConstants();
1446     os << " - ObjectFunction: ";
1447     GetObjectFunction().GetTaggedValue().Dump(thread, os);
1448     os << " - FunctionFunction: ";
1449     GetFunctionFunction().GetTaggedValue().Dump(thread, os);
1450     os << " - NumberFunction: ";
1451     GetNumberFunction().GetTaggedValue().Dump(thread, os);
1452     os << " - BigIntFunction: ";
1453     GetBigIntFunction().GetTaggedValue().Dump(thread, os);
1454     os << " - DateFunction: ";
1455     GetDateFunction().GetTaggedValue().Dump(thread, os);
1456     os << " - BooleanFunction: ";
1457     GetBooleanFunction().GetTaggedValue().Dump(thread, os);
1458     os << " - ErrorFunction: ";
1459     GetErrorFunction().GetTaggedValue().Dump(thread, os);
1460     os << " - ArrayFunction: ";
1461     GetArrayFunction().GetTaggedValue().Dump(thread, os);
1462     os << " - TypedArrayFunction: ";
1463     GetTypedArrayFunction().GetTaggedValue().Dump(thread, os);
1464     os << " - Int8ArrayFunction: ";
1465     GetInt8ArrayFunction().GetTaggedValue().Dump(thread, os);
1466     os << " - Uint8ArrayFunction: ";
1467     GetUint8ArrayFunction().GetTaggedValue().Dump(thread, os);
1468     os << " - Uint8ClampedArrayFunction: ";
1469     GetUint8ClampedArrayFunction().GetTaggedValue().Dump(thread, os);
1470     os << " - Int16ArrayFunction: ";
1471     GetInt16ArrayFunction().GetTaggedValue().Dump(thread, os);
1472     os << " - ArrayBufferFunction: ";
1473     GetArrayBufferFunction().GetTaggedValue().Dump(thread, os);
1474     os << " - SymbolFunction: ";
1475     GetSymbolFunction().GetTaggedValue().Dump(thread, os);
1476     os << " - RangeErrorFunction: ";
1477     GetRangeErrorFunction().GetTaggedValue().Dump(thread, os);
1478     os << " - ReferenceErrorFunction: ";
1479     GetReferenceErrorFunction().GetTaggedValue().Dump(thread, os);
1480     os << " - TypeErrorFunction: ";
1481     GetTypeErrorFunction().GetTaggedValue().Dump(thread, os);
1482     os << " - URIErrorFunction: ";
1483     GetURIErrorFunction().GetTaggedValue().Dump(thread, os);
1484     os << " - SyntaxErrorFunction: ";
1485     GetSyntaxErrorFunction().GetTaggedValue().Dump(thread, os);
1486     os << " - EvalErrorFunction: ";
1487     GetEvalErrorFunction().GetTaggedValue().Dump(thread, os);
1488     os << " - RegExpFunction: ";
1489     GetRegExpFunction().GetTaggedValue().Dump(thread, os);
1490     os << " - BuiltinsSetFunction: ";
1491     GetBuiltinsSetFunction().GetTaggedValue().Dump(thread, os);
1492     os << " - BuiltinsMapFunction: ";
1493     GetBuiltinsMapFunction().GetTaggedValue().Dump(thread, os);
1494     os << " - BuiltinsWeakSetFunction: ";
1495     GetBuiltinsWeakSetFunction().GetTaggedValue().Dump(thread, os);
1496     os << " - BuiltinsWeakMapFunction: ";
1497     GetBuiltinsWeakMapFunction().GetTaggedValue().Dump(thread, os);
1498     os << " - MathFunction: ";
1499     GetMathFunction().GetTaggedValue().Dump(thread, os);
1500     os << " - JsonFunction: ";
1501     GetJsonFunction().GetTaggedValue().Dump(thread, os);
1502     os << " - StringFunction: ";
1503     GetStringFunction().GetTaggedValue().Dump(thread, os);
1504     os << " - ProxyFunction: ";
1505     GetProxyFunction().GetTaggedValue().Dump(thread, os);
1506     os << " - ReflectFunction: ";
1507     GetReflectFunction().GetTaggedValue().Dump(thread, os);
1508     os << " - AsyncFunction: ";
1509     GetAsyncFunction().GetTaggedValue().Dump(thread, os);
1510     os << " - AsyncFunctionPrototype: ";
1511     GetAsyncFunctionPrototype().GetTaggedValue().Dump(thread, os);
1512     os << " - JSGlobalObject: ";
1513     GetJSGlobalObject().GetTaggedValue().Dump(thread, os);
1514     os << " - EmptyArray: ";
1515     GetEmptyArray().GetTaggedValue().Dump(thread, os);
1516     os << " - EmptyString ";
1517     globalConst->GetEmptyString().Dump(thread, os);
1518     os << " - EmptyTaggedQueue: ";
1519     GetEmptyTaggedQueue().GetTaggedValue().Dump(thread, os);
1520     os << " - PrototypeString: ";
1521     globalConst->GetPrototypeString().Dump(thread, os);
1522     os << " - HasInstanceSymbol: ";
1523     GetHasInstanceSymbol().GetTaggedValue().Dump(thread, os);
1524     os << " - IsConcatSpreadableSymbol: ";
1525     GetIsConcatSpreadableSymbol().GetTaggedValue().Dump(thread, os);
1526     os << " - ToStringTagSymbol: ";
1527     GetToStringTagSymbol().GetTaggedValue().Dump(thread, os);
1528     os << " - IteratorSymbol: ";
1529     GetIteratorSymbol().GetTaggedValue().Dump(thread, os);
1530     os << " - MatchSymbol: ";
1531     GetMatchSymbol().GetTaggedValue().Dump(thread, os);
1532     os << " - ReplaceSymbol: ";
1533     GetReplaceSymbol().GetTaggedValue().Dump(thread, os);
1534     os << " - SearchSymbol: ";
1535     GetSearchSymbol().GetTaggedValue().Dump(thread, os);
1536     os << " - SpeciesSymbol: ";
1537     GetSpeciesSymbol().GetTaggedValue().Dump(thread, os);
1538     os << " - SplitSymbol: ";
1539     GetSplitSymbol().GetTaggedValue().Dump(thread, os);
1540     os << " - ToPrimitiveSymbol: ";
1541     GetToPrimitiveSymbol().GetTaggedValue().Dump(thread, os);
1542     os << " - UnscopablesSymbol: ";
1543     GetUnscopablesSymbol().GetTaggedValue().Dump(thread, os);
1544     os << " - HoleySymbol: ";
1545     GetHoleySymbol().GetTaggedValue().Dump(thread, os);
1546     os << " - ConstructorString: ";
1547     globalConst->GetConstructorString().Dump(thread, os);
1548     os << " - IteratorPrototype: ";
1549     GetIteratorPrototype().GetTaggedValue().Dump(thread, os);
1550     os << " - ForinIteratorPrototype: ";
1551     GetForinIteratorPrototype().GetTaggedValue().Dump(thread, os);
1552     os << " - StringIterator: ";
1553     GetStringIterator().GetTaggedValue().Dump(thread, os);
1554     os << " - MapIteratorPrototype: ";
1555     GetMapIteratorPrototype().GetTaggedValue().Dump(thread, os);
1556     os << " - SetIteratorPrototype: ";
1557     GetSetIteratorPrototype().GetTaggedValue().Dump(thread, os);
1558     os << " - ArrayIteratorPrototype: ";
1559     GetArrayIteratorPrototype().GetTaggedValue().Dump(thread, os);
1560     os << " - StringIteratorPrototype: ";
1561     GetStringIteratorPrototype().GetTaggedValue().Dump(thread, os);
1562     os << " - LengthString: ";
1563     globalConst->GetLengthString().Dump(thread, os);
1564     os << " - ValueString: ";
1565     globalConst->GetValueString().Dump(thread, os);
1566     os << " - WritableString: ";
1567     globalConst->GetWritableString().Dump(thread, os);
1568     os << " - GetString: ";
1569     globalConst->GetGetString().Dump(thread, os);
1570     os << " - SetString: ";
1571     globalConst->GetSetString().Dump(thread, os);
1572     os << " - EnumerableString: ";
1573     globalConst->GetEnumerableString().Dump(thread, os);
1574     os << " - ConfigurableString: ";
1575     globalConst->GetConfigurableString().Dump(thread, os);
1576     os << " - NameString: ";
1577     globalConst->GetNameString().Dump(thread, os);
1578     os << " - ValueOfString: ";
1579     globalConst->GetValueOfString().Dump(thread, os);
1580     os << " - ToStringString: ";
1581     globalConst->GetToStringString().Dump(thread, os);
1582     os << " - ToLocaleStringString: ";
1583     globalConst->GetToLocaleStringString().Dump(thread, os);
1584     os << " - UndefinedString: ";
1585     globalConst->GetUndefinedString().Dump(thread, os);
1586     os << " - NullString: ";
1587     globalConst->GetNullString().Dump(thread, os);
1588     os << " - TrueString: ";
1589     globalConst->GetTrueString().Dump(thread, os);
1590     os << " - FalseString: ";
1591     globalConst->GetFalseString().Dump(thread, os);
1592     os << " - RegisterSymbols: ";
1593     GetRegisterSymbols().GetTaggedValue().Dump(thread, os);
1594     os << " - ThrowTypeError: ";
1595     GetThrowTypeError().GetTaggedValue().Dump(thread, os);
1596     os << " - GetPrototypeOfString: ";
1597     globalConst->GetGetPrototypeOfString().Dump(thread, os);
1598     os << " - SetPrototypeOfString: ";
1599     globalConst->GetSetPrototypeOfString().Dump(thread, os);
1600     os << " - IsExtensibleString: ";
1601     globalConst->GetIsExtensibleString().Dump(thread, os);
1602     os << " - PreventExtensionsString: ";
1603     globalConst->GetPreventExtensionsString().Dump(thread, os);
1604     os << " - GetOwnPropertyDescriptorString: ";
1605     globalConst->GetGetOwnPropertyDescriptorString().Dump(thread, os);
1606     os << " - DefinePropertyString: ";
1607     globalConst->GetDefinePropertyString().Dump(thread, os);
1608     os << " - HasString: ";
1609     globalConst->GetHasString().Dump(thread, os);
1610     os << " - DeletePropertyString: ";
1611     globalConst->GetDeletePropertyString().Dump(thread, os);
1612     os << " - EnumerateString: ";
1613     globalConst->GetEnumerateString().Dump(thread, os);
1614     os << " - OwnKeysString: ";
1615     globalConst->GetOwnKeysString().Dump(thread, os);
1616     os << " - ApplyString: ";
1617     globalConst->GetApplyString().Dump(thread, os);
1618     os << " - ProxyString: ";
1619     globalConst->GetProxyString().Dump(thread, os);
1620     os << " - RevokeString: ";
1621     globalConst->GetRevokeString().Dump(thread, os);
1622     os << " - ProxyConstructString: ";
1623     globalConst->GetProxyConstructString().Dump(thread, os);
1624     os << " - ProxyCallString: ";
1625     globalConst->GetProxyCallString().Dump(thread, os);
1626     os << " - DoneString: ";
1627     globalConst->GetDoneString().Dump(thread, os);
1628     os << " - NegativeZeroString: ";
1629     globalConst->GetNegativeZeroString().Dump(thread, os);
1630     os << " - NextString: ";
1631     globalConst->GetNextString().Dump(thread, os);
1632     os << " - PromiseThenString: ";
1633     globalConst->GetPromiseThenString().Dump(thread, os);
1634     os << " - PromiseFunction: ";
1635     GetPromiseFunction().GetTaggedValue().Dump(thread, os);
1636     os << " - PromiseReactionJob: ";
1637     GetPromiseReactionJob().GetTaggedValue().Dump(thread, os);
1638     os << " - PromiseResolveThenableJob: ";
1639     GetPromiseResolveThenableJob().GetTaggedValue().Dump(thread, os);
1640     os << " - ScriptJobString: ";
1641     globalConst->GetScriptJobString().Dump(thread, os);
1642     os << " - PromiseString: ";
1643     globalConst->GetPromiseString().Dump(thread, os);
1644     os << " - IdentityString: ";
1645     globalConst->GetIdentityString().Dump(thread, os);
1646     os << " - AsyncFunctionString: ";
1647     globalConst->GetAsyncFunctionString().Dump(thread, os);
1648     os << " - ThrowerString: ";
1649     globalConst->GetThrowerString().Dump(thread, os);
1650     os << " - Undefined: ";
1651     globalConst->GetUndefined().Dump(thread, os);
1652 }
1653 
Dump(JSThread * thread,std::ostream & os) const1654 void JSDataView::Dump(JSThread *thread, std::ostream &os) const
1655 {
1656     os << " - data-view: ";
1657     GetDataView().D();
1658     os << " - buffer: ";
1659     GetViewedArrayBuffer().D();
1660     os << "- byte-length: " << GetByteLength();
1661     os << "\n - byte-offset: " << GetByteOffset();
1662 }
1663 
Dump(JSThread * thread,std::ostream & os) const1664 void JSArrayBuffer::Dump(JSThread *thread, std::ostream &os) const
1665 {
1666     os << " - byte-length: " << GetArrayBufferByteLength();
1667     os << " - buffer-data: ";
1668     GetArrayBufferData().D();
1669     os << " - Shared: " << GetShared();
1670 }
1671 
Dump(JSThread * thread,std::ostream & os) const1672 void PromiseReaction::Dump(JSThread *thread, std::ostream &os) const
1673 {
1674     os << " - promise-capability: ";
1675     GetPromiseCapability().D();
1676     os << " - type: " << static_cast<int>(GetType());
1677     os << " - handler: ";
1678     GetHandler().D();
1679 }
1680 
Dump(JSThread * thread,std::ostream & os) const1681 void PromiseCapability::Dump(JSThread *thread, std::ostream &os) const
1682 {
1683     os << " - promise: ";
1684     GetPromise().D();
1685     os << " - resolve: ";
1686     GetResolve().D();
1687     os << " - reject: ";
1688     GetReject().D();
1689 }
1690 
Dump(JSThread * thread,std::ostream & os) const1691 void PromiseIteratorRecord::Dump(JSThread *thread, std::ostream &os) const
1692 {
1693     os << " - iterator: ";
1694     GetIterator().D();
1695     os << " - done: " << GetDone();
1696 }
1697 
Dump(JSThread * thread,std::ostream & os) const1698 void PromiseRecord::Dump(JSThread *thread, std::ostream &os) const
1699 {
1700     os << " - value: ";
1701     GetValue().D();
1702 }
1703 
Dump(JSThread * thread,std::ostream & os) const1704 void ResolvingFunctionsRecord::Dump(JSThread *thread, std::ostream &os) const
1705 {
1706     os << " - resolve-function: ";
1707     GetResolveFunction().D();
1708     os << " - reject-function: ";
1709     GetRejectFunction().D();
1710 }
1711 
Dump(JSThread * thread,std::ostream & os) const1712 void JSPromise::Dump(JSThread *thread, std::ostream &os) const
1713 {
1714     os << " - promise-state: " << static_cast<int>(GetPromiseState());
1715     os << "\n - promise-result: ";
1716     GetPromiseResult().D();
1717     os << " - promise-fulfill-reactions: ";
1718     GetPromiseFulfillReactions().D();
1719     os << " - promise-reject-reactions: ";
1720     GetPromiseRejectReactions().D();
1721     os << " - promise-is-handled: " << GetPromiseIsHandled();
1722     JSObject::Dump(thread, os);
1723 }
1724 
Dump(JSThread * thread,std::ostream & os) const1725 void JSPromiseReactionsFunction::Dump(JSThread *thread, std::ostream &os) const
1726 {
1727     os << " - promise: ";
1728     GetPromise().D();
1729     os << " - already-resolved: ";
1730     GetAlreadyResolved().D();
1731     JSObject::Dump(thread, os);
1732 }
1733 
Dump(JSThread * thread,std::ostream & os) const1734 void JSPromiseExecutorFunction::Dump(JSThread *thread, std::ostream &os) const
1735 {
1736     os << " - capability: ";
1737     GetCapability().D();
1738     JSObject::Dump(thread, os);
1739 }
1740 
Dump(JSThread * thread,std::ostream & os) const1741 void JSPromiseAllResolveElementFunction::Dump(JSThread *thread, std::ostream &os) const
1742 {
1743     os << " - index: ";
1744     GetIndex().D();
1745     os << " - values: ";
1746     GetValues().D();
1747     os << " - capability: ";
1748     GetCapabilities().D();
1749     os << " - remaining-elements: ";
1750     GetRemainingElements().D();
1751     os << " - already-called: ";
1752     GetAlreadyCalled().D();
1753     JSObject::Dump(thread, os);
1754 }
1755 
Dump(JSThread * thread,std::ostream & os) const1756 void MicroJobQueue::Dump(JSThread *thread, std::ostream &os) const
1757 {
1758     os << " - promise-job-queue: ";
1759     GetPromiseJobQueue().D();
1760     os << " - script-job-queue: ";
1761     GetScriptJobQueue().D();
1762 }
1763 
Dump(JSThread * thread,std::ostream & os) const1764 void PendingJob::Dump(JSThread *thread, std::ostream &os) const
1765 {
1766     os << " - job: ";
1767     GetJob().D();
1768     os << "\n";
1769     os << " - arguments: ";
1770     GetArguments().D();
1771     os << "\n";
1772     os << " - chainId: " << GetChainId();
1773     os << "\n";
1774     os << " - spanId: " << GetSpanId();
1775     os << "\n";
1776     os << " - parentSpanId: " << GetParentSpanId();
1777     os << "\n";
1778     os << " - flags: " << GetFlags();
1779     os << "\n";
1780 }
1781 
Dump(JSThread * thread,std::ostream & os) const1782 void CompletionRecord::Dump(JSThread *thread, std::ostream &os) const
1783 {
1784     os << " - type: " << static_cast<int>(GetType());
1785     os << " - value: ";
1786     GetValue().D();
1787 }
1788 
Dump(JSThread * thread,std::ostream & os) const1789 void JSProxyRevocFunction::Dump(JSThread *thread, std::ostream &os) const
1790 {
1791     os << " - RevocableProxy: ";
1792     os << "\n";
1793     GetRevocableProxy().D();
1794     os << "\n";
1795 }
1796 
Dump(JSThread * thread,std::ostream & os) const1797 void JSAsyncFunction::Dump(JSThread *thread, std::ostream &os) const
1798 {
1799     JSFunction::Dump(thread, os);
1800 }
1801 
Dump(JSThread * thread,std::ostream & os) const1802 void JSAsyncAwaitStatusFunction::Dump(JSThread *thread, std::ostream &os) const
1803 {
1804     os << " - AsyncContext: ";
1805     os << "\n";
1806     GetAsyncContext().D();
1807     os << "\n";
1808 }
1809 
Dump(JSThread * thread,std::ostream & os) const1810 void JSGeneratorFunction::Dump(JSThread *thread, std::ostream &os) const
1811 {
1812     JSFunction::Dump(thread, os);
1813 }
1814 
Dump(JSThread * thread,std::ostream & os) const1815 void JSIntlBoundFunction::Dump(JSThread *thread, std::ostream &os) const
1816 {
1817     os << " - NumberFormat: ";
1818     GetNumberFormat().D();
1819     os << "\n";
1820     os << " - DateTimeFormat: ";
1821     GetDateTimeFormat().D();
1822     os << "\n";
1823     os << " - Collator: ";
1824     GetCollator().D();
1825     os << "\n";
1826     JSObject::Dump(thread, os);
1827 }
1828 
Dump(JSThread * thread,std::ostream & os) const1829 void PropertyBox::Dump(JSThread *thread, std::ostream &os) const
1830 {
1831     os << " - Value: ";
1832     GetValue().D();
1833     os << "\n";
1834 }
1835 
Dump(JSThread * thread,std::ostream & os) const1836 void PrototypeHandler::Dump(JSThread *thread, std::ostream &os) const
1837 {
1838     os << " - HandlerInfo: ";
1839     GetHandlerInfo().D();
1840     os << "\n";
1841     os << " - ProtoCell: ";
1842     GetHandlerInfo().D();
1843     os << "\n";
1844     os << " - Holder: ";
1845     GetHandlerInfo().D();
1846     os << "\n";
1847 }
1848 
Dump(JSThread * thread,std::ostream & os) const1849 void TransitionHandler::Dump(JSThread *thread, std::ostream &os) const
1850 {
1851     os << " - HandlerInfo: ";
1852     GetHandlerInfo().D();
1853     os << "\n";
1854     os << " - TransitionHClass: ";
1855     GetTransitionHClass().D();
1856     os << "\n";
1857 }
1858 
Dump(JSThread * thread,std::ostream & os) const1859 void JSRealm::Dump(JSThread *thread, std::ostream &os) const
1860 {
1861     os << " - Value: ";
1862     GetValue().D();
1863     os << "\n";
1864     os << " - GlobalEnv: ";
1865     GetGlobalEnv().D();
1866     os << "\n";
1867     JSObject::Dump(thread, os);
1868 }
1869 
Dump(JSThread * thread,std::ostream & os) const1870 void JSIntl::Dump(JSThread *thread, std::ostream &os) const
1871 {
1872     os << " - FallbackSymbol: ";
1873     GetFallbackSymbol().D();
1874     os << "\n";
1875     JSObject::Dump(thread, os);
1876 }
1877 
Dump(JSThread * thread,std::ostream & os) const1878 void JSLocale::Dump(JSThread *thread, std::ostream &os) const
1879 {
1880     os << " - IcuField: ";
1881     GetIcuField().D();
1882     os << "\n";
1883     JSObject::Dump(thread, os);
1884 }
1885 
Dump(JSThread * thread,std::ostream & os) const1886 void JSDateTimeFormat::Dump(JSThread *thread, std::ostream &os) const
1887 {
1888     os << " - Locale: ";
1889     GetLocale().D();
1890     os << "\n";
1891     os << " - Calendar: ";
1892     GetCalendar().D();
1893     os << "\n";
1894     os << " - NumberingSystem: ";
1895     GetNumberingSystem().D();
1896     os << "\n";
1897     os << " - TimeZone: ";
1898     GetTimeZone().D();
1899     os << "\n";
1900     os << " - HourCycle: " << static_cast<int>(GetHourCycle());
1901     os << "\n";
1902     os << " - LocaleIcu: ";
1903     GetLocaleIcu().D();
1904     os << "\n";
1905     os << " - SimpleDateTimeFormatIcu: ";
1906     GetSimpleDateTimeFormatIcu().D();
1907     os << "\n";
1908     os << " - Iso8601: ";
1909     GetIso8601().D();
1910     os << "\n";
1911     os << " - DateStyle: " << static_cast<int>(GetDateStyle());
1912     os << "\n";
1913     os << " - TimeStyle: " << static_cast<int>(GetTimeStyle());
1914     os << "\n";
1915     os << " - BoundFormat: ";
1916     GetBoundFormat().D();
1917     os << "\n";
1918     JSObject::Dump(thread, os);
1919 }
1920 
Dump(JSThread * thread,std::ostream & os) const1921 void JSRelativeTimeFormat::Dump(JSThread *thread, std::ostream &os) const
1922 {
1923     os << " - Locale: ";
1924     GetLocale().D();
1925     os << "\n";
1926     os << " - InitializedRelativeTimeFormat: ";
1927     GetInitializedRelativeTimeFormat().D();
1928     os << "\n";
1929     os << " - NumberingSystem: ";
1930     GetNumberingSystem().D();
1931     os << "\n";
1932     os << " - Style: " << static_cast<int>(GetStyle());
1933     os << "\n";
1934     os << " - Numeric: " << static_cast<int>(GetNumeric());
1935     os << "\n";
1936     os << " - AvailableLocales: ";
1937     GetAvailableLocales().D();
1938     os << "\n";
1939     os << " - IcuField: ";
1940     GetIcuField().D();
1941     os << "\n";
1942     JSObject::Dump(thread, os);
1943 }
1944 
Dump(JSThread * thread,std::ostream & os) const1945 void JSNumberFormat::Dump(JSThread *thread, std::ostream &os) const
1946 {
1947     os << " - Locale: ";
1948     GetLocale().D();
1949     os << "\n" << " - NumberingSystem: ";
1950     GetNumberingSystem().D();
1951     os << "\n" << " - Style: " << static_cast<int>(GetStyle());
1952     os << "\n" << " - Currency: ";
1953     GetCurrency().D();
1954     os << "\n" << " - CurrencyDisplay: " << static_cast<int>(GetCurrencyDisplay());
1955     os << "\n" << " - CurrencySign: " << static_cast<int>(GetCurrencySign());
1956     os << "\n" << " - Unit: ";
1957     GetUnit().D();
1958     os << "\n" << " - UnitDisplay: " << static_cast<int>(GetUnitDisplay());
1959     os << "\n" << " - MinimumIntegerDigits: ";
1960     GetMinimumIntegerDigits().D();
1961     os << "\n" << " - MinimumFractionDigits: ";
1962     GetMinimumFractionDigits().D();
1963     os << "\n" << " - MaximumFractionDigits: ";
1964     GetMaximumFractionDigits().D();
1965     os << "\n" << " - MinimumSignificantDigits: ";
1966     GetMinimumSignificantDigits().D();
1967     os << "\n" << " - MaximumSignificantDigits: ";
1968     GetMaximumSignificantDigits().D();
1969     os << "\n" << " - UseGrouping: ";
1970     GetUseGrouping().D();
1971     os << "\n" << " - RoundingType: " << static_cast<int>(GetRoundingType());
1972     os << "\n" << " - Notation: " << static_cast<int>(GetNotation());
1973     os << "\n" << " - CompactDisplay: " << static_cast<int>(GetCompactDisplay());
1974     os << "\n" << " - SignDisplay: " << static_cast<int>(GetSignDisplay());
1975     os << "\n" << " - BoundFormat: ";
1976     GetBoundFormat().D();
1977     os << "\n" << " - IcuField: ";
1978     GetIcuField().D();
1979     os << "\n";
1980     JSObject::Dump(thread, os);
1981 }
1982 
Dump(JSThread * thread,std::ostream & os) const1983 void JSCollator::Dump(JSThread *thread, std::ostream &os) const
1984 {
1985     os << " - IcuField: ";
1986     GetIcuField().D();
1987     os << "\n - Locale: ";
1988     GetLocale().D();
1989     os << "\n - Usage: " << static_cast<int>(GetUsage());
1990     os << "\n - Sensitivity: " << static_cast<int>(GetSensitivity());
1991     os << "\n - IgnorePunctuation: " << GetIgnorePunctuation();
1992     os << "\n - Collation: ";
1993     GetCollation().D();
1994     os << "\n - Numeric: " << GetNumeric();
1995     os << "\n - CaseFirst: " << static_cast<int>(GetCaseFirst());
1996     os << "\n - BoundCompare: ";
1997     GetBoundCompare().D();
1998     os << "\n";
1999     JSObject::Dump(thread, os);
2000 }
2001 
Dump(JSThread * thread,std::ostream & os) const2002 void JSPluralRules::Dump(JSThread *thread, std::ostream &os) const
2003 {
2004     os << " - Locale: ";
2005     GetLocale().D();
2006     os << "\n";
2007     os << " - InitializedPluralRules: ";
2008     GetInitializedPluralRules().D();
2009     os << "\n";
2010     os << " - Type: " << static_cast<int>(GetType());
2011     os << "\n";
2012     os << " - MinimumIntegerDigits: ";
2013     GetMinimumIntegerDigits().D();
2014     os << "\n";
2015     os << " - MinimumFractionDigits: ";
2016     GetMinimumFractionDigits().D();
2017     os << "\n";
2018     os << " - MaximumFractionDigits: ";
2019     GetMaximumFractionDigits().D();
2020     os << "\n";
2021     os << " - MinimumSignificantDigits: ";
2022     GetMinimumSignificantDigits().D();
2023     os << "\n";
2024     os << " - MaximumSignificantDigits: ";
2025     GetMaximumSignificantDigits().D();
2026     os << "\n";
2027     os << " - RoundingType: " << static_cast<int>(GetRoundingType());
2028     os << "\n";
2029     os << " - IcuPR: ";
2030     GetIcuPR().D();
2031     os << "\n";
2032     os << " - IcuNF: ";
2033     GetIcuNF().D();
2034     os << "\n";
2035     JSObject::Dump(thread, os);
2036 }
2037 
Dump(JSThread * thread,std::ostream & os) const2038 void JSGeneratorObject::Dump(JSThread *thread, std::ostream &os) const
2039 {
2040     os << " - GeneratorContext: ";
2041     GetGeneratorContext().D();
2042     os << "\n";
2043     os << " - ResumeResult: ";
2044     GetResumeResult().D();
2045     os << "\n";
2046     os << " - GeneratorState: " << static_cast<uint8_t>(GetGeneratorState());
2047     os << "\n";
2048     os << " - ResumeMode: " << static_cast<uint8_t>(GetResumeMode());
2049     os << "\n";
2050     JSObject::Dump(thread, os);
2051 }
2052 
Dump(JSThread * thread,std::ostream & os) const2053 void JSAsyncFuncObject::Dump(JSThread *thread, std::ostream &os) const
2054 {
2055     os << " - Promise: ";
2056     GetPromise().D();
2057     os << "\n";
2058 }
2059 
Dump(JSThread * thread,std::ostream & os) const2060 void GeneratorContext::Dump(JSThread *thread, std::ostream &os) const
2061 {
2062     os << " - RegsArray: ";
2063     GetRegsArray().D();
2064     os << "\n";
2065     os << " - Method: ";
2066     GetMethod().D();
2067     os << "\n";
2068     os << " - Acc: ";
2069     GetAcc().D();
2070     os << "\n";
2071     os << " - GeneratorObject: ";
2072     GetGeneratorObject().D();
2073     os << "\n";
2074     os << " - LexicalEnv: ";
2075     GetLexicalEnv().D();
2076     os << "\n";
2077     os << " - NRegs: " << GetNRegs();
2078     os << "\n";
2079     os << " - BCOffset: " << GetBCOffset();
2080     os << "\n";
2081 }
2082 
Dump(JSThread * thread,std::ostream & os) const2083 void ProtoChangeMarker::Dump(JSThread *thread, std::ostream &os) const
2084 {
2085     os << " - HasChanged: " << GetHasChanged() << "\n";
2086 }
2087 
Dump(JSThread * thread,std::ostream & os) const2088 void ProtoChangeDetails::Dump(JSThread *thread, std::ostream &os) const
2089 {
2090     os << " - ChangeListener: ";
2091     GetChangeListener().D();
2092     os << "\n";
2093     os << " - RegisterIndex: " << GetRegisterIndex();
2094     os << "\n";
2095 }
2096 
Dump(JSThread * thread,std::ostream & os) const2097 void MachineCode::Dump(JSThread *thread, std::ostream &os) const
2098 {
2099     os << " - InstructionSizeInBytes: " << GetInstructionSizeInBytes();
2100     os << "\n";
2101 }
2102 
Dump(JSThread * thread,std::ostream & os) const2103 void EcmaModule::Dump(JSThread *thread, std::ostream &os) const
2104 {
2105     os << " - NameDictionary: ";
2106     GetNameDictionary().D();
2107     os << "\n";
2108 }
2109 
Dump(JSThread * thread,std::ostream & os) const2110 void ClassInfoExtractor::Dump(JSThread *thread, std::ostream &os) const
2111 {
2112     os << " - PrototypeHClass: ";
2113     GetPrototypeHClass().D();
2114     os << "\n";
2115     os << " - NonStaticKeys: ";
2116     GetNonStaticKeys().D();
2117     os << "\n";
2118     os << " - NonStaticProperties: ";
2119     GetNonStaticProperties().D();
2120     os << "\n";
2121     os << " - NonStaticElements: ";
2122     GetNonStaticElements().D();
2123     os << "\n";
2124     os << " - ConstructorHClass: ";
2125     GetConstructorHClass().D();
2126     os << "\n";
2127     os << " - StaticKeys: ";
2128     GetStaticKeys().D();
2129     os << "\n";
2130     os << " - StaticProperties: ";
2131     GetStaticProperties().D();
2132     os << "\n";
2133     os << " - StaticElements: ";
2134     GetStaticElements().D();
2135     os << "\n";
2136 }
2137 
Dump(JSThread * thread,std::ostream & os) const2138 void TSObjectType::Dump(JSThread *thread, std::ostream &os) const
2139 {
2140     os << " - TSObjectType globalTSTypeRef: ";
2141     GlobalTSTypeRef gt = GetGTRef();
2142     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2143     os << globalTSTypeRef;
2144     os << "\n";
2145     os << " - TSObjectType moduleId: ";
2146     uint32_t moduleId = gt.GetModuleId();
2147     os << moduleId;
2148     os << "\n";
2149     os << " - TSObjectType localTypeId: ";
2150     uint32_t localTypeId = gt.GetLocalId();
2151     os << localTypeId;
2152     os << "\n";
2153     os << " - TSObjectType typeKind: ";
2154     uint32_t typeKind = gt.GetUserDefineTypeKind();
2155     os << typeKind;
2156     os << "\n";
2157     os << "  - ObjLayoutInfo: ";
2158     DumpArrayClass(thread, TaggedArray::Cast(GetObjLayoutInfo().GetTaggedObject()), os);
2159     os << "  - HClass: ";
2160     GetHClass().D();
2161 }
2162 
Dump(JSThread * thread,std::ostream & os) const2163 void TSClassType::Dump(JSThread *thread, std::ostream &os) const
2164 {
2165     os << " - Dump Class Type - " << "\n";
2166     os << " - TSClassType globalTSTypeRef: ";
2167     GlobalTSTypeRef gt = GetGTRef();
2168     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2169     os << globalTSTypeRef;
2170     os << "\n";
2171     os << " - TSClassType moduleId: ";
2172     uint32_t moduleId = gt.GetModuleId();
2173     os << moduleId;
2174     os << "\n";
2175     os << " - TSClassType localTypeId: ";
2176     uint32_t localTypeId = gt.GetLocalId();
2177     os << localTypeId;
2178     os << "\n";
2179     os << " - TSClassType typeKind: ";
2180     uint32_t typeKind = gt.GetUserDefineTypeKind();
2181     os << typeKind;
2182     os << "\n";
2183     os << " - ExtensionTypeGT: ";
2184     JSTaggedValue extensionType = GetExtensionType();
2185     if (extensionType.IsUndefined()) {
2186         os << " (base class type) ";
2187     } else {
2188         uint64_t extensionTypeGT = TSType::Cast(extensionType.GetTaggedObject())->GetGTRef().GetGlobalTSTypeRef();
2189         os << extensionTypeGT;
2190     }
2191     os << "\n";
2192 
2193     os << " - InstanceType: " << "\n";
2194     if (GetInstanceType().IsTSObjectType()) {
2195         TSObjectType *instanceType = TSObjectType::Cast(GetInstanceType().GetTaggedObject());
2196         instanceType->Dump(thread, os);
2197         os << "\n";
2198     }
2199 
2200     os << " - ConstructorType: " << "\n";
2201     if (GetConstructorType().IsTSObjectType()) {
2202         TSObjectType *constructorType = TSObjectType::Cast(GetConstructorType().GetTaggedObject());
2203         constructorType->Dump(thread, os);
2204         os << "\n";
2205     }
2206 
2207     os << " - PrototypeType: " << "\n";
2208     if (GetPrototypeType().IsTSObjectType()) {
2209         TSObjectType *prototypeType = TSObjectType::Cast(GetPrototypeType().GetTaggedObject());
2210         prototypeType->Dump(thread, os);
2211         os << "\n";
2212     }
2213 }
2214 
Dump(JSThread * thread,std::ostream & os) const2215 void TSInterfaceType::Dump(JSThread *thread, std::ostream &os) const
2216 {
2217     os << " - Dump Interface Type - " << "\n";
2218     os << " - TSInterfaceType globalTSTypeRef: ";
2219     GlobalTSTypeRef gt = GetGTRef();
2220     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2221     os << globalTSTypeRef;
2222     os << "\n";
2223     os << " - TSInterfaceType moduleId: ";
2224     uint32_t moduleId = gt.GetModuleId();
2225     os << moduleId;
2226     os << "\n";
2227     os << " - TSInterfaceType localTypeId: ";
2228     uint32_t localTypeId = gt.GetLocalId();
2229     os << localTypeId;
2230     os << "\n";
2231     os << " - TSInterfaceType typeKind: ";
2232     uint32_t typeKind = gt.GetUserDefineTypeKind();
2233     os << typeKind;
2234     os << "\n";
2235     os << " - Extends TypeId: " << "\n";
2236     JSHandle<TaggedArray> extendsId(thread, GetExtends());
2237     if (extendsId->GetLength() == 0) {
2238             os << " (base interface type) "<< "\n";
2239     }
2240     DumpArrayClass(thread, TaggedArray::Cast(GetExtends().GetTaggedObject()), os);
2241 
2242     os << " - Fields: " << "\n";
2243     if (GetFields().IsTSObjectType()) {
2244         TSObjectType *fieldsType = TSObjectType::Cast(GetFields().GetTaggedObject());
2245         fieldsType->Dump(thread, os);
2246         os << "\n";
2247     }
2248 }
2249 
Dump(JSThread * thread,std::ostream & os) const2250 void TSImportType::Dump(JSThread *thread, std::ostream &os) const
2251 {
2252     os << " - Dump Import Type - " << "\n";
2253     os << " - TSImportType globalTSTypeRef: ";
2254     GlobalTSTypeRef gt = GetGTRef();
2255     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2256     os << globalTSTypeRef;
2257     os << "\n";
2258     os << " - TSImportType moduleId: ";
2259     uint32_t moduleId = gt.GetModuleId();
2260     os << moduleId;
2261     os << "\n";
2262     os << " - TSImportType localTypeId: ";
2263     uint32_t localTypeId = gt.GetLocalId();
2264     os << localTypeId;
2265     os << "\n";
2266     os << " - TSImportType typeKind: ";
2267     uint32_t typeKind = gt.GetUserDefineTypeKind();
2268     os << typeKind;
2269     os << "\n";
2270     os << " - Target Type: ";
2271     if (GetTargetType().IsTSInterfaceType()) {
2272         TSInterfaceType *targetType = TSInterfaceType::Cast(GetTargetType().GetTaggedObject());
2273         targetType->Dump(thread, os);
2274         os << "\n";
2275     } else if (GetTargetType().IsTSClassType()) {
2276         TSClassType *targetType = TSClassType::Cast(GetTargetType().GetTaggedObject());
2277         targetType->Dump(thread, os);
2278         os << "\n";
2279     } else if (GetTargetType().IsTSClassInstanceType()) {
2280         TSClassInstanceType *targetType = TSClassInstanceType::Cast(GetTargetType().GetTaggedObject());
2281         targetType->Dump(thread, os);
2282         os << "\n";
2283     } else if (GetTargetType().IsTSUnionType()) {
2284         TSUnionType *targetType = TSUnionType::Cast(GetTargetType().GetTaggedObject());
2285         targetType->Dump(thread, os);
2286         os << "\n";
2287     } else {
2288         os << " - no link Target Type: ";
2289         os << "\n";
2290     }
2291     os << " - Taget Type Path: ";
2292     JSTaggedValue importPath = GetImportPath();
2293     importPath.DumpTaggedValue(thread, os);
2294     os << "\n";
2295 }
2296 
Dump(JSThread * thread,std::ostream & os) const2297 void TSClassInstanceType::Dump(JSThread *thread, std::ostream &os) const
2298 {
2299     os << " - Dump ClassInstance Type - " << "\n";
2300     os << " - TSClassInstanceType globalTSTypeRef: ";
2301     GlobalTSTypeRef gt = GetGTRef();
2302     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2303     os << globalTSTypeRef;
2304     os << "\n";
2305     os << " - TSClassInstanceType moduleId: ";
2306     uint32_t moduleId = gt.GetModuleId();
2307     os << moduleId;
2308     os << "\n";
2309     os << " - TSClassInstanceType localTypeId: ";
2310     uint32_t localTypeId = gt.GetLocalId();
2311     os << localTypeId;
2312     os << "\n";
2313     os << " - TSClassInstanceType typeKind: ";
2314     uint32_t typeKind = gt.GetUserDefineTypeKind();
2315     os << typeKind;
2316     os << "\n";
2317 
2318     JSTaggedValue createClassType = GetCreateClassType();
2319     if (!createClassType.IsUndefined()) {
2320         os << " - CreateClassType GT: ";
2321         uint64_t createClassTypeGT = TSClassType::Cast(createClassType
2322                                                        .GetTaggedObject())->GetGTRef().GetGlobalTSTypeRef();
2323         os << createClassTypeGT;
2324         os << "\n";
2325     }
2326 }
2327 
Dump(JSThread * thread,std::ostream & os) const2328 void TSUnionType::Dump(JSThread *thread, std::ostream &os) const
2329 {
2330     os << " - Dump UnionType Type - " << "\n";
2331     os << " - TSUnionType globalTSTypeRef: ";
2332     GlobalTSTypeRef gt = GetGTRef();
2333     uint64_t globalTSTypeRef = gt.GetGlobalTSTypeRef();
2334     os << globalTSTypeRef;
2335     os << "\n";
2336     os << " - TSUnionType moduleId: ";
2337     uint32_t moduleId = gt.GetModuleId();
2338     os << moduleId;
2339     os << "\n";
2340     os << " - TSUnionType localTypeId: ";
2341     uint32_t localTypeId = gt.GetLocalId();
2342     os << localTypeId;
2343     os << "\n";
2344     os << " - TSUnionType typeKind: ";
2345     uint32_t typeKind = gt.GetUserDefineTypeKind();
2346     os << typeKind;
2347     os << "\n";
2348     os << " - TSUnionType TypeId: " << "\n";
2349     JSHandle<TaggedArray> componentTypes(thread, GetComponentTypes());
2350 
2351     DumpArrayClass(thread, TaggedArray::Cast(GetComponentTypes().GetTaggedObject()), os);
2352 }
2353 // ########################################################################################
2354 // Dump for Snapshot
2355 // ########################################################################################
DumpArrayClass(JSThread * thread,const TaggedArray * arr,std::vector<std::pair<CString,JSTaggedValue>> & vec)2356 static void DumpArrayClass([[maybe_unused]] JSThread *thread, const TaggedArray *arr,
2357                            std::vector<std::pair<CString, JSTaggedValue>> &vec)
2358 {
2359     DISALLOW_GARBAGE_COLLECTION;
2360     uint32_t len = arr->GetLength();
2361     for (uint32_t i = 0; i < len; i++) {
2362         JSTaggedValue val(arr->Get(i));
2363         CString str = ToCString(i);
2364         vec.push_back(std::make_pair(str, val));
2365     }
2366 }
2367 
DumpStringClass(JSThread * thread,const EcmaString * str,std::vector<std::pair<CString,JSTaggedValue>> & vec)2368 static void DumpStringClass([[maybe_unused]] JSThread *thread, const EcmaString *str,
2369                             std::vector<std::pair<CString, JSTaggedValue>> &vec)
2370 {
2371     vec.push_back(std::make_pair("string", JSTaggedValue(str)));
2372 }
2373 
DumpDynClass(JSThread * thread,TaggedObject * obj,std::vector<std::pair<CString,JSTaggedValue>> & vec)2374 static void DumpDynClass([[maybe_unused]] JSThread *thread, TaggedObject *obj,
2375                          std::vector<std::pair<CString, JSTaggedValue>> &vec)
2376 {
2377     JSHClass *jshclass = obj->GetClass();
2378     vec.push_back(std::make_pair("__proto__", jshclass->GetPrototype()));
2379 }
2380 
DumpObject(JSThread * thread,TaggedObject * obj,std::vector<std::pair<CString,JSTaggedValue>> & vec,bool isVmMode)2381 static void DumpObject(JSThread *thread, TaggedObject *obj,
2382                        std::vector<std::pair<CString, JSTaggedValue>> &vec, bool isVmMode)
2383 {
2384     DISALLOW_GARBAGE_COLLECTION;
2385     auto jsHclass = obj->GetClass();
2386     JSType type = jsHclass->GetObjectType();
2387 
2388     switch (type) {
2389         case JSType::HCLASS:
2390             DumpDynClass(thread, obj, vec);
2391             return;
2392         case JSType::TAGGED_ARRAY:
2393         case JSType::TAGGED_DICTIONARY:
2394             DumpArrayClass(thread, TaggedArray::Cast(obj), vec);
2395             return;
2396         case JSType::STRING:
2397             DumpStringClass(thread, EcmaString::Cast(obj), vec);
2398             return;
2399         case JSType::JS_NATIVE_POINTER:
2400             return;
2401         case JSType::JS_OBJECT:
2402         case JSType::JS_ERROR:
2403         case JSType::JS_EVAL_ERROR:
2404         case JSType::JS_RANGE_ERROR:
2405         case JSType::JS_TYPE_ERROR:
2406         case JSType::JS_REFERENCE_ERROR:
2407         case JSType::JS_URI_ERROR:
2408         case JSType::JS_SYNTAX_ERROR:
2409         case JSType::JS_ARGUMENTS:
2410         case JSType::JS_GLOBAL_OBJECT:
2411             JSObject::Cast(obj)->DumpForSnapshot(thread, vec);
2412             return;
2413         case JSType::JS_FUNCTION_BASE:
2414         case JSType::JS_FUNCTION:
2415             JSFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2416             return;
2417         case JSType::JS_BOUND_FUNCTION:
2418             JSBoundFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2419             return;
2420         case JSType::JS_SET:
2421             JSSet::Cast(obj)->DumpForSnapshot(thread, vec);
2422             return;
2423         case JSType::JS_MAP:
2424             JSMap::Cast(obj)->DumpForSnapshot(thread, vec);
2425             return;
2426         case JSType::JS_WEAK_SET:
2427             JSWeakSet::Cast(obj)->DumpForSnapshot(thread, vec);
2428             return;
2429         case JSType::JS_WEAK_MAP:
2430             JSWeakMap::Cast(obj)->DumpForSnapshot(thread, vec);
2431             return;
2432         case JSType::JS_REG_EXP:
2433             JSRegExp::Cast(obj)->DumpForSnapshot(thread, vec);
2434             return;
2435         case JSType::JS_DATE:
2436             JSDate::Cast(obj)->DumpForSnapshot(thread, vec);
2437             return;
2438         case JSType::JS_ARRAY:
2439             JSArray::Cast(obj)->DumpForSnapshot(thread, vec);
2440             return;
2441         case JSType::JS_TYPED_ARRAY:
2442         case JSType::JS_INT8_ARRAY:
2443         case JSType::JS_UINT8_ARRAY:
2444         case JSType::JS_UINT8_CLAMPED_ARRAY:
2445         case JSType::JS_INT16_ARRAY:
2446         case JSType::JS_UINT16_ARRAY:
2447         case JSType::JS_INT32_ARRAY:
2448         case JSType::JS_UINT32_ARRAY:
2449         case JSType::JS_FLOAT32_ARRAY:
2450         case JSType::JS_FLOAT64_ARRAY:
2451             JSTypedArray::Cast(obj)->DumpForSnapshot(thread, vec);
2452             return;
2453         case JSType::BIGINT:
2454             BigInt::Cast(obj)->DumpForSnapshot(thread, vec);
2455             return;
2456         case JSType::JS_PROXY:
2457             JSProxy::Cast(obj)->DumpForSnapshot(thread, vec);
2458             return;
2459         case JSType::JS_PRIMITIVE_REF:
2460             JSPrimitiveRef::Cast(obj)->DumpForSnapshot(thread, vec);
2461             return;
2462         case JSType::SYMBOL:
2463             JSSymbol::Cast(obj)->DumpForSnapshot(thread, vec);
2464             return;
2465         case JSType::ACCESSOR_DATA:
2466         case JSType::INTERNAL_ACCESSOR:
2467             AccessorData::Cast(obj)->DumpForSnapshot(thread, vec);
2468             return;
2469         case JSType::JS_DATA_VIEW:
2470             JSDataView::Cast(obj)->DumpForSnapshot(thread, vec);
2471             return;
2472         case JSType::PROMISE_REACTIONS:
2473             PromiseReaction::Cast(obj)->DumpForSnapshot(thread, vec);
2474             return;
2475         case JSType::PROMISE_CAPABILITY:
2476             PromiseCapability::Cast(obj)->DumpForSnapshot(thread, vec);
2477             return;
2478         case JSType::PROMISE_ITERATOR_RECORD:
2479             PromiseIteratorRecord::Cast(obj)->DumpForSnapshot(thread, vec);
2480             return;
2481         case JSType::PROMISE_RECORD:
2482             PromiseRecord::Cast(obj)->DumpForSnapshot(thread, vec);
2483             return;
2484         case JSType::RESOLVING_FUNCTIONS_RECORD:
2485             ResolvingFunctionsRecord::Cast(obj)->DumpForSnapshot(thread, vec);
2486             return;
2487         case JSType::JS_PROMISE:
2488             JSPromise::Cast(obj)->DumpForSnapshot(thread, vec);
2489             return;
2490         case JSType::JS_PROMISE_REACTIONS_FUNCTION:
2491             JSPromiseReactionsFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2492             return;
2493         case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
2494             JSPromiseExecutorFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2495             return;
2496         case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
2497             JSPromiseAllResolveElementFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2498             return;
2499         case JSType::MICRO_JOB_QUEUE:
2500             MicroJobQueue::Cast(obj)->DumpForSnapshot(thread, vec);
2501             return;
2502         case JSType::PENDING_JOB:
2503             PendingJob::Cast(obj)->DumpForSnapshot(thread, vec);
2504             return;
2505         case JSType::COMPLETION_RECORD:
2506             CompletionRecord::Cast(obj)->DumpForSnapshot(thread, vec);
2507             return;
2508         case JSType::JS_ITERATOR:
2509         case JSType::JS_FORIN_ITERATOR:
2510         case JSType::JS_MAP_ITERATOR:
2511         case JSType::JS_SET_ITERATOR:
2512         case JSType::JS_ARRAY_ITERATOR:
2513         case JSType::JS_STRING_ITERATOR:
2514         case JSType::JS_ARRAY_BUFFER:
2515             JSArrayBuffer::Cast(obj)->DumpForSnapshot(thread, vec);
2516             return;
2517         case JSType::JS_PROXY_REVOC_FUNCTION:
2518             JSProxyRevocFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2519             return;
2520         case JSType::JS_ASYNC_FUNCTION:
2521             JSAsyncFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2522             return;
2523         case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
2524             JSAsyncAwaitStatusFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2525             return;
2526         case JSType::JS_GENERATOR_FUNCTION:
2527             JSGeneratorFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2528             return;
2529         case JSType::JS_INTL_BOUND_FUNCTION:
2530             JSIntlBoundFunction::Cast(obj)->DumpForSnapshot(thread, vec);
2531             return;
2532         case JSType::JS_REALM:
2533             JSRealm::Cast(obj)->DumpForSnapshot(thread, vec);
2534             return;
2535         case JSType::JS_INTL:
2536             JSIntl::Cast(obj)->DumpForSnapshot(thread, vec);
2537             return;
2538         case JSType::JS_LOCALE:
2539             JSLocale::Cast(obj)->DumpForSnapshot(thread, vec);
2540             return;
2541         case JSType::JS_DATE_TIME_FORMAT:
2542             JSDateTimeFormat::Cast(obj)->DumpForSnapshot(thread, vec);
2543             return;
2544         case JSType::JS_RELATIVE_TIME_FORMAT:
2545             JSRelativeTimeFormat::Cast(obj)->DumpForSnapshot(thread, vec);
2546             return;
2547         case JSType::JS_NUMBER_FORMAT:
2548             JSNumberFormat::Cast(obj)->DumpForSnapshot(thread, vec);
2549             return;
2550         case JSType::JS_COLLATOR:
2551             JSCollator::Cast(obj)->DumpForSnapshot(thread, vec);
2552             return;
2553         case JSType::JS_PLURAL_RULES:
2554             JSPluralRules::Cast(obj)->DumpForSnapshot(thread, vec);
2555             return;
2556         case JSType::JS_GENERATOR_OBJECT:
2557             JSGeneratorObject::Cast(obj)->DumpForSnapshot(thread, vec);
2558             return;
2559         case JSType::JS_ASYNC_FUNC_OBJECT:
2560             JSAsyncFuncObject::Cast(obj)->DumpForSnapshot(thread, vec);
2561             return;
2562         case JSType::JS_GENERATOR_CONTEXT:
2563             GeneratorContext::Cast(obj)->DumpForSnapshot(thread, vec);
2564             return;
2565         case JSType::ECMA_MODULE:
2566             EcmaModule::Cast(obj)->DumpForSnapshot(thread, vec);
2567             return;
2568         case JSType::JS_API_ARRAY_LIST:
2569             JSAPIArrayList::Cast(obj)->DumpForSnapshot(thread, vec);
2570             return;
2571         case JSType::JS_API_ARRAYLIST_ITERATOR:
2572             JSAPIArrayListIterator::Cast(obj)->DumpForSnapshot(thread, vec);
2573             return;
2574         case JSType::JS_API_TREE_MAP:
2575             JSAPITreeMap::Cast(obj)->DumpForSnapshot(thread, vec);
2576             return;
2577         case JSType::JS_API_TREE_SET:
2578             JSAPITreeSet::Cast(obj)->DumpForSnapshot(thread, vec);
2579             return;
2580         case JSType::JS_API_TREEMAP_ITERATOR:
2581             JSAPITreeMapIterator::Cast(obj)->DumpForSnapshot(thread, vec);
2582             return;
2583         case JSType::JS_API_TREESET_ITERATOR:
2584             JSAPITreeSetIterator::Cast(obj)->DumpForSnapshot(thread, vec);
2585             return;
2586         default:
2587             break;
2588     }
2589     if (isVmMode) {
2590         switch (type) {
2591             case JSType::PROPERTY_BOX:
2592                 PropertyBox::Cast(obj)->DumpForSnapshot(thread, vec);
2593                 return;
2594             case JSType::TEMPLATE_MAP:
2595                 DumpArrayClass(thread, TaggedArray::Cast(obj), vec);
2596                 return;
2597             case JSType::GLOBAL_ENV:
2598                 GlobalEnv::Cast(obj)->DumpForSnapshot(thread, vec);
2599                 return;
2600             case JSType::PROTO_CHANGE_MARKER:
2601                 ProtoChangeMarker::Cast(obj)->DumpForSnapshot(thread, vec);
2602                 return;
2603             case JSType::PROTOTYPE_INFO:
2604                 ProtoChangeDetails::Cast(obj)->DumpForSnapshot(thread, vec);
2605                 return;
2606             case JSType::PROGRAM:
2607                 Program::Cast(obj)->DumpForSnapshot(thread, vec);
2608                 return;
2609             case JSType::MACHINE_CODE_OBJECT:
2610                 MachineCode::Cast(obj)->DumpForSnapshot(thread, vec);
2611                 return;
2612             case JSType::TRANSITION_HANDLER:
2613                 TransitionHandler::Cast(obj)->DumpForSnapshot(thread, vec);
2614                 return;
2615             case JSType::PROTOTYPE_HANDLER:
2616                 PrototypeHandler::Cast(obj)->DumpForSnapshot(thread, vec);
2617                 return;
2618             case JSType::CLASS_INFO_EXTRACTOR:
2619                 ClassInfoExtractor::Cast(obj)->DumpForSnapshot(thread, vec);
2620                 return;
2621             case JSType::TS_OBJECT_TYPE:
2622                 TSObjectType::Cast(obj)->DumpForSnapshot(thread, vec);
2623                 return;
2624             case JSType::TS_CLASS_TYPE:
2625                 TSClassType::Cast(obj)->DumpForSnapshot(thread, vec);
2626                 return;
2627             case JSType::TS_INTERFACE_TYPE:
2628                 TSInterfaceType::Cast(obj)->DumpForSnapshot(thread, vec);
2629                 return;
2630             case JSType::TS_IMPORT_TYPE:
2631                 TSImportType::Cast(obj)->DumpForSnapshot(thread, vec);
2632                 return;
2633             case JSType::TS_CLASS_INSTANCE_TYPE:
2634                 TSClassInstanceType::Cast(obj)->DumpForSnapshot(thread, vec);
2635                 return;
2636             case JSType::TS_UNION_TYPE:
2637                 TSUnionType::Cast(obj)->DumpForSnapshot(thread, vec);
2638                 return;
2639             default:
2640                 UNREACHABLE();
2641                 break;
2642         }
2643     }
2644 }
2645 
EcmaStringToStd(CString & res,EcmaString * str)2646 static inline void EcmaStringToStd(CString &res, EcmaString *str)
2647 {
2648     if (str->GetLength() == 0) {
2649         CString emptyStr = "EmptyString";
2650         res.append(emptyStr);
2651     }
2652 
2653     CString string = ConvertToString(str);
2654     res.append(string);
2655 }
2656 
KeyToStd(CString & res,JSTaggedValue key)2657 static void KeyToStd(CString &res, JSTaggedValue key)
2658 {
2659     if (key.IsInt()) {
2660         res = std::to_string(key.GetInt());
2661     } else if (key.IsDouble()) {
2662         res = std::to_string(key.GetDouble());
2663     } else if (key.IsBoolean()) {
2664         res = key.IsTrue() ? "true" : "false";
2665     } else if (key.IsHeapObject()) {
2666         if (key.IsWeak()) {
2667             key.RemoveWeakTag();
2668         }
2669         if (key.IsString()) {
2670             EcmaStringToStd(res, EcmaString::Cast(key.GetTaggedObject()));
2671         } else if (key.IsSymbol()) {
2672             JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
2673             EcmaStringToStd(res, EcmaString::Cast(sym->GetDescription().GetTaggedObject()));
2674         }
2675     }
2676 }
2677 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec,bool isVmMode) const2678 void JSTaggedValue::DumpForSnapshot(JSThread *thread,
2679                                     std::vector<std::pair<CString, JSTaggedValue>> &vec, bool isVmMode) const
2680 {
2681     if (IsHeapObject()) {
2682         return DumpObject(thread, GetTaggedObject(), vec, isVmMode);
2683     }
2684 
2685     UNREACHABLE();
2686 }
2687 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2688 void NumberDictionary::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2689                                        std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2690 {
2691     DISALLOW_GARBAGE_COLLECTION;
2692     int size = Size();
2693     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
2694         JSTaggedValue key(GetKey(hashIndex));
2695         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2696             JSTaggedValue val(GetValue(hashIndex));
2697             CString str = ToCString(static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()));
2698             vec.push_back(std::make_pair(str, val));
2699         }
2700     }
2701 }
2702 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2703 void NameDictionary::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2704                                      std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2705 {
2706     DISALLOW_GARBAGE_COLLECTION;
2707     int size = Size();
2708     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
2709         JSTaggedValue key(GetKey(hashIndex));
2710         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2711             JSTaggedValue val(GetValue(hashIndex));
2712             CString str;
2713             KeyToStd(str, key);
2714             vec.push_back(std::make_pair(str, val));
2715         }
2716     }
2717 }
2718 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2719 void GlobalDictionary::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2720                                        std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2721 {
2722     DISALLOW_GARBAGE_COLLECTION;
2723     int size = Size();
2724     for (int hashIndex = 0; hashIndex < size; hashIndex++) {
2725         JSTaggedValue key(GetKey(hashIndex));
2726         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2727             CString str;
2728             KeyToStd(str, key);
2729             JSTaggedValue val = GetValue(hashIndex);
2730             vec.push_back(std::make_pair(str, val));
2731         }
2732     }
2733 }
2734 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2735 void LinkedHashSet::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2736                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2737 {
2738     DISALLOW_GARBAGE_COLLECTION;
2739     int capacity = NumberOfElements() + NumberOfDeletedElements();
2740     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
2741         JSTaggedValue key(GetKey(hashIndex));
2742         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2743             CString str;
2744             KeyToStd(str, key);
2745             vec.push_back(std::make_pair(str, JSTaggedValue::Hole()));
2746         }
2747     }
2748 }
2749 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2750 void LinkedHashMap::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2751                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2752 {
2753     DISALLOW_GARBAGE_COLLECTION;
2754     int capacity = NumberOfElements() + NumberOfDeletedElements();
2755     for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
2756         JSTaggedValue key(GetKey(hashIndex));
2757         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2758             JSTaggedValue val = GetValue(hashIndex);
2759             CString str;
2760             KeyToStd(str, key);
2761             vec.push_back(std::make_pair(str, val));
2762         }
2763     }
2764 }
2765 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2766 void TaggedTreeMap::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2767                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2768 {
2769     DISALLOW_GARBAGE_COLLECTION;
2770     int capacity = NumberOfElements() + NumberOfDeletedElements();
2771     for (int index = 0; index < capacity; index++) {
2772         JSTaggedValue key(GetKey(index));
2773         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2774             JSTaggedValue val = GetValue(index);
2775             CString str;
2776             KeyToStd(str, key);
2777             vec.push_back(std::make_pair(str, val));
2778         }
2779     }
2780 }
2781 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2782 void TaggedTreeSet::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2783                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2784 {
2785     DISALLOW_GARBAGE_COLLECTION;
2786     int capacity = NumberOfElements() + NumberOfDeletedElements();
2787     for (int index = 0; index < capacity; index++) {
2788         JSTaggedValue key(GetKey(index));
2789         if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
2790             CString str;
2791             KeyToStd(str, key);
2792             vec.push_back(std::make_pair(str, JSTaggedValue::Hole()));
2793         }
2794     }
2795 }
2796 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2797 void JSObject::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2798 {
2799     DISALLOW_GARBAGE_COLLECTION;
2800     JSHClass *jshclass = GetJSHClass();
2801     vec.push_back(std::make_pair("__proto__", jshclass->GetPrototype()));
2802 
2803     TaggedArray *elements = TaggedArray::Cast(GetElements().GetTaggedObject());
2804     if (elements->GetLength() == 0) {
2805     } else if (!elements->IsDictionaryMode()) {
2806         DumpArrayClass(thread, elements, vec);
2807     } else {
2808         NumberDictionary *dict = NumberDictionary::Cast(elements);
2809         dict->DumpForSnapshot(thread, vec);
2810     }
2811 
2812     TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
2813     if (IsJSGlobalObject()) {
2814         GlobalDictionary *dict = GlobalDictionary::Cast(properties);
2815         dict->DumpForSnapshot(thread, vec);
2816         return;
2817     }
2818 
2819     if (!properties->IsDictionaryMode()) {
2820         JSTaggedValue attrs = jshclass->GetLayout();
2821         if (attrs.IsNull()) {
2822             return;
2823         }
2824 
2825         LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
2826         int propNumber = jshclass->NumberOfProps();
2827         for (int i = 0; i < propNumber; i++) {
2828             JSTaggedValue key = layoutInfo->GetKey(i);
2829             PropertyAttributes attr = layoutInfo->GetAttr(i);
2830             ASSERT(i == static_cast<int>(attr.GetOffset()));
2831             JSTaggedValue val;
2832             if (attr.IsInlinedProps()) {
2833                 val = GetPropertyInlinedProps(i);
2834             } else {
2835                 val = properties->Get(i - jshclass->GetInlinedProperties());
2836             }
2837 
2838             CString str;
2839             KeyToStd(str, key);
2840             vec.push_back(std::make_pair(str, val));
2841         }
2842     } else {
2843         NameDictionary *dict = NameDictionary::Cast(properties);
2844         dict->DumpForSnapshot(thread, vec);
2845     }
2846 }
2847 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2848 void JSHClass::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2849                                [[maybe_unused]] std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2850 {
2851 }
2852 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2853 void JSFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2854                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2855 {
2856     vec.push_back(std::make_pair(CString("ProtoOrDynClass"), GetProtoOrDynClass()));
2857     vec.push_back(std::make_pair(CString("LexicalEnv"), GetLexicalEnv()));
2858     vec.push_back(std::make_pair(CString("HomeObject"), GetHomeObject()));
2859     vec.push_back(std::make_pair(CString("FunctionKind"), JSTaggedValue(static_cast<int>(GetFunctionKind()))));
2860     vec.push_back(std::make_pair(CString("Strict"), JSTaggedValue(GetStrict())));
2861     vec.push_back(std::make_pair(CString("Resolved"), JSTaggedValue(GetResolved())));
2862     vec.push_back(std::make_pair(CString("ThisMode"), JSTaggedValue(static_cast<int>(GetThisMode()))));
2863     vec.push_back(std::make_pair(CString("FunctionExtraInfo"), GetFunctionExtraInfo()));
2864     vec.push_back(std::make_pair(CString("ConstantPool"), GetConstantPool()));
2865     vec.push_back(std::make_pair(CString("ProfileTypeInfo"), GetProfileTypeInfo()));
2866     JSObject::DumpForSnapshot(thread, vec);
2867 }
2868 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2869 void Program::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2870                               std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2871 {
2872     vec.push_back(std::make_pair(CString("MainFunction"), GetMainFunction()));
2873 }
2874 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2875 void ConstantPool::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2876                                    std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2877 {
2878     DumpArrayClass(thread, this, vec);
2879 }
2880 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2881 void JSBoundFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2882                                       std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2883 {
2884     JSObject::DumpForSnapshot(thread, vec);
2885 
2886     vec.push_back(std::make_pair(CString("BoundTarget"), GetBoundTarget()));
2887     vec.push_back(std::make_pair(CString("BoundThis"), GetBoundThis()));
2888     vec.push_back(std::make_pair(CString("BoundArguments"), GetBoundArguments()));
2889 }
2890 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2891 void JSPrimitiveRef::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2892                                      std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2893 {
2894     vec.push_back(std::make_pair(CString("subValue"), GetValue()));
2895     JSObject::DumpForSnapshot(thread, vec);
2896 }
2897 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2898 void BigInt::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2899                              std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2900 {
2901     vec.push_back(std::make_pair(CString("Data"), GetData()));
2902     vec.push_back(std::make_pair(CString("Sign"), JSTaggedValue(GetSign())));
2903 }
2904 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2905 void JSDate::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2906                              std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2907 {
2908     vec.push_back(std::make_pair(CString("time"), GetTime()));
2909     vec.push_back(std::make_pair(CString("localOffset"), GetLocalOffset()));
2910 
2911     JSObject::DumpForSnapshot(thread, vec);
2912 }
2913 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2914 void JSMap::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2915                             std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2916 {
2917     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
2918     map->DumpForSnapshot(thread, vec);
2919 
2920     JSObject::DumpForSnapshot(thread, vec);
2921 }
2922 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2923 void JSForInIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2924                                       std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2925 {
2926     vec.push_back(std::make_pair(CString("Object"), GetObject()));
2927     vec.push_back(std::make_pair(CString("WasVisited"), JSTaggedValue(GetWasVisited())));
2928     vec.push_back(std::make_pair(CString("VisitedKeys"), GetVisitedKeys()));
2929     vec.push_back(std::make_pair(CString("RemainingKeys"), GetRemainingKeys()));
2930     JSObject::DumpForSnapshot(thread, vec);
2931 }
2932 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2933 void JSMapIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2934                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2935 {
2936     LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap().GetTaggedObject());
2937     map->DumpForSnapshot(thread, vec);
2938     vec.push_back(std::make_pair(CString("NextIndex"), JSTaggedValue(GetNextIndex())));
2939     vec.push_back(std::make_pair(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind()))));
2940     JSObject::DumpForSnapshot(thread, vec);
2941 }
2942 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2943 void JSSet::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2944                             std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2945 {
2946     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
2947     set->DumpForSnapshot(thread, vec);
2948 
2949     JSObject::DumpForSnapshot(thread, vec);
2950 }
2951 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2952 void JSWeakMap::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2953                                 std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2954 {
2955     LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap().GetTaggedObject());
2956     map->DumpForSnapshot(thread, vec);
2957 
2958     JSObject::DumpForSnapshot(thread, vec);
2959 }
2960 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2961 void JSWeakSet::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2962                                 std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2963 {
2964     LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet().GetTaggedObject());
2965     set->DumpForSnapshot(thread, vec);
2966 
2967     JSObject::DumpForSnapshot(thread, vec);
2968 }
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2969 void JSSetIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2970                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2971 {
2972     LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet().GetTaggedObject());
2973     set->DumpForSnapshot(thread, vec);
2974     vec.push_back(std::make_pair(CString("NextIndex"), JSTaggedValue(GetNextIndex())));
2975     vec.push_back(std::make_pair(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind()))));
2976     JSObject::DumpForSnapshot(thread, vec);
2977 }
2978 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2979 void JSArray::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2980                               std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2981 {
2982     JSObject::DumpForSnapshot(thread, vec);
2983 }
2984 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2985 void JSAPIArrayList::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2986                                      std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2987 {
2988     JSObject::DumpForSnapshot(thread, vec);
2989 }
2990 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const2991 void JSAPIArrayListIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
2992                                              std::vector<std::pair<CString, JSTaggedValue>> &vec) const
2993 {
2994     JSAPIArrayList *arraylist = JSAPIArrayList::Cast(GetIteratedArrayList().GetTaggedObject());
2995     arraylist->DumpForSnapshot(thread, vec);
2996     vec.push_back(std::make_pair(CString("NextIndex"), GetNextIndex()));
2997     JSObject::DumpForSnapshot(thread, vec);
2998 }
2999 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3000 void JSArrayIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3001                                       std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3002 {
3003     JSArray *array = JSArray::Cast(GetIteratedArray().GetTaggedObject());
3004     array->DumpForSnapshot(thread, vec);
3005     vec.push_back(std::make_pair(CString("NextIndex"), JSTaggedValue(GetNextIndex())));
3006     vec.push_back(std::make_pair(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind()))));
3007     JSObject::DumpForSnapshot(thread, vec);
3008 }
3009 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3010 void JSStringIterator::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3011                                        std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3012 {
3013     vec.push_back(std::make_pair(CString("IteratedString"), GetIteratedString()));
3014     vec.push_back(std::make_pair(CString("StringIteratorNextIndex"), JSTaggedValue(GetStringIteratorNextIndex())));
3015     JSObject::DumpForSnapshot(thread, vec);
3016 }
3017 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3018 void JSTypedArray::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3019                                    std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3020 {
3021     vec.push_back(std::make_pair(CString("viewed-array-buffer"), GetViewedArrayBuffer()));
3022     vec.push_back(std::make_pair(CString("typed-array-name"), GetTypedArrayName()));
3023     vec.push_back(std::make_pair(CString("byte-length"), GetByteLength()));
3024     vec.push_back(std::make_pair(CString("byte-offset"), GetByteOffset()));
3025     vec.push_back(std::make_pair(CString("array-length"), GetArrayLength()));
3026 }
3027 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3028 void JSRegExp::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3029                                std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3030 {
3031     vec.push_back(std::make_pair(CString("originalSource"), GetOriginalSource()));
3032     vec.push_back(std::make_pair(CString("originalFlags"), GetOriginalFlags()));
3033 
3034     JSObject::DumpForSnapshot(thread, vec);
3035 }
3036 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3037 void JSProxy::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3038                               std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3039 {
3040     vec.push_back(std::make_pair(CString("target"), GetTarget()));
3041     vec.push_back(std::make_pair(CString("handler"), GetHandler()));
3042 }
3043 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3044 void JSSymbol::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3045                                std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3046 {
3047     vec.push_back(std::make_pair(CString("hash-field"), JSTaggedValue(GetHashField())));
3048     vec.push_back(std::make_pair(CString("flags"), JSTaggedValue(GetFlags())));
3049     vec.push_back(std::make_pair(CString("description"), GetDescription()));
3050 }
3051 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3052 void AccessorData::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3053                                    std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3054 {
3055     vec.push_back(std::make_pair(CString("getter"), GetGetter()));
3056     vec.push_back(std::make_pair(CString("setter"), GetSetter()));
3057 }
3058 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3059 void LexicalEnv::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3060                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3061 {
3062     DumpArrayClass(thread, this, vec);
3063 }
3064 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3065 void GlobalEnv::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3066                                 std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3067 {
3068     auto globalConst = thread->GlobalConstants();
3069     vec.push_back(std::make_pair(CString("ObjectFunction"), GetObjectFunction().GetTaggedValue()));
3070     vec.push_back(std::make_pair(CString("FunctionFunction"), GetFunctionFunction().GetTaggedValue()));
3071     vec.push_back(std::make_pair(CString("NumberFunction"), GetNumberFunction().GetTaggedValue()));
3072     vec.push_back(std::make_pair(CString("BigIntFunction"), GetBigIntFunction().GetTaggedValue()));
3073     vec.push_back(std::make_pair(CString("DateFunction"), GetDateFunction().GetTaggedValue()));
3074     vec.push_back(std::make_pair(CString("BooleanFunction"), GetBooleanFunction().GetTaggedValue()));
3075     vec.push_back(std::make_pair(CString("ErrorFunction"), GetErrorFunction().GetTaggedValue()));
3076     vec.push_back(std::make_pair(CString("ArrayFunction"), GetArrayFunction().GetTaggedValue()));
3077     vec.push_back(std::make_pair(CString("TypedArrayFunction"), GetTypedArrayFunction().GetTaggedValue()));
3078     vec.push_back(std::make_pair(CString("Int8ArrayFunction"), GetInt8ArrayFunction().GetTaggedValue()));
3079     vec.push_back(std::make_pair(CString("Uint8ArrayFunction"), GetUint8ArrayFunction().GetTaggedValue()));
3080     vec.push_back(
3081         std::make_pair(CString("Uint8ClampedArrayFunction"), GetUint8ClampedArrayFunction().GetTaggedValue()));
3082     vec.push_back(std::make_pair(CString("Int16ArrayFunction"), GetInt16ArrayFunction().GetTaggedValue()));
3083     vec.push_back(std::make_pair(CString("Uint16ArrayFunction"), GetUint16ArrayFunction().GetTaggedValue()));
3084     vec.push_back(std::make_pair(CString("Int32ArrayFunction"), GetInt32ArrayFunction().GetTaggedValue()));
3085     vec.push_back(std::make_pair(CString("Uint32ArrayFunction"), GetUint32ArrayFunction().GetTaggedValue()));
3086     vec.push_back(std::make_pair(CString("Float32ArrayFunction"), GetFloat32ArrayFunction().GetTaggedValue()));
3087     vec.push_back(std::make_pair(CString("Float64ArrayFunction"), GetFloat64ArrayFunction().GetTaggedValue()));
3088     vec.push_back(std::make_pair(CString("ArrayBufferFunction"), GetArrayBufferFunction().GetTaggedValue()));
3089     vec.push_back(std::make_pair(CString("SymbolFunction"), GetSymbolFunction().GetTaggedValue()));
3090     vec.push_back(std::make_pair(CString("RangeErrorFunction"), GetRangeErrorFunction().GetTaggedValue()));
3091     vec.push_back(std::make_pair(CString("ReferenceErrorFunction"), GetReferenceErrorFunction().GetTaggedValue()));
3092     vec.push_back(std::make_pair(CString("TypeErrorFunction"), GetTypeErrorFunction().GetTaggedValue()));
3093     vec.push_back(std::make_pair(CString("URIErrorFunction"), GetURIErrorFunction().GetTaggedValue()));
3094     vec.push_back(std::make_pair(CString("SyntaxErrorFunction"), GetSyntaxErrorFunction().GetTaggedValue()));
3095     vec.push_back(std::make_pair(CString("EvalErrorFunction"), GetEvalErrorFunction().GetTaggedValue()));
3096     vec.push_back(std::make_pair(CString("RegExpFunction"), GetRegExpFunction().GetTaggedValue()));
3097     vec.push_back(std::make_pair(CString("BuiltinsSetFunction"), GetBuiltinsSetFunction().GetTaggedValue()));
3098     vec.push_back(std::make_pair(CString("BuiltinsMapFunction"), GetBuiltinsMapFunction().GetTaggedValue()));
3099     vec.push_back(std::make_pair(CString("BuiltinsWeakSetFunction"), GetBuiltinsWeakSetFunction().GetTaggedValue()));
3100     vec.push_back(std::make_pair(CString("BuiltinsWeakMapFunction"), GetBuiltinsWeakMapFunction().GetTaggedValue()));
3101     vec.push_back(std::make_pair(CString("MathFunction"), GetMathFunction().GetTaggedValue()));
3102     vec.push_back(std::make_pair(CString("JsonFunction"), GetJsonFunction().GetTaggedValue()));
3103     vec.push_back(std::make_pair(CString("StringFunction"), GetStringFunction().GetTaggedValue()));
3104     vec.push_back(std::make_pair(CString("ProxyFunction"), GetProxyFunction().GetTaggedValue()));
3105     vec.push_back(std::make_pair(CString("ReflectFunction"), GetReflectFunction().GetTaggedValue()));
3106     vec.push_back(std::make_pair(CString("AsyncFunction"), GetAsyncFunction().GetTaggedValue()));
3107     vec.push_back(std::make_pair(CString("AsyncFunctionPrototype"), GetAsyncFunctionPrototype().GetTaggedValue()));
3108     vec.push_back(std::make_pair(CString("JSGlobalObject"), GetJSGlobalObject().GetTaggedValue()));
3109     vec.push_back(std::make_pair(CString("EmptyArray"), GetEmptyArray().GetTaggedValue()));
3110     vec.push_back(std::make_pair(CString("EmptyString"), globalConst->GetEmptyString()));
3111     vec.push_back(std::make_pair(CString("EmptyTaggedQueue"), GetEmptyTaggedQueue().GetTaggedValue()));
3112     vec.push_back(std::make_pair(CString("PrototypeString"), globalConst->GetPrototypeString()));
3113     vec.push_back(std::make_pair(CString("HasInstanceSymbol"), GetHasInstanceSymbol().GetTaggedValue()));
3114     vec.push_back(std::make_pair(CString("IsConcatSpreadableSymbol"), GetIsConcatSpreadableSymbol().GetTaggedValue()));
3115     vec.push_back(std::make_pair(CString("ToStringTagSymbol"), GetToStringTagSymbol().GetTaggedValue()));
3116     vec.push_back(std::make_pair(CString("IteratorSymbol"), GetIteratorSymbol().GetTaggedValue()));
3117     vec.push_back(std::make_pair(CString("MatchSymbol"), GetMatchSymbol().GetTaggedValue()));
3118     vec.push_back(std::make_pair(CString("ReplaceSymbol"), GetReplaceSymbol().GetTaggedValue()));
3119     vec.push_back(std::make_pair(CString("SearchSymbol"), GetSearchSymbol().GetTaggedValue()));
3120     vec.push_back(std::make_pair(CString("SpeciesSymbol"), GetSpeciesSymbol().GetTaggedValue()));
3121     vec.push_back(std::make_pair(CString("SplitSymbol"), GetSplitSymbol().GetTaggedValue()));
3122     vec.push_back(std::make_pair(CString("ToPrimitiveSymbol"), GetToPrimitiveSymbol().GetTaggedValue()));
3123     vec.push_back(std::make_pair(CString("UnscopablesSymbol"), GetUnscopablesSymbol().GetTaggedValue()));
3124     vec.push_back(std::make_pair(CString("HoleySymbol"), GetHoleySymbol().GetTaggedValue()));
3125     vec.push_back(std::make_pair(CString("ConstructorString"), globalConst->GetConstructorString()));
3126     vec.push_back(std::make_pair(CString("IteratorPrototype"), GetIteratorPrototype().GetTaggedValue()));
3127     vec.push_back(std::make_pair(CString("ForinIteratorPrototype"), GetForinIteratorPrototype().GetTaggedValue()));
3128     vec.push_back(std::make_pair(CString("StringIterator"), GetStringIterator().GetTaggedValue()));
3129     vec.push_back(std::make_pair(CString("MapIteratorPrototype"), GetMapIteratorPrototype().GetTaggedValue()));
3130     vec.push_back(std::make_pair(CString("SetIteratorPrototype"), GetSetIteratorPrototype().GetTaggedValue()));
3131     vec.push_back(std::make_pair(CString("ArrayIteratorPrototype"), GetArrayIteratorPrototype().GetTaggedValue()));
3132     vec.push_back(std::make_pair(CString("StringIteratorPrototype"), GetStringIteratorPrototype().GetTaggedValue()));
3133     vec.push_back(std::make_pair(CString("LengthString"), globalConst->GetLengthString()));
3134     vec.push_back(std::make_pair(CString("ValueString"), globalConst->GetValueString()));
3135     vec.push_back(std::make_pair(CString("WritableString"), globalConst->GetWritableString()));
3136     vec.push_back(std::make_pair(CString("GetString"), globalConst->GetGetString()));
3137     vec.push_back(std::make_pair(CString("SetString"), globalConst->GetSetString()));
3138     vec.push_back(std::make_pair(CString("EnumerableString"), globalConst->GetEnumerableString()));
3139     vec.push_back(std::make_pair(CString("ConfigurableString"), globalConst->GetConfigurableString()));
3140     vec.push_back(std::make_pair(CString("NameString"), globalConst->GetNameString()));
3141     vec.push_back(std::make_pair(CString("ValueOfString"), globalConst->GetValueOfString()));
3142     vec.push_back(std::make_pair(CString("ToStringString"), globalConst->GetToStringString()));
3143     vec.push_back(std::make_pair(CString("ToLocaleStringString"), globalConst->GetToLocaleStringString()));
3144     vec.push_back(std::make_pair(CString("UndefinedString"), globalConst->GetUndefinedString()));
3145     vec.push_back(std::make_pair(CString("NullString"), globalConst->GetNullString()));
3146     vec.push_back(std::make_pair(CString("TrueString"), globalConst->GetTrueString()));
3147     vec.push_back(std::make_pair(CString("FalseString"), globalConst->GetFalseString()));
3148     vec.push_back(std::make_pair(CString("RegisterSymbols"), GetRegisterSymbols().GetTaggedValue()));
3149     vec.push_back(std::make_pair(CString("ThrowTypeError"), GetThrowTypeError().GetTaggedValue()));
3150     vec.push_back(std::make_pair(CString("GetPrototypeOfString"), globalConst->GetGetPrototypeOfString()));
3151     vec.push_back(std::make_pair(CString("SetPrototypeOfString"), globalConst->GetSetPrototypeOfString()));
3152     vec.push_back(std::make_pair(CString("IsExtensibleString"), globalConst->GetIsExtensibleString()));
3153     vec.push_back(std::make_pair(CString("PreventExtensionsString"), globalConst->GetPreventExtensionsString()));
3154     vec.push_back(
3155         std::make_pair(CString("GetOwnPropertyDescriptorString"), globalConst->GetGetOwnPropertyDescriptorString()));
3156     vec.push_back(std::make_pair(CString("DefinePropertyString"), globalConst->GetDefinePropertyString()));
3157     vec.push_back(std::make_pair(CString("HasString"), globalConst->GetHasString()));
3158     vec.push_back(std::make_pair(CString("DeletePropertyString"), globalConst->GetDeletePropertyString()));
3159     vec.push_back(std::make_pair(CString("EnumerateString"), globalConst->GetEnumerateString()));
3160     vec.push_back(std::make_pair(CString("OwnKeysString"), globalConst->GetOwnKeysString()));
3161     vec.push_back(std::make_pair(CString("ApplyString"), globalConst->GetApplyString()));
3162     vec.push_back(std::make_pair(CString("ProxyString"), globalConst->GetProxyString()));
3163     vec.push_back(std::make_pair(CString("RevokeString"), globalConst->GetRevokeString()));
3164     vec.push_back(std::make_pair(CString("ProxyConstructString"), globalConst->GetProxyConstructString()));
3165     vec.push_back(std::make_pair(CString("ProxyCallString"), globalConst->GetProxyCallString()));
3166     vec.push_back(std::make_pair(CString("DoneString"), globalConst->GetDoneString()));
3167     vec.push_back(std::make_pair(CString("NegativeZeroString"), globalConst->GetNegativeZeroString()));
3168     vec.push_back(std::make_pair(CString("NextString"), globalConst->GetNextString()));
3169     vec.push_back(std::make_pair(CString("PromiseThenString"), globalConst->GetPromiseThenString()));
3170     vec.push_back(std::make_pair(CString("PromiseFunction"), GetPromiseFunction().GetTaggedValue()));
3171     vec.push_back(std::make_pair(CString("PromiseReactionJob"), GetPromiseReactionJob().GetTaggedValue()));
3172     vec.push_back(
3173         std::make_pair(CString("PromiseResolveThenableJob"), GetPromiseResolveThenableJob().GetTaggedValue()));
3174     vec.push_back(std::make_pair(CString("ScriptJobString"), globalConst->GetScriptJobString()));
3175     vec.push_back(std::make_pair(CString("PromiseString"), globalConst->GetPromiseString()));
3176     vec.push_back(std::make_pair(CString("IdentityString"), globalConst->GetIdentityString()));
3177     vec.push_back(std::make_pair(CString("AsyncFunctionString"), globalConst->GetAsyncFunctionString()));
3178     vec.push_back(std::make_pair(CString("ThrowerString"), globalConst->GetThrowerString()));
3179     vec.push_back(std::make_pair(CString("Undefined"), globalConst->GetUndefined()));
3180     vec.push_back(std::make_pair(CString("ArrayListFunction"), globalConst->GetArrayListFunction()));
3181     vec.push_back(std::make_pair(CString("ArrayListIteratorPrototype"), globalConst->GetArrayListIteratorPrototype()));
3182     vec.push_back(std::make_pair(CString("TreeMapIteratorPrototype"), globalConst->GetTreeMapIteratorPrototype()));
3183     vec.push_back(std::make_pair(CString("TreeSetIteratorPrototype"), globalConst->GetTreeSetIteratorPrototype()));
3184 }
3185 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3186 void JSDataView::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3187                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3188 {
3189     vec.push_back(std::make_pair(CString("data-view"), GetDataView()));
3190     vec.push_back(std::make_pair(CString("buffer"), GetViewedArrayBuffer()));
3191     vec.push_back(std::make_pair(CString("byte-length"), JSTaggedValue(GetByteLength())));
3192     vec.push_back(std::make_pair(CString("byte-offset"), JSTaggedValue(GetByteOffset())));
3193 }
3194 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3195 void JSArrayBuffer::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3196                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3197 {
3198     vec.push_back(std::make_pair(CString("buffer-data"), GetArrayBufferData()));
3199     vec.push_back(std::make_pair(CString("byte-length"), JSTaggedValue(GetArrayBufferByteLength())));
3200     vec.push_back(std::make_pair(CString("shared"), JSTaggedValue(GetShared())));
3201 }
3202 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3203 void PromiseReaction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3204                                       std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3205 {
3206     vec.push_back(std::make_pair(CString("promise-capability"), GetPromiseCapability()));
3207     vec.push_back(std::make_pair(CString("handler"), GetHandler()));
3208     vec.push_back(std::make_pair(CString("type"), JSTaggedValue(static_cast<int>(GetType()))));
3209 }
3210 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3211 void PromiseCapability::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3212                                         std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3213 {
3214     vec.push_back(std::make_pair(CString("promise"), GetPromise()));
3215     vec.push_back(std::make_pair(CString("resolve"), GetResolve()));
3216     vec.push_back(std::make_pair(CString("reject"), GetReject()));
3217 }
3218 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3219 void PromiseIteratorRecord::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3220                                             std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3221 {
3222     vec.push_back(std::make_pair(CString("iterator"), GetIterator()));
3223     vec.push_back(std::make_pair(CString("done"), JSTaggedValue(GetDone())));
3224 }
3225 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3226 void PromiseRecord::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3227                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3228 {
3229     vec.push_back(std::make_pair(CString("value"), GetValue()));
3230 }
3231 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3232 void ResolvingFunctionsRecord::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3233                                                std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3234 {
3235     vec.push_back(std::make_pair(CString("resolve-function"), GetResolveFunction()));
3236     vec.push_back(std::make_pair(CString("reject-function"), GetRejectFunction()));
3237 }
3238 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3239 void JSPromise::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3240                                 std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3241 {
3242     vec.push_back(std::make_pair(CString("promise-state"), JSTaggedValue(static_cast<int>(GetPromiseState()))));
3243     vec.push_back(std::make_pair(CString("promise-result"), GetPromiseResult()));
3244     vec.push_back(std::make_pair(CString("promise-fulfill-reactions"), GetPromiseFulfillReactions()));
3245     vec.push_back(std::make_pair(CString("promise-reject-reactions"), GetPromiseRejectReactions()));
3246     vec.push_back(std::make_pair(CString("promise-is-handled"), JSTaggedValue(GetPromiseIsHandled())));
3247     JSObject::DumpForSnapshot(thread, vec);
3248 }
3249 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3250 void JSPromiseReactionsFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3251                                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3252 {
3253     vec.push_back(std::make_pair(CString("promise"), GetPromise()));
3254     vec.push_back(std::make_pair(CString("already-resolved"), GetAlreadyResolved()));
3255     JSObject::DumpForSnapshot(thread, vec);
3256 }
3257 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3258 void JSPromiseExecutorFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3259                                                 std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3260 {
3261     vec.push_back(std::make_pair(CString("capability"), GetCapability()));
3262     JSObject::DumpForSnapshot(thread, vec);
3263 }
3264 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3265 void JSPromiseAllResolveElementFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3266                                                          std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3267 {
3268     vec.push_back(std::make_pair(CString("index"), GetIndex()));
3269     vec.push_back(std::make_pair(CString("values"), GetValues()));
3270     vec.push_back(std::make_pair(CString("capabilities"), GetCapabilities()));
3271     vec.push_back(std::make_pair(CString("remaining-elements"), GetRemainingElements()));
3272     vec.push_back(std::make_pair(CString("already-called"), GetAlreadyCalled()));
3273     JSObject::DumpForSnapshot(thread, vec);
3274 }
3275 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3276 void MicroJobQueue::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3277                                     std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3278 {
3279     vec.push_back(std::make_pair(CString("promise-job-queue"), GetPromiseJobQueue()));
3280     vec.push_back(std::make_pair(CString("script-job-queue"), GetScriptJobQueue()));
3281 }
3282 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3283 void PendingJob::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3284                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3285 {
3286     vec.push_back(std::make_pair(CString("job"), GetJob()));
3287     vec.push_back(std::make_pair(CString("arguments"), GetArguments()));
3288     vec.push_back(std::make_pair(CString("chainId"), JSTaggedValue(GetChainId())));
3289     vec.push_back(std::make_pair(CString("spanId"), JSTaggedValue(GetChainId())));
3290     vec.push_back(std::make_pair(CString("parentSpanId"), JSTaggedValue(GetChainId())));
3291     vec.push_back(std::make_pair(CString("flags"), JSTaggedValue(GetChainId())));
3292 }
3293 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3294 void CompletionRecord::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3295                                        std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3296 {
3297     vec.push_back(std::make_pair(CString("value"), GetValue()));
3298     vec.push_back(std::make_pair(CString("type"), JSTaggedValue(static_cast<int>(GetType()))));
3299 }
3300 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3301 void JSProxyRevocFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3302                                            std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3303 {
3304     vec.push_back(std::make_pair(CString("RevocableProxy"), GetRevocableProxy()));
3305 }
3306 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3307 void JSAsyncFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3308                                       std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3309 {
3310     JSFunction::DumpForSnapshot(thread, vec);
3311 }
3312 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3313 void JSAsyncAwaitStatusFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3314                                                  std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3315 {
3316     vec.push_back(std::make_pair(CString("AsyncContext"), GetAsyncContext()));
3317 }
3318 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3319 void JSGeneratorFunction::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3320                                           std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3321 {
3322     JSFunction::DumpForSnapshot(thread, vec);
3323 }
3324 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3325 void JSIntlBoundFunction::DumpForSnapshot(JSThread *thread,
3326                                           std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3327 {
3328     vec.push_back(std::make_pair(CString("NumberFormat"), GetNumberFormat()));
3329     vec.push_back(std::make_pair(CString("DateTimeFormat"), GetDateTimeFormat()));
3330     vec.push_back(std::make_pair(CString("Collator"), GetCollator()));
3331     JSObject::DumpForSnapshot(thread, vec);
3332 }
3333 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3334 void PropertyBox::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3335                                   std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3336 {
3337     vec.push_back(std::make_pair(CString("Value"), GetValue()));
3338 }
3339 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3340 void PrototypeHandler::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3341                                        std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3342 {
3343     vec.push_back(std::make_pair(CString("HandlerInfo"), GetHandlerInfo()));
3344     vec.push_back(std::make_pair(CString("ProtoCell"), GetProtoCell()));
3345     vec.push_back(std::make_pair(CString("Holder"), GetHolder()));
3346 }
3347 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3348 void TransitionHandler::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3349                                         std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3350 {
3351     vec.push_back(std::make_pair(CString("HandlerInfo"), GetHandlerInfo()));
3352     vec.push_back(std::make_pair(CString("TransitionHClass"), GetTransitionHClass()));
3353 }
3354 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3355 void JSRealm::DumpForSnapshot([[maybe_unused]] JSThread *thread,
3356                               std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3357 {
3358     vec.push_back(std::make_pair(CString("Value"), GetValue()));
3359     vec.push_back(std::make_pair(CString("GLobalEnv"), GetGlobalEnv()));
3360     JSObject::DumpForSnapshot(thread, vec);
3361 }
3362 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3363 void JSIntl::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3364 {
3365     vec.push_back(std::make_pair(CString("FallbackSymbol"), GetFallbackSymbol()));
3366     JSObject::DumpForSnapshot(thread, vec);
3367 }
3368 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3369 void JSLocale::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3370 {
3371     vec.push_back(std::make_pair(CString("IcuField"), GetIcuField()));
3372     JSObject::DumpForSnapshot(thread, vec);
3373 }
3374 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3375 void JSDateTimeFormat::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3376 {
3377     vec.push_back(std::make_pair(CString("Locale"), GetLocale()));
3378     vec.push_back(std::make_pair(CString("Calendar"), GetCalendar()));
3379     vec.push_back(std::make_pair(CString("NumberingSystem"), GetNumberingSystem()));
3380     vec.push_back(std::make_pair(CString("TimeZone"), GetTimeZone()));
3381     vec.push_back(std::make_pair(CString("HourCycle"), JSTaggedValue(static_cast<int>(GetHourCycle()))));
3382     vec.push_back(std::make_pair(CString("LocaleIcu"), GetLocaleIcu()));
3383     vec.push_back(std::make_pair(CString("SimpleDateTimeFormatIcu"), GetSimpleDateTimeFormatIcu()));
3384     vec.push_back(std::make_pair(CString("Iso8601"), GetIso8601()));
3385     vec.push_back(std::make_pair(CString("DateStyle"), JSTaggedValue(static_cast<int>(GetDateStyle()))));
3386     vec.push_back(std::make_pair(CString("TimeStyle"), JSTaggedValue(static_cast<int>(GetTimeStyle()))));
3387     vec.push_back(std::make_pair(CString("BoundFormat"), GetBoundFormat()));
3388     JSObject::DumpForSnapshot(thread, vec);
3389 }
3390 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3391 void JSRelativeTimeFormat::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3392 {
3393     vec.push_back(std::make_pair(CString("Locale"), GetLocale()));
3394     vec.push_back(std::make_pair(CString("InitializedRelativeTimeFormat"), GetInitializedRelativeTimeFormat()));
3395     vec.push_back(std::make_pair(CString("NumberingSystem"), GetNumberingSystem()));
3396     vec.push_back(std::make_pair(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle()))));
3397     vec.push_back(std::make_pair(CString("Numeric"), JSTaggedValue(static_cast<int>(GetNumeric()))));
3398     vec.push_back(std::make_pair(CString("AvailableLocales"), GetAvailableLocales()));
3399     vec.push_back(std::make_pair(CString("IcuField"), GetIcuField()));
3400     JSObject::DumpForSnapshot(thread, vec);
3401 }
3402 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3403 void JSNumberFormat::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3404 {
3405     vec.push_back(std::make_pair(CString("Locale"), GetLocale()));
3406     vec.push_back(std::make_pair(CString("NumberingSystem"), GetNumberingSystem()));
3407     vec.push_back(std::make_pair(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle()))));
3408     vec.push_back(std::make_pair(CString("Currency"), GetCurrency()));
3409     vec.push_back(std::make_pair(CString("CurrencyDisplay"), JSTaggedValue(static_cast<int>(GetCurrencyDisplay()))));
3410     vec.push_back(std::make_pair(CString("CurrencySign"), JSTaggedValue(static_cast<int>(GetCurrencySign()))));
3411     vec.push_back(std::make_pair(CString("Unit"), GetUnit()));
3412     vec.push_back(std::make_pair(CString("UnitDisplay"), JSTaggedValue(static_cast<int>(GetUnitDisplay()))));
3413     vec.push_back(std::make_pair(CString("MinimumIntegerDigits"), GetMinimumIntegerDigits()));
3414     vec.push_back(std::make_pair(CString("MinimumFractionDigits"), GetMinimumFractionDigits()));
3415     vec.push_back(std::make_pair(CString("MaximumFractionDigits"), GetMaximumFractionDigits()));
3416     vec.push_back(std::make_pair(CString("MinimumSignificantDigits"), GetMinimumSignificantDigits()));
3417     vec.push_back(std::make_pair(CString("MaximumSignificantDigits"), GetMaximumSignificantDigits()));
3418     vec.push_back(std::make_pair(CString("UseGrouping"), GetUseGrouping()));
3419     vec.push_back(std::make_pair(CString("RoundingType"), JSTaggedValue(static_cast<int>(GetRoundingType()))));
3420     vec.push_back(std::make_pair(CString("Notation"), JSTaggedValue(static_cast<int>(GetNotation()))));
3421     vec.push_back(std::make_pair(CString("CompactDisplay"), JSTaggedValue(static_cast<int>(GetCompactDisplay()))));
3422     vec.push_back(std::make_pair(CString("SignDisplay"), JSTaggedValue(static_cast<int>(GetSignDisplay()))));
3423     vec.push_back(std::make_pair(CString("BoundFormat"), GetBoundFormat()));
3424     vec.push_back(std::make_pair(CString("IcuField"), GetIcuField()));
3425     JSObject::DumpForSnapshot(thread, vec);
3426 }
3427 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3428 void JSCollator::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3429 {
3430     vec.push_back(std::make_pair(CString("IcuField"), GetIcuField()));
3431     vec.push_back(std::make_pair(CString("Locale"), GetLocale()));
3432     vec.push_back(std::make_pair(CString("Collation"), GetCollation()));
3433     vec.push_back(std::make_pair(CString("BoundCompare"), GetBoundCompare()));
3434     vec.push_back(std::make_pair(CString("CaseFirst"), JSTaggedValue(static_cast<int>(GetCaseFirst()))));
3435     vec.push_back(std::make_pair(CString("Usage"), JSTaggedValue(static_cast<int>(GetUsage()))));
3436     vec.push_back(std::make_pair(CString("Sensitivity"), JSTaggedValue(static_cast<int>(GetSensitivity()))));
3437     vec.push_back(std::make_pair(CString("IgnorePunctuation"), JSTaggedValue(GetIgnorePunctuation())));
3438     vec.push_back(std::make_pair(CString("Numeric"), JSTaggedValue(GetNumeric())));
3439     JSObject::DumpForSnapshot(thread, vec);
3440 }
3441 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3442 void JSPluralRules::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3443 {
3444     vec.push_back(std::make_pair(CString("Locale"), GetLocale()));
3445     vec.push_back(std::make_pair(CString("InitializedPluralRules"), GetInitializedPluralRules()));
3446     vec.push_back(std::make_pair(CString("MinimumIntegerDigits"), GetMinimumIntegerDigits()));
3447     vec.push_back(std::make_pair(CString("MinimumFractionDigits"), GetMinimumFractionDigits()));
3448     vec.push_back(std::make_pair(CString("MaximumFractionDigits"), GetMaximumFractionDigits()));
3449     vec.push_back(std::make_pair(CString("MinimumSignificantDigits"), GetMinimumSignificantDigits()));
3450     vec.push_back(std::make_pair(CString("MaximumSignificantDigits"), GetMaximumSignificantDigits()));
3451     vec.push_back(std::make_pair(CString("RoundingType"), JSTaggedValue(static_cast<int>(GetRoundingType()))));
3452     vec.push_back(std::make_pair(CString("IcuPR"), GetIcuPR()));
3453     vec.push_back(std::make_pair(CString("IcuNF"), GetIcuNF()));
3454     vec.push_back(std::make_pair(CString("Type"), JSTaggedValue(static_cast<int>(GetType()))));
3455     JSObject::DumpForSnapshot(thread, vec);
3456 }
3457 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3458 void JSGeneratorObject::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3459 {
3460     vec.push_back(std::make_pair(CString("GeneratorContext"), GetGeneratorContext()));
3461     vec.push_back(std::make_pair(CString("ResumeResult"), GetResumeResult()));
3462     vec.push_back(std::make_pair(CString("GeneratorState"), JSTaggedValue(static_cast<int>(GetGeneratorState()))));
3463     vec.push_back(std::make_pair(CString("ResumeMode"), JSTaggedValue(static_cast<int>(GetResumeMode()))));
3464     JSObject::DumpForSnapshot(thread, vec);
3465 }
3466 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3467 void JSAsyncFuncObject::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3468 {
3469     vec.push_back(std::make_pair(CString("Promise"), GetPromise()));
3470 }
3471 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3472 void GeneratorContext::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3473 {
3474     vec.push_back(std::make_pair(CString("RegsArray"), GetRegsArray()));
3475     vec.push_back(std::make_pair(CString("Method"), GetMethod()));
3476     vec.push_back(std::make_pair(CString("Acc"), GetAcc()));
3477     vec.push_back(std::make_pair(CString("GeneratorObject"), GetGeneratorObject()));
3478     vec.push_back(std::make_pair(CString("LexicalEnv"), GetLexicalEnv()));
3479     vec.push_back(std::make_pair(CString("NRegs"),  JSTaggedValue(GetNRegs())));
3480     vec.push_back(std::make_pair(CString("BCOffset"),  JSTaggedValue(GetBCOffset())));
3481 }
3482 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3483 void ProtoChangeMarker::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3484 {
3485     vec.push_back(std::make_pair(CString("Promise"), JSTaggedValue(GetHasChanged())));
3486 }
3487 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3488 void ProtoChangeDetails::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3489 {
3490     vec.push_back(std::make_pair(CString("ChangeListener"), GetChangeListener()));
3491     vec.push_back(std::make_pair(CString("RegisterIndex"), JSTaggedValue(GetRegisterIndex())));
3492 }
3493 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3494 void MachineCode::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3495 {
3496     vec.push_back(std::make_pair(CString("InstructionSizeInBytes"), JSTaggedValue(GetInstructionSizeInBytes())));
3497 }
3498 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3499 void EcmaModule::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3500 {
3501     vec.push_back(std::make_pair(CString("NameDictionary"), GetNameDictionary()));
3502 }
3503 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3504 void ClassInfoExtractor::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3505 {
3506     vec.push_back(std::make_pair(CString("PrototypeHClass"), GetPrototypeHClass()));
3507     vec.push_back(std::make_pair(CString("NonStaticKeys"), GetNonStaticKeys()));
3508     vec.push_back(std::make_pair(CString("NonStaticProperties"), GetNonStaticProperties()));
3509     vec.push_back(std::make_pair(CString("NonStaticElements"), GetNonStaticElements()));
3510     vec.push_back(std::make_pair(CString("ConstructorHClass"), GetConstructorHClass()));
3511     vec.push_back(std::make_pair(CString("StaticKeys"), GetStaticKeys()));
3512     vec.push_back(std::make_pair(CString("StaticProperties"), GetStaticProperties()));
3513     vec.push_back(std::make_pair(CString("StaticElements"), GetStaticElements()));
3514 }
3515 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3516 void TSObjectType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3517 {
3518     vec.push_back(std::make_pair(CString("ObjLayoutInfo"), GetObjLayoutInfo()));
3519     vec.push_back(std::make_pair(CString("HClass"), GetHClass()));
3520 }
3521 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3522 void TSClassType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3523 {
3524     vec.push_back(std::make_pair(CString("InstanceType"), GetInstanceType()));
3525     vec.push_back(std::make_pair(CString("ConstructorType"), GetConstructorType()));
3526     vec.push_back(std::make_pair(CString("PrototypeType"), GetPrototypeType()));
3527     vec.push_back(std::make_pair(CString("ExtensionType"), GetExtensionType()));
3528 }
3529 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3530 void TSInterfaceType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3531 {
3532     vec.push_back(std::make_pair(CString("Fields"), GetFields()));
3533     vec.push_back(std::make_pair(CString("Extends"), GetExtends()));
3534 }
3535 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3536 void TSClassInstanceType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3537 {
3538     vec.push_back(std::make_pair(CString("classTypeIndex"), GetCreateClassType()));
3539 }
3540 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3541 void TSImportType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3542 {
3543     vec.push_back(std::make_pair(CString("TargetType"), GetTargetType()));
3544     vec.push_back(std::make_pair(CString("ImportTypePath"), GetImportPath()));
3545 }
3546 
DumpForSnapshot(JSThread * thread,std::vector<std::pair<CString,JSTaggedValue>> & vec) const3547 void TSUnionType::DumpForSnapshot(JSThread *thread, std::vector<std::pair<CString, JSTaggedValue>> &vec) const
3548 {
3549     vec.push_back(std::make_pair(CString("ComponentTypes"), GetComponentTypes()));
3550 }
3551 }  // namespace panda::ecmascript
3552