1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16
17 #include "ecmascript/dfx/hprof/heap_snapshot.h"
18 #include "ecmascript/global_dictionary-inl.h"
19 #include "ecmascript/vtable.h"
20 #include "ecmascript/linked_hash_table.h"
21 #include "ecmascript/tagged_tree.h"
22 #ifdef ARK_SUPPORT_INTL
23 #include "ecmascript/js_bigint.h"
24 #include "ecmascript/js_collator.h"
25 #include "ecmascript/js_date_time_format.h"
26 #include "ecmascript/js_intl.h"
27 #include "ecmascript/js_locale.h"
28 #include "ecmascript/js_relative_time_format.h"
29 #include "ecmascript/js_segmenter.h"
30 #include "ecmascript/js_segments.h"
31 #include "ecmascript/js_segment_iterator.h"
32 #endif
33
34 namespace panda::ecmascript {
35 using MicroJobQueue = panda::ecmascript::job::MicroJobQueue;
36 using PendingJob = panda::ecmascript::job::PendingJob;
37 using ExtraProfileTypeInfo = panda::ecmascript::pgo::ExtraProfileTypeInfo;
38
39 static constexpr uint32_t DUMP_TYPE_OFFSET = 12;
40 static constexpr uint32_t DUMP_PROPERTY_OFFSET = 20;
41 static constexpr uint32_t DUMP_ELEMENT_OFFSET = 2;
42
DumpJSType(JSType type)43 CString JSHClass::DumpJSType(JSType type)
44 {
45 switch (type) {
46 case JSType::HCLASS:
47 return "JSHClass";
48 case JSType::COMPOSITE_BASE_CLASS:
49 return "CompositeBaseClass";
50 case JSType::TAGGED_ARRAY:
51 return "TaggedArray";
52 case JSType::LEXICAL_ENV:
53 return "LexicalEnv";
54 case JSType::SFUNCTION_ENV:
55 return "SFunctionEnv";
56 case JSType::SENDABLE_ENV:
57 return "SendableEnv";
58 case JSType::TAGGED_DICTIONARY:
59 return "TaggedDictionary";
60 case JSType::CONSTANT_POOL:
61 return "ConstantPool";
62 case JSType::PROFILE_TYPE_INFO:
63 return "ProfileTypeInfo";
64 case JSType::COW_TAGGED_ARRAY:
65 return "COWArray";
66 case JSType::MUTANT_TAGGED_ARRAY:
67 return "MutantTaggedArray";
68 case JSType::COW_MUTANT_TAGGED_ARRAY:
69 return "COWMutantTaggedArray";
70 case JSType::LINE_STRING:
71 case JSType::TREE_STRING:
72 case JSType::SLICED_STRING:
73 return "BaseString";
74 case JSType::JS_NATIVE_POINTER:
75 return "NativePointer";
76 case JSType::JS_OBJECT:
77 return "Object";
78 case JSType::JS_XREF_OBJECT:
79 return "XRefObject";
80 case JSType::JS_SHARED_OBJECT:
81 return "SharedObject";
82 case JSType::JS_FUNCTION_BASE:
83 return "Function Base";
84 case JSType::JS_FUNCTION:
85 return "Function";
86 case JSType::JS_SHARED_FUNCTION:
87 return "Shared Function";
88 case JSType::JS_ERROR:
89 return "Error";
90 case JSType::NATIVE_MODULE_FAILURE_INFO:
91 return "NativeModuleFailureInfo";
92 case JSType::JS_EVAL_ERROR:
93 return "Eval Error";
94 case JSType::JS_RANGE_ERROR:
95 return "Range Error";
96 case JSType::JS_TYPE_ERROR:
97 return "Type Error";
98 case JSType::JS_AGGREGATE_ERROR:
99 return "Aggregate Error";
100 case JSType::JS_REFERENCE_ERROR:
101 return "Reference Error";
102 case JSType::JS_URI_ERROR:
103 return "Uri Error";
104 case JSType::JS_SYNTAX_ERROR:
105 return "Syntax Error";
106 case JSType::JS_OOM_ERROR:
107 return "OutOfMemory Error";
108 case JSType::JS_TERMINATION_ERROR:
109 return "Termination Error";
110 case JSType::JS_REG_EXP:
111 return "Regexp";
112 case JSType::JS_SET:
113 return "Set";
114 case JSType::JS_SHARED_SET:
115 return "SharedSet";
116 case JSType::JS_MAP:
117 return "Map";
118 case JSType::JS_SHARED_MAP:
119 return "SharedMap";
120 case JSType::JS_WEAK_SET:
121 return "WeakSet";
122 case JSType::JS_WEAK_MAP:
123 return "WeakMap";
124 case JSType::JS_WEAK_REF:
125 return "WeakRef";
126 case JSType::JS_FINALIZATION_REGISTRY:
127 return "JSFinalizationRegistry";
128 case JSType::CELL_RECORD:
129 return "CellRecord";
130 case JSType::JS_DATE:
131 return "Date";
132 case JSType::JS_BOUND_FUNCTION:
133 return "Bound Function";
134 case JSType::JS_ARRAY:
135 return "Array";
136 case JSType::JS_SHARED_ARRAY:
137 return "SharedArray";
138 case JSType::JS_SHARED_ARRAY_ITERATOR:
139 return "SharedArrayIterator";
140 case JSType::JS_TYPED_ARRAY:
141 return "Typed Array";
142 case JSType::JS_INT8_ARRAY:
143 return "Int8 Array";
144 case JSType::JS_UINT8_ARRAY:
145 return "Uint8 Array";
146 case JSType::JS_UINT8_CLAMPED_ARRAY:
147 return "Uint8 Clamped Array";
148 case JSType::JS_INT16_ARRAY:
149 return "Int16 Array";
150 case JSType::JS_UINT16_ARRAY:
151 return "Uint16 Array";
152 case JSType::JS_INT32_ARRAY:
153 return "Int32 Array";
154 case JSType::JS_UINT32_ARRAY:
155 return "Uint32 Array";
156 case JSType::BIGINT:
157 return "BigInt";
158 case JSType::JS_FLOAT32_ARRAY:
159 return "Float32 Array";
160 case JSType::JS_FLOAT64_ARRAY:
161 return "Float64 Array";
162 case JSType::JS_BIGINT64_ARRAY:
163 return "BigInt64 Array";
164 case JSType::JS_BIGUINT64_ARRAY:
165 return "BigUint64 Array";
166 case JSType::JS_SHARED_TYPED_ARRAY:
167 return "Shared Typed Array";
168 case JSType::JS_SHARED_INT8_ARRAY:
169 return "Shared Int8 Array";
170 case JSType::JS_SHARED_UINT8_ARRAY:
171 return "Shared Uint8 Array";
172 case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY:
173 return "Shared Uint8 Clamped Array";
174 case JSType::JS_SHARED_INT16_ARRAY:
175 return "Shared Int16 Array";
176 case JSType::JS_SHARED_UINT16_ARRAY:
177 return "Shared Uint16 Array";
178 case JSType::JS_SHARED_INT32_ARRAY:
179 return "Shared Int32 Array";
180 case JSType::JS_SHARED_UINT32_ARRAY:
181 return "Shared Uint32 Array";
182 case JSType::JS_SHARED_FLOAT32_ARRAY:
183 return "Shared Float32 Array";
184 case JSType::JS_SHARED_FLOAT64_ARRAY:
185 return "Shared Float64 Array";
186 case JSType::JS_SHARED_BIGINT64_ARRAY:
187 return "Shared BigInt64 Array";
188 case JSType::JS_SHARED_BIGUINT64_ARRAY:
189 return "Shared BigUint64 Array";
190 case JSType::BYTE_ARRAY:
191 return "ByteArray";
192 case JSType::JS_ARGUMENTS:
193 return "Arguments";
194 case JSType::JS_PROXY:
195 return "Proxy";
196 case JSType::JS_PRIMITIVE_REF:
197 return "Primitive";
198 case JSType::JS_MODULE_NAMESPACE:
199 return "ModuleNamespace";
200 case JSType::JS_DATA_VIEW:
201 return "DataView";
202 case JSType::JS_ITERATOR:
203 return "Iterator";
204 case JSType::JS_ASYNCITERATOR:
205 return "AsyncIterator";
206 case JSType::JS_FORIN_ITERATOR:
207 return "ForinInterator";
208 case JSType::JS_MAP_ITERATOR:
209 return "MapIterator";
210 case JSType::JS_SHARED_MAP_ITERATOR:
211 return "SharedMapIterator";
212 case JSType::JS_SET_ITERATOR:
213 return "SetIterator";
214 case JSType::JS_SHARED_SET_ITERATOR:
215 return "SharedSetIterator";
216 case JSType::JS_ARRAY_ITERATOR:
217 return "ArrayIterator";
218 case JSType::JS_STRING_ITERATOR:
219 return "StringIterator";
220 case JSType::JS_REG_EXP_ITERATOR:
221 return "RegExpIterator";
222 case JSType::JS_ARRAY_BUFFER:
223 return "ArrayBuffer";
224 case JSType::JS_SENDABLE_ARRAY_BUFFER:
225 return "SendableArrayBuffer";
226 case JSType::JS_SHARED_ARRAY_BUFFER:
227 return "SharedArrayBuffer";
228 case JSType::JS_PROXY_REVOC_FUNCTION:
229 return "ProxyRevocFunction";
230 case JSType::PROMISE_REACTIONS:
231 return "PromiseReaction";
232 case JSType::PROMISE_CAPABILITY:
233 return "PromiseCapability";
234 case JSType::PROMISE_ITERATOR_RECORD:
235 return "PromiseIteratorRecord";
236 case JSType::PROMISE_RECORD:
237 return "PromiseRecord";
238 case JSType::RESOLVING_FUNCTIONS_RECORD:
239 return "ResolvingFunctionsRecord";
240 case JSType::ASYNC_GENERATOR_REQUEST:
241 return "AsyncGeneratorRequest";
242 case JSType::ASYNC_ITERATOR_RECORD:
243 return "AsyncIteratorRecord";
244 case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
245 return "AsyncFromSyncIterator";
246 case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
247 return "AsyncFromSyncIterUnwarpFunction";
248 case JSType::JS_PROMISE:
249 return "Promise";
250 case JSType::JS_PROMISE_REACTIONS_FUNCTION:
251 return "PromiseReactionsFunction";
252 case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
253 return "PromiseExecutorFunction";
254 case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION:
255 return "AsyncModuleFulfilledFunction";
256 case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION:
257 return "AsyncModuleRejectedFunction";
258 case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
259 return "PromiseAllResolveElementFunction";
260 case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
261 return "PromiseAnyRejectElementFunction";
262 case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
263 return "PromiseAllSettledElementFunction";
264 case JSType::JS_PROMISE_FINALLY_FUNCTION:
265 return "PromiseFinallyFunction";
266 case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
267 return "PromiseValueThunkOrThrowerFunction";
268 case JSType::JS_GENERATOR_FUNCTION:
269 return "GeneratorFunction";
270 case JSType::JS_ASYNC_GENERATOR_FUNCTION:
271 return "AsyncGeneratorFunction";
272 case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
273 return "AsyncGeneratorResumeNextReturnProcessorRstFtn";
274 case JSType::MICRO_JOB_QUEUE:
275 return "MicroJobQueue";
276 case JSType::PENDING_JOB:
277 return "PendingJob";
278 case JSType::COMPLETION_RECORD:
279 return "CompletionRecord";
280 case JSType::GLOBAL_ENV:
281 return "GlobalEnv";
282 case JSType::ACCESSOR_DATA:
283 return "AccessorData";
284 case JSType::INTERNAL_ACCESSOR:
285 return "InternalAccessor";
286 case JSType::SYMBOL:
287 return "Symbol";
288 case JSType::PROPERTY_BOX:
289 return "PropertyBox";
290 case JSType::JS_ASYNC_FUNCTION:
291 return "AsyncFunction";
292 case JSType::JS_SHARED_ASYNC_FUNCTION:
293 return "SharedAsyncFunction";
294 case JSType::JS_INTL_BOUND_FUNCTION:
295 return "IntlBoundFunction";
296 case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
297 return "AsyncAwaitStatusFunction";
298 case JSType::JS_ASYNC_FUNC_OBJECT:
299 return "AsyncFunctionObject";
300 case JSType::JS_REALM:
301 return "Realm";
302 case JSType::JS_GLOBAL_OBJECT:
303 return "GlobalObject";
304 case JSType::JS_INTL:
305 return "JSIntl";
306 case JSType::JS_LOCALE:
307 return "JSLocale";
308 case JSType::JS_DATE_TIME_FORMAT:
309 return "JSDateTimeFormat";
310 case JSType::JS_RELATIVE_TIME_FORMAT:
311 return "JSRelativeTimeFormat";
312 case JSType::JS_NUMBER_FORMAT:
313 return "JSNumberFormat";
314 case JSType::JS_COLLATOR:
315 return "JSCollator";
316 case JSType::JS_PLURAL_RULES:
317 return "JSPluralRules";
318 case JSType::JS_DISPLAYNAMES:
319 return "JSDisplayNames";
320 case JSType::JS_SEGMENTER:
321 return "JSSegmenter";
322 case JSType::JS_SEGMENTS:
323 return "JSSegments";
324 case JSType::JS_SEGMENT_ITERATOR:
325 return "JSSegmentIterator";
326 case JSType::JS_LIST_FORMAT:
327 return "JSListFormat";
328 case JSType::JS_GENERATOR_OBJECT:
329 return "JSGeneratorObject";
330 case JSType::JS_ASYNC_GENERATOR_OBJECT:
331 return "JSAsyncGeneratorObject";
332 case JSType::JS_GENERATOR_CONTEXT:
333 return "JSGeneratorContext";
334 case JSType::PROTOTYPE_HANDLER:
335 return "PrototypeHandler";
336 case JSType::TRANSITION_HANDLER:
337 return "TransitionHandler";
338 case JSType::TRANS_WITH_PROTO_HANDLER:
339 return "TransWithProtoHandler";
340 case JSType::STORE_TS_HANDLER:
341 return "StoreTSHandler";
342 case JSType::ENUM_CACHE:
343 return "EnumCache";
344 case JSType::PROTO_CHANGE_MARKER:
345 return "ProtoChangeMarker";
346 case JSType::MARKER_CELL:
347 return "MarkerCell";
348 case JSType::TRACK_INFO:
349 return "TrackInfo";
350 case JSType::PROTOTYPE_INFO:
351 return "PrototypeInfo";
352 case JSType::TEMPLATE_MAP:
353 return "TemplateMap";
354 case JSType::PROGRAM:
355 return "program";
356 case JSType::MACHINE_CODE_OBJECT:
357 return "MachineCode";
358 case JSType::CLASS_INFO_EXTRACTOR:
359 return "ClassInfoExtractor";
360 case JSType::JS_API_ARRAY_LIST:
361 return "ArrayList";
362 case JSType::JS_API_ARRAYLIST_ITERATOR:
363 return "JSArraylistIterator";
364 case JSType::LINKED_NODE:
365 return "LinkedNode";
366 case JSType::RB_TREENODE:
367 return "RBTreeNode";
368 case JSType::FREE_OBJECT_WITH_ONE_FIELD:
369 return "FreeObjectWithOneField";
370 case JSType::FREE_OBJECT_WITH_NONE_FIELD:
371 return "FreeObjectWithNoneField";
372 case JSType::FREE_OBJECT_WITH_TWO_FIELD:
373 return "FreeObjectWithTwoField";
374 case JSType::JS_API_HASH_MAP:
375 return "HashMap";
376 case JSType::JS_API_HASH_SET:
377 return "HashSet";
378 case JSType::JS_API_HASHMAP_ITERATOR:
379 return "HashMapIterator";
380 case JSType::JS_API_HASHSET_ITERATOR:
381 return "HashSetIterator";
382 case JSType::JS_API_LIGHT_WEIGHT_MAP:
383 return "LightWeightMap";
384 case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
385 return "LightWeightMapIterator";
386 case JSType::JS_API_LIGHT_WEIGHT_SET:
387 return "LightWeightSet";
388 case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
389 return "LightWeightSetIterator";
390 case JSType::JS_API_TREE_MAP:
391 return "TreeMap";
392 case JSType::JS_API_TREE_SET:
393 return "TreeSet";
394 case JSType::JS_API_TREEMAP_ITERATOR:
395 return "TreeMapIterator";
396 case JSType::JS_API_TREESET_ITERATOR:
397 return "TreeSetIterator";
398 case JSType::JS_API_VECTOR:
399 return "Vector";
400 case JSType::JS_API_VECTOR_ITERATOR:
401 return "VectorIterator";
402 case JSType::JS_API_BITVECTOR:
403 return "BitVector";
404 case JSType::JS_API_BITVECTOR_ITERATOR:
405 return "BitVectorIterator";
406 case JSType::JS_API_FAST_BUFFER:
407 return "Buffer";
408 case JSType::JS_API_QUEUE:
409 return "Queue";
410 case JSType::JS_API_QUEUE_ITERATOR:
411 return "QueueIterator";
412 case JSType::JS_API_PLAIN_ARRAY:
413 return "PlainArray";
414 case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
415 return "PlainArrayIterator";
416 case JSType::JS_API_DEQUE:
417 return "Deque";
418 case JSType::JS_API_DEQUE_ITERATOR:
419 return "DequeIterator";
420 case JSType::JS_API_STACK:
421 return "Stack";
422 case JSType::JS_API_STACK_ITERATOR:
423 return "StackIterator";
424 case JSType::JS_API_LIST:
425 return "List";
426 case JSType::JS_API_LIST_ITERATOR:
427 return "ListIterator";
428 case JSType::JS_API_LINKED_LIST:
429 return "LinkedList";
430 case JSType::JS_API_LINKED_LIST_ITERATOR:
431 return "LinkedListIterator";
432 case JSType::JS_CJS_EXPORTS:
433 return "CommonJSExports";
434 case JSType::JS_CJS_MODULE:
435 return "CommonJSModule";
436 case JSType::JS_CJS_REQUIRE:
437 return "CommonJSRequire";
438 case JSType::METHOD:
439 return "Method";
440 case JSType::AOT_LITERAL_INFO:
441 return "AOTLiteralInfo";
442 case JSType::CLASS_LITERAL:
443 return "ClassLiteral";
444 case JSType::PROFILE_TYPE_INFO_CELL_0:
445 case JSType::PROFILE_TYPE_INFO_CELL_1:
446 case JSType::PROFILE_TYPE_INFO_CELL_N:
447 return "ProfileTypeInfoCell";
448 case JSType::FUNCTION_TEMPLATE:
449 return "FunctionTemplate";
450 case JSType::VTABLE:
451 return "VTable";
452 case JSType::EXTRA_PROFILE_TYPE_INFO:
453 return "ExtraProfileTypeInfo";
454 case JSType::MODULE_RECORD:
455 return "ModuleRecord";
456 case JSType::SOURCE_TEXT_MODULE_RECORD:
457 return "SourceTextModuleRecord";
458 case JSType::RESOLVEDBINDING_RECORD:
459 return "ResolvedBindingRecord";
460 case JSType::RESOLVEDINDEXBINDING_RECORD:
461 return "ResolvedIndexBindingRecord";
462 case JSType::RESOLVEDRECORDINDEXBINDING_RECORD:
463 return "ResolvedRecordIndexBindingRecord";
464 case JSType::RESOLVEDRECORDBINDING_RECORD:
465 return "ResolvedRecordBindingRecord";
466 case JSType::IMPORTENTRY_RECORD:
467 return "ImportEntry";
468 case JSType::LOCAL_EXPORTENTRY_RECORD:
469 return "LocalExportEntry";
470 case JSType::INDIRECT_EXPORTENTRY_RECORD:
471 return "IndirectExportEntry";
472 case JSType::STAR_EXPORTENTRY_RECORD:
473 return "StarExportEntry";
474 default: {
475 CString ret = "unknown type ";
476 return ret.append(std::to_string(static_cast<char>(type)));
477 }
478 }
479 }
480
DumpArrayClass(const JSThread * thread,const TaggedArray * arr,std::ostream & os)481 static void DumpArrayClass(const JSThread *thread, const TaggedArray *arr, std::ostream &os)
482 {
483 DISALLOW_GARBAGE_COLLECTION;
484 uint32_t len = arr->GetLength();
485 os << " <TaggedArray[" << std::dec << len << "]>\n";
486 for (uint32_t i = 0; i < len; i++) {
487 JSTaggedValue val(arr->Get(thread, i));
488 if (!val.IsHole()) {
489 os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
490 val.DumpTaggedValue(thread, os);
491 os << "\n";
492 }
493 }
494 }
495
DumpMutantTaggedArray(const JSThread * thread,const MutantTaggedArray * arr,std::ostream & os)496 static void DumpMutantTaggedArray(const JSThread *thread, const MutantTaggedArray *arr, std::ostream &os)
497 {
498 DISALLOW_GARBAGE_COLLECTION;
499 uint32_t len = arr->GetLength();
500 os << " <MutantTaggedArray[" << std::dec << len << "]>\n";
501 for (uint32_t i = 0; i < len; i++) {
502 JSTaggedValue val(arr->Get(thread, i));
503 os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
504 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[JSTaggedType] : " << val.GetRawData();
505 os << "\n";
506 }
507 }
508
DumpCOWMutantTaggedArray(const JSThread * thread,const COWMutantTaggedArray * arr,std::ostream & os)509 static void DumpCOWMutantTaggedArray(const JSThread *thread, const COWMutantTaggedArray *arr, std::ostream &os)
510 {
511 DISALLOW_GARBAGE_COLLECTION;
512 uint32_t len = arr->GetLength();
513 os << " <COWMutantTaggedArray[" << std::dec << len << "]>\n";
514 for (uint32_t i = 0; i < len; i++) {
515 JSTaggedValue val(arr->Get(thread, i));
516 os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
517 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[JSTaggedType] : " << val.GetRawData();
518 os << "\n";
519 }
520 }
521
DumpConstantPoolClass(const JSThread * thread,const ConstantPool * pool,std::ostream & os)522 static void DumpConstantPoolClass(const JSThread *thread, const ConstantPool *pool, std::ostream &os)
523 {
524 DISALLOW_GARBAGE_COLLECTION;
525 uint32_t len = pool->GetCacheLength();
526 os << " <ConstantPool[" << std::dec << len << "]>\n";
527 for (uint32_t i = 0; i < len; i++) {
528 JSTaggedValue val(pool->GetObjectFromCache(thread, i));
529 if (!val.IsHole()) {
530 os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
531 val.DumpTaggedValue(thread, os);
532 os << "\n";
533 }
534 }
535 }
536
DumpStringClass(const JSThread * thread,const EcmaString * str,std::ostream & os)537 static void DumpStringClass(const JSThread *thread, const EcmaString *str, std::ostream &os)
538 {
539 DISALLOW_GARBAGE_COLLECTION;
540 CString string = ConvertToString(thread, str);
541 os << string;
542 }
543
DumpPropertyKey(const JSThread * thread,JSTaggedValue key,std::ostream & os)544 static void DumpPropertyKey(const JSThread *thread, JSTaggedValue key, std::ostream &os)
545 {
546 if (key.IsString()) {
547 DumpStringClass(thread, EcmaString::Cast(key.GetTaggedObject()), os);
548 } else if (key.IsSymbol()) {
549 JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
550 if (sym->GetDescription(thread).IsString()) {
551 os << "Symbol(\"";
552 DumpStringClass(thread, EcmaString::Cast(sym->GetDescription(thread).GetTaggedObject()), os);
553 os << "\")";
554 } else {
555 os << "Symbol(" << sym << ")";
556 }
557 } else {
558 LOG_ECMA(FATAL) << "this branch is unreachable";
559 UNREACHABLE();
560 }
561 }
562
DumpAttr(const PropertyAttributes & attr,bool fastMode,std::ostream & os)563 static void DumpAttr(const PropertyAttributes &attr, bool fastMode, std::ostream &os)
564 {
565 if (attr.IsAccessor()) {
566 os << "(Accessor) ";
567 }
568
569 os << "Attr(";
570 os << "[Raw: " << std::hex << attr.GetValue() << "] ";
571 if (attr.IsNoneAttributes()) {
572 os << "NONE";
573 }
574 if (attr.IsWritable()) {
575 os << "W";
576 }
577 if (attr.IsEnumerable()) {
578 os << "E";
579 }
580 if (attr.IsConfigurable()) {
581 os << "C";
582 }
583
584 os << ")";
585
586 os << " Rep: " << static_cast<int>(attr.GetRepresentation());
587
588 os << " InlinedProps: " << attr.IsInlinedProps();
589
590 if (fastMode) {
591 os << " Order: " << std::dec << attr.GetOffset();
592 os << " SortedIndex: " << std::dec << attr.GetSortedIndex();
593 } else {
594 os << " Order: " << std::dec << attr.GetDictionaryOrder();
595 }
596 }
597
DumpHClass(const JSThread * thread,const JSHClass * jshclass,std::ostream & os,bool withDetail)598 static void DumpHClass(const JSThread *thread, const JSHClass *jshclass, std::ostream &os, bool withDetail)
599 {
600 DISALLOW_GARBAGE_COLLECTION;
601 os << "JSHClass :" << std::setw(DUMP_TYPE_OFFSET);
602 os << "Type :" << JSHClass::DumpJSType(jshclass->GetObjectType()) << "\n";
603
604 os << " - Prototype :" << std::setw(DUMP_TYPE_OFFSET);
605 jshclass->GetPrototype(thread).DumpTaggedValue(thread, os);
606 os << "\n";
607 os << " - PropertyDescriptors :" << std::setw(DUMP_TYPE_OFFSET);
608 JSTaggedValue attrs = jshclass->GetLayout(thread);
609 attrs.DumpTaggedValue(thread, os);
610 os << "\n";
611 if (withDetail && !attrs.IsNull()) {
612 LayoutInfo *layout = LayoutInfo::Cast(jshclass->GetLayout(thread).GetTaggedObject());
613 int element = static_cast<int>(jshclass->NumberOfProps());
614 for (int i = 0; i < element; i++) {
615 JSTaggedValue key = layout->GetKey(thread, i);
616 PropertyAttributes attr = layout->GetAttr(thread, i);
617 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
618 os << "[" << i << "]: ";
619 DumpPropertyKey(thread, key, os);
620 os << " : ";
621 DumpAttr(attr, true, os);
622 os << "\n";
623 }
624 }
625
626 os << " - Transitions :" << std::setw(DUMP_TYPE_OFFSET);
627 JSTaggedValue transtions = jshclass->GetTransitions(thread);
628 transtions.DumpTaggedValue(thread, os);
629 os << "\n";
630 if (withDetail && !transtions.IsWeakForHeapObject() && transtions.IsDictionary()) {
631 transtions.Dump(thread, os);
632 }
633
634 os << " - ProtoChangeMarker :" << std::setw(DUMP_TYPE_OFFSET);
635 JSTaggedValue marker = jshclass->GetProtoChangeMarker(thread);
636 marker.DumpTaggedValue(thread, os);
637 if (marker.IsHeapObject()) {
638 ProtoChangeMarker::Cast(marker.GetTaggedObject())->Dump(thread, os);
639 } else {
640 os << "\n";
641 }
642
643 os << " - ProtoChangeDetails :" << std::setw(DUMP_TYPE_OFFSET);
644 JSTaggedValue details = jshclass->GetProtoChangeDetails(thread);
645 details.DumpTaggedValue(thread, os);
646 if (details.IsHeapObject()) {
647 ProtoChangeDetails::Cast(details.GetTaggedObject())->Dump(thread, os);
648 } else {
649 os << "\n";
650 }
651
652 os << " - ProfileType : " << std::hex << jshclass->GetProfileType() << "\n";
653
654 os << " - Flags : " << std::setw(DUMP_TYPE_OFFSET);
655 os << "IsCtor :" << std::boolalpha << jshclass->IsConstructor();
656 os << "| IsCallable :" << std::boolalpha << jshclass->IsCallable();
657 os << "| IsExtensible :" << std::boolalpha << jshclass->IsExtensible();
658 os << "| ElementsKind :" << Elements::GetString(jshclass->GetElementsKind());
659 os << "| NumberOfProps :" << std::dec << jshclass->NumberOfProps();
660 os << "| InlinedProperties :" << std::dec << jshclass->GetInlinedProperties();
661 os << "| IsAOT :" << std::boolalpha << jshclass->IsAOT();
662 os << "| HasCtor :" << std::boolalpha << jshclass->HasConstructor();
663 os << "| IsStable :" << std::boolalpha << jshclass->IsStableElements();
664 os << "\n";
665 }
666
DumpClass(const JSThread * thread,TaggedObject * obj,std::ostream & os)667 static void DumpClass(const JSThread *thread, TaggedObject *obj, std::ostream &os)
668 {
669 ASSERT(obj->GetClass()->GetObjectType() == JSType::HCLASS);
670 DumpHClass(thread, JSHClass::Cast(obj), os, true);
671 }
672
DumpObject(const JSThread * thread,TaggedObject * obj,std::ostream & os,bool isPrivacy)673 static void DumpObject(const JSThread *thread, TaggedObject *obj, std::ostream &os, bool isPrivacy)
674 {
675 DISALLOW_GARBAGE_COLLECTION;
676 auto jsHclass = obj->GetClass();
677 JSType type = jsHclass->GetObjectType();
678
679 bool needDumpHClass = false;
680 switch (type) {
681 case JSType::HCLASS:
682 return DumpClass(thread, obj, os);
683 case JSType::TAGGED_ARRAY:
684 case JSType::TAGGED_DICTIONARY:
685 case JSType::TEMPLATE_MAP:
686 case JSType::LEXICAL_ENV:
687 case JSType::SFUNCTION_ENV:
688 case JSType::SENDABLE_ENV:
689 case JSType::COW_TAGGED_ARRAY:
690 case JSType::AOT_LITERAL_INFO:
691 DumpArrayClass(thread, TaggedArray::Cast(obj), os);
692 break;
693 case JSType::MUTANT_TAGGED_ARRAY:
694 DumpMutantTaggedArray(thread, MutantTaggedArray::Cast(obj), os);
695 break;
696 case JSType::COW_MUTANT_TAGGED_ARRAY:
697 DumpCOWMutantTaggedArray(thread, COWMutantTaggedArray::Cast(obj), os);
698 break;
699 case JSType::CONSTANT_POOL:
700 DumpConstantPoolClass(thread, ConstantPool::Cast(obj), os);
701 break;
702 case JSType::PROFILE_TYPE_INFO:
703 ProfileTypeInfo::Cast(obj)->Dump(thread, os);
704 break;
705 case JSType::PROFILE_TYPE_INFO_CELL_0:
706 case JSType::PROFILE_TYPE_INFO_CELL_1:
707 case JSType::PROFILE_TYPE_INFO_CELL_N:
708 ProfileTypeInfoCell::Cast(obj)->Dump(thread, os);
709 break;
710 case JSType::FUNCTION_TEMPLATE:
711 FunctionTemplate::Cast(obj)->Dump(thread, os);
712 break;
713 case JSType::VTABLE:
714 VTable::Cast(obj)->Dump(thread, os);
715 break;
716 case JSType::EXTRA_PROFILE_TYPE_INFO:
717 ExtraProfileTypeInfo::Cast(obj)->Dump(thread, os);
718 break;
719 case JSType::LINE_STRING:
720 case JSType::TREE_STRING:
721 case JSType::SLICED_STRING:
722 DumpStringClass(thread, EcmaString::Cast(obj), os);
723 os << "\n";
724 break;
725 case JSType::JS_NATIVE_POINTER:
726 break;
727 case JSType::JS_OBJECT:
728 case JSType::JS_XREF_OBJECT:
729 case JSType::JS_SHARED_OBJECT:
730 case JSType::JS_GLOBAL_OBJECT:
731 case JSType::JS_ERROR:
732 case JSType::JS_EVAL_ERROR:
733 case JSType::JS_RANGE_ERROR:
734 case JSType::JS_TYPE_ERROR:
735 case JSType::JS_AGGREGATE_ERROR:
736 case JSType::JS_REFERENCE_ERROR:
737 case JSType::JS_URI_ERROR:
738 case JSType::JS_SYNTAX_ERROR:
739 case JSType::JS_OOM_ERROR:
740 case JSType::JS_TERMINATION_ERROR:
741 case JSType::JS_ARGUMENTS:
742 needDumpHClass = true;
743 JSObject::Cast(obj)->Dump(thread, os, isPrivacy);
744 break;
745 case JSType::JS_FUNCTION_BASE:
746 needDumpHClass = true;
747 JSFunctionBase::Cast(obj)->Dump(thread, os);
748 break;
749 case JSType::GLOBAL_ENV:
750 GlobalEnv::Cast(obj)->Dump(thread, os);
751 break;
752 case JSType::ACCESSOR_DATA:
753 break;
754 case JSType::JS_SHARED_FUNCTION:
755 case JSType::JS_FUNCTION:
756 needDumpHClass = true;
757 JSFunction::Cast(obj)->Dump(thread, os);
758 break;
759 case JSType::JS_BOUND_FUNCTION:
760 needDumpHClass = true;
761 JSBoundFunction::Cast(obj)->Dump(thread, os);
762 break;
763 case JSType::JS_SET:
764 needDumpHClass = true;
765 JSSet::Cast(obj)->Dump(thread, os);
766 break;
767 case JSType::JS_SHARED_SET:
768 needDumpHClass = true;
769 JSSharedSet::Cast(obj)->Dump(thread, os);
770 break;
771 case JSType::JS_MAP:
772 needDumpHClass = true;
773 JSMap::Cast(obj)->Dump(thread, os);
774 break;
775 case JSType::JS_SHARED_MAP:
776 needDumpHClass = true;
777 JSSharedMap::Cast(obj)->Dump(thread, os);
778 break;
779 case JSType::JS_WEAK_SET:
780 needDumpHClass = true;
781 JSWeakSet::Cast(obj)->Dump(thread, os);
782 break;
783 case JSType::JS_WEAK_MAP:
784 needDumpHClass = true;
785 JSWeakMap::Cast(obj)->Dump(thread, os);
786 break;
787 case JSType::JS_WEAK_REF:
788 needDumpHClass = true;
789 JSWeakRef::Cast(obj)->Dump(thread, os);
790 break;
791 case JSType::JS_FINALIZATION_REGISTRY:
792 JSFinalizationRegistry::Cast(obj)->Dump(thread, os);
793 break;
794 case JSType::CELL_RECORD:
795 CellRecord::Cast(obj)->Dump(thread, os);
796 break;
797 case JSType::JS_REG_EXP:
798 needDumpHClass = true;
799 JSRegExp::Cast(obj)->Dump(thread, os);
800 break;
801 case JSType::JS_DATE:
802 needDumpHClass = true;
803 JSDate::Cast(obj)->Dump(thread, os);
804 break;
805 case JSType::JS_ARRAY:
806 needDumpHClass = true;
807 JSArray::Cast(obj)->Dump(thread, os);
808 break;
809 case JSType::JS_SHARED_ARRAY:
810 needDumpHClass = true;
811 JSSharedArray::Cast(obj)->Dump(thread, os);
812 break;
813 case JSType::JS_TYPED_ARRAY:
814 case JSType::JS_INT8_ARRAY:
815 case JSType::JS_UINT8_ARRAY:
816 case JSType::JS_UINT8_CLAMPED_ARRAY:
817 case JSType::JS_INT16_ARRAY:
818 case JSType::JS_UINT16_ARRAY:
819 case JSType::JS_INT32_ARRAY:
820 case JSType::JS_UINT32_ARRAY:
821 case JSType::JS_FLOAT32_ARRAY:
822 case JSType::JS_FLOAT64_ARRAY:
823 case JSType::JS_BIGINT64_ARRAY:
824 case JSType::JS_BIGUINT64_ARRAY:
825 needDumpHClass = true;
826 JSTypedArray::Cast(obj)->Dump(thread, os);
827 break;
828 case JSType::JS_SHARED_TYPED_ARRAY:
829 case JSType::JS_SHARED_INT8_ARRAY:
830 case JSType::JS_SHARED_UINT8_ARRAY:
831 case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY:
832 case JSType::JS_SHARED_INT16_ARRAY:
833 case JSType::JS_SHARED_UINT16_ARRAY:
834 case JSType::JS_SHARED_INT32_ARRAY:
835 case JSType::JS_SHARED_UINT32_ARRAY:
836 case JSType::JS_SHARED_FLOAT32_ARRAY:
837 case JSType::JS_SHARED_FLOAT64_ARRAY:
838 case JSType::JS_SHARED_BIGINT64_ARRAY:
839 case JSType::JS_SHARED_BIGUINT64_ARRAY:
840 needDumpHClass = true;
841 JSSharedTypedArray::Cast(obj)->Dump(thread, os);
842 break;
843 case JSType::BIGINT:
844 BigInt::Cast(obj)->Dump(thread, os);
845 break;
846 case JSType::BYTE_ARRAY:
847 ByteArray::Cast(obj)->Dump(thread, os);
848 break;
849 case JSType::JS_PROXY:
850 needDumpHClass = true;
851 JSProxy::Cast(obj)->Dump(thread, os);
852 break;
853 case JSType::JS_PRIMITIVE_REF:
854 JSPrimitiveRef::Cast(obj)->Dump(thread, os);
855 break;
856 case JSType::SYMBOL:
857 JSSymbol::Cast(obj)->Dump(thread, os);
858 break;
859 case JSType::JS_DATA_VIEW:
860 JSDataView::Cast(obj)->Dump(thread, os);
861 break;
862 case JSType::JS_ARRAY_BUFFER:
863 JSArrayBuffer::Cast(obj)->Dump(thread, os);
864 break;
865 case JSType::JS_SENDABLE_ARRAY_BUFFER:
866 JSSendableArrayBuffer::Cast(obj)->Dump(thread, os);
867 break;
868 case JSType::JS_SHARED_ARRAY_BUFFER:
869 JSArrayBuffer::Cast(obj)->Dump(thread, os);
870 break;
871 case JSType::PROMISE_REACTIONS:
872 PromiseReaction::Cast(obj)->Dump(thread, os);
873 break;
874 case JSType::PROMISE_CAPABILITY:
875 PromiseCapability::Cast(obj)->Dump(thread, os);
876 break;
877 case JSType::PROMISE_ITERATOR_RECORD:
878 PromiseIteratorRecord::Cast(obj)->Dump(thread, os);
879 break;
880 case JSType::PROMISE_RECORD:
881 PromiseRecord::Cast(obj)->Dump(thread, os);
882 break;
883 case JSType::RESOLVING_FUNCTIONS_RECORD:
884 ResolvingFunctionsRecord::Cast(obj)->Dump(thread, os);
885 break;
886 case JSType::JS_PROMISE:
887 needDumpHClass = true;
888 JSPromise::Cast(obj)->Dump(thread, os);
889 break;
890 case JSType::JS_PROMISE_REACTIONS_FUNCTION:
891 JSPromiseReactionsFunction::Cast(obj)->Dump(thread, os);
892 break;
893 case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
894 JSPromiseExecutorFunction::Cast(obj)->Dump(thread, os);
895 break;
896 case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION:
897 JSAsyncModuleFulfilledFunction::Cast(obj)->Dump(thread, os);
898 break;
899 case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION:
900 JSAsyncModuleRejectedFunction::Cast(obj)->Dump(thread, os);
901 break;
902 case JSType::ASYNC_GENERATOR_REQUEST:
903 AsyncGeneratorRequest::Cast(obj)->Dump(thread, os);
904 break;
905 case JSType::ASYNC_ITERATOR_RECORD:
906 AsyncIteratorRecord::Cast(obj)->Dump(thread, os);
907 break;
908 case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
909 JSAsyncFromSyncIterator::Cast(obj)->Dump(thread, os);
910 break;
911 case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
912 JSAsyncFromSyncIterUnwarpFunction::Cast(obj)->Dump(thread, os);
913 break;
914 case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
915 JSPromiseAllResolveElementFunction::Cast(obj)->Dump(thread, os);
916 break;
917 case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
918 JSPromiseAnyRejectElementFunction::Cast(obj)->Dump(thread, os);
919 break;
920 case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
921 JSPromiseAllSettledElementFunction::Cast(obj)->Dump(thread, os);
922 break;
923 case JSType::JS_PROMISE_FINALLY_FUNCTION:
924 JSPromiseFinallyFunction::Cast(obj)->Dump(thread, os);
925 break;
926 case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
927 JSPromiseValueThunkOrThrowerFunction::Cast(obj)->Dump(thread, os);
928 break;
929 case JSType::MICRO_JOB_QUEUE:
930 MicroJobQueue::Cast(obj)->Dump(thread, os);
931 break;
932 case JSType::PENDING_JOB:
933 PendingJob::Cast(obj)->Dump(thread, os);
934 break;
935 case JSType::COMPLETION_RECORD:
936 CompletionRecord::Cast(obj)->Dump(thread, os);
937 break;
938 case JSType::JS_PROXY_REVOC_FUNCTION:
939 JSProxyRevocFunction::Cast(obj)->Dump(thread, os);
940 break;
941 case JSType::JS_ASYNC_FUNCTION:
942 case JSType::JS_SHARED_ASYNC_FUNCTION:
943 needDumpHClass = true;
944 JSAsyncFunction::Cast(obj)->Dump(thread, os);
945 break;
946 case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
947 JSAsyncAwaitStatusFunction::Cast(obj)->Dump(thread, os);
948 break;
949 case JSType::JS_GENERATOR_FUNCTION:
950 JSGeneratorFunction::Cast(obj)->Dump(thread, os);
951 break;
952 case JSType::JS_ASYNC_GENERATOR_FUNCTION:
953 needDumpHClass = true;
954 JSAsyncGeneratorFunction::Cast(obj)->Dump(thread, os);
955 break;
956 case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
957 JSAsyncGeneratorResNextRetProRstFtn::Cast(obj)->Dump(thread, os);
958 break;
959 case JSType::JS_INTL_BOUND_FUNCTION:
960 JSIntlBoundFunction::Cast(obj)->Dump(thread, os);
961 break;
962 case JSType::JS_ITERATOR:
963 break;
964 case JSType::JS_ASYNCITERATOR:
965 break;
966 case JSType::JS_FORIN_ITERATOR:
967 JSForInIterator::Cast(obj)->Dump(thread, os);
968 break;
969 case JSType::JS_MAP_ITERATOR:
970 JSMapIterator::Cast(obj)->Dump(thread, os);
971 break;
972 case JSType::JS_SHARED_MAP_ITERATOR:
973 JSSharedMapIterator::Cast(obj)->Dump(thread, os);
974 break;
975 case JSType::JS_SET_ITERATOR:
976 JSSetIterator::Cast(obj)->Dump(thread, os);
977 break;
978 case JSType::JS_SHARED_SET_ITERATOR:
979 JSSharedSetIterator::Cast(obj)->Dump(thread, os);
980 break;
981 case JSType::JS_REG_EXP_ITERATOR:
982 JSRegExpIterator::Cast(obj)->Dump(thread, os);
983 break;
984 case JSType::JS_ARRAY_ITERATOR:
985 JSArrayIterator::Cast(obj)->Dump(thread, os);
986 break;
987 case JSType::JS_SHARED_ARRAY_ITERATOR:
988 JSSharedArrayIterator::Cast(obj)->Dump(thread, os);
989 break;
990 case JSType::JS_STRING_ITERATOR:
991 JSStringIterator::Cast(obj)->Dump(thread, os);
992 break;
993 case JSType::PROTOTYPE_HANDLER:
994 PrototypeHandler::Cast(obj)->Dump(thread, os);
995 break;
996 case JSType::TRANSITION_HANDLER:
997 TransitionHandler::Cast(obj)->Dump(thread, os);
998 break;
999 case JSType::TRANS_WITH_PROTO_HANDLER:
1000 TransWithProtoHandler::Cast(obj)->Dump(thread, os);
1001 break;
1002 case JSType::STORE_TS_HANDLER:
1003 StoreAOTHandler::Cast(obj)->Dump(thread, os);
1004 break;
1005 case JSType::PROPERTY_BOX:
1006 PropertyBox::Cast(obj)->Dump(thread, os);
1007 break;
1008 case JSType::JS_REALM:
1009 needDumpHClass = true;
1010 JSRealm::Cast(obj)->Dump(thread, os);
1011 break;
1012 #ifdef ARK_SUPPORT_INTL
1013 case JSType::JS_INTL:
1014 needDumpHClass = true;
1015 JSIntl::Cast(obj)->Dump(thread, os);
1016 break;
1017 case JSType::JS_LOCALE:
1018 needDumpHClass = true;
1019 JSLocale::Cast(obj)->Dump(thread, os);
1020 break;
1021 case JSType::JS_DATE_TIME_FORMAT:
1022 JSDateTimeFormat::Cast(obj)->Dump(thread, os);
1023 break;
1024 case JSType::JS_RELATIVE_TIME_FORMAT:
1025 JSRelativeTimeFormat::Cast(obj)->Dump(thread, os);
1026 break;
1027 case JSType::JS_NUMBER_FORMAT:
1028 JSNumberFormat::Cast(obj)->Dump(thread, os);
1029 break;
1030 case JSType::JS_COLLATOR:
1031 needDumpHClass = true;
1032 JSCollator::Cast(obj)->Dump(thread, os);
1033 break;
1034 case JSType::JS_PLURAL_RULES:
1035 JSPluralRules::Cast(obj)->Dump(thread, os);
1036 break;
1037 case JSType::JS_DISPLAYNAMES:
1038 JSDisplayNames::Cast(obj)->Dump(thread, os);
1039 break;
1040 case JSType::JS_SEGMENTER:
1041 JSSegmenter::Cast(obj)->Dump(thread, os);
1042 break;
1043 case JSType::JS_SEGMENTS:
1044 JSSegments::Cast(obj)->Dump(thread, os);
1045 break;
1046 case JSType::JS_SEGMENT_ITERATOR:
1047 JSSegmentIterator::Cast(obj)->Dump(thread, os);
1048 break;
1049 case JSType::JS_LIST_FORMAT:
1050 JSListFormat::Cast(obj)->Dump(thread, os);
1051 break;
1052 #else
1053 case JSType::JS_INTL:
1054 case JSType::JS_LOCALE:
1055 case JSType::JS_DATE_TIME_FORMAT:
1056 case JSType::JS_RELATIVE_TIME_FORMAT:
1057 case JSType::JS_NUMBER_FORMAT:
1058 case JSType::JS_COLLATOR:
1059 case JSType::JS_PLURAL_RULES:
1060 case JSType::JS_DISPLAYNAMES:
1061 case JSType::JS_SEGMENTER:
1062 case JSType::JS_SEGMENTS:
1063 case JSType::JS_SEGMENT_ITERATOR:
1064 case JSType::JS_LIST_FORMAT:
1065 break;
1066 #endif
1067 case JSType::JS_GENERATOR_OBJECT:
1068 needDumpHClass = true;
1069 JSGeneratorObject::Cast(obj)->Dump(thread, os);
1070 break;
1071 case JSType::JS_ASYNC_GENERATOR_OBJECT:
1072 needDumpHClass = true;
1073 JSAsyncGeneratorObject::Cast(obj)->Dump(thread, os);
1074 break;
1075 case JSType::JS_ASYNC_FUNC_OBJECT:
1076 needDumpHClass = true;
1077 JSAsyncFuncObject::Cast(obj)->Dump(thread, os);
1078 break;
1079 case JSType::JS_GENERATOR_CONTEXT:
1080 GeneratorContext::Cast(obj)->Dump(thread, os);
1081 break;
1082 case JSType::PROTOTYPE_INFO:
1083 ProtoChangeDetails::Cast(obj)->Dump(thread, os);
1084 break;
1085 case JSType::TRACK_INFO:
1086 TrackInfo::Cast(obj)->Dump(thread, os);
1087 break;
1088 case JSType::ENUM_CACHE:
1089 EnumCache::Cast(obj)->Dump(thread, os);
1090 break;
1091 case JSType::PROTO_CHANGE_MARKER:
1092 ProtoChangeMarker::Cast(obj)->Dump(thread, os);
1093 break;
1094 case JSType::MARKER_CELL:
1095 MarkerCell::Cast(obj)->Dump(thread, os);
1096 break;
1097 case JSType::PROGRAM:
1098 Program::Cast(obj)->Dump(thread, os);
1099 break;
1100 case JSType::MACHINE_CODE_OBJECT:
1101 MachineCode::Cast(obj)->Dump(thread, os);
1102 break;
1103 case JSType::CLASS_INFO_EXTRACTOR:
1104 ClassInfoExtractor::Cast(obj)->Dump(thread, os);
1105 break;
1106 case JSType::JS_API_ARRAY_LIST:
1107 JSAPIArrayList::Cast(obj)->Dump(thread, os);
1108 break;
1109 case JSType::JS_API_ARRAYLIST_ITERATOR:
1110 JSAPIArrayListIterator::Cast(obj)->Dump(thread, os);
1111 break;
1112 case JSType::JS_API_BITVECTOR:
1113 JSAPIBitVector::Cast(obj)->Dump(thread, os);
1114 break;
1115 case JSType::JS_API_BITVECTOR_ITERATOR:
1116 JSAPIBitVectorIterator::Cast(obj)->Dump(thread, os);
1117 break;
1118 case JSType::JS_API_FAST_BUFFER:
1119 JSAPIFastBuffer::Cast(obj)->Dump(thread, os);
1120 break;
1121 case JSType::JS_API_LIGHT_WEIGHT_MAP:
1122 JSAPILightWeightMap::Cast(obj)->Dump(thread, os);
1123 break;
1124 case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
1125 JSAPILightWeightMapIterator::Cast(obj)->Dump(thread, os);
1126 break;
1127 case JSType::JS_API_LIGHT_WEIGHT_SET:
1128 JSAPILightWeightSet::Cast(obj)->Dump(thread, os);
1129 break;
1130 case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
1131 JSAPILightWeightSetIterator::Cast(obj)->Dump(thread, os);
1132 break;
1133 case JSType::LINKED_NODE:
1134 LinkedNode::Cast(obj)->Dump(thread, os);
1135 break;
1136 case JSType::RB_TREENODE:
1137 RBTreeNode::Cast(obj)->Dump(thread, os);
1138 break;
1139 case JSType::JS_API_HASH_MAP:
1140 JSAPIHashMap::Cast(obj)->Dump(thread, os);
1141 break;
1142 case JSType::JS_API_HASH_SET:
1143 JSAPIHashSet::Cast(obj)->Dump(thread, os);
1144 break;
1145 case JSType::JS_API_HASHMAP_ITERATOR:
1146 JSAPIHashMapIterator::Cast(obj)->Dump(thread, os);
1147 break;
1148 case JSType::JS_API_HASHSET_ITERATOR:
1149 JSAPIHashSetIterator::Cast(obj)->Dump(thread, os);
1150 break;
1151 case JSType::JS_API_TREE_MAP:
1152 JSAPITreeMap::Cast(obj)->Dump(thread, os);
1153 break;
1154 case JSType::JS_API_TREE_SET:
1155 JSAPITreeSet::Cast(obj)->Dump(thread, os);
1156 break;
1157 case JSType::JS_API_TREEMAP_ITERATOR:
1158 JSAPITreeMapIterator::Cast(obj)->Dump(thread, os);
1159 break;
1160 case JSType::JS_API_TREESET_ITERATOR:
1161 JSAPITreeSetIterator::Cast(obj)->Dump(thread, os);
1162 break;
1163 case JSType::JS_API_VECTOR:
1164 JSAPIVector::Cast(obj)->Dump(thread, os);
1165 break;
1166 case JSType::JS_API_VECTOR_ITERATOR:
1167 JSAPIVectorIterator::Cast(obj)->Dump(thread, os);
1168 break;
1169 case JSType::JS_API_QUEUE:
1170 JSAPIQueue::Cast(obj)->Dump(thread, os);
1171 break;
1172 case JSType::JS_API_QUEUE_ITERATOR:
1173 JSAPIQueueIterator::Cast(obj)->Dump(thread, os);
1174 break;
1175 case JSType::JS_API_DEQUE:
1176 JSAPIDeque::Cast(obj)->Dump(thread, os);
1177 break;
1178 case JSType::JS_API_DEQUE_ITERATOR:
1179 JSAPIDequeIterator::Cast(obj)->Dump(thread, os);
1180 break;
1181 case JSType::JS_API_STACK:
1182 JSAPIStack::Cast(obj)->Dump(thread, os);
1183 break;
1184 case JSType::JS_API_STACK_ITERATOR:
1185 JSAPIStackIterator::Cast(obj)->Dump(thread, os);
1186 break;
1187 case JSType::JS_API_LIST:
1188 JSAPIList::Cast(obj)->Dump(thread, os);
1189 break;
1190 case JSType::JS_API_LIST_ITERATOR:
1191 JSAPIListIterator::Cast(obj)->Dump(thread, os);
1192 break;
1193 case JSType::JS_API_LINKED_LIST:
1194 JSAPILinkedList::Cast(obj)->Dump(thread, os);
1195 break;
1196 case JSType::JS_API_LINKED_LIST_ITERATOR:
1197 JSAPILinkedListIterator::Cast(obj)->Dump(thread, os);
1198 break;
1199 case JSType::SOURCE_TEXT_MODULE_RECORD:
1200 SourceTextModule::Cast(obj)->Dump(thread, os);
1201 break;
1202 case JSType::IMPORTENTRY_RECORD:
1203 ImportEntry::Cast(obj)->Dump(thread, os);
1204 break;
1205 case JSType::LOCAL_EXPORTENTRY_RECORD:
1206 LocalExportEntry::Cast(obj)->Dump(thread, os);
1207 break;
1208 case JSType::INDIRECT_EXPORTENTRY_RECORD:
1209 IndirectExportEntry::Cast(obj)->Dump(thread, os);
1210 break;
1211 case JSType::STAR_EXPORTENTRY_RECORD:
1212 StarExportEntry::Cast(obj)->Dump(thread, os);
1213 break;
1214 case JSType::RESOLVEDBINDING_RECORD:
1215 ResolvedBinding::Cast(obj)->Dump(thread, os);
1216 break;
1217 case JSType::RESOLVEDINDEXBINDING_RECORD:
1218 ResolvedIndexBinding::Cast(obj)->Dump(thread, os);
1219 break;
1220 case JSType::RESOLVEDRECORDINDEXBINDING_RECORD:
1221 ResolvedRecordIndexBinding::Cast(obj)->Dump(thread, os);
1222 break;
1223 case JSType::RESOLVEDRECORDBINDING_RECORD:
1224 ResolvedRecordBinding::Cast(obj)->Dump(thread, os);
1225 break;
1226 case JSType::NATIVE_MODULE_FAILURE_INFO:
1227 NativeModuleFailureInfo::Cast(obj)->Dump(thread, os);
1228 break;
1229 case JSType::JS_MODULE_NAMESPACE:
1230 ModuleNamespace::Cast(obj)->Dump(thread, os);
1231 break;
1232 case JSType::JS_API_PLAIN_ARRAY:
1233 JSAPIPlainArray::Cast(obj)->Dump(thread, os);
1234 break;
1235 case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
1236 JSAPIPlainArrayIterator::Cast(obj)->Dump(thread, os);
1237 break;
1238 case JSType::JS_CJS_MODULE:
1239 CjsModule::Cast(obj)->Dump(thread, os);
1240 break;
1241 case JSType::JS_CJS_REQUIRE:
1242 CjsRequire::Cast(obj)->Dump(thread, os);
1243 break;
1244 case JSType::JS_CJS_EXPORTS:
1245 CjsExports::Cast(obj)->Dump(thread, os);
1246 break;
1247 case JSType::METHOD:
1248 Method::Cast(obj)->Dump(thread, os);
1249 break;
1250 case JSType::CLASS_LITERAL:
1251 ClassLiteral::Cast(obj)->Dump(thread, os);
1252 break;
1253 default:
1254 LOG_ECMA(FATAL) << "this branch is unreachable";
1255 UNREACHABLE();
1256 break;
1257 }
1258
1259 if (needDumpHClass) {
1260 DumpHClass(thread, jsHclass, os, false);
1261 }
1262 }
1263
DumpSpecialValue(std::ostream & os) const1264 void JSTaggedValue::DumpSpecialValue(std::ostream &os) const
1265 {
1266 ASSERT(IsSpecial());
1267 os << "[Special Value] : ";
1268 switch (GetRawData()) {
1269 case VALUE_HOLE:
1270 os << "Hole";
1271 break;
1272 case VALUE_NULL:
1273 os << "Null";
1274 break;
1275 case VALUE_FALSE:
1276 os << "False";
1277 break;
1278 case VALUE_TRUE:
1279 os << "True";
1280 break;
1281 case VALUE_UNDEFINED:
1282 os << "Undefined";
1283 break;
1284 case VALUE_EXCEPTION:
1285 os << "Exception";
1286 break;
1287 default:
1288 LOG_ECMA(FATAL) << "this branch is unreachable";
1289 UNREACHABLE();
1290 break;
1291 }
1292 }
1293
DumpHeapObjectType(const JSThread * thread,std::ostream & os) const1294 void JSTaggedValue::DumpHeapObjectType(const JSThread *thread, std::ostream &os) const
1295 {
1296 ASSERT(IsWeak() || IsHeapObject());
1297 bool isWeak = IsWeak();
1298 TaggedObject *obj = isWeak ? GetTaggedWeakRef() : GetTaggedObject();
1299 if (isWeak) {
1300 os << " [Weak Ref] ";
1301 }
1302
1303 JSType type = obj->GetClass()->GetObjectType();
1304 if (type >= JSType::STRING_FIRST && type <= JSType::STRING_LAST) {
1305 CString string = ConvertToString(thread, EcmaString::Cast(obj));
1306 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + string + "]";
1307 } else if (type == JSType::METHOD) {
1308 std::ostringstream address;
1309 address << obj;
1310 CString addrStr = CString(address.str());
1311 Method *method = Method::Cast(obj);
1312
1313 os << std::left << std::setw(DUMP_TYPE_OFFSET)
1314 << "[" + JSHClass::DumpJSType(type) + "(" + addrStr + "-" + method->GetMethodName(thread) + ")]";
1315 } else {
1316 std::ostringstream address;
1317 address << obj;
1318 CString addrStr = CString(address.str());
1319
1320 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[" + JSHClass::DumpJSType(type) + "(" + addrStr + ")]";
1321 }
1322 }
1323
DumpTaggedValue(const JSThread * thread,std::ostream & os) const1324 void JSTaggedValue::DumpTaggedValue(const JSThread *thread, std::ostream &os) const
1325 {
1326 if (IsInt()) {
1327 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Int] : " << std::hex << "0x" << GetInt() << std::dec << " ("
1328 << GetInt() << ")";
1329 } else if (IsDouble()) {
1330 os << std::left << std::setw(DUMP_TYPE_OFFSET) << "[Double] : " << GetDouble();
1331 } else if (IsSpecial()) {
1332 DumpSpecialValue(os);
1333 } else {
1334 DumpHeapObjectType(thread, os);
1335 }
1336 }
1337
DumpTaggedValueType(std::ostream & os) const1338 void JSTaggedValue::DumpTaggedValueType(std::ostream &os) const
1339 {
1340 if (IsInt()) {
1341 os << "[Int]";
1342 } else if (IsDouble()) {
1343 os << "[Double]";
1344 } else if (IsSpecial()) {
1345 DumpSpecialValue(os);
1346 } else {
1347 ASSERT(IsWeak() || IsHeapObject());
1348 TaggedObject *obj = IsWeak() ? GetTaggedWeakRef() : GetTaggedObject();
1349 os << "[" + JSHClass::DumpJSType(obj->GetClass()->GetObjectType()) + "]";
1350 }
1351 }
1352
Dump(const JSThread * thread,std::ostream & os,bool isPrivacy) const1353 void JSTaggedValue::Dump(const JSThread *thread, std::ostream &os, bool isPrivacy) const
1354 {
1355 DumpTaggedValue(thread, os);
1356 os << "\n";
1357
1358 if (IsHeapObject()) {
1359 if (UNLIKELY(thread == nullptr)) {
1360 thread = JSThread::GetCurrent();
1361 }
1362 TaggedObject *obj = IsWeak() ? GetTaggedWeakRef() : GetTaggedObject();
1363 DumpObject(thread, obj, os, isPrivacy);
1364 }
1365 }
1366
DumpHeapObjAddress(const JSThread * thread,std::ostream & os) const1367 void JSTaggedValue::DumpHeapObjAddress([[maybe_unused]]const JSThread *thread, std::ostream &os) const
1368 {
1369 if (IsHeapObject()) {
1370 TaggedObject *obj = IsWeak() ? GetTaggedWeakRef() : GetTaggedObject();
1371 os << obj << "\n";
1372 } else {
1373 os << "not a heapobject\n";
1374 }
1375 }
1376
D(const JSThread * thread) const1377 void JSTaggedValue::D(const JSThread *thread) const
1378 {
1379 Dump(thread, std::cout);
1380 }
1381
DV(const JSThread * thread,JSTaggedType val)1382 void JSTaggedValue::DV(const JSThread *thread, JSTaggedType val)
1383 {
1384 JSTaggedValue(val).D(thread);
1385 }
1386
DumpStack()1387 void JSThread::DumpStack()
1388 {
1389 FrameHandler handler(this);
1390 handler.DumpStack(std::cout);
1391 }
1392
Dump(const JSThread * thread,std::ostream & os,bool isPrivacy) const1393 void NumberDictionary::Dump(const JSThread *thread, std::ostream &os, bool isPrivacy) const
1394 {
1395 DISALLOW_GARBAGE_COLLECTION;
1396 int size = Size();
1397 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1398 JSTaggedValue key(GetKey(thread, hashIndex));
1399 if (!key.IsUndefined() && !key.IsHole()) {
1400 os << std::right << std::setw(DUMP_PROPERTY_OFFSET)
1401 << static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()) << ": ";
1402 if (!isPrivacy) {
1403 JSTaggedValue val(GetValue(thread, hashIndex));
1404 val.DumpTaggedValue(thread, os);
1405 }
1406 os << " ";
1407 DumpAttr(GetAttributes(thread, hashIndex), false, os);
1408 os << "\n";
1409 }
1410 }
1411 }
1412
Dump(const JSThread * thread,std::ostream & os,bool isPrivacy) const1413 void NameDictionary::Dump(const JSThread *thread, std::ostream &os, bool isPrivacy) const
1414 {
1415 DISALLOW_GARBAGE_COLLECTION;
1416 int size = Size();
1417 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1418 JSTaggedValue key(GetKey(thread, hashIndex));
1419 if (!key.IsUndefined() && !key.IsHole()) {
1420 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1421 DumpPropertyKey(thread, key, os);
1422 os << ": ";
1423 if (!isPrivacy) {
1424 JSTaggedValue val(GetValue(thread, hashIndex));
1425 val.DumpTaggedValue(thread, os);
1426 }
1427 os << " ";
1428 DumpAttr(GetAttributes(thread, hashIndex), false, os);
1429 os << "\n";
1430 }
1431 }
1432 }
1433
Dump(const JSThread * thread,std::ostream & os,bool isPrivacy) const1434 void GlobalDictionary::Dump(const JSThread *thread, std::ostream &os, bool isPrivacy) const
1435 {
1436 DISALLOW_GARBAGE_COLLECTION;
1437 int size = Size();
1438 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1439 JSTaggedValue key(GetKey(thread, hashIndex));
1440 if (!key.IsUndefined() && !key.IsHole()) {
1441 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1442 DumpPropertyKey(thread, key, os);
1443 os << " : ";
1444 if (!isPrivacy) {
1445 JSTaggedValue val(GetValue(thread, hashIndex));
1446 val.DumpTaggedValue(thread, os);
1447 }
1448 os << " ";
1449 DumpAttr(GetAttributes(thread, hashIndex), false, os);
1450 os << "\n";
1451 }
1452 }
1453 }
1454
Dump(const JSThread * thread,std::ostream & os) const1455 void LayoutInfo::Dump(const JSThread *thread, std::ostream &os) const
1456 {
1457 DISALLOW_GARBAGE_COLLECTION;
1458 int num = NumberOfElements();
1459 for (int i = 0; i < num; i++) {
1460 JSTaggedValue key = GetKey(thread, i);
1461 PropertyAttributes attr = GetAttr(thread, i);
1462 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1463 os << "[" << i << "]: ";
1464 DumpPropertyKey(thread, key, os);
1465 os << " : ";
1466 DumpAttr(attr, true, os);
1467 os << "\n";
1468 }
1469 }
1470
Dump(const JSThread * thread,std::ostream & os) const1471 void TransitionsDictionary::Dump(const JSThread *thread, std::ostream &os) const
1472 {
1473 DISALLOW_GARBAGE_COLLECTION;
1474 int size = Size();
1475 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
1476 JSTaggedValue key(GetKey(thread, hashIndex));
1477 if (!key.IsUndefined() && !key.IsHole()) {
1478 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1479 DumpPropertyKey(thread, key, os);
1480 os << " : ";
1481 GetValue(thread, hashIndex).DumpTaggedValue(thread, os);
1482 os << " : ";
1483 GetAttributes(thread, hashIndex).DumpTaggedValue(thread, os);
1484 os << "\n";
1485 }
1486 }
1487 }
1488
Dump(const JSThread * thread,std::ostream & os) const1489 void LinkedHashSet::Dump(const JSThread *thread, std::ostream &os) const
1490 {
1491 DISALLOW_GARBAGE_COLLECTION;
1492 int capacity = NumberOfElements() + NumberOfDeletedElements();
1493 for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
1494 JSTaggedValue key(GetKey(thread, hashIndex));
1495 if (!key.IsUndefined() && !key.IsHole()) {
1496 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1497 key.DumpTaggedValue(thread, os);
1498 os << "\n";
1499 }
1500 }
1501 }
1502
Dump(const JSThread * thread,std::ostream & os) const1503 void LinkedHashMap::Dump(const JSThread *thread, std::ostream &os) const
1504 {
1505 DISALLOW_GARBAGE_COLLECTION;
1506 int capacity = NumberOfElements() + NumberOfDeletedElements();
1507 for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
1508 JSTaggedValue key(GetKey(thread, hashIndex));
1509 if (!key.IsUndefined() && !key.IsHole()) {
1510 JSTaggedValue val(GetValue(thread, hashIndex));
1511 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1512 key.DumpTaggedValue(thread, os);
1513 os << ": ";
1514 val.DumpTaggedValue(thread, os);
1515 os << "\n";
1516 }
1517 }
1518 }
1519
Dump(const JSThread * thread,std::ostream & os) const1520 void TaggedDoubleList::Dump(const JSThread *thread, std::ostream &os) const
1521 {
1522 DISALLOW_GARBAGE_COLLECTION;
1523 int capacity = NumberOfNodes();
1524 os << " - node num: " << std::dec << capacity << "\n";
1525 os << " - delete node num: " << std::dec << NumberOfDeletedNodes() << "\n";
1526 os << "head-next: ";
1527 // 5 : 5 first element next ptr
1528 GetElement(thread, 5).Dump(thread, os);
1529 os << "head-pre: ";
1530 // 6 : 6 first element per ptr
1531 GetElement(thread, 6).Dump(thread, os);
1532 os << "\n";
1533 int i = 0;
1534 int next = GetElement(thread, 5).GetInt();
1535 while (capacity > i) {
1536 os << " value: ";
1537 GetElement(thread, next).DumpTaggedValue(thread, os);
1538 os << " next: ";
1539 // 1 : 1 current element next ptr offset
1540 GetElement(thread, next + 1).Dump(thread, os);
1541 os << " pre: ";
1542 // 2 : 2 current element pre ptr offset
1543 GetElement(thread, next + 2).Dump(thread, os);
1544 os << "\n";
1545 next = GetElement(thread, next + 1).GetInt();
1546 i++;
1547 }
1548 }
1549
Dump(const JSThread * thread,std::ostream & os) const1550 void TaggedSingleList::Dump(const JSThread *thread, std::ostream &os) const
1551 {
1552 DISALLOW_GARBAGE_COLLECTION;
1553 int capacity = NumberOfNodes();
1554 os << "head-next: ";
1555 // 5 : 5 first element next ptr
1556 GetElement(thread, 5).Dump(thread, os);
1557 os << "\n";
1558 int i = 0;
1559 int next = GetElement(thread, 5).GetInt();
1560 while (capacity > i) {
1561 os << " value: ";
1562 GetElement(thread, next).DumpTaggedValue(thread, os);
1563 os << " next: ";
1564 // 1 : 1 current element next ptr offset
1565 GetElement(thread, next + 1).Dump(thread, os);
1566 os << "\n";
1567 next = GetElement(thread, next + 1).GetInt();
1568 i++;
1569 }
1570 }
1571
Dump(const JSThread * thread,std::ostream & os,bool isPrivacy) const1572 void JSObject::Dump(const JSThread *thread, std::ostream &os, bool isPrivacy) const
1573 {
1574 DISALLOW_GARBAGE_COLLECTION;
1575 JSHClass *jshclass = GetJSHClass();
1576 os << " - hclass: " << std::hex << jshclass << "\n";
1577 os << " - prototype: ";
1578 jshclass->GetPrototype(thread).DumpTaggedValue(thread, os);
1579 os << "\n";
1580
1581 JSTaggedType hashField = Barriers::GetTaggedValue(thread, this, HASH_OFFSET);
1582 JSTaggedValue value(hashField);
1583 os << " - hash: " << std::hex << hashField;
1584 value.Dump(thread, os);
1585
1586 TaggedArray *elements = TaggedArray::Cast(GetElements(thread).GetTaggedObject());
1587 os << " - elements: " << std::hex << elements;
1588 if (elements->GetLength() == 0) {
1589 os << " NONE\n";
1590 } else if (!elements->IsDictionaryMode()) {
1591 DumpArrayClass(thread, elements, os);
1592 } else {
1593 NumberDictionary *dict = NumberDictionary::Cast(elements);
1594 os << " <NumberDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1595 dict->Dump(thread, os, isPrivacy);
1596 }
1597
1598 TaggedArray *properties = TaggedArray::Cast(GetProperties(thread).GetTaggedObject());
1599 os << " - properties: " << std::hex << properties;
1600 if (IsJSGlobalObject()) {
1601 GlobalDictionary *dict = GlobalDictionary::Cast(properties);
1602 os << " <GlobalDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1603 dict->Dump(thread, os, isPrivacy);
1604 return;
1605 }
1606
1607 if (!properties->IsDictionaryMode()) {
1608 JSTaggedValue attrs = jshclass->GetLayout(thread);
1609 if (attrs.IsNull()) {
1610 return;
1611 }
1612
1613 LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
1614 int propNumber = static_cast<int>(jshclass->NumberOfProps());
1615 os << " <LayoutInfo[" << std::dec << propNumber << "]>\n";
1616 for (int i = 0; i < propNumber; i++) {
1617 JSTaggedValue key = layoutInfo->GetKey(thread, i);
1618 PropertyAttributes attr = layoutInfo->GetAttr(thread, i);
1619 ASSERT(i == static_cast<int>(attr.GetOffset()));
1620 os << " " << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1621 DumpPropertyKey(thread, key, os);
1622 os << ": (";
1623 JSTaggedValue val;
1624 if (attr.IsInlinedProps()) {
1625 val = GetPropertyInlinedPropsWithRep(thread, i, attr);
1626 } else {
1627 val = properties->Get(thread, i - static_cast<int>(jshclass->GetInlinedProperties()));
1628 }
1629 if (!isPrivacy) {
1630 val.DumpTaggedValue(thread, os);
1631 }
1632 os << ") ";
1633 DumpAttr(attr, true, os);
1634 os << "\n";
1635 }
1636 } else {
1637 NameDictionary *dict = NameDictionary::Cast(properties);
1638 os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
1639 dict->Dump(thread, os, isPrivacy);
1640 }
1641 }
1642
Dump(const JSThread * thread,std::ostream & os) const1643 void TaggedArray::Dump(const JSThread *thread, std::ostream &os) const
1644 {
1645 DumpArrayClass(thread, this, os);
1646 }
1647
Dump(const JSThread * thread,std::ostream & os) const1648 void AccessorData::Dump(const JSThread *thread, std::ostream &os) const
1649 {
1650 auto *hclass = GetClass();
1651 if (hclass->GetObjectType() == JSType::INTERNAL_ACCESSOR) {
1652 os << " - Getter: " << InternalAccessor::ConstCast(this)->GetGetter() << "\n";
1653 os << " - Setter: " << InternalAccessor::ConstCast(this)->GetSetter() << "\n";
1654 return;
1655 }
1656
1657 os << " - Getter: ";
1658 GetGetter(thread).DumpTaggedValue(thread, os);
1659 os << "\n";
1660
1661 os << " - Setter: ";
1662 GetSetter(thread).DumpTaggedValue(thread, os);
1663 os << "\n";
1664 }
1665
Dump(const JSThread * thread,std::ostream & os) const1666 void Program::Dump(const JSThread *thread, std::ostream &os) const
1667 {
1668 os << " - MainFunction: ";
1669 GetMainFunction(thread).Dump(thread, os);
1670 os << "\n";
1671 }
1672
Dump(const JSThread * thread,std::ostream & os) const1673 void LinkedNode::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
1674 {
1675 os << " - Next: ";
1676
1677 os << "\n";
1678 }
1679
Dump(const JSThread * thread,std::ostream & os) const1680 void RBTreeNode::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
1681 {
1682 // dump with (presentNode key, parents key, color, left or right)
1683 os << " - RBTree:\n";
1684 std::queue<std::tuple<std::string, RBTreeNode *, bool> > q;
1685 q.push({"null", const_cast<RBTreeNode *>(this), false});
1686 while (!q.empty()) {
1687 auto now = q.front();
1688 RBTreeNode *root;
1689 std::string key;
1690 bool isLeft;
1691 std::tie(key, root, isLeft) = now;
1692 auto presentKey = EcmaStringAccessor(EcmaString::Cast(root->GetKey(thread))).ToStdString(thread);
1693 os << "(presentNode : " << presentKey << ", parents : " << key <<
1694 ", color :" << (IsRed(JSTaggedValue(root)) ? "red" : "black") <<
1695 ", hash :" << root->GetHash(thread).GetInt() << ", isLeftSon: " << (isLeft ? "true" : "false") <<
1696 ")\n";
1697 q.pop();
1698 if (!root->GetLeft(thread).IsHole()) {
1699 q.push({presentKey, RBTreeNode::Cast(root->GetLeft(thread).GetTaggedObject()), true});
1700 }
1701 if (!root->GetRight(thread).IsHole()) {
1702 q.push({presentKey, RBTreeNode::Cast(root->GetRight(thread).GetTaggedObject()), false});
1703 }
1704 }
1705 os << "\n";
1706 }
1707
Dump(const JSThread * thread,std::ostream & os) const1708 void ConstantPool::Dump(const JSThread *thread, std::ostream &os) const
1709 {
1710 DumpArrayClass(thread, this, os);
1711 }
1712
Dump(const JSThread * thread,std::ostream & os) const1713 void ProfileTypeInfo::Dump(const JSThread *thread, std::ostream &os) const
1714 {
1715 DISALLOW_GARBAGE_COLLECTION;
1716 uint32_t len = GetIcSlotLength();
1717 os << " <ProfileTypeInfo[" << std::dec << len << "]>\n";
1718 for (uint32_t i = 0; i < len; i++) {
1719 JSTaggedValue val(Get(thread, i));
1720 if (!val.IsHole()) {
1721 os << std::right << std::setw(DUMP_PROPERTY_OFFSET) << i << ": ";
1722 val.DumpTaggedValue(thread, os);
1723 os << "\n";
1724 }
1725 }
1726 }
1727
Dump(const JSThread * thread,std::ostream & os) const1728 void ExtraProfileTypeInfo::Dump(const JSThread *thread, std::ostream &os) const
1729 {
1730 DISALLOW_GARBAGE_COLLECTION;
1731 os << " - Receiver: ";
1732 GetReceiverObject(thread).Dump(thread, os);
1733 os << " - Holder: ";
1734 GetHolderObject(thread).Dump(thread, os);
1735 os << "\n";
1736 }
1737
Dump(const JSThread * thread,std::ostream & os) const1738 void ProfileTypeInfoCell::Dump(const JSThread *thread, std::ostream &os) const
1739 {
1740 DISALLOW_GARBAGE_COLLECTION;
1741 os << " - Value: ";
1742 GetValue(thread).Dump(thread, os);
1743 os << " - Handle: ";
1744 GetHandle(thread).Dump(thread, os);
1745 os << "\n";
1746 }
1747
Dump(const JSThread * thread,std::ostream & os) const1748 void FunctionTemplate::Dump(const JSThread *thread, std::ostream &os) const
1749 {
1750 DISALLOW_GARBAGE_COLLECTION;
1751 os << " - Method: ";
1752 GetMethod(thread).Dump(thread, os);
1753 os << " - Module: ";
1754 GetModule(thread).Dump(thread, os);
1755 os << " - RawProfileTypeInfo: ";
1756 GetRawProfileTypeInfo(thread).Dump(thread, os);
1757 os << " - length : " << GetLength() << "\n";
1758 }
1759
Dump(const JSThread * thread,std::ostream & os) const1760 void VTable::Dump(const JSThread *thread, std::ostream &os) const
1761 {
1762 DISALLOW_GARBAGE_COLLECTION;
1763 uint32_t num = GetNumberOfTuples();
1764
1765 for (uint32_t i = 0; i < num; i++) {
1766 os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
1767 os << "[" << i << "]: [ name :";
1768 JSTaggedValue name = GetTupleItem(thread, i, VTable::TupleItem::NAME);
1769 DumpPropertyKey(thread, name, os);
1770 os << ", type :" << (IsAccessor(thread, i) ? "Accessor" : "Function");
1771 JSTaggedValue owner = GetTupleItem(thread, i, VTable::TupleItem::OWNER);
1772 os << ", owner :";
1773 owner.DumpTaggedValue(thread, os);
1774 JSTaggedValue offset = GetTupleItem(thread, i, VTable::TupleItem::OFFSET);
1775 os << ", offset :" << offset.GetInt();
1776 os << " ] ";
1777 os << "\n";
1778 }
1779 }
1780
Dump(const JSThread * thread,std::ostream & os) const1781 void JSFunction::Dump(const JSThread *thread, std::ostream &os) const
1782 {
1783 os << " - ProtoOrHClass: ";
1784 GetProtoOrHClass(thread).Dump(thread, os);
1785 os << "\n";
1786 os << " - LexicalEnv: ";
1787 if (GetLexicalEnv(thread).IsLexicalEnv()) {
1788 GetLexicalEnv(thread).Dump(thread, os);
1789 } else {
1790 GetLexicalEnv(thread).DumpTaggedValue(thread, os); // reduce circular calls
1791 }
1792 os << "\n";
1793 os << " - RawProfileTypeInfo: ";
1794 GetRawProfileTypeInfo(thread).Dump(thread, os);
1795 os << "\n";
1796 os << " - HomeObject: ";
1797 GetHomeObject(thread).Dump(thread, os);
1798 os << "\n";
1799 os << " - FunctionExtraInfo: ";
1800 GetFunctionExtraInfo(thread).Dump(thread, os);
1801 os << "\n";
1802 os << " - Method: ";
1803 GetMethod(thread).Dump(thread, os);
1804 os << "\n";
1805 os << " - Module: ";
1806 GetModule(thread).Dump(thread, os);
1807 os << "\n";
1808 JSObject::Dump(thread, os);
1809 }
1810
Dump(const JSThread * thread,std::ostream & os) const1811 void JSHClass::Dump(const JSThread *thread, std::ostream &os) const
1812 {
1813 DumpHClass(thread, this, os, true);
1814 }
1815
Dump(const JSThread * thread,std::ostream & os) const1816 void JSBoundFunction::Dump(const JSThread *thread, std::ostream &os) const
1817 {
1818 os << " - BoundTarget: ";
1819 GetBoundTarget(thread).DumpTaggedValue(thread, os);
1820 os << "\n";
1821
1822 os << " - BoundThis: ";
1823 GetBoundThis(thread).DumpTaggedValue(thread, os);
1824 os << "\n";
1825
1826 os << " - BoundArguments: ";
1827 GetBoundArguments(thread).DumpTaggedValue(thread, os);
1828 os << "\n";
1829
1830 JSObject::Dump(thread, os);
1831 }
1832
Dump(const JSThread * thread,std::ostream & os) const1833 void JSPrimitiveRef::Dump(const JSThread *thread, std::ostream &os) const
1834 {
1835 os << " - SubValue : ";
1836 GetValue(thread).DumpTaggedValue(thread, os);
1837 os << "\n";
1838 JSObject::Dump(thread, os);
1839 }
1840
Dump(const JSThread * thread,std::ostream & os) const1841 void BigInt::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
1842 {
1843 os << " - length : " << GetLength() << "\n";
1844 os << " - Sign : " << GetSign() << "\n";
1845 os << " - value : " << ToStdString(DECIMAL) << "\n";
1846 }
1847
Dump(const JSThread * thread,std::ostream & os) const1848 void JSDate::Dump(const JSThread *thread, std::ostream &os) const
1849 {
1850 os << " - time: " << GetTime(const_cast<JSThread*>(thread)).GetDouble() << "\n";
1851 os << " - localOffset: " << GetLocalOffset(thread).GetDouble() << "\n";
1852 JSObject::Dump(thread, os);
1853 }
1854
Dump(const JSThread * thread,std::ostream & os) const1855 void JSMap::Dump(const JSThread *thread, std::ostream &os) const
1856 {
1857 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
1858 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1859 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1860 os << " - capacity: " << std::dec << map->Capacity() << "\n";
1861 JSObject::Dump(thread, os);
1862
1863 os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1864 map->Dump(thread, os);
1865 }
1866
Dump(const JSThread * thread,std::ostream & os) const1867 void JSSharedMap::Dump(const JSThread *thread, std::ostream &os) const
1868 {
1869 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
1870 os << " - modRecord: " << std::dec << GetModRecord() << "\n";
1871 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1872 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1873 os << " - capacity: " << std::dec << map->Capacity() << "\n";
1874 JSObject::Dump(thread, os);
1875
1876 os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
1877 map->Dump(thread, os);
1878 }
1879
Dump(const JSThread * thread,std::ostream & os) const1880 void JSAPITreeMap::Dump(const JSThread *thread, std::ostream &os) const
1881 {
1882 TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap(thread).GetTaggedObject());
1883 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1884 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1885 os << " - capacity: " << std::dec << map->Capacity() << "\n";
1886 JSObject::Dump(thread, os);
1887
1888 os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1889 map->Dump(thread, os);
1890 }
1891
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const1892 void JSAPITreeMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
1893 {
1894 if (!(GetTreeMap(thread).IsInvalidValue())) {
1895 TaggedTreeMap *map = TaggedTreeMap::Cast(GetTreeMap(thread).GetTaggedObject());
1896 vec.emplace_back("treemap", GetTreeMap(thread));
1897 map->DumpForSnapshot(thread, vec);
1898 }
1899
1900 JSObject::DumpForSnapshot(thread, vec);
1901 }
1902
Dump(const JSThread * thread,std::ostream & os) const1903 void JSAPITreeMapIterator::Dump(const JSThread *thread, std::ostream &os) const
1904 {
1905 TaggedTreeMap *map =
1906 TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap(thread).GetTaggedObject())->
1907 GetTreeMap(thread).GetTaggedObject());
1908 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
1909 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
1910 os << " - capacity: " << std::dec << map->Capacity() << "\n";
1911 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
1912 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
1913 JSObject::Dump(thread, os);
1914
1915 os << " <TaggedTree[" << map->NumberOfElements() << "]>\n";
1916 map->Dump(thread, os);
1917 }
1918
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const1919 void JSAPITreeMapIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
1920 {
1921 if (!(GetIteratedMap(thread).IsInvalidValue())) {
1922 TaggedTreeMap *map =
1923 TaggedTreeMap::Cast(JSAPITreeMap::Cast(GetIteratedMap(thread).GetTaggedObject())->
1924 GetTreeMap(thread).GetTaggedObject());
1925 vec.emplace_back("iteratedmap", GetIteratedMap(thread));
1926 map->DumpForSnapshot(thread, vec);
1927 }
1928
1929 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
1930 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
1931 JSObject::DumpForSnapshot(thread, vec);
1932 }
1933
1934 template <typename T>
DumpTaggedTreeEntry(const JSThread * thread,T tree,std::ostream & os,int index,bool isMap=false)1935 void DumpTaggedTreeEntry(const JSThread *thread, T tree, std::ostream &os, int index, bool isMap = false)
1936 {
1937 DISALLOW_GARBAGE_COLLECTION;
1938 JSTaggedValue parent(tree->GetParent(index));
1939 JSTaggedValue val(tree->GetValue(thread, index));
1940 JSTaggedValue color(static_cast<int>(tree->GetColor(index)));
1941 JSTaggedValue left = tree->GetLeftChild(index);
1942 JSTaggedValue right = tree->GetRightChild(index);
1943 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1944 os << "\n";
1945 if (isMap) {
1946 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << " [key]: {";
1947 JSTaggedValue key(tree->GetKey(thread, index));
1948 key.DumpTaggedValue(thread, os);
1949 os << std::right << "};";
1950 os << "\n";
1951 }
1952 os << std::left << std::setw(DUMP_TYPE_OFFSET) << " [value]: {";
1953 val.DumpTaggedValue(thread, os);
1954 os << std::right << "};";
1955 os << "\n";
1956 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << " [parent]: {";
1957 parent.DumpTaggedValue(thread, os);
1958 os << std::right << "};";
1959 os << "\n";
1960 os << std::left << std::setw(DUMP_TYPE_OFFSET) << " [color]: {";
1961 color.DumpTaggedValue(thread, os);
1962 os << std::right << "};";
1963 os << "\n";
1964 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << " [left]: {";
1965 left.DumpTaggedValue(thread, os);
1966 os << std::right << "}; ";
1967 os << std::left << std::setw(DUMP_TYPE_OFFSET) << " [right]: {";
1968 right.DumpTaggedValue(thread, os);
1969 os << std::right << "};";
1970 os << "\n";
1971 }
Dump(const JSThread * thread,std::ostream & os) const1972 void TaggedTreeMap::Dump(const JSThread *thread, std::ostream &os) const
1973 {
1974 DISALLOW_GARBAGE_COLLECTION;
1975 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
1976 JSTaggedValue node = TaggedArray::Get(thread, 0);
1977 node.DumpTaggedValue(thread, os);
1978 os << std::right << "}" << "\n";
1979 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]: {";
1980 node = TaggedArray::Get(thread, 1);
1981 node.DumpTaggedValue(thread, os);
1982 os << std::right << "}" << "\n";
1983 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
1984 node = TaggedArray::Get(thread, 2); // 2 means the three element
1985 node.DumpTaggedValue(thread, os);
1986 os << std::right << "}" << "\n";
1987 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
1988 node = TaggedArray::Get(thread, 3); // 3 means the three element
1989 node.DumpTaggedValue(thread, os);
1990 os << std::right << "}" << "\n";
1991
1992 uint32_t capacity = NumberOfElements() + NumberOfDeletedElements();
1993 for (uint32_t index = 0; index < capacity; index++) {
1994 if (GetKey(thread, index).IsHole()) {
1995 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
1996 GetKey(thread, index).DumpTaggedValue(thread, os);
1997 os << "\n";
1998 } else {
1999 DumpTaggedTreeEntry(thread, const_cast<TaggedTreeMap *>(this), os, index, true);
2000 }
2001 }
2002 }
2003
Dump(const JSThread * thread,std::ostream & os) const2004 void JSAPITreeSet::Dump(const JSThread *thread, std::ostream &os) const
2005 {
2006 TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet(thread).GetTaggedObject());
2007 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2008 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2009 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2010 JSObject::Dump(thread, os);
2011
2012 os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
2013 set->Dump(thread, os);
2014 }
2015
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2016 void JSAPITreeSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2017 {
2018 if (!(GetTreeSet(thread).IsInvalidValue())) {
2019 TaggedTreeSet *set = TaggedTreeSet::Cast(GetTreeSet(thread).GetTaggedObject());
2020 vec.emplace_back("treeset", GetTreeSet(thread));
2021 set->DumpForSnapshot(thread, vec);
2022 }
2023
2024 JSObject::DumpForSnapshot(thread, vec);
2025 }
2026
Dump(const JSThread * thread,std::ostream & os) const2027 void JSAPITreeSetIterator::Dump(const JSThread *thread, std::ostream &os) const
2028 {
2029 TaggedTreeSet *set =
2030 TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet(thread).GetTaggedObject())->
2031 GetTreeSet(thread).GetTaggedObject());
2032 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2033 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2034 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2035 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2036 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2037 JSObject::Dump(thread, os);
2038
2039 os << " <TaggedTree[" << set->NumberOfElements() << "]>\n";
2040 set->Dump(thread, os);
2041 }
2042
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2043 void JSAPITreeSetIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2044 {
2045 if (!(GetIteratedSet(thread).IsInvalidValue())) {
2046 TaggedTreeSet *set =
2047 TaggedTreeSet::Cast(JSAPITreeSet::Cast(GetIteratedSet(thread).GetTaggedObject())->
2048 GetTreeSet(thread).GetTaggedObject());
2049 vec.emplace_back("iteratedset", GetIteratedSet(thread));
2050 set->DumpForSnapshot(thread, vec);
2051 }
2052
2053 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
2054 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
2055 JSObject::DumpForSnapshot(thread, vec);
2056 }
2057
Dump(const JSThread * thread,std::ostream & os) const2058 void TaggedTreeSet::Dump(const JSThread *thread, std::ostream &os) const
2059 {
2060 DISALLOW_GARBAGE_COLLECTION;
2061 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Elements]: {";
2062 JSTaggedValue node = TaggedArray::Get(thread, 0);
2063 node.DumpTaggedValue(thread, os);
2064 os << std::right << "}" << "\n";
2065 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Delete]: {";
2066 node = TaggedArray::Get(thread, 1);
2067 node.DumpTaggedValue(thread, os);
2068 os << std::right << "}" << "\n";
2069 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[Capacity]: {";
2070 node = TaggedArray::Get(thread, 2); // 2 means the three element
2071 node.DumpTaggedValue(thread, os);
2072 os << std::right << "}" << "\n";
2073 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[RootNode]: {";
2074 node = TaggedArray::Get(thread, 3); // 3 means the three element
2075 node.DumpTaggedValue(thread, os);
2076 os << std::right << "}" << "\n";
2077
2078 uint32_t capacity = NumberOfElements() + NumberOfDeletedElements();
2079 for (uint32_t index = 0; index < capacity; index++) {
2080 if (GetKey(thread, index).IsHole()) {
2081 os << std::left << std::setw(DUMP_ELEMENT_OFFSET) << "[entry] " << index << ": ";
2082 GetKey(thread, index).DumpTaggedValue(thread, os);
2083 os << "\n";
2084 } else {
2085 DumpTaggedTreeEntry(thread, const_cast<TaggedTreeSet *>(this), os, index);
2086 }
2087 }
2088 }
2089
Dump(const JSThread * thread,std::ostream & os) const2090 void JSAPIPlainArray::Dump(const JSThread *thread, std::ostream &os) const
2091 {
2092 TaggedArray *keys = TaggedArray::Cast(GetKeys(thread).GetTaggedObject());
2093 TaggedArray *values = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
2094 uint32_t len = static_cast<uint32_t>(GetLength());
2095 for (uint32_t i = 0; i < len; i++) {
2096 os << " - keys: ";
2097 keys->Get(thread, i).DumpTaggedValue(thread, os);
2098 os << "\n";
2099 os << " - values: ";
2100 values->Get(thread, i).DumpTaggedValue(thread, os);
2101 os << "\n";
2102 }
2103 os << " - length: " << std::dec << len << "\n";
2104 JSObject::Dump(thread, os);
2105 }
2106
Dump(const JSThread * thread,std::ostream & os) const2107 void JSAPIPlainArrayIterator::Dump(const JSThread *thread, std::ostream &os) const
2108 {
2109 JSAPIPlainArray *array = JSAPIPlainArray::Cast(GetIteratedPlainArray(thread).GetTaggedObject());
2110 os << " - length: " << std::dec << array->GetSize() << "\n";
2111 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2112 JSObject::Dump(thread, os);
2113 }
2114
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2115 void JSAPIPlainArrayIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2116 {
2117 if (!(GetIteratedPlainArray(thread).IsInvalidValue())) {
2118 JSAPIPlainArray *array = JSAPIPlainArray::Cast(GetIteratedPlainArray(thread).GetTaggedObject());
2119 vec.emplace_back("iteratedplainarray", GetIteratedPlainArray(thread));
2120 array->DumpForSnapshot(thread, vec);
2121 }
2122
2123 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
2124 JSObject::DumpForSnapshot(thread, vec);
2125 }
2126
Dump(const JSThread * thread,std::ostream & os) const2127 void JSForInIterator::Dump(const JSThread *thread, std::ostream &os) const
2128 {
2129 os << " - Object : ";
2130 GetObject(thread).DumpTaggedValue(thread, os);
2131 os << " - CachedHclass : ";
2132 GetCachedHClass(thread).DumpTaggedValue(thread, os);
2133 os << "\n";
2134 os << " - Keys : ";
2135 GetKeys(thread).DumpTaggedValue(thread, os);
2136 os << "\n";
2137 os << " - Index : " << GetIndex();
2138 os << "\n";
2139 os << " - Length : " << GetLength();
2140 os << "\n";
2141 JSObject::Dump(thread, os);
2142 }
2143
Dump(const JSThread * thread,std::ostream & os) const2144 void JSMapIterator::Dump(const JSThread *thread, std::ostream &os) const
2145 {
2146 LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap(thread).GetTaggedObject());
2147 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
2148 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
2149 os << " - capacity: " << std::dec << map->Capacity() << "\n";
2150 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2151 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2152 JSObject::Dump(thread, os);
2153
2154 os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
2155 map->Dump(thread, os);
2156 }
2157
Dump(const JSThread * thread,std::ostream & os) const2158 void JSSharedMapIterator::Dump(const JSThread *thread, std::ostream &os) const
2159 {
2160 JSSharedMap *iteratedMap = JSSharedMap::Cast(GetIteratedMap(thread).GetTaggedObject());
2161 LinkedHashMap *map = LinkedHashMap::Cast(iteratedMap->GetLinkedMap(thread).GetTaggedObject());
2162 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
2163 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
2164 os << " - capacity: " << std::dec << map->Capacity() << "\n";
2165 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2166 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2167 JSObject::Dump(thread, os);
2168
2169 os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
2170 map->Dump(thread, os);
2171 }
2172
Dump(const JSThread * thread,std::ostream & os) const2173 void JSSet::Dump(const JSThread *thread, std::ostream &os) const
2174 {
2175 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
2176 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2177 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2178 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2179 JSObject::Dump(thread, os);
2180
2181 os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
2182 set->Dump(thread, os);
2183 }
2184
Dump(const JSThread * thread,std::ostream & os) const2185 void JSSharedSet::Dump(const JSThread *thread, std::ostream &os) const
2186 {
2187 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
2188 os << " - modRecord: " << std::dec << GetModRecord() << "\n";
2189 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2190 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2191 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2192 JSObject::Dump(thread, os);
2193
2194 os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
2195 set->Dump(thread, os);
2196 }
2197
Dump(const JSThread * thread,std::ostream & os) const2198 void JSWeakMap::Dump(const JSThread *thread, std::ostream &os) const
2199 {
2200 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
2201 os << " - length: " << std::dec << GetSize(thread) << "\n";
2202 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
2203 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
2204 os << " - capacity: " << std::dec << map->Capacity() << "\n";
2205 JSObject::Dump(thread, os);
2206
2207 os << " <NameDictionary[" << map->NumberOfElements() << "]>\n";
2208 map->Dump(thread, os);
2209 }
2210
Dump(const JSThread * thread,std::ostream & os) const2211 void JSWeakSet::Dump(const JSThread *thread, std::ostream &os) const
2212 {
2213 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
2214 os << " - size: " << std::dec << GetSize(thread) << "\n";
2215 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2216 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2217 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2218 JSObject::Dump(thread, os);
2219
2220 os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
2221 set->Dump(thread, os);
2222 }
2223
Dump(const JSThread * thread,std::ostream & os) const2224 void JSWeakRef::Dump(const JSThread *thread, std::ostream &os) const
2225 {
2226 os << " - WeakObject : ";
2227 GetWeakObject(thread).DumpTaggedValue(thread, os);
2228 os << "\n";
2229 JSObject::Dump(thread, os);
2230 }
2231
Dump(const JSThread * thread,std::ostream & os) const2232 void JSFinalizationRegistry::Dump(const JSThread *thread, std::ostream &os) const
2233 {
2234 os << " - CleanupCallback : ";
2235 GetCleanupCallback(thread).DumpTaggedValue(thread, os);
2236 os << "\n";
2237 os << " - NoUnregister : ";
2238 GetNoUnregister(thread).Dump(thread, os);
2239 os << "\n";
2240 os << " - MaybeUnregister : ";
2241 LinkedHashMap *map = LinkedHashMap::Cast(GetMaybeUnregister(thread).GetTaggedObject());
2242 os << " - elements: " << std::dec << map->NumberOfElements() << "\n";
2243 os << " - deleted-elements: " << std::dec << map->NumberOfDeletedElements() << "\n";
2244 os << " - capacity: " << std::dec << map->Capacity() << "\n";
2245 JSObject::Dump(thread, os);
2246 }
2247
Dump(const JSThread * thread,std::ostream & os) const2248 void CellRecord::Dump(const JSThread *thread, std::ostream &os) const
2249 {
2250 os << " - WeakRefTarget : ";
2251 GetFromWeakRefTarget(thread).DumpTaggedValue(thread, os);
2252 os << "\n";
2253 os << " - HeldValue : ";
2254 GetHeldValue(thread).DumpTaggedValue(thread, os);
2255 os << "\n";
2256 }
2257
Dump(const JSThread * thread,std::ostream & os) const2258 void JSSetIterator::Dump(const JSThread *thread, std::ostream &os) const
2259 {
2260 LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet(thread).GetTaggedObject());
2261 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2262 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2263 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2264 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2265 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2266 JSObject::Dump(thread, os);
2267
2268 os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
2269 set->Dump(thread, os);
2270 }
2271
Dump(const JSThread * thread,std::ostream & os) const2272 void JSSharedSetIterator::Dump(const JSThread *thread, std::ostream &os) const
2273 {
2274 JSSharedSet *iteratedSet = JSSharedSet::Cast(GetIteratedSet(thread).GetTaggedObject());
2275 LinkedHashSet *set = LinkedHashSet::Cast(iteratedSet->GetLinkedSet(thread).GetTaggedObject());
2276 os << " - elements: " << std::dec << set->NumberOfElements() << "\n";
2277 os << " - deleted-elements: " << std::dec << set->NumberOfDeletedElements() << "\n";
2278 os << " - capacity: " << std::dec << set->Capacity() << "\n";
2279 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2280 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2281 JSObject::Dump(thread, os);
2282
2283 os << " <NameDictionary[" << set->NumberOfElements() << "]>\n";
2284 set->Dump(thread, os);
2285 }
2286
Dump(const JSThread * thread,std::ostream & os) const2287 void JSRegExpIterator::Dump(const JSThread *thread, std::ostream &os) const
2288 {
2289 os << " - IteratingRegExp: ";
2290 GetIteratingRegExp(thread).Dump(thread, os);
2291 os << "\n";
2292 os << " - IteratedString: ";
2293 GetIteratedString(thread).Dump(thread, os);
2294 os << "\n";
2295 os << " - Global: " << std::dec << GetGlobal() << "\n";
2296 os << " - Unicode: " << std::dec << GetUnicode() << "\n";
2297 os << " - Done: " << std::dec << GetDone() << "\n";
2298 JSObject::Dump(thread, os);
2299 }
2300
Dump(const JSThread * thread,std::ostream & os) const2301 void JSArray::Dump(const JSThread *thread, std::ostream &os) const
2302 {
2303 os << " - length: " << std::dec << GetArrayLength() << "\n";
2304 JSObject::Dump(thread, os);
2305 }
2306
Dump(const JSThread * thread,std::ostream & os) const2307 void JSSharedArray::Dump(const JSThread *thread, std::ostream &os) const
2308 {
2309 os << " - length: " << std::dec << GetArrayLength() << "\n";
2310 JSObject::Dump(thread, os);
2311 }
2312
Dump(const JSThread * thread,std::ostream & os) const2313 void JSArrayIterator::Dump(const JSThread *thread, std::ostream &os) const
2314 {
2315 JSArray *array = JSArray::Cast(GetIteratedArray(thread).GetTaggedObject());
2316 os << " - length: " << std::dec << array->GetArrayLength() << "\n";
2317 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2318 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2319 JSObject::Dump(thread, os);
2320 }
2321
Dump(const JSThread * thread,std::ostream & os) const2322 void JSSharedArrayIterator::Dump(const JSThread *thread, std::ostream &os) const
2323 {
2324 JSSharedArray *array = JSSharedArray::Cast(GetIteratedArray(thread).GetTaggedObject());
2325 os << " - length: " << std::dec << array->GetArrayLength() << "\n";
2326 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2327 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2328 JSObject::Dump(thread, os);
2329 }
2330
Dump(const JSThread * thread,std::ostream & os) const2331 void JSAPIArrayList::Dump(const JSThread *thread, std::ostream &os) const
2332 {
2333 os << " - length: " << std::dec << GetSize(const_cast<JSThread *>(thread)) << "\n";
2334 JSObject::Dump(thread, os);
2335 }
2336
Dump(const JSThread * thread,std::ostream & os) const2337 void JSAPIArrayListIterator::Dump(const JSThread *thread, std::ostream &os) const
2338 {
2339 JSAPIArrayList *arrayList = JSAPIArrayList::Cast(GetIteratedArrayList(thread).GetTaggedObject());
2340 os << " - length: " << std::dec << arrayList->GetSize(const_cast<JSThread *>(thread)) << "\n";
2341 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2342 JSObject::Dump(thread, os);
2343 }
2344
Dump(const JSThread * thread,std::ostream & os) const2345 void JSAPIDeque::Dump(const JSThread *thread, std::ostream &os) const
2346 {
2347 os << " - first: " << std::dec << GetFirst() << "\n";
2348 os << " - last: " << std::dec << GetLast() << "\n";
2349 JSObject::Dump(thread, os);
2350 }
2351
Dump(const JSThread * thread,std::ostream & os) const2352 void JSAPIDequeIterator::Dump(const JSThread *thread, std::ostream &os) const
2353 {
2354 JSAPIDeque *deque = JSAPIDeque::Cast(GetIteratedDeque(thread).GetTaggedObject());
2355 os << " - length: " << std::dec << deque->GetSize(thread) << "\n";
2356 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2357 JSObject::Dump(thread, os);
2358 }
2359
Dump(const JSThread * thread,std::ostream & os) const2360 void JSAPILightWeightMap::Dump(const JSThread *thread, std::ostream &os) const
2361 {
2362 uint32_t capacity = GetSize();
2363 os << " - length: " << std::dec << capacity << "\n";
2364 uint32_t i = 0;
2365 TaggedArray *hashArray = TaggedArray::Cast(GetHashes(thread).GetTaggedObject());
2366 TaggedArray *keyArray = TaggedArray::Cast(GetKeys(thread).GetTaggedObject());
2367 TaggedArray *valueArray = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
2368 while (capacity > i) {
2369 os << " hash: ";
2370 hashArray->Get(thread, i).DumpTaggedValue(thread, os);
2371 os << " key: ";
2372 keyArray->Get(thread, i).DumpTaggedValue(thread, os);
2373 os << " value: ";
2374 valueArray->Get(thread, i).DumpTaggedValue(thread, os);
2375 os << "\n";
2376 i++;
2377 }
2378 JSObject::Dump(thread, os);
2379 }
2380
Dump(const JSThread * thread,std::ostream & os) const2381 void JSAPILightWeightMapIterator::Dump(const JSThread *thread, std::ostream &os) const
2382 {
2383 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2384 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2385 JSObject::Dump(thread, os);
2386 }
2387
Dump(const JSThread * thread,std::ostream & os) const2388 void JSAPIHashMap::Dump(const JSThread *thread, std::ostream &os) const
2389 {
2390 TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable(thread).GetTaggedObject());
2391 os << " - elements: " << std::dec << GetSize() << "\n";
2392 os << " - table capacity: " << std::dec << static_cast<int>(hashArray->GetLength()) << "\n";
2393 hashArray->Dump(thread, os);
2394 JSObject::Dump(thread, os);
2395 }
2396
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2397 void JSAPIHashMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2398 {
2399 if (!(GetTable(thread).IsInvalidValue())) {
2400 TaggedHashArray *map = TaggedHashArray::Cast(GetTable(thread).GetTaggedObject());
2401 vec.emplace_back("hashmap", GetTable(thread));
2402 map->DumpForSnapshot(thread, vec);
2403 }
2404
2405 JSObject::DumpForSnapshot(thread, vec);
2406 }
2407
Dump(const JSThread * thread,std::ostream & os) const2408 void JSAPIHashSet::Dump(const JSThread *thread, std::ostream &os) const
2409 {
2410 TaggedHashArray *hashArray = TaggedHashArray::Cast(GetTable(thread).GetTaggedObject());
2411 os << " - elements: " << std::dec << GetSize() << "\n";
2412 os << " - table capacity: " << std::dec << static_cast<int>(hashArray->GetLength()) << "\n";
2413 hashArray->Dump(thread, os);
2414 JSObject::Dump(thread, os);
2415 }
2416
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2417 void JSAPIHashSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2418 {
2419 if (!(GetTable(thread).IsInvalidValue())) {
2420 TaggedHashArray *set = TaggedHashArray::Cast(GetTable(thread).GetTaggedObject());
2421 vec.emplace_back("hashset", GetTable(thread));
2422 set->DumpForSnapshot(thread, vec);
2423 }
2424
2425 JSObject::DumpForSnapshot(thread, vec);
2426 }
2427
Dump(const JSThread * thread,std::ostream & os) const2428 void JSAPIHashMapIterator::Dump(const JSThread *thread, std::ostream &os) const
2429 {
2430 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2431 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2432 JSObject::Dump(thread, os);
2433 }
2434
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2435 void JSAPIHashMapIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2436 {
2437 vec.emplace_back(CString("IteratedHashMap"), JSTaggedValue(GetIteratedHashMap(thread)));
2438 vec.emplace_back(CString("TaggedQueue"), JSTaggedValue(GetTaggedQueue(thread)));
2439 vec.emplace_back(CString("CurrentNodeResult"), JSTaggedValue(GetCurrentNodeResult(thread)));
2440 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
2441 JSObject::DumpForSnapshot(thread, vec);
2442 }
2443
Dump(const JSThread * thread,std::ostream & os) const2444 void JSAPIHashSetIterator::Dump(const JSThread *thread, std::ostream &os) const
2445 {
2446 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2447 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2448 JSObject::Dump(thread, os);
2449 }
2450
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2451 void JSAPIHashSetIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2452 {
2453 JSObject::DumpForSnapshot(thread, vec);
2454 }
2455
Dump(const JSThread * thread,std::ostream & os) const2456 void JSAPILightWeightSet::Dump(const JSThread *thread, std::ostream &os) const
2457 {
2458 TaggedArray *keys = TaggedArray::Cast(GetHashes(thread).GetTaggedObject());
2459 TaggedArray *values = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
2460 uint32_t len = GetLength();
2461 for (uint32_t i = 0; i < len; i++) {
2462 os << " - keys: ";
2463 keys->Get(thread, i).DumpTaggedValue(thread, os);
2464 os << "\n";
2465 os << " - values: ";
2466 values->Get(thread, i).DumpTaggedValue(thread, os);
2467 os << "\n";
2468 }
2469 os << " - length: " << std::dec << len << "\n";
2470 JSObject::Dump(thread, os);
2471 }
2472
Dump(const JSThread * thread,std::ostream & os) const2473 void JSAPILightWeightSetIterator::Dump(const JSThread *thread, std::ostream &os) const
2474 {
2475 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2476 os << " - IterationKind: " << std::dec << static_cast<int>(GetIterationKind()) << "\n";
2477 JSObject::Dump(thread, os);
2478 }
2479
Dump(const JSThread * thread,std::ostream & os) const2480 void JSAPIList::Dump(const JSThread *thread, std::ostream &os) const
2481 {
2482 TaggedSingleList *list = TaggedSingleList::Cast(GetSingleList(thread).GetTaggedObject());
2483 os << " - length: " << std::dec << list->GetCapacityFromTaggedArray() << "\n";
2484 os << " - node num: " << std::dec << list->NumberOfNodes() << "\n";
2485 os << " - delete node num: " << std::dec << list->NumberOfDeletedNodes() << "\n";
2486 os << " - is odered list: " << std::dec << this->IsOrderedList() << "\n";
2487 JSObject::Dump(thread, os);
2488 list->Dump(thread, os);
2489 }
2490
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2491 void JSAPIList::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2492 {
2493 if (!(GetSingleList(thread).IsInvalidValue())) {
2494 TaggedSingleList *list = TaggedSingleList::Cast(GetSingleList(thread).GetTaggedObject());
2495 vec.emplace_back("singleList", GetSingleList(thread));
2496 list->DumpForSnapshot(thread, vec);
2497 }
2498 JSObject::DumpForSnapshot(thread, vec);
2499 }
2500
Dump(const JSThread * thread,std::ostream & os) const2501 void JSAPIListIterator::Dump(const JSThread *thread, std::ostream &os) const
2502 {
2503 TaggedSingleList *list = TaggedSingleList::Cast(GetIteratedList(thread).GetTaggedObject());
2504 os << " - length: " << std::dec << list->GetCapacityFromTaggedArray() << "\n";
2505 os << " - node num: " << std::dec << list->NumberOfNodes() << "\n";
2506 os << " - delete node num: " << std::dec << list->NumberOfDeletedNodes() << "\n";
2507 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2508 JSObject::Dump(thread, os);
2509 list->Dump(thread, os);
2510 }
2511
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2512 void JSAPIListIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2513 {
2514 if (!(GetIteratedList(thread).IsInvalidValue())) {
2515 TaggedSingleList *list = TaggedSingleList::Cast(GetIteratedList(thread).GetTaggedObject());
2516 vec.emplace_back("iteratedlist", GetIteratedList(thread));
2517 list->DumpForSnapshot(thread, vec);
2518 }
2519 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
2520 JSObject::DumpForSnapshot(thread, vec);
2521 }
2522
Dump(const JSThread * thread,std::ostream & os) const2523 void JSAPILinkedList::Dump(const JSThread *thread, std::ostream &os) const
2524 {
2525 TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetDoubleList(thread).GetTaggedObject());
2526 os << " - length: " << std::dec << linkedList->GetCapacityFromTaggedArray() << "\n";
2527 os << " - node num: " << std::dec << linkedList->NumberOfNodes() << "\n";
2528 os << " - delete node num: " << std::dec << linkedList->NumberOfDeletedNodes() << "\n";
2529 JSObject::Dump(thread, os);
2530 linkedList->Dump(thread, os);
2531 }
2532
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2533 void JSAPILinkedList::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2534 {
2535 if (!(GetDoubleList(thread).IsInvalidValue())) {
2536 TaggedDoubleList *list = TaggedDoubleList::Cast(GetDoubleList(thread).GetTaggedObject());
2537 vec.emplace_back("doubleList", GetDoubleList(thread));
2538 list->DumpForSnapshot(thread, vec);
2539 }
2540
2541 JSObject::DumpForSnapshot(thread, vec);
2542 }
2543
Dump(const JSThread * thread,std::ostream & os) const2544 void JSAPILinkedListIterator::Dump(const JSThread *thread, std::ostream &os) const
2545 {
2546 TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetIteratedLinkedList(thread).GetTaggedObject());
2547 os << " - length: " << std::dec << linkedList->GetCapacityFromTaggedArray() << "\n";
2548 os << " - node num: " << std::dec << linkedList->NumberOfNodes() << "\n";
2549 os << " - delete node num: " << std::dec << linkedList->NumberOfDeletedNodes() << "\n";
2550 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2551 JSObject::Dump(thread, os);
2552 linkedList->Dump(thread, os);
2553 }
2554
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const2555 void JSAPILinkedListIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
2556 {
2557 if (!(GetIteratedLinkedList(thread).IsInvalidValue())) {
2558 TaggedDoubleList *linkedList = TaggedDoubleList::Cast(GetIteratedLinkedList(thread).GetTaggedObject());
2559 vec.emplace_back("iteratedlist", GetIteratedLinkedList(thread));
2560 linkedList->DumpForSnapshot(thread, vec);
2561 }
2562
2563 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
2564 JSObject::DumpForSnapshot(thread, vec);
2565 }
2566
Dump(const JSThread * thread,std::ostream & os) const2567 void JSAPIQueue::Dump(const JSThread *thread, std::ostream &os) const
2568 {
2569 os << " - length: " << std::dec << GetSize(thread) << "\n";
2570 os << " - front: " << std::dec << GetFront() << "\n";
2571 os << " - tail: " << std::dec << GetTail() << "\n";
2572 JSObject::Dump(thread, os);
2573 }
2574
Dump(const JSThread * thread,std::ostream & os) const2575 void JSAPIQueueIterator::Dump(const JSThread *thread, std::ostream &os) const
2576 {
2577 JSAPIQueue *queue = JSAPIQueue::Cast(GetIteratedQueue(thread).GetTaggedObject());
2578 os << " - length: " << std::dec << queue->GetSize(thread) << "\n";
2579 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2580 JSObject::Dump(thread, os);
2581 }
2582
Dump(const JSThread * thread,std::ostream & os) const2583 void JSAPIStack::Dump(const JSThread *thread, std::ostream &os) const
2584 {
2585 os << " - top: " << std::dec << GetTop() << "\n";
2586 JSObject::Dump(thread, os);
2587 }
2588
Dump(const JSThread * thread,std::ostream & os) const2589 void JSAPIStackIterator::Dump(const JSThread *thread, std::ostream &os) const
2590 {
2591 JSAPIStack *stack = JSAPIStack::Cast(GetIteratedStack(thread).GetTaggedObject());
2592 os << " - length: " << std::dec << stack->GetSize() << "\n";
2593 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2594 JSObject::Dump(thread, os);
2595 }
2596
Dump(const JSThread * thread,std::ostream & os) const2597 void JSAPIVector::Dump(const JSThread *thread, std::ostream &os) const
2598 {
2599 os << " - length: " << std::dec << GetSize() << "\n";
2600 JSObject::Dump(thread, os);
2601 }
2602
Dump(const JSThread * thread,std::ostream & os) const2603 void JSAPIVectorIterator::Dump(const JSThread *thread, std::ostream &os) const
2604 {
2605 JSAPIVector *vector = JSAPIVector::Cast(GetIteratedVector(thread).GetTaggedObject());
2606 os << " - length: " << std::dec << vector->GetSize() << "\n";
2607 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2608 JSObject::Dump(thread, os);
2609 }
2610
Dump(const JSThread * thread,std::ostream & os) const2611 void JSAPIBitVector::Dump(const JSThread *thread, std::ostream &os) const
2612 {
2613 os << " - length: " << std::dec << GetSize() << "\n";
2614 JSObject::Dump(thread, os);
2615 }
2616
Dump(const JSThread * thread,std::ostream & os) const2617 void JSAPIBitVectorIterator::Dump(const JSThread *thread, std::ostream &os) const
2618 {
2619 JSAPIBitVector *bitVector = JSAPIBitVector::Cast(GetIteratedBitVector(thread).GetTaggedObject());
2620 os << " - length: " << std::dec << bitVector->GetSize() << "\n";
2621 os << " - nextIndex: " << std::dec << GetNextIndex() << "\n";
2622 JSObject::Dump(thread, os);
2623 }
2624
Dump(const JSThread * thread,std::ostream & os) const2625 void JSAPIFastBuffer::Dump(const JSThread *thread, std::ostream &os) const
2626 {
2627 os << " - ByteLength: " << std::dec << GetSize() << "\n";
2628 os << " - Length: " << std::dec << GetLength() << "\n";
2629 auto array = JSTypedArray::Cast(GetFastBufferData(thread).GetTaggedObject());
2630 array->Dump(thread, os);
2631 JSObject::Dump(thread, os);
2632 }
2633
Dump(const JSThread * thread,std::ostream & os) const2634 void JSStringIterator::Dump(const JSThread *thread, std::ostream &os) const
2635 {
2636 EcmaString *str = EcmaString::Cast(GetIteratedString(thread).GetTaggedObject());
2637 os << " - IteratedString: " << EcmaStringAccessor(str).ToCString(thread) << "\n";
2638 os << " - StringIteratorNextIndex: " << std::dec << GetStringIteratorNextIndex() << "\n";
2639 JSObject::Dump(thread, os);
2640 }
Dump(const JSThread * thread,std::ostream & os) const2641 void JSTypedArray::Dump(const JSThread *thread, std::ostream &os) const
2642 {
2643 os << " - viewed-array-buffer: ";
2644 GetViewedArrayBufferOrByteArray(thread).Dump(thread, os);
2645 os << " - typed-array-name: ";
2646 GetTypedArrayName(thread).Dump(thread, os);
2647 os << " - byte-length: " << GetByteLength();
2648 os << " - byte-offset: " << GetByteOffset();
2649 os << " - array-length: " << GetArrayLength();
2650 JSObject::Dump(thread, os);
2651 }
2652
Dump(const JSThread * thread,std::ostream & os) const2653 void JSSharedTypedArray::Dump(const JSThread *thread, std::ostream &os) const
2654 {
2655 os << " - viewed-array-buffer: ";
2656 GetViewedArrayBufferOrByteArray(thread).Dump(thread, os);
2657 os << " - typed-array-name: ";
2658 GetTypedArrayName(thread).Dump(thread, os);
2659 os << " - byte-length: " << GetByteLength();
2660 os << " - byte-offset: " << GetByteOffset();
2661 os << " - array-length: " << GetArrayLength();
2662 JSObject::Dump(thread, os);
2663 }
2664
Dump(const JSThread * thread,std::ostream & os) const2665 void ByteArray::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
2666 {
2667 os << " - array-length: " << GetArrayLength();
2668 os << " - byte-length: " << GetByteLength();
2669 }
2670
Dump(const JSThread * thread,std::ostream & os) const2671 void JSRegExp::Dump(const JSThread *thread, std::ostream &os) const
2672 {
2673 os << "\n";
2674 os << " - ByteCodeBuffer: ";
2675 GetByteCodeBuffer(thread).Dump(thread, os);
2676 os << "\n";
2677 os << " - OriginalSource: ";
2678 GetOriginalSource(thread).Dump(thread, os);
2679 os << "\n";
2680 os << " - OriginalFlags: ";
2681 GetOriginalFlags(thread).Dump(thread, os);
2682 os << "\n";
2683 os << " - GroupName: ";
2684 GetGroupName(thread).Dump(thread, os);
2685 os << "\n";
2686 os << " - Length: " << GetLength();
2687 os << "\n";
2688 JSObject::Dump(thread, os);
2689 }
2690
Dump(const JSThread * thread,std::ostream & os) const2691 void JSProxy::Dump(const JSThread *thread, std::ostream &os) const
2692 {
2693 os << " - Target: ";
2694 os << "\n";
2695 JSObject::Cast(GetTarget(thread).GetTaggedObject())->Dump(thread, os);
2696 os << " - Handler: ";
2697 os << "\n";
2698 JSObject::Cast(GetHandler(thread).GetTaggedObject())->Dump(thread, os);
2699 os << "\n";
2700 }
2701
Dump(const JSThread * thread,std::ostream & os) const2702 void JSSymbol::Dump(const JSThread *thread, std::ostream &os) const
2703 {
2704 os << " - hash-field: " << GetHashField();
2705 os << "\n - flags: " << GetFlags();
2706 os << "\n - description: ";
2707 JSTaggedValue description = GetDescription(thread);
2708 description.Dump(thread, os);
2709 }
2710
Dump(const JSThread * thread,std::ostream & os) const2711 void LexicalEnv::Dump(const JSThread *thread, std::ostream &os) const
2712 {
2713 DumpArrayClass(thread, this, os);
2714 }
2715
Dump(const JSThread * thread,std::ostream & os) const2716 void SFunctionEnv::Dump(const JSThread *thread, std::ostream &os) const
2717 {
2718 DumpArrayClass(thread, this, os);
2719 }
2720
Dump(const JSThread * thread,std::ostream & os) const2721 void SendableEnv::Dump(const JSThread *thread, std::ostream &os) const
2722 {
2723 DumpArrayClass(thread, this, os);
2724 }
2725
Dump(const JSThread * thread,std::ostream & os) const2726 void COWTaggedArray::Dump(const JSThread *thread, std::ostream &os) const
2727 {
2728 DumpArrayClass(thread, this, os);
2729 }
2730
Dump(const JSThread * thread,std::ostream & os) const2731 void MutantTaggedArray::Dump(const JSThread *thread, std::ostream &os) const
2732 {
2733 DumpMutantTaggedArray(thread, this, os);
2734 }
2735
Dump(const JSThread * thread,std::ostream & os) const2736 void COWMutantTaggedArray::Dump(const JSThread *thread, std::ostream &os) const
2737 {
2738 DumpCOWMutantTaggedArray(thread, this, os);
2739 }
2740
2741 // NOLINTNEXTLINE(readability-function-size)
Dump(const JSThread * thread,std::ostream & os) const2742 void GlobalEnv::Dump(const JSThread *thread, std::ostream &os) const
2743 {
2744 auto globalConst = GetJSThread()->GlobalConstants();
2745 os << " - ObjectFunction: ";
2746 GetObjectFunction().GetTaggedValue().Dump(thread, os);
2747 os << " - FunctionFunction: ";
2748 GetFunctionFunction().GetTaggedValue().Dump(thread, os);
2749 os << " - NumberFunction: ";
2750 GetNumberFunction().GetTaggedValue().Dump(thread, os);
2751 os << " - BigIntFunction: ";
2752 GetBigIntFunction().GetTaggedValue().Dump(thread, os);
2753 os << " - DateFunction: ";
2754 GetDateFunction().GetTaggedValue().Dump(thread, os);
2755 os << " - BooleanFunction: ";
2756 GetBooleanFunction().GetTaggedValue().Dump(thread, os);
2757 os << " - ErrorFunction: ";
2758 GetErrorFunction().GetTaggedValue().Dump(thread, os);
2759 os << " - ArrayFunction: ";
2760 GetArrayFunction().GetTaggedValue().Dump(thread, os);
2761 os << " - TypedArrayFunction: ";
2762 GetTypedArrayFunction().GetTaggedValue().Dump(thread, os);
2763 os << " - Int8ArrayFunction: ";
2764 GetInt8ArrayFunction().GetTaggedValue().Dump(thread, os);
2765 os << " - Uint8ArrayFunction: ";
2766 GetUint8ArrayFunction().GetTaggedValue().Dump(thread, os);
2767 os << " - Uint8ClampedArrayFunction: ";
2768 GetUint8ClampedArrayFunction().GetTaggedValue().Dump(thread, os);
2769 os << " - Int16ArrayFunction: ";
2770 GetInt16ArrayFunction().GetTaggedValue().Dump(thread, os);
2771 os << " - ArrayBufferFunction: ";
2772 GetArrayBufferFunction().GetTaggedValue().Dump(thread, os);
2773 os << " - SharedArrayBufferFunction: ";
2774 GetSharedArrayBufferFunction().GetTaggedValue().Dump(thread, os);
2775 os << " - SymbolFunction: ";
2776 GetSymbolFunction().GetTaggedValue().Dump(thread, os);
2777 os << " - RangeErrorFunction: ";
2778 GetRangeErrorFunction().GetTaggedValue().Dump(thread, os);
2779 os << " - ReferenceErrorFunction: ";
2780 GetReferenceErrorFunction().GetTaggedValue().Dump(thread, os);
2781 os << " - TypeErrorFunction: ";
2782 GetTypeErrorFunction().GetTaggedValue().Dump(thread, os);
2783 os << " - AggregateErrorFunction: ";
2784 GetAggregateErrorFunction().GetTaggedValue().Dump(thread, os);
2785 os << " - URIErrorFunction: ";
2786 GetURIErrorFunction().GetTaggedValue().Dump(thread, os);
2787 os << " - SyntaxErrorFunction: ";
2788 GetSyntaxErrorFunction().GetTaggedValue().Dump(thread, os);
2789 os << " - EvalErrorFunction: ";
2790 GetEvalErrorFunction().GetTaggedValue().Dump(thread, os);
2791 os << " - OOMErrorFunction: ";
2792 GetOOMErrorFunction().GetTaggedValue().Dump(thread, os);
2793 os << " - TerminationErrorFunction: ";
2794 GetTerminationErrorFunction().GetTaggedValue().Dump(thread, os);
2795 os << " - RegExpFunction: ";
2796 GetRegExpFunction().GetTaggedValue().Dump(thread, os);
2797 os << " - BuiltinsSetFunction: ";
2798 GetBuiltinsSetFunction().GetTaggedValue().Dump(thread, os);
2799 os << " - BuiltinsMapFunction: ";
2800 GetBuiltinsMapFunction().GetTaggedValue().Dump(thread, os);
2801 os << " - BuiltinsWeakSetFunction: ";
2802 GetBuiltinsWeakSetFunction().GetTaggedValue().Dump(thread, os);
2803 os << " - BuiltinsWeakMapFunction: ";
2804 GetBuiltinsWeakMapFunction().GetTaggedValue().Dump(thread, os);
2805 os << " - BuiltinsWeakRefFunction: ";
2806 GetBuiltinsWeakRefFunction().GetTaggedValue().Dump(thread, os);
2807 os << " - BuiltinsFinalizationRegistryFunction: ";
2808 GetBuiltinsFinalizationRegistryFunction().GetTaggedValue().Dump(thread, os);
2809 os << " - MathFunction: ";
2810 GetMathFunction().GetTaggedValue().Dump(thread, os);
2811 os << " - AtomicsFunction: ";
2812 GetAtomicsFunction().GetTaggedValue().Dump(thread, os);
2813 os << " - JsonFunction: ";
2814 GetJsonFunction().GetTaggedValue().Dump(thread, os);
2815 os << " - StringFunction: ";
2816 GetStringFunction().GetTaggedValue().Dump(thread, os);
2817 os << " - ProxyFunction: ";
2818 GetProxyFunction().GetTaggedValue().Dump(thread, os);
2819 os << " - ReflectFunction: ";
2820 GetReflectFunction().GetTaggedValue().Dump(thread, os);
2821 os << " - AsyncFunction: ";
2822 GetAsyncFunction().GetTaggedValue().Dump(thread, os);
2823 os << " - AsyncFunctionPrototype: ";
2824 GetAsyncFunctionPrototype().GetTaggedValue().Dump(thread, os);
2825 os << " - JSGlobalObject: ";
2826 GetJSGlobalObject().GetTaggedValue().Dump(thread, os);
2827 os << " - GlobalPatch: ";
2828 GetGlobalPatch().GetTaggedValue().Dump(thread, os);
2829 os << " - EmptyArray: ";
2830 globalConst->GetEmptyArray().Dump(thread, os);
2831 os << " - EmptyString ";
2832 globalConst->GetEmptyString().Dump(thread, os);
2833 os << " - EmptyTaggedQueue: ";
2834 globalConst->GetEmptyTaggedQueue().Dump(thread, os);
2835 os << " - EmptyProfileTypeInfoCell: ";
2836 globalConst->GetEmptyProfileTypeInfoCell().Dump(thread, os);
2837 os << " - PrototypeString: ";
2838 globalConst->GetPrototypeString().Dump(thread, os);
2839 os << " - HasInstanceSymbol: ";
2840 GetHasInstanceSymbol().GetTaggedValue().Dump(thread, os);
2841 os << " - IsConcatSpreadableSymbol: ";
2842 GetIsConcatSpreadableSymbol().GetTaggedValue().Dump(thread, os);
2843 os << " - ToStringTagSymbol: ";
2844 GetToStringTagSymbol().GetTaggedValue().Dump(thread, os);
2845 os << " - IteratorSymbol: ";
2846 GetIteratorSymbol().GetTaggedValue().Dump(thread, os);
2847 os << " - AsyncIteratorSymbol: ";
2848 GetAsyncIteratorSymbol().GetTaggedValue().Dump(thread, os);
2849 os << " - MatchSymbol: ";
2850 GetMatchSymbol().GetTaggedValue().Dump(thread, os);
2851 os << " - MatchAllSymbol: ";
2852 GetMatchAllSymbol().GetTaggedValue().Dump(thread, os);
2853 os << " - ReplaceSymbol: ";
2854 GetReplaceSymbol().GetTaggedValue().Dump(thread, os);
2855 os << " - SearchSymbol: ";
2856 GetSearchSymbol().GetTaggedValue().Dump(thread, os);
2857 os << " - SpeciesSymbol: ";
2858 GetSpeciesSymbol().GetTaggedValue().Dump(thread, os);
2859 os << " - SplitSymbol: ";
2860 GetSplitSymbol().GetTaggedValue().Dump(thread, os);
2861 os << " - ToPrimitiveSymbol: ";
2862 GetToPrimitiveSymbol().GetTaggedValue().Dump(thread, os);
2863 os << " - UnscopablesSymbol: ";
2864 GetUnscopablesSymbol().GetTaggedValue().Dump(thread, os);
2865 os << " - HoleySymbol: ";
2866 GetHoleySymbol().GetTaggedValue().Dump(thread, os);
2867 os << " - NativeBindingSymbol: ";
2868 GetNativeBindingSymbol().GetTaggedValue().Dump(thread, os);
2869 os << " - ConstructorString: ";
2870 globalConst->GetConstructorString().Dump(thread, os);
2871 os << " - IteratorPrototype: ";
2872 GetIteratorPrototype().GetTaggedValue().Dump(thread, os);
2873 os << " - ForinIteratorPrototype: ";
2874 GetForinIteratorPrototype().GetTaggedValue().Dump(thread, os);
2875 os << " - StringIterator: ";
2876 GetStringIterator().GetTaggedValue().Dump(thread, os);
2877 os << " - MapIteratorPrototype: ";
2878 GetMapIteratorPrototype().GetTaggedValue().Dump(thread, os);
2879 os << " - SetIteratorPrototype: ";
2880 GetSetIteratorPrototype().GetTaggedValue().Dump(thread, os);
2881 os << " - RegExpIteratorPrototype: ";
2882 GetRegExpIteratorPrototype().GetTaggedValue().Dump(thread, os);
2883 os << " - ArrayIteratorPrototype: ";
2884 GetArrayIteratorPrototype().GetTaggedValue().Dump(thread, os);
2885 os << " - StringIteratorPrototype: ";
2886 GetStringIteratorPrototype().GetTaggedValue().Dump(thread, os);
2887 os << " - LengthString: ";
2888 globalConst->GetLengthString().Dump(thread, os);
2889 os << " - ValueString: ";
2890 globalConst->GetValueString().Dump(thread, os);
2891 os << " - WritableString: ";
2892 globalConst->GetWritableString().Dump(thread, os);
2893 os << " - GetString: ";
2894 globalConst->GetGetString().Dump(thread, os);
2895 os << " - SetString: ";
2896 globalConst->GetSetString().Dump(thread, os);
2897 os << " - EnumerableString: ";
2898 globalConst->GetEnumerableString().Dump(thread, os);
2899 os << " - ConfigurableString: ";
2900 globalConst->GetConfigurableString().Dump(thread, os);
2901 os << " - NameString: ";
2902 globalConst->GetNameString().Dump(thread, os);
2903 os << " - ValueOfString: ";
2904 globalConst->GetValueOfString().Dump(thread, os);
2905 os << " - ToStringString: ";
2906 globalConst->GetToStringString().Dump(thread, os);
2907 os << " - ToLocaleStringString: ";
2908 globalConst->GetToLocaleStringString().Dump(thread, os);
2909 os << " - UndefinedString: ";
2910 globalConst->GetUndefinedString().Dump(thread, os);
2911 os << " - NullString: ";
2912 globalConst->GetNullString().Dump(thread, os);
2913 os << " - TrueString: ";
2914 globalConst->GetTrueString().Dump(thread, os);
2915 os << " - FalseString: ";
2916 globalConst->GetFalseString().Dump(thread, os);
2917 os << " - ThrowTypeError: ";
2918 GetThrowTypeError().GetTaggedValue().Dump(thread, os);
2919 os << " - GetPrototypeOfString: ";
2920 globalConst->GetGetPrototypeOfString().Dump(thread, os);
2921 os << " - SetPrototypeOfString: ";
2922 globalConst->GetSetPrototypeOfString().Dump(thread, os);
2923 os << " - IsExtensibleString: ";
2924 globalConst->GetIsExtensibleString().Dump(thread, os);
2925 os << " - PreventExtensionsString: ";
2926 globalConst->GetPreventExtensionsString().Dump(thread, os);
2927 os << " - GetOwnPropertyDescriptorString: ";
2928 globalConst->GetGetOwnPropertyDescriptorString().Dump(thread, os);
2929 os << " - DefinePropertyString: ";
2930 globalConst->GetDefinePropertyString().Dump(thread, os);
2931 os << " - HasString: ";
2932 globalConst->GetHasString().Dump(thread, os);
2933 os << " - DeletePropertyString: ";
2934 globalConst->GetDeletePropertyString().Dump(thread, os);
2935 os << " - EnumerateString: ";
2936 globalConst->GetEnumerateString().Dump(thread, os);
2937 os << " - OwnKeysString: ";
2938 globalConst->GetOwnKeysString().Dump(thread, os);
2939 os << " - ApplyString: ";
2940 globalConst->GetApplyString().Dump(thread, os);
2941 os << " - ProxyString: ";
2942 globalConst->GetProxyString().Dump(thread, os);
2943 os << " - RevokeString: ";
2944 globalConst->GetRevokeString().Dump(thread, os);
2945 os << " - ProxyConstructString: ";
2946 globalConst->GetProxyConstructString().Dump(thread, os);
2947 os << " - ProxyCallString: ";
2948 globalConst->GetProxyCallString().Dump(thread, os);
2949 os << " - DoneString: ";
2950 globalConst->GetDoneString().Dump(thread, os);
2951 os << " - NegativeZeroString: ";
2952 globalConst->GetNegativeZeroString().Dump(thread, os);
2953 os << " - NextString: ";
2954 globalConst->GetNextString().Dump(thread, os);
2955 os << " - PromiseThenString: ";
2956 globalConst->GetPromiseThenString().Dump(thread, os);
2957 os << " - PromiseFunction: ";
2958 GetPromiseFunction().GetTaggedValue().Dump(thread, os);
2959 os << " - PromiseReactionJob: ";
2960 GetPromiseReactionJob().GetTaggedValue().Dump(thread, os);
2961 os << " - PromiseResolveThenableJob: ";
2962 GetPromiseResolveThenableJob().GetTaggedValue().Dump(thread, os);
2963 os << " - DynamicImportJob: ";
2964 GetDynamicImportJob().GetTaggedValue().Dump(thread, os);
2965 os << " - ScriptJobString: ";
2966 globalConst->GetScriptJobString().Dump(thread, os);
2967 os << " - PromiseString: ";
2968 globalConst->GetPromiseString().Dump(thread, os);
2969 os << " - IdentityString: ";
2970 globalConst->GetIdentityString().Dump(thread, os);
2971 os << " - AsyncFunctionString: ";
2972 globalConst->GetAsyncFunctionString().Dump(thread, os);
2973 os << " - ThrowerString: ";
2974 globalConst->GetThrowerString().Dump(thread, os);
2975 os << " - Undefined: ";
2976 globalConst->GetUndefined().Dump(thread, os);
2977 }
2978
Dump(const JSThread * thread,std::ostream & os) const2979 void JSDataView::Dump(const JSThread *thread, std::ostream &os) const
2980 {
2981 os << " - data-view: ";
2982 GetDataView(thread).Dump(thread, os);
2983 os << " - buffer: ";
2984 GetViewedArrayBuffer(thread).Dump(thread, os);
2985 os << "- byte-length: " << GetByteLength();
2986 os << "\n - byte-offset: " << GetByteOffset();
2987 }
2988
Dump(const JSThread * thread,std::ostream & os) const2989 void JSArrayBuffer::Dump(const JSThread *thread, std::ostream &os) const
2990 {
2991 os << " - byte-length: " << GetArrayBufferByteLength();
2992 os << " - buffer-data: ";
2993 GetArrayBufferData(thread).Dump(thread, os);
2994 os << " - Shared: " << GetShared();
2995 }
2996
Dump(const JSThread * thread,std::ostream & os) const2997 void JSSendableArrayBuffer::Dump(const JSThread *thread, std::ostream &os) const
2998 {
2999 os << " - byte-length: " << GetArrayBufferByteLength();
3000 os << " - buffer-data: ";
3001 GetArrayBufferData(thread).Dump(thread, os);
3002 os << " - Shared: " << GetShared();
3003 }
3004
Dump(const JSThread * thread,std::ostream & os) const3005 void PromiseReaction::Dump(const JSThread *thread, std::ostream &os) const
3006 {
3007 os << " - promise-capability: ";
3008 GetPromiseCapability(thread).Dump(thread, os);
3009 os << " - type: " << static_cast<int>(GetType());
3010 os << " - handler: ";
3011 GetHandler(thread).Dump(thread, os);
3012 }
3013
Dump(const JSThread * thread,std::ostream & os) const3014 void PromiseCapability::Dump(const JSThread *thread, std::ostream &os) const
3015 {
3016 os << " - promise: ";
3017 GetPromise(thread).Dump(thread, os);
3018 os << " - resolve: ";
3019 GetResolve(thread).Dump(thread, os);
3020 os << " - reject: ";
3021 GetReject(thread).Dump(thread, os);
3022 }
3023
Dump(const JSThread * thread,std::ostream & os) const3024 void PromiseIteratorRecord::Dump(const JSThread *thread, std::ostream &os) const
3025 {
3026 os << " - iterator: ";
3027 GetIterator(thread).Dump(thread, os);
3028 os << " - done: " << GetDone();
3029 }
3030
Dump(const JSThread * thread,std::ostream & os) const3031 void PromiseRecord::Dump(const JSThread *thread, std::ostream &os) const
3032 {
3033 os << " - value: ";
3034 GetValue(thread).Dump(thread, os);
3035 }
3036
Dump(const JSThread * thread,std::ostream & os) const3037 void ResolvingFunctionsRecord::Dump(const JSThread *thread, std::ostream &os) const
3038 {
3039 os << " - resolve-function: ";
3040 GetResolveFunction(thread).Dump(thread, os);
3041 os << " - reject-function: ";
3042 GetRejectFunction(thread).Dump(thread, os);
3043 }
3044
Dump(const JSThread * thread,std::ostream & os) const3045 void AsyncGeneratorRequest::Dump(const JSThread *thread, std::ostream &os) const
3046 {
3047 os << " - completion: ";
3048 GetCompletion(thread).Dump(thread, os);
3049 os << " - capability: ";
3050 GetCapability(thread).Dump(thread, os);
3051 }
3052
Dump(const JSThread * thread,std::ostream & os) const3053 void AsyncIteratorRecord::Dump(const JSThread *thread, std::ostream &os) const
3054 {
3055 os << " - completion: ";
3056 GetIterator(thread).Dump(thread, os);
3057 os << " - nextmethod: ";
3058 GetNextMethod(thread).Dump(thread, os);
3059 os << " - done: " << GetDone();
3060 }
3061
Dump(const JSThread * thread,std::ostream & os) const3062 void JSAsyncFromSyncIterator::Dump(const JSThread *thread, std::ostream &os) const
3063 {
3064 os << " - sync-iterator-record: ";
3065 GetSyncIteratorRecord(thread).Dump(thread, os);
3066 JSObject::Dump(thread, os);
3067 }
3068
Dump(const JSThread * thread,std::ostream & os) const3069 void JSAsyncFromSyncIterUnwarpFunction::Dump(const JSThread *thread, std::ostream &os) const
3070 {
3071 os << " - done: " ;
3072 GetDone(thread).Dump(thread, os);
3073 JSObject::Dump(thread, os);
3074 }
3075
Dump(const JSThread * thread,std::ostream & os) const3076 void JSPromise::Dump(const JSThread *thread, std::ostream &os) const
3077 {
3078 os << " - promise-state: " << static_cast<int>(GetPromiseState());
3079 os << "\n - promise-result: ";
3080 GetPromiseResult(thread).Dump(thread, os);
3081 os << " - promise-fulfill-reactions: ";
3082 GetPromiseFulfillReactions(thread).Dump(thread, os);
3083 os << " - promise-reject-reactions: ";
3084 GetPromiseRejectReactions(thread).Dump(thread, os);
3085 os << " - promise-is-handled: " << GetPromiseIsHandled();
3086 JSObject::Dump(thread, os);
3087 }
3088
Dump(const JSThread * thread,std::ostream & os) const3089 void JSPromiseReactionsFunction::Dump(const JSThread *thread, std::ostream &os) const
3090 {
3091 os << " - promise: ";
3092 GetPromise(thread).Dump(thread, os);
3093 os << " - already-resolved: ";
3094 GetAlreadyResolved(thread).Dump(thread, os);
3095 JSObject::Dump(thread, os);
3096 }
3097
Dump(const JSThread * thread,std::ostream & os) const3098 void JSPromiseExecutorFunction::Dump(const JSThread *thread, std::ostream &os) const
3099 {
3100 os << " - capability: ";
3101 GetCapability(thread).Dump(thread, os);
3102 JSObject::Dump(thread, os);
3103 }
3104
Dump(const JSThread * thread,std::ostream & os) const3105 void JSAsyncModuleFulfilledFunction::Dump(const JSThread *thread, std::ostream &os) const
3106 {
3107 os << " - module: ";
3108 GetModule(thread).Dump(thread, os);
3109 JSObject::Dump(thread, os);
3110 }
3111
Dump(const JSThread * thread,std::ostream & os) const3112 void JSAsyncModuleRejectedFunction::Dump(const JSThread *thread, std::ostream &os) const
3113 {
3114 os << " - module: ";
3115 GetModule(thread).Dump(thread, os);
3116 JSObject::Dump(thread, os);
3117 }
3118
Dump(const JSThread * thread,std::ostream & os) const3119 void JSPromiseAllResolveElementFunction::Dump(const JSThread *thread, std::ostream &os) const
3120 {
3121 os << " - index: ";
3122 GetIndex(thread).Dump(thread, os);
3123 os << " - values: ";
3124 GetValues(thread).Dump(thread, os);
3125 os << " - capability: ";
3126 GetCapabilities(thread).Dump(thread, os);
3127 os << " - remaining-elements: ";
3128 GetRemainingElements(thread).Dump(thread, os);
3129 os << " - already-called: ";
3130 GetAlreadyCalled(thread).Dump(thread, os);
3131 JSObject::Dump(thread, os);
3132 }
3133
Dump(const JSThread * thread,std::ostream & os) const3134 void JSPromiseAnyRejectElementFunction::Dump(const JSThread *thread, std::ostream &os) const
3135 {
3136 os << " - index: ";
3137 JSTaggedValue(GetIndex()).Dump(thread, os);
3138 os << " - errors: ";
3139 GetErrors(thread).Dump(thread, os);
3140 os << " - capability: ";
3141 GetCapability(thread).Dump(thread, os);
3142 os << " - remaining-elements: ";
3143 GetRemainingElements(thread).Dump(thread, os);
3144 os << " - already-called: ";
3145 GetAlreadyCalled(thread).Dump(thread, os);
3146 JSObject::Dump(thread, os);
3147 }
3148
Dump(const JSThread * thread,std::ostream & os) const3149 void JSPromiseAllSettledElementFunction::Dump(const JSThread *thread, std::ostream &os) const
3150 {
3151 os << " - already-called: ";
3152 GetAlreadyCalled(thread).Dump(thread, os);
3153 os << " - index: ";
3154 JSTaggedValue(GetIndex()).Dump(thread, os);
3155 os << " - values: ";
3156 GetValues(thread).Dump(thread, os);
3157 os << " - capability: ";
3158 GetCapability(thread).Dump(thread, os);
3159 os << " - remaining-elements: ";
3160 GetRemainingElements(thread).Dump(thread, os);
3161 JSObject::Dump(thread, os);
3162 }
3163
Dump(const JSThread * thread,std::ostream & os) const3164 void JSPromiseFinallyFunction::Dump(const JSThread *thread, std::ostream &os) const
3165 {
3166 os << " - constructor: ";
3167 GetConstructor(thread).Dump(thread, os);
3168 os << " - onFinally: ";
3169 GetOnFinally(thread).Dump(thread, os);
3170 JSObject::Dump(thread, os);
3171 }
3172
Dump(const JSThread * thread,std::ostream & os) const3173 void JSPromiseValueThunkOrThrowerFunction::Dump(const JSThread *thread, std::ostream &os) const
3174 {
3175 os << " - result: ";
3176 GetResult(thread).Dump(thread, os);
3177 JSObject::Dump(thread, os);
3178 }
3179
Dump(const JSThread * thread,std::ostream & os) const3180 void JSAsyncGeneratorResNextRetProRstFtn::Dump(const JSThread *thread, std::ostream &os) const
3181 {
3182 os << " - AsyncGeneratorObject";
3183 GetAsyncGeneratorObject(thread).Dump(thread, os);
3184 JSObject::Dump(thread, os);
3185 }
3186
Dump(const JSThread * thread,std::ostream & os) const3187 void MicroJobQueue::Dump(const JSThread *thread, std::ostream &os) const
3188 {
3189 os << " - promise-job-queue: ";
3190 GetPromiseJobQueue(thread).Dump(thread, os);
3191 os << " - script-job-queue: ";
3192 GetScriptJobQueue(thread).Dump(thread, os);
3193 }
3194
Dump(const JSThread * thread,std::ostream & os) const3195 void PendingJob::Dump(const JSThread *thread, std::ostream &os) const
3196 {
3197 os << " - job: ";
3198 GetJob(thread).Dump(thread, os);
3199 os << "\n";
3200 os << " - arguments: ";
3201 GetArguments(thread).Dump(thread, os);
3202 #if defined(ENABLE_HITRACE)
3203 os << "\n";
3204 os << " - chainId: " << GetChainId();
3205 os << "\n";
3206 os << " - spanId: " << GetSpanId();
3207 os << "\n";
3208 os << " - parentSpanId: " << GetParentSpanId();
3209 os << "\n";
3210 os << " - flags: " << GetFlags();
3211 os << "\n";
3212 #endif
3213 }
3214
Dump(const JSThread * thread,std::ostream & os) const3215 void CompletionRecord::Dump(const JSThread *thread, std::ostream &os) const
3216 {
3217 os << " - type: " << static_cast<int>(GetType());
3218 os << " - value: ";
3219 GetValue(thread).Dump(thread, os);
3220 }
3221
Dump(const JSThread * thread,std::ostream & os) const3222 void JSProxyRevocFunction::Dump(const JSThread *thread, std::ostream &os) const
3223 {
3224 os << " - RevocableProxy: ";
3225 os << "\n";
3226 GetRevocableProxy(thread).Dump(thread, os);
3227 os << "\n";
3228 }
3229
Dump(const JSThread * thread,std::ostream & os) const3230 void JSAsyncFunction::Dump(const JSThread *thread, std::ostream &os) const
3231 {
3232 JSFunction::Dump(thread, os);
3233 }
3234
Dump(const JSThread * thread,std::ostream & os) const3235 void JSAsyncAwaitStatusFunction::Dump(const JSThread *thread, std::ostream &os) const
3236 {
3237 os << " - AsyncContext: ";
3238 os << "\n";
3239 GetAsyncContext(thread).Dump(thread, os);
3240 os << "\n";
3241 }
3242
Dump(const JSThread * thread,std::ostream & os) const3243 void JSGeneratorFunction::Dump(const JSThread *thread, std::ostream &os) const
3244 {
3245 JSFunction::Dump(thread, os);
3246 }
3247
Dump(const JSThread * thread,std::ostream & os) const3248 void JSAsyncGeneratorFunction::Dump(const JSThread *thread, std::ostream &os) const
3249 {
3250 JSFunction::Dump(thread, os);
3251 }
3252
Dump(const JSThread * thread,std::ostream & os) const3253 void JSIntlBoundFunction::Dump(const JSThread *thread, std::ostream &os) const
3254 {
3255 JSObject::Dump(thread, os);
3256 }
3257
Dump(const JSThread * thread,std::ostream & os) const3258 void PropertyBox::Dump(const JSThread *thread, std::ostream &os) const
3259 {
3260 os << " - Value: ";
3261 GetValue(thread).Dump(thread, os);
3262 os << "\n";
3263 }
3264
Dump(const JSThread * thread,std::ostream & os) const3265 void PrototypeHandler::Dump(const JSThread *thread, std::ostream &os) const
3266 {
3267 os << " - HandlerInfo: ";
3268 GetHandlerInfo(thread).Dump(thread, os);
3269 os << "\n";
3270 os << " - ProtoCell: ";
3271 GetProtoCell(thread).Dump(thread, os);
3272 os << "\n";
3273 os << " - Holder: ";
3274 GetHolder(thread).Dump(thread, os);
3275 os << "\n";
3276 }
3277
Dump(const JSThread * thread,std::ostream & os) const3278 void TransitionHandler::Dump(const JSThread *thread, std::ostream &os) const
3279 {
3280 os << " - HandlerInfo: ";
3281 GetHandlerInfo(thread).Dump(thread, os);
3282 os << "\n";
3283 os << " - TransitionHClass: ";
3284 GetTransitionHClass(thread).Dump(thread, os);
3285 os << "\n";
3286 }
3287
Dump(const JSThread * thread,std::ostream & os) const3288 void TransWithProtoHandler::Dump(const JSThread *thread, std::ostream &os) const
3289 {
3290 os << " - HandlerInfo: ";
3291 GetHandlerInfo(thread).Dump(thread, os);
3292 os << "\n";
3293 os << " - TransitionHClass: ";
3294 GetTransitionHClass(thread).Dump(thread, os);
3295 os << "\n";
3296 os << " - ProtoCell: ";
3297 GetProtoCell(thread).Dump(thread, os);
3298 os << "\n";
3299 }
3300
Dump(const JSThread * thread,std::ostream & os) const3301 void StoreAOTHandler::Dump(const JSThread *thread, std::ostream &os) const
3302 {
3303 os << " - HandlerInfo: ";
3304 GetHandlerInfo(thread).Dump(thread, os);
3305 os << "\n";
3306 os << " - ProtoCell: ";
3307 GetProtoCell(thread).Dump(thread, os);
3308 os << "\n";
3309 os << " - Holder: ";
3310 GetHolder(thread).Dump(thread, os);
3311 os << "\n";
3312 }
3313
Dump(const JSThread * thread,std::ostream & os) const3314 void JSRealm::Dump(const JSThread *thread, std::ostream &os) const
3315 {
3316 os << " - Value: ";
3317 GetValue(thread).Dump(thread, os);
3318 os << "\n";
3319 os << " - GlobalEnv: ";
3320 GetGlobalEnv(thread).Dump(thread, os);
3321 os << "\n";
3322 JSObject::Dump(thread, os);
3323 }
3324 #ifdef ARK_SUPPORT_INTL
Dump(const JSThread * thread,std::ostream & os) const3325 void JSIntl::Dump(const JSThread *thread, std::ostream &os) const
3326 {
3327 os << " - FallbackSymbol: ";
3328 GetFallbackSymbol(thread).Dump(thread, os);
3329 os << "\n";
3330 JSObject::Dump(thread, os);
3331 }
3332
Dump(const JSThread * thread,std::ostream & os) const3333 void JSLocale::Dump(const JSThread *thread, std::ostream &os) const
3334 {
3335 os << " - IcuField: ";
3336 GetIcuField(thread).Dump(thread, os);
3337 os << "\n";
3338 JSObject::Dump(thread, os);
3339 }
3340
Dump(const JSThread * thread,std::ostream & os) const3341 void JSDateTimeFormat::Dump(const JSThread *thread, std::ostream &os) const
3342 {
3343 os << " - Locale: ";
3344 GetLocale(thread).Dump(thread, os);
3345 os << "\n";
3346 os << " - Calendar: ";
3347 GetCalendar(thread).Dump(thread, os);
3348 os << "\n";
3349 os << " - NumberingSystem: ";
3350 GetNumberingSystem(thread).Dump(thread, os);
3351 os << "\n";
3352 os << " - TimeZone: ";
3353 GetTimeZone(thread).Dump(thread, os);
3354 os << "\n";
3355 os << " - HourCycle: " << static_cast<int>(GetHourCycle());
3356 os << "\n";
3357 os << " - LocaleIcu: ";
3358 GetLocaleIcu(thread).Dump(thread, os);
3359 os << "\n";
3360 os << " - SimpleDateTimeFormatIcu: ";
3361 GetSimpleDateTimeFormatIcu(thread).Dump(thread, os);
3362 os << "\n";
3363 os << " - Iso8601: ";
3364 GetIso8601(thread).Dump(thread, os);
3365 os << "\n";
3366 os << " - DateStyle: " << static_cast<int>(GetDateStyle());
3367 os << "\n";
3368 os << " - TimeStyle: " << static_cast<int>(GetTimeStyle());
3369 os << "\n";
3370 os << " - BoundFormat: ";
3371 GetBoundFormat(thread).Dump(thread, os);
3372 os << "\n";
3373 JSObject::Dump(thread, os);
3374 }
3375
Dump(const JSThread * thread,std::ostream & os) const3376 void JSRelativeTimeFormat::Dump(const JSThread *thread, std::ostream &os) const
3377 {
3378 os << " - Locale: ";
3379 GetLocale(thread).Dump(thread, os);
3380 os << "\n";
3381 os << " - NumberingSystem: ";
3382 GetNumberingSystem(thread).Dump(thread, os);
3383 os << "\n";
3384 os << " - Style: " << static_cast<int>(GetStyle());
3385 os << "\n";
3386 os << " - Numeric: " << static_cast<int>(GetNumeric());
3387 os << "\n";
3388 os << " - IcuField: ";
3389 GetIcuField(thread).Dump(thread, os);
3390 os << "\n";
3391 JSObject::Dump(thread, os);
3392 }
3393
Dump(const JSThread * thread,std::ostream & os) const3394 void JSNumberFormat::Dump(const JSThread *thread, std::ostream &os) const
3395 {
3396 os << " - Locale: ";
3397 GetLocale(thread).Dump(thread, os);
3398 os << "\n" << " - NumberingSystem: ";
3399 GetNumberingSystem(thread).Dump(thread, os);
3400 os << "\n" << " - Style: " << static_cast<int>(GetStyle());
3401 os << "\n" << " - Currency: ";
3402 GetCurrency(thread).Dump(thread, os);
3403 os << "\n" << " - CurrencyDisplay: " << static_cast<int>(GetCurrencyDisplay());
3404 os << "\n" << " - CurrencySign: " << static_cast<int>(GetCurrencySign());
3405 os << "\n" << " - Unit: ";
3406 GetUnit(thread).Dump(thread, os);
3407 os << "\n" << " - UnitDisplay: " << static_cast<int>(GetUnitDisplay());
3408 os << "\n" << " - MinimumIntegerDigits: ";
3409 GetMinimumIntegerDigits(thread).Dump(thread, os);
3410 os << "\n" << " - MinimumFractionDigits: ";
3411 GetMinimumFractionDigits(thread).Dump(thread, os);
3412 os << "\n" << " - MaximumFractionDigits: ";
3413 GetMaximumFractionDigits(thread).Dump(thread, os);
3414 os << "\n" << " - MinimumSignificantDigits: ";
3415 GetMinimumSignificantDigits(thread).Dump(thread, os);
3416 os << "\n" << " - MaximumSignificantDigits: ";
3417 GetMaximumSignificantDigits(thread).Dump(thread, os);
3418 os << "\n" << " - UseGrouping: ";
3419 GetUseGrouping(thread).Dump(thread, os);
3420 os << "\n" << " - RoundingType: " << static_cast<int>(GetRoundingType());
3421 os << "\n" << " - Notation: " << static_cast<int>(GetNotation());
3422 os << "\n" << " - CompactDisplay: " << static_cast<int>(GetCompactDisplay());
3423 os << "\n" << " - SignDisplay: " << static_cast<int>(GetSignDisplay());
3424 os << "\n" << " - BoundFormat: ";
3425 GetBoundFormat(thread).Dump(thread, os);
3426 os << "\n" << " - IcuField: ";
3427 GetIcuField(thread).Dump(thread, os);
3428 os << "\n";
3429 JSObject::Dump(thread, os);
3430 }
3431
Dump(const JSThread * thread,std::ostream & os) const3432 void JSCollator::Dump(const JSThread *thread, std::ostream &os) const
3433 {
3434 os << " - IcuField: ";
3435 GetIcuField(thread).Dump(thread, os);
3436 os << "\n - Locale: ";
3437 GetLocale(thread).Dump(thread, os);
3438 os << "\n - Usage: " << static_cast<int>(GetUsage());
3439 os << "\n - Sensitivity: " << static_cast<int>(GetSensitivity());
3440 os << "\n - IgnorePunctuation: " << GetIgnorePunctuation();
3441 os << "\n - Collation: ";
3442 GetCollation(thread).Dump(thread, os);
3443 os << "\n - Numeric: " << GetNumeric();
3444 os << "\n - CaseFirst: " << static_cast<int>(GetCaseFirst());
3445 os << "\n - BoundCompare: ";
3446 GetBoundCompare(thread).Dump(thread, os);
3447 os << "\n";
3448 JSObject::Dump(thread, os);
3449 }
3450
Dump(const JSThread * thread,std::ostream & os) const3451 void JSPluralRules::Dump(const JSThread *thread, std::ostream &os) const
3452 {
3453 os << " - Locale: ";
3454 GetLocale(thread).Dump(thread, os);
3455 os << "\n";
3456 os << " - Type: " << static_cast<int>(GetType());
3457 os << "\n";
3458 os << " - MinimumIntegerDigits: ";
3459 GetMinimumIntegerDigits(thread).Dump(thread, os);
3460 os << "\n";
3461 os << " - MinimumFractionDigits: ";
3462 GetMinimumFractionDigits(thread).Dump(thread, os);
3463 os << "\n";
3464 os << " - MaximumFractionDigits: ";
3465 GetMaximumFractionDigits(thread).Dump(thread, os);
3466 os << "\n";
3467 os << " - MinimumSignificantDigits: ";
3468 GetMinimumSignificantDigits(thread).Dump(thread, os);
3469 os << "\n";
3470 os << " - MaximumSignificantDigits: ";
3471 GetMaximumSignificantDigits(thread).Dump(thread, os);
3472 os << "\n";
3473 os << " - RoundingType: " << static_cast<int>(GetRoundingType());
3474 os << "\n";
3475 os << " - IcuPR: ";
3476 GetIcuPR(thread).Dump(thread, os);
3477 os << "\n";
3478 os << " - IcuNF: ";
3479 GetIcuNF(thread).Dump(thread, os);
3480 os << "\n";
3481 JSObject::Dump(thread, os);
3482 }
3483
Dump(const JSThread * thread,std::ostream & os) const3484 void JSDisplayNames::Dump(const JSThread *thread, std::ostream &os) const
3485 {
3486 os << " - Locale: ";
3487 GetLocale(thread).Dump(thread, os);
3488 os << "\n";
3489 os << " - Type: "<< static_cast<int>(GetType());
3490 os << "\n";
3491 os << " - Style: "<< static_cast<int>(GetStyle());
3492 os << "\n";
3493 os << " - Fallback: "<< static_cast<int>(GetFallback());
3494 os << "\n";
3495 os << " - IcuLDN: ";
3496 GetIcuLDN(thread).Dump(thread, os);
3497 os << "\n";
3498 JSObject::Dump(thread, os);
3499 }
3500
Dump(const JSThread * thread,std::ostream & os) const3501 void JSSegmenter::Dump(const JSThread *thread, std::ostream &os) const
3502 {
3503 os << " - Locale: ";
3504 GetLocale(thread).Dump(thread, os);
3505 os << "\n";
3506 os << " - Granularity: "<< static_cast<int>(GetGranularity());
3507 os << "\n";
3508 os << " - IcuField: ";
3509 GetIcuField(thread).Dump(thread, os);
3510 os << "\n";
3511 JSObject::Dump(thread, os);
3512 }
3513
Dump(const JSThread * thread,std::ostream & os) const3514 void JSSegments::Dump(const JSThread *thread, std::ostream &os) const
3515 {
3516 os << " - SegmentsString: ";
3517 GetSegmentsString(thread).Dump(thread, os);
3518 os << "\n";
3519 os << " - UnicodeString: ";
3520 GetUnicodeString(thread).Dump(thread, os);
3521 os << "\n";
3522 os << " - Granularity: "<< static_cast<int>(GetGranularity());
3523 os << "\n";
3524 os << " - IcuField: ";
3525 GetIcuField(thread).Dump(thread, os);
3526 os << "\n";
3527 JSObject::Dump(thread, os);
3528 }
3529
Dump(const JSThread * thread,std::ostream & os) const3530 void JSSegmentIterator::Dump(const JSThread *thread, std::ostream &os) const
3531 {
3532 os << " - IteratedString: ";
3533 GetIteratedString(thread).Dump(thread, os);
3534 os << "\n";
3535 os << " - UnicodeString: ";
3536 GetUnicodeString(thread).Dump(thread, os);
3537 os << "\n";
3538 os << " - Granularity: "<< static_cast<int>(GetGranularity());
3539 os << "\n";
3540 os << " - IcuField: ";
3541 GetIcuField(thread).Dump(thread, os);
3542 os << "\n";
3543 JSObject::Dump(thread, os);
3544 }
3545
Dump(const JSThread * thread,std::ostream & os) const3546 void JSListFormat::Dump(const JSThread *thread, std::ostream &os) const
3547 {
3548 os << " - Locale: ";
3549 GetLocale(thread).Dump(thread, os);
3550 os << "\n";
3551 os << " - Type: "<< static_cast<int>(GetType());
3552 os << "\n";
3553 os << " - Style: "<< static_cast<int>(GetStyle());
3554 os << "\n";
3555 os << " - IcuLF: ";
3556 GetIcuLF(thread).Dump(thread, os);
3557 os << "\n";
3558 JSObject::Dump(thread, os);
3559 }
3560 #endif
Dump(const JSThread * thread,std::ostream & os) const3561 void JSGeneratorObject::Dump(const JSThread *thread, std::ostream &os) const
3562 {
3563 os << " - GeneratorContext: ";
3564 GetGeneratorContext(thread).Dump(thread, os);
3565 os << "\n";
3566 os << " - ResumeResult: ";
3567 GetResumeResult(thread).Dump(thread, os);
3568 os << "\n";
3569 os << " - GeneratorState: " << static_cast<uint8_t>(GetGeneratorState());
3570 os << "\n";
3571 os << " - ResumeMode: " << static_cast<uint8_t>(GetResumeMode());
3572 os << "\n";
3573 JSObject::Dump(thread, os);
3574 }
3575
Dump(const JSThread * thread,std::ostream & os) const3576 void JSAsyncGeneratorObject::Dump(const JSThread *thread, std::ostream &os) const
3577 {
3578 os << " - GeneratorContext: ";
3579 GetGeneratorContext(thread).Dump(thread, os);
3580 os << "\n";
3581 os << " - AsyncGeneratorQueue: ";
3582 GetAsyncGeneratorQueue(thread).Dump(thread, os);
3583 os << "\n";
3584 os << " - GeneratorBrand: ";
3585 GetGeneratorBrand(thread).Dump(thread, os);
3586 os << "\n";
3587 os << " - ResumeResult: ";
3588 GetResumeResult(thread).Dump(thread, os);
3589 os << "\n";
3590 os << " - AsyncGeneratorState: " << static_cast<uint8_t>(GetAsyncGeneratorState());
3591 os << "\n";
3592 os << " - ResumeMode: " << static_cast<uint8_t>(GetResumeMode());
3593 os << "\n";
3594 JSObject::Dump(thread, os);
3595 }
3596
Dump(const JSThread * thread,std::ostream & os) const3597 void JSAsyncFuncObject::Dump(const JSThread *thread, std::ostream &os) const
3598 {
3599 os << " - Promise: ";
3600 GetPromise(thread).Dump(thread, os);
3601 os << "\n";
3602 }
3603
Dump(const JSThread * thread,std::ostream & os) const3604 void GeneratorContext::Dump(const JSThread *thread, std::ostream &os) const
3605 {
3606 os << " - RegsArray: ";
3607 GetRegsArray(thread).Dump(thread, os);
3608 os << "\n";
3609 os << " - Method: ";
3610 GetMethod(thread).Dump(thread, os);
3611 os << "\n";
3612 os << " - This: ";
3613 GetThis(thread).Dump(thread, os);
3614 os << "\n";
3615 os << " - Acc: ";
3616 GetAcc(thread).Dump(thread, os);
3617 os << "\n";
3618 os << " - GeneratorObject: ";
3619 GetGeneratorObject(thread).Dump(thread, os);
3620 os << "\n";
3621 os << " - LexicalEnv: ";
3622 GetLexicalEnv(thread).Dump(thread, os);
3623 os << "\n";
3624 os << " - NRegs: " << GetNRegs();
3625 os << "\n";
3626 os << " - BCOffset: " << GetBCOffset();
3627 os << "\n";
3628 }
3629
Dump(const JSThread * thread,std::ostream & os) const3630 void EnumCache::Dump(const JSThread *thread, std::ostream &os) const
3631 {
3632 os << " - EnumCacheOwn: " << GetEnumCacheOwn(thread);
3633 os << "\n";
3634 os << " - EnumCacheAll: " << GetEnumCacheAll(thread);
3635 os << "\n";
3636 os << " - ProtoChainInfoEnumCache: " << GetProtoChainInfoEnumCache(thread);
3637 os << "\n";
3638 os << " - EnumCacheKind: " << GetEnumCacheKind();
3639 os << "\n";
3640 }
3641
Dump(const JSThread * thread,std::ostream & os) const3642 void ProtoChangeMarker::Dump([[maybe_unused]]const JSThread *thread, std::ostream &os) const
3643 {
3644 os << " - HasChanged: " << GetHasChanged() << "\n";
3645 os << " - HasAccessorChanged: " << GetAccessorHasChanged() << "\n";
3646 os << " - HasNotFoundChanged: " << GetNotFoundHasChanged() << "\n";
3647 }
3648
Dump(const JSThread * thread,std::ostream & os) const3649 void MarkerCell::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
3650 {
3651 os << " - IsDetectorInvalid: " << GetIsDetectorInvalid() << "\n";
3652 }
3653
Dump(const JSThread * thread,std::ostream & os) const3654 void ProtoChangeDetails::Dump(const JSThread *thread, std::ostream &os) const
3655 {
3656 os << " - ChangeListener: ";
3657 GetChangeListener(thread).Dump(thread, os);
3658 os << " \t- RegisterIndex: " << GetRegisterIndex();
3659 os << "\n";
3660 }
3661
Dump(const JSThread * thread,std::ostream & os) const3662 void TrackInfo::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
3663 {
3664 os << " - ElementsKind: " << static_cast<uint32_t>(GetElementsKind()) << "\n";
3665 os << " - ArrayLength: " << static_cast<uint32_t>(GetArrayLength()) << "\n";
3666 os << " - SpaceFlag: " << static_cast<uint32_t>(GetSpaceFlag()) << "\n";
3667 }
3668
Dump(const JSThread * thread,std::ostream & os) const3669 void MachineCode::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
3670 {
3671 os << " - InstructionSizeInBytes: " << GetInstructionSizeInBytes();
3672 os << "\n";
3673 }
3674
Dump(const JSThread * thread,std::ostream & os) const3675 void ClassInfoExtractor::Dump(const JSThread *thread, std::ostream &os) const
3676 {
3677 os << " - NonStaticKeys: ";
3678 GetNonStaticKeys(thread).Dump(thread, os);
3679 os << "\n";
3680 os << " - NonStaticProperties: ";
3681 GetNonStaticProperties(thread).Dump(thread, os);
3682 os << "\n";
3683 os << " - NonStaticElements: ";
3684 GetNonStaticElements(thread).Dump(thread, os);
3685 os << "\n";
3686 os << " - StaticKeys: ";
3687 GetStaticKeys(thread).Dump(thread, os);
3688 os << "\n";
3689 os << " - StaticProperties: ";
3690 GetStaticProperties(thread).Dump(thread, os);
3691 os << "\n";
3692 os << " - StaticElements: ";
3693 GetStaticElements(thread).Dump(thread, os);
3694 os << "\n";
3695 }
3696
Dump(const JSThread * thread,std::ostream & os) const3697 void SourceTextModule::Dump(const JSThread *thread, std::ostream &os) const
3698 {
3699 os << " - Environment: ";
3700 GetEnvironment(thread).Dump(thread, os);
3701 os << "\n";
3702 os << " - Namespace: ";
3703 GetNamespace(thread).Dump(thread, os);
3704 os << "\n";
3705 os << " - EcmaModuleFilename: ";
3706 os << GetEcmaModuleFilenameString();
3707 os << "\n";
3708 os << " - EcmaModuleRecordName: ";
3709 os << GetEcmaModuleRecordNameString();
3710 os << "\n";
3711 os << " - ModuleRequests: ";
3712 GetModuleRequests(thread).Dump(thread, os);
3713 os << "\n";
3714 os << " - RequestedModules: ";
3715 GetRequestedModules(thread).Dump(thread, os);
3716 os << "\n";
3717 os << " - ImportEntries: ";
3718 GetImportEntries(thread).Dump(thread, os);
3719 os << "\n";
3720 os << " - LocalExportEntries: ";
3721 GetLocalExportEntries(thread).Dump(thread, os);
3722 os << "\n";
3723 os << " - IndirectExportEntries: ";
3724 GetIndirectExportEntries(thread).Dump(thread, os);
3725 os << "\n";
3726 os << " - StarExportEntries: ";
3727 GetStarExportEntries(thread).Dump(thread, os);
3728 os << "\n";
3729 os << " - Status: ";
3730 os << static_cast<int32_t>(GetStatus());
3731 os << "\n";
3732 os << " - Exception: ";
3733 GetException(thread).Dump(thread, os);
3734 os << "\n";
3735 os << " - DFSIndex: ";
3736 os << GetDFSIndex();
3737 os << "\n";
3738 os << " - DFSAncestorIndex: ";
3739 os << GetDFSAncestorIndex();
3740 os << "\n";
3741 os << " - NameDictionary: ";
3742 GetNameDictionary(thread).Dump(thread, os);
3743 os << "\n";
3744 os << " - CycleRoot: ";
3745 // avoid infinite dump
3746 if (GetCycleRoot(thread) != JSTaggedValue(this)) {
3747 GetCycleRoot(thread).Dump(thread, os);
3748 } else {
3749 os << "this";
3750 }
3751 os << "\n";
3752 os << " - TopLevelCapability: ";
3753 GetTopLevelCapability(thread).Dump(thread, os);
3754 os << "\n";
3755 os << " - AsyncParentModules: ";
3756 GetAsyncParentModules(thread).Dump(thread, os);
3757 os << "\n";
3758 os << " - SendableEnv: ";
3759 GetSendableEnv(thread).Dump(thread, os);
3760 os << "\n";
3761 os << " - HasTLA: ";
3762 os << GetHasTLA();
3763 os << "\n";
3764 os << " - AsyncEvaluatingOrdinal: ";
3765 os << GetAsyncEvaluatingOrdinal();
3766 os << "\n";
3767 os << " - PendingAsyncDependencies: ";
3768 os << GetPendingAsyncDependencies();
3769 os << "\n";
3770 }
3771
Dump(const JSThread * thread,std::ostream & os) const3772 void ImportEntry::Dump(const JSThread *thread, std::ostream &os) const
3773 {
3774 os << " - ModuleRequestIndex: ";
3775 os << GetModuleRequestIndex();
3776 os << "\n";
3777 os << " - ImportName: ";
3778 GetImportName(thread).Dump(thread, os);
3779 os << "\n";
3780 os << " - LocalName: ";
3781 GetLocalName(thread).Dump(thread, os);
3782 os << "\n";
3783 }
3784
Dump(const JSThread * thread,std::ostream & os) const3785 void LocalExportEntry::Dump(const JSThread *thread, std::ostream &os) const
3786 {
3787 os << " - ExportName: ";
3788 GetExportName(thread).Dump(thread, os);
3789 os << "\n";
3790 os << " - LocalName: ";
3791 GetLocalName(thread).Dump(thread, os);
3792 os << "\n";
3793 os << " - LocalIndex: " << GetLocalIndex();
3794 os << "\n";
3795 }
3796
Dump(const JSThread * thread,std::ostream & os) const3797 void IndirectExportEntry::Dump(const JSThread *thread, std::ostream &os) const
3798 {
3799 os << " - ExportName: ";
3800 GetExportName(thread).Dump(thread, os);
3801 os << "\n";
3802 os << " - ModuleRequestIndex: ";
3803 os << GetModuleRequestIndex();
3804 os << "\n";
3805 os << " - ImportName: ";
3806 GetImportName(thread).Dump(thread, os);
3807 os << "\n";
3808 }
3809
Dump(const JSThread * thread,std::ostream & os) const3810 void StarExportEntry::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
3811 {
3812 os << " - ModuleRequestIndex: ";
3813 os << GetModuleRequestIndex();
3814 os << "\n";
3815 }
3816
Dump(const JSThread * thread,std::ostream & os) const3817 void ResolvedBinding::Dump(const JSThread *thread, std::ostream &os) const
3818 {
3819 os << " - Module: ";
3820 GetModule(thread).Dump(thread, os);
3821 os << "\n";
3822 os << " - BindingName: ";
3823 GetBindingName(thread).Dump(thread, os);
3824 os << "\n";
3825 }
3826
Dump(const JSThread * thread,std::ostream & os) const3827 void ResolvedIndexBinding::Dump(const JSThread *thread, std::ostream &os) const
3828 {
3829 os << " - Module: ";
3830 GetModule(thread).Dump(thread, os);
3831 os << "\n";
3832 os << " - Index: " << GetIndex();
3833 os << "\n";
3834 os << " - IsUpdatedFromResolvedBinding: " << GetIsUpdatedFromResolvedBinding();
3835 os << "\n";
3836 }
3837
Dump(const JSThread * thread,std::ostream & os) const3838 void ResolvedRecordIndexBinding::Dump(const JSThread *thread, std::ostream &os) const
3839 {
3840 os << " - Module: ";
3841 GetModuleRecord(thread).Dump(thread, os);
3842 os << "\n";
3843 os << " - AbcFileName: ";
3844 GetAbcFileName(thread).Dump(thread, os);
3845 os << "\n";
3846 os << " - Index: " << GetIndex();
3847 os << "\n";
3848 }
3849
Dump(const JSThread * thread,std::ostream & os) const3850 void ResolvedRecordBinding::Dump(const JSThread *thread, std::ostream &os) const
3851 {
3852 os << " - Module: ";
3853 GetModuleRecord(thread).Dump(thread, os);
3854 os << "\n";
3855 os << " - BindingName: ";
3856 GetBindingName(thread).Dump(thread, os);
3857 os << "\n";
3858 }
3859
Dump(const JSThread * thread,std::ostream & os) const3860 void ModuleNamespace::Dump(const JSThread *thread, std::ostream &os) const
3861 {
3862 os << " - Exports: ";
3863 GetExports(thread).Dump(thread, os);
3864 os << "\n";
3865 }
3866
Dump(const JSThread * thread,std::ostream & os) const3867 void NativeModuleFailureInfo::Dump(const JSThread *thread, std::ostream &os) const
3868 {
3869 os << " - ArkNativeModuleFailureInfo: ";
3870 GetArkNativeModuleFailureInfo(thread).Dump(thread, os);
3871 os << "\n";
3872 }
3873
Dump(const JSThread * thread,std::ostream & os) const3874 void CjsModule::Dump(const JSThread *thread, std::ostream &os) const
3875 {
3876 os << " - current module path: ";
3877 GetPath(thread).Dump(thread, os);
3878 os << "\n";
3879 os << " - current module filename: ";
3880 GetFilename(thread).Dump(thread, os);
3881 os << "\n";
3882 }
3883
Dump(const JSThread * thread,std::ostream & os) const3884 void CjsRequire::Dump([[maybe_unused]] const JSThread *thread, std::ostream &os) const
3885 {
3886 os << " --- CjsRequire is JSFunction: ";
3887 os << "\n";
3888 }
3889
Dump(const JSThread * thread,std::ostream & os) const3890 void CjsExports::Dump(const JSThread *thread, std::ostream &os) const
3891 {
3892 DISALLOW_GARBAGE_COLLECTION;
3893 JSHClass *jshclass = GetJSHClass();
3894 os << " - hclass: " << std::hex << jshclass << "\n";
3895 os << " - prototype: ";
3896 jshclass->GetPrototype(thread).DumpTaggedValue(thread, os);
3897 os << "\n";
3898
3899 TaggedArray *properties = TaggedArray::Cast(GetProperties(thread).GetTaggedObject());
3900 os << " - properties: " << std::hex << properties;
3901
3902 if (!properties->IsDictionaryMode()) {
3903 JSTaggedValue attrs = jshclass->GetLayout(thread);
3904 if (attrs.IsNull()) {
3905 return;
3906 }
3907
3908 LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
3909 int propNumber = static_cast<int>(jshclass->NumberOfProps());
3910 os << " <LayoutInfo[" << std::dec << propNumber << "]>\n";
3911 for (int i = 0; i < propNumber; i++) {
3912 JSTaggedValue key = layoutInfo->GetKey(thread, i);
3913 PropertyAttributes attr = layoutInfo->GetAttr(thread, i);
3914 ASSERT(i == static_cast<int>(attr.GetOffset()));
3915 os << " " << std::right << std::setw(DUMP_PROPERTY_OFFSET);
3916 DumpPropertyKey(thread, key, os);
3917 os << ": (";
3918 JSTaggedValue val;
3919 if (attr.IsInlinedProps()) {
3920 val = GetPropertyInlinedPropsWithRep(thread, i, attr);
3921 } else {
3922 val = properties->Get(thread, i - static_cast<int>(jshclass->GetInlinedProperties()));
3923 }
3924 val.DumpTaggedValue(thread, os);
3925 os << ") ";
3926 DumpAttr(attr, true, os);
3927 os << "\n";
3928 }
3929 } else {
3930 NameDictionary *dict = NameDictionary::Cast(properties);
3931 os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
3932 dict->Dump(thread, os);
3933 }
3934 }
3935
Dump(const JSThread * thread,std::ostream & os) const3936 void JSFunctionBase::Dump(const JSThread *thread, std::ostream &os) const
3937 {
3938 os << " - Method: ";
3939 GetMethod(thread).Dump(thread, os);
3940 os << "\n";
3941 }
3942
Dump(const JSThread * thread,std::ostream & os) const3943 void Method::Dump(const JSThread *thread, std::ostream &os) const
3944 {
3945 os << " - MethodName: ";
3946 os << GetMethodName(thread);
3947 os << "\n";
3948 os << " - ConstantPool: ";
3949 GetConstantPool(thread).Dump(thread, os);
3950 os << "\n";
3951 os << " - FunctionKind: " << static_cast<int>(GetFunctionKind());
3952 os << "\n";
3953 os << " - CodeEntryOrLiteral: " << std::hex << GetCodeEntryOrLiteral() << "\n";
3954 os << "\n";
3955 }
3956
Dump(const JSThread * thread,std::ostream & os) const3957 void ClassLiteral::Dump(const JSThread *thread, std::ostream &os) const
3958 {
3959 os << " - ClassLiteral: ";
3960 os << "\n";
3961 os << " - IsAOTUsed: " << std::boolalpha << GetIsAOTUsed();
3962 os << "\n";
3963 os << " - Array: ";
3964 GetArray(thread).Dump(thread, os);
3965 os << "\n";
3966 }
3967
3968 // ########################################################################################
3969 // Dump for Snapshot
3970 // ########################################################################################
DumpArrayClass(const JSThread * thread,const TaggedArray * arr,std::vector<Reference> & vec)3971 static void DumpArrayClass(const JSThread *thread, const TaggedArray *arr, std::vector<Reference> &vec)
3972 {
3973 DISALLOW_GARBAGE_COLLECTION;
3974 uint32_t len = arr->GetLength();
3975 vec.reserve(vec.size() + len);
3976 for (uint32_t i = 0; i < len; i++) {
3977 JSTaggedValue val(arr->Get(thread, i));
3978 CString str = ToCString(i);
3979 vec.emplace_back(str, val);
3980 }
3981 }
3982
DumpMutantTaggedArrayClass(const JSThread * thread,const MutantTaggedArray * arr,std::vector<Reference> & vec)3983 static void DumpMutantTaggedArrayClass(const JSThread *thread, const MutantTaggedArray *arr,
3984 std::vector<Reference> &vec)
3985 {
3986 DISALLOW_GARBAGE_COLLECTION;
3987 uint32_t len = arr->GetLength();
3988 vec.reserve(vec.size() + len);
3989 for (uint32_t i = 0; i < len; i++) {
3990 JSTaggedValue val(arr->Get(thread, i));
3991 CString str = ToCString(i);
3992 vec.emplace_back(str, val);
3993 }
3994 }
3995
DumpCOWMutantTaggedArrayClass(const JSThread * thread,const COWMutantTaggedArray * arr,std::vector<Reference> & vec)3996 static void DumpCOWMutantTaggedArrayClass(const JSThread *thread, const COWMutantTaggedArray *arr,
3997 std::vector<Reference> &vec)
3998 {
3999 DISALLOW_GARBAGE_COLLECTION;
4000 uint32_t len = arr->GetLength();
4001 vec.reserve(vec.size() + len);
4002 for (uint32_t i = 0; i < len; i++) {
4003 JSTaggedValue val(arr->Get(thread, i));
4004 CString str = ToCString(i);
4005 vec.emplace_back(str, val);
4006 }
4007 }
4008
DumpElementClass(const JSThread * thread,const TaggedArray * arr,std::vector<Reference> & vec)4009 static void DumpElementClass(const JSThread *thread, const TaggedArray *arr, std::vector<Reference> &vec)
4010 {
4011 DISALLOW_GARBAGE_COLLECTION;
4012 uint32_t len = arr->GetLength();
4013 vec.reserve(vec.size() + len);
4014 for (uint32_t i = 0; i < len; i++) {
4015 JSTaggedValue val(arr->Get(thread, i));
4016 vec.emplace_back(i, val, Reference::ReferenceType::ELEMENT);
4017 }
4018 }
4019
DumpConstantPoolClass(const JSThread * thread,const ConstantPool * arr,std::vector<Reference> & vec)4020 static void DumpConstantPoolClass(const JSThread *thread, const ConstantPool *arr, std::vector<Reference> &vec)
4021 {
4022 DISALLOW_GARBAGE_COLLECTION;
4023 uint32_t len = arr->GetCacheLength();
4024 vec.reserve(vec.size() + len);
4025 for (uint32_t i = 0; i < len; i++) {
4026 JSTaggedValue val(arr->GetObjectFromCache(thread, i));
4027 CString str = ToCString(i);
4028 vec.emplace_back(str, val);
4029 }
4030 }
4031
DumpStringClass(const EcmaString * str,std::vector<Reference> & vec)4032 static void DumpStringClass([[maybe_unused]] const EcmaString *str, [[maybe_unused]] std::vector<Reference> &vec)
4033 {
4034 // Before EcmaString dump self node, it need not show, so delete.
4035 // If some properties need be shown, add here.
4036 }
4037
DumpObject(const JSThread * thread,TaggedObject * obj,std::vector<Reference> & vec,bool isVmMode)4038 static void DumpObject(const JSThread *thread, TaggedObject *obj, std::vector<Reference> &vec, bool isVmMode)
4039 {
4040 JSTaggedValue objValue(obj);
4041 DISALLOW_GARBAGE_COLLECTION;
4042 auto jsHclass = obj->GetClass();
4043 JSType type = jsHclass->GetObjectType();
4044 vec.emplace_back("hclass", JSTaggedValue(jsHclass));
4045 switch (type) {
4046 case JSType::HCLASS:
4047 JSHClass::Cast(obj)->DumpForSnapshot(thread, vec);
4048 break;
4049 case JSType::TAGGED_ARRAY:
4050 case JSType::TAGGED_DICTIONARY:
4051 case JSType::LEXICAL_ENV:
4052 case JSType::SFUNCTION_ENV:
4053 case JSType::SENDABLE_ENV:
4054 case JSType::COW_TAGGED_ARRAY:
4055 case JSType::AOT_LITERAL_INFO:
4056 DumpArrayClass(thread, TaggedArray::Cast(obj), vec);
4057 break;
4058 case JSType::MUTANT_TAGGED_ARRAY:
4059 DumpMutantTaggedArrayClass(thread, MutantTaggedArray::Cast(obj), vec);
4060 break;
4061 case JSType::COW_MUTANT_TAGGED_ARRAY:
4062 DumpCOWMutantTaggedArrayClass(thread, COWMutantTaggedArray::Cast(obj), vec);
4063 break;
4064 case JSType::CONSTANT_POOL:
4065 DumpConstantPoolClass(thread, ConstantPool::Cast(obj), vec);
4066 break;
4067 case JSType::PROFILE_TYPE_INFO_CELL_0:
4068 case JSType::PROFILE_TYPE_INFO_CELL_1:
4069 case JSType::PROFILE_TYPE_INFO_CELL_N:
4070 ProfileTypeInfoCell::Cast(obj)->DumpForSnapshot(thread, vec);
4071 break;
4072 case JSType::FUNCTION_TEMPLATE:
4073 FunctionTemplate::Cast(obj)->DumpForSnapshot(thread, vec);
4074 break;
4075 case JSType::VTABLE:
4076 VTable::Cast(obj)->DumpForSnapshot(thread, vec);
4077 break;
4078 case JSType::PROFILE_TYPE_INFO:
4079 ProfileTypeInfo::Cast(obj)->DumpForSnapshot(thread, vec);
4080 break;
4081 case JSType::LINE_STRING:
4082 case JSType::TREE_STRING:
4083 case JSType::SLICED_STRING:
4084 DumpStringClass(EcmaString::Cast(obj), vec);
4085 break;
4086 case JSType::JS_NATIVE_POINTER:
4087 break;
4088 case JSType::JS_OBJECT:
4089 case JSType::JS_XREF_OBJECT:
4090 case JSType::JS_ERROR:
4091 case JSType::JS_EVAL_ERROR:
4092 case JSType::JS_RANGE_ERROR:
4093 case JSType::JS_TYPE_ERROR:
4094 case JSType::JS_AGGREGATE_ERROR:
4095 case JSType::JS_REFERENCE_ERROR:
4096 case JSType::JS_URI_ERROR:
4097 case JSType::JS_SYNTAX_ERROR:
4098 case JSType::JS_OOM_ERROR:
4099 case JSType::JS_TERMINATION_ERROR:
4100 case JSType::JS_ARGUMENTS:
4101 case JSType::JS_GLOBAL_OBJECT:
4102 case JSType::JS_SHARED_OBJECT:
4103 JSObject::Cast(obj)->DumpForSnapshot(thread, vec);
4104 break;
4105 case JSType::JS_FUNCTION_BASE:
4106 case JSType::JS_FUNCTION:
4107 case JSType::JS_SHARED_FUNCTION:
4108 JSFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4109 break;
4110 case JSType::JS_BOUND_FUNCTION:
4111 JSBoundFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4112 break;
4113 case JSType::JS_SET:
4114 JSSet::Cast(obj)->DumpForSnapshot(thread, vec);
4115 break;
4116 case JSType::JS_SHARED_SET:
4117 JSSharedSet::Cast(obj)->DumpForSnapshot(thread, vec);
4118 break;
4119 case JSType::JS_MAP:
4120 JSMap::Cast(obj)->DumpForSnapshot(thread, vec);
4121 break;
4122 case JSType::JS_SHARED_MAP:
4123 JSSharedMap::Cast(obj)->DumpForSnapshot(thread, vec);
4124 break;
4125 case JSType::JS_WEAK_SET:
4126 JSWeakSet::Cast(obj)->DumpForSnapshot(thread, vec);
4127 break;
4128 case JSType::JS_WEAK_MAP:
4129 JSWeakMap::Cast(obj)->DumpForSnapshot(thread, vec);
4130 break;
4131 case JSType::JS_WEAK_REF:
4132 JSWeakRef::Cast(obj)->DumpForSnapshot(thread, vec);
4133 break;
4134 case JSType::JS_FINALIZATION_REGISTRY:
4135 JSFinalizationRegistry::Cast(obj)->DumpForSnapshot(thread, vec);
4136 break;
4137 case JSType::CELL_RECORD:
4138 CellRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4139 break;
4140 case JSType::JS_REG_EXP:
4141 JSRegExp::Cast(obj)->DumpForSnapshot(thread, vec);
4142 break;
4143 case JSType::JS_DATE:
4144 JSDate::Cast(obj)->DumpForSnapshot(thread, vec);
4145 break;
4146 case JSType::JS_ARRAY:
4147 JSArray::Cast(obj)->DumpForSnapshot(thread, vec);
4148 break;
4149 case JSType::JS_SHARED_ARRAY:
4150 JSSharedArray::Cast(obj)->DumpForSnapshot(thread, vec);
4151 break;
4152 case JSType::JS_TYPED_ARRAY:
4153 case JSType::JS_INT8_ARRAY:
4154 case JSType::JS_UINT8_ARRAY:
4155 case JSType::JS_UINT8_CLAMPED_ARRAY:
4156 case JSType::JS_INT16_ARRAY:
4157 case JSType::JS_UINT16_ARRAY:
4158 case JSType::JS_INT32_ARRAY:
4159 case JSType::JS_UINT32_ARRAY:
4160 case JSType::JS_FLOAT32_ARRAY:
4161 case JSType::JS_FLOAT64_ARRAY:
4162 case JSType::JS_BIGINT64_ARRAY:
4163 case JSType::JS_BIGUINT64_ARRAY:
4164 JSTypedArray::Cast(obj)->DumpForSnapshot(thread, vec);
4165 break;
4166 case JSType::JS_SHARED_TYPED_ARRAY:
4167 case JSType::JS_SHARED_INT8_ARRAY:
4168 case JSType::JS_SHARED_UINT8_ARRAY:
4169 case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY:
4170 case JSType::JS_SHARED_INT16_ARRAY:
4171 case JSType::JS_SHARED_UINT16_ARRAY:
4172 case JSType::JS_SHARED_INT32_ARRAY:
4173 case JSType::JS_SHARED_UINT32_ARRAY:
4174 case JSType::JS_SHARED_FLOAT32_ARRAY:
4175 case JSType::JS_SHARED_FLOAT64_ARRAY:
4176 case JSType::JS_SHARED_BIGINT64_ARRAY:
4177 case JSType::JS_SHARED_BIGUINT64_ARRAY:
4178 JSSharedTypedArray::Cast(obj)->DumpForSnapshot(thread, vec);
4179 break;
4180 case JSType::BIGINT:
4181 BigInt::Cast(obj)->DumpForSnapshot(thread, vec);
4182 break;
4183 case JSType::BYTE_ARRAY:
4184 ByteArray::Cast(obj)->DumpForSnapshot(thread, vec);
4185 break;
4186 case JSType::JS_PROXY:
4187 JSProxy::Cast(obj)->DumpForSnapshot(thread, vec);
4188 break;
4189 case JSType::JS_PRIMITIVE_REF:
4190 JSPrimitiveRef::Cast(obj)->DumpForSnapshot(thread, vec);
4191 break;
4192 case JSType::SYMBOL:
4193 JSSymbol::Cast(obj)->DumpForSnapshot(thread, vec);
4194 break;
4195 case JSType::ACCESSOR_DATA:
4196 case JSType::INTERNAL_ACCESSOR:
4197 AccessorData::Cast(obj)->DumpForSnapshot(thread, vec);
4198 break;
4199 case JSType::JS_DATA_VIEW:
4200 JSDataView::Cast(obj)->DumpForSnapshot(thread, vec);
4201 break;
4202 case JSType::PROMISE_REACTIONS:
4203 PromiseReaction::Cast(obj)->DumpForSnapshot(thread, vec);
4204 break;
4205 case JSType::PROMISE_CAPABILITY:
4206 PromiseCapability::Cast(obj)->DumpForSnapshot(thread, vec);
4207 break;
4208 case JSType::PROMISE_ITERATOR_RECORD:
4209 PromiseIteratorRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4210 break;
4211 case JSType::PROMISE_RECORD:
4212 PromiseRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4213 break;
4214 case JSType::RESOLVING_FUNCTIONS_RECORD:
4215 ResolvingFunctionsRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4216 break;
4217 case JSType::JS_PROMISE:
4218 JSPromise::Cast(obj)->DumpForSnapshot(thread, vec);
4219 break;
4220 case JSType::JS_PROMISE_REACTIONS_FUNCTION:
4221 JSPromiseReactionsFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4222 break;
4223 case JSType::JS_PROMISE_EXECUTOR_FUNCTION:
4224 JSPromiseExecutorFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4225 break;
4226 case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION:
4227 JSAsyncModuleFulfilledFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4228 break;
4229 case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION:
4230 JSAsyncModuleRejectedFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4231 break;
4232 case JSType::ASYNC_GENERATOR_REQUEST:
4233 AsyncGeneratorRequest::Cast(obj)->DumpForSnapshot(thread, vec);
4234 break;
4235 case JSType::ASYNC_ITERATOR_RECORD:
4236 AsyncIteratorRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4237 break;
4238 case JSType::JS_ASYNC_FROM_SYNC_ITERATOR:
4239 JSAsyncFromSyncIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4240 break;
4241 case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION:
4242 JSAsyncFromSyncIterUnwarpFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4243 break;
4244 case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION:
4245 JSPromiseAllResolveElementFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4246 break;
4247 case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION:
4248 JSPromiseAnyRejectElementFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4249 break;
4250 case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION:
4251 JSPromiseAllSettledElementFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4252 break;
4253 case JSType::JS_PROMISE_FINALLY_FUNCTION:
4254 JSPromiseFinallyFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4255 break;
4256 case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION:
4257 JSPromiseValueThunkOrThrowerFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4258 break;
4259 case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN:
4260 JSAsyncGeneratorResNextRetProRstFtn::Cast(obj)->DumpForSnapshot(thread, vec);
4261 break;
4262 case JSType::MICRO_JOB_QUEUE:
4263 MicroJobQueue::Cast(obj)->DumpForSnapshot(thread, vec);
4264 break;
4265 case JSType::PENDING_JOB:
4266 PendingJob::Cast(obj)->DumpForSnapshot(thread, vec);
4267 break;
4268 case JSType::COMPLETION_RECORD:
4269 CompletionRecord::Cast(obj)->DumpForSnapshot(thread, vec);
4270 break;
4271 case JSType::JS_ITERATOR:
4272 case JSType::JS_ASYNCITERATOR:
4273 case JSType::JS_FORIN_ITERATOR:
4274 case JSType::JS_MAP_ITERATOR:
4275 case JSType::JS_SHARED_MAP_ITERATOR:
4276 case JSType::JS_SET_ITERATOR:
4277 case JSType::JS_SHARED_SET_ITERATOR:
4278 case JSType::JS_ARRAY_ITERATOR:
4279 case JSType::JS_SHARED_ARRAY_ITERATOR:
4280 case JSType::JS_STRING_ITERATOR:
4281 case JSType::JS_REG_EXP_ITERATOR:
4282 case JSType::JS_ARRAY_BUFFER:
4283 JSArrayBuffer::Cast(obj)->DumpForSnapshot(thread, vec);
4284 break;
4285 case JSType::JS_SHARED_ARRAY_BUFFER:
4286 JSArrayBuffer::Cast(obj)->DumpForSnapshot(thread, vec);
4287 break;
4288 case JSType::JS_SENDABLE_ARRAY_BUFFER:
4289 JSSendableArrayBuffer::Cast(obj)->DumpForSnapshot(thread, vec);
4290 break;
4291 case JSType::JS_PROXY_REVOC_FUNCTION:
4292 JSProxyRevocFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4293 break;
4294 case JSType::JS_ASYNC_FUNCTION:
4295 case JSType::JS_SHARED_ASYNC_FUNCTION:
4296 JSAsyncFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4297 break;
4298 case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION:
4299 JSAsyncAwaitStatusFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4300 break;
4301 case JSType::JS_GENERATOR_FUNCTION:
4302 JSGeneratorFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4303 break;
4304 case JSType::JS_ASYNC_GENERATOR_FUNCTION:
4305 JSAsyncGeneratorFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4306 break;
4307 case JSType::JS_INTL_BOUND_FUNCTION:
4308 JSIntlBoundFunction::Cast(obj)->DumpForSnapshot(thread, vec);
4309 break;
4310 case JSType::JS_REALM:
4311 JSRealm::Cast(obj)->DumpForSnapshot(thread, vec);
4312 break;
4313 #ifdef ARK_SUPPORT_INTL
4314 case JSType::JS_INTL:
4315 JSIntl::Cast(obj)->DumpForSnapshot(thread, vec);
4316 break;
4317 case JSType::JS_LOCALE:
4318 JSLocale::Cast(obj)->DumpForSnapshot(thread, vec);
4319 break;
4320 case JSType::JS_DATE_TIME_FORMAT:
4321 JSDateTimeFormat::Cast(obj)->DumpForSnapshot(thread, vec);
4322 break;
4323 case JSType::JS_RELATIVE_TIME_FORMAT:
4324 JSRelativeTimeFormat::Cast(obj)->DumpForSnapshot(thread, vec);
4325 break;
4326 case JSType::JS_NUMBER_FORMAT:
4327 JSNumberFormat::Cast(obj)->DumpForSnapshot(thread, vec);
4328 break;
4329 case JSType::JS_COLLATOR:
4330 JSCollator::Cast(obj)->DumpForSnapshot(thread, vec);
4331 break;
4332 case JSType::JS_PLURAL_RULES:
4333 JSPluralRules::Cast(obj)->DumpForSnapshot(thread, vec);
4334 break;
4335 case JSType::JS_DISPLAYNAMES:
4336 JSDisplayNames::Cast(obj)->DumpForSnapshot(thread, vec);
4337 break;
4338 case JSType::JS_SEGMENTER:
4339 JSSegmenter::Cast(obj)->DumpForSnapshot(thread, vec);
4340 break;
4341 case JSType::JS_SEGMENTS:
4342 JSSegments::Cast(obj)->DumpForSnapshot(thread, vec);
4343 break;
4344 case JSType::JS_SEGMENT_ITERATOR:
4345 JSSegmentIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4346 break;
4347 case JSType::JS_LIST_FORMAT:
4348 JSListFormat::Cast(obj)->DumpForSnapshot(thread, vec);
4349 break;
4350 #else
4351 case JSType::JS_INTL:
4352 case JSType::JS_LOCALE:
4353 case JSType::JS_DATE_TIME_FORMAT:
4354 case JSType::JS_RELATIVE_TIME_FORMAT:
4355 case JSType::JS_NUMBER_FORMAT:
4356 case JSType::JS_COLLATOR:
4357 case JSType::JS_PLURAL_RULES:
4358 case JSType::JS_DISPLAYNAMES:
4359 case JSType::JS_SEGMENTER:
4360 case JSType::JS_SEGMENTS:
4361 case JSType::JS_SEGMENT_ITERATOR:
4362 case JSType::JS_LIST_FORMAT:
4363 break;
4364 #endif
4365 case JSType::JS_CJS_MODULE:
4366 CjsModule::Cast(obj)->DumpForSnapshot(thread, vec);
4367 break;
4368 case JSType::JS_CJS_EXPORTS:
4369 CjsExports::Cast(obj)->DumpForSnapshot(thread, vec);
4370 break;
4371 case JSType::JS_CJS_REQUIRE:
4372 CjsRequire::Cast(obj)->DumpForSnapshot(thread, vec);
4373 break;
4374 case JSType::JS_GENERATOR_OBJECT:
4375 JSGeneratorObject::Cast(obj)->DumpForSnapshot(thread, vec);
4376 break;
4377 case JSType::JS_ASYNC_GENERATOR_OBJECT:
4378 JSAsyncGeneratorObject::Cast(obj)->DumpForSnapshot(thread, vec);
4379 break;
4380 case JSType::JS_ASYNC_FUNC_OBJECT:
4381 JSAsyncFuncObject::Cast(obj)->DumpForSnapshot(thread, vec);
4382 break;
4383 case JSType::JS_GENERATOR_CONTEXT:
4384 GeneratorContext::Cast(obj)->DumpForSnapshot(thread, vec);
4385 break;
4386 case JSType::JS_API_ARRAY_LIST:
4387 JSAPIArrayList::Cast(obj)->DumpForSnapshot(thread, vec);
4388 break;
4389 case JSType::JS_API_ARRAYLIST_ITERATOR:
4390 JSAPIArrayListIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4391 break;
4392 case JSType::LINKED_NODE:
4393 LinkedNode::Cast(obj)->DumpForSnapshot(thread, vec);
4394 break;
4395 case JSType::RB_TREENODE:
4396 break;
4397 case JSType::JS_API_HASH_MAP:
4398 JSAPIHashMap::Cast(obj)->DumpForSnapshot(thread, vec);
4399 break;
4400 case JSType::JS_API_HASH_SET:
4401 JSAPIHashSet::Cast(obj)->DumpForSnapshot(thread, vec);
4402 break;
4403 case JSType::JS_API_HASHMAP_ITERATOR:
4404 JSAPIHashMapIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4405 break;
4406 case JSType::JS_API_HASHSET_ITERATOR:
4407 JSAPIHashSetIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4408 break;
4409 case JSType::JS_API_LIGHT_WEIGHT_MAP:
4410 JSAPILightWeightMap::Cast(obj)->DumpForSnapshot(thread, vec);
4411 break;
4412 case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR:
4413 JSAPILightWeightMapIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4414 break;
4415 case JSType::JS_API_LIGHT_WEIGHT_SET:
4416 JSAPILightWeightSet::Cast(obj)->DumpForSnapshot(thread, vec);
4417 break;
4418 case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR:
4419 JSAPILightWeightSetIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4420 break;
4421 case JSType::JS_API_TREE_MAP:
4422 JSAPITreeMap::Cast(obj)->DumpForSnapshot(thread, vec);
4423 break;
4424 case JSType::JS_API_TREE_SET:
4425 JSAPITreeSet::Cast(obj)->DumpForSnapshot(thread, vec);
4426 break;
4427 case JSType::JS_API_TREEMAP_ITERATOR:
4428 JSAPITreeMapIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4429 break;
4430 case JSType::JS_API_TREESET_ITERATOR:
4431 JSAPITreeSetIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4432 break;
4433 case JSType::JS_API_VECTOR:
4434 JSAPIVector::Cast(obj)->DumpForSnapshot(thread, vec);
4435 break;
4436 case JSType::JS_API_VECTOR_ITERATOR:
4437 JSAPIVectorIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4438 break;
4439 case JSType::JS_API_BITVECTOR:
4440 JSAPIBitVector::Cast(obj)->DumpForSnapshot(thread, vec);
4441 break;
4442 case JSType::JS_API_BITVECTOR_ITERATOR:
4443 JSAPIBitVectorIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4444 break;
4445 case JSType::JS_API_FAST_BUFFER:
4446 JSAPIFastBuffer::Cast(obj)->DumpForSnapshot(thread, vec);
4447 break;
4448 case JSType::JS_API_QUEUE:
4449 JSAPIQueue::Cast(obj)->DumpForSnapshot(thread, vec);
4450 break;
4451 case JSType::JS_API_QUEUE_ITERATOR:
4452 JSAPIQueueIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4453 break;
4454 case JSType::JS_API_DEQUE:
4455 JSAPIDeque::Cast(obj)->DumpForSnapshot(thread, vec);
4456 break;
4457 case JSType::JS_API_DEQUE_ITERATOR:
4458 JSAPIDequeIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4459 break;
4460 case JSType::JS_API_STACK:
4461 JSAPIStack::Cast(obj)->DumpForSnapshot(thread, vec);
4462 break;
4463 case JSType::JS_API_STACK_ITERATOR:
4464 JSAPIStackIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4465 break;
4466 case JSType::JS_API_LIST:
4467 JSAPIList::Cast(obj)->DumpForSnapshot(thread, vec);
4468 break;
4469 case JSType::JS_API_LINKED_LIST:
4470 JSAPILinkedList::Cast(obj)->DumpForSnapshot(thread, vec);
4471 break;
4472 case JSType::JS_API_LIST_ITERATOR:
4473 JSAPIListIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4474 break;
4475 case JSType::JS_API_LINKED_LIST_ITERATOR:
4476 JSAPILinkedListIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4477 break;
4478 case JSType::SOURCE_TEXT_MODULE_RECORD:
4479 SourceTextModule::Cast(obj)->DumpForSnapshot(thread, vec);
4480 break;
4481 case JSType::IMPORTENTRY_RECORD:
4482 ImportEntry::Cast(obj)->DumpForSnapshot(thread, vec);
4483 break;
4484 case JSType::LOCAL_EXPORTENTRY_RECORD:
4485 LocalExportEntry::Cast(obj)->DumpForSnapshot(thread, vec);
4486 break;
4487 case JSType::INDIRECT_EXPORTENTRY_RECORD:
4488 IndirectExportEntry::Cast(obj)->DumpForSnapshot(thread, vec);
4489 break;
4490 case JSType::STAR_EXPORTENTRY_RECORD:
4491 StarExportEntry::Cast(obj)->DumpForSnapshot(thread, vec);
4492 break;
4493 case JSType::RESOLVEDBINDING_RECORD:
4494 ResolvedBinding::Cast(obj)->DumpForSnapshot(thread, vec);
4495 break;
4496 case JSType::RESOLVEDINDEXBINDING_RECORD:
4497 ResolvedIndexBinding::Cast(obj)->DumpForSnapshot(thread, vec);
4498 break;
4499 case JSType::RESOLVEDRECORDINDEXBINDING_RECORD:
4500 ResolvedRecordIndexBinding::Cast(obj)->DumpForSnapshot(thread, vec);
4501 break;
4502 case JSType::RESOLVEDRECORDBINDING_RECORD:
4503 ResolvedRecordBinding::Cast(obj)->DumpForSnapshot(thread, vec);
4504 break;
4505 case JSType::JS_MODULE_NAMESPACE:
4506 ModuleNamespace::Cast(obj)->DumpForSnapshot(thread, vec);
4507 break;
4508 case JSType::NATIVE_MODULE_FAILURE_INFO:
4509 NativeModuleFailureInfo::Cast(obj)->DumpForSnapshot(thread, vec);
4510 break;
4511 case JSType::JS_API_PLAIN_ARRAY:
4512 JSAPIPlainArray::Cast(obj)->DumpForSnapshot(thread, vec);
4513 break;
4514 case JSType::JS_API_PLAIN_ARRAY_ITERATOR:
4515 JSAPIPlainArrayIterator::Cast(obj)->DumpForSnapshot(thread, vec);
4516 break;
4517 default:
4518 break;
4519 }
4520 if (isVmMode) {
4521 switch (type) {
4522 case JSType::PROPERTY_BOX:
4523 PropertyBox::Cast(obj)->DumpForSnapshot(thread, vec);
4524 break;
4525 case JSType::TEMPLATE_MAP:
4526 DumpArrayClass(thread, TaggedArray::Cast(obj), vec);
4527 break;
4528 case JSType::GLOBAL_ENV:
4529 GlobalEnv::Cast(obj)->DumpForSnapshot(thread, vec);
4530 break;
4531 case JSType::ENUM_CACHE:
4532 EnumCache::Cast(obj)->DumpForSnapshot(thread, vec);
4533 break;
4534 case JSType::PROTO_CHANGE_MARKER:
4535 ProtoChangeMarker::Cast(obj)->DumpForSnapshot(thread, vec);
4536 break;
4537 case JSType::MARKER_CELL:
4538 MarkerCell::Cast(obj)->DumpForSnapshot(thread, vec);
4539 break;
4540 case JSType::PROTOTYPE_INFO:
4541 ProtoChangeDetails::Cast(obj)->DumpForSnapshot(thread, vec);
4542 break;
4543 case JSType::TRACK_INFO:
4544 TrackInfo::Cast(obj)->DumpForSnapshot(thread, vec);
4545 break;
4546 case JSType::PROGRAM:
4547 Program::Cast(obj)->DumpForSnapshot(thread, vec);
4548 break;
4549 case JSType::MACHINE_CODE_OBJECT:
4550 MachineCode::Cast(obj)->DumpForSnapshot(thread, vec);
4551 break;
4552 case JSType::TRANSITION_HANDLER:
4553 TransitionHandler::Cast(obj)->DumpForSnapshot(thread, vec);
4554 break;
4555 case JSType::TRANS_WITH_PROTO_HANDLER:
4556 TransWithProtoHandler::Cast(obj)->DumpForSnapshot(thread, vec);
4557 break;
4558 case JSType::STORE_TS_HANDLER:
4559 StoreAOTHandler::Cast(obj)->DumpForSnapshot(thread, vec);
4560 break;
4561 case JSType::PROTOTYPE_HANDLER:
4562 PrototypeHandler::Cast(obj)->DumpForSnapshot(thread, vec);
4563 break;
4564 case JSType::CLASS_INFO_EXTRACTOR:
4565 ClassInfoExtractor::Cast(obj)->DumpForSnapshot(thread, vec);
4566 break;
4567 case JSType::METHOD:
4568 Method::Cast(obj)->DumpForSnapshot(thread, vec);
4569 break;
4570 case JSType::CLASS_LITERAL:
4571 ClassLiteral::Cast(obj)->DumpForSnapshot(thread, vec);
4572 break;
4573 default:
4574 break;
4575 }
4576 } else {
4577 vec.pop_back();
4578 }
4579 }
4580
EcmaStringToStd(const JSThread * thread,CString & res,EcmaString * str)4581 static inline void EcmaStringToStd(const JSThread *thread, CString &res, EcmaString *str)
4582 {
4583 if (EcmaStringAccessor(str).GetLength() == 0) {
4584 CString emptyStr = "EmptyString";
4585 res.append(emptyStr);
4586 }
4587
4588 CString string = ConvertToString(thread, str);
4589 res.append(string);
4590 }
4591
KeyToStd(const JSThread * thread,CString & res,JSTaggedValue key)4592 static void KeyToStd(const JSThread *thread, CString &res, JSTaggedValue key)
4593 {
4594 if (key.IsInt()) {
4595 res = std::to_string(key.GetInt());
4596 } else if (key.IsDouble()) {
4597 res = std::to_string(key.GetDouble());
4598 } else if (key.IsBoolean()) {
4599 res = key.IsTrue() ? "true" : "false";
4600 } else if (key.IsHeapObject()) {
4601 if (key.IsWeak()) {
4602 key.RemoveWeakTag();
4603 }
4604 if (key.IsString()) {
4605 EcmaStringToStd(thread, res, EcmaString::Cast(key.GetTaggedObject()));
4606 } else if (key.IsSymbol()) {
4607 JSSymbol *sym = JSSymbol::Cast(key.GetTaggedObject());
4608 JSTaggedValue desc = sym->GetDescription(thread);
4609 if (desc.IsString()) {
4610 EcmaStringToStd(thread, res, EcmaString::Cast(desc.GetTaggedObject()));
4611 }
4612 }
4613 }
4614 }
4615
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4616 void JSAPIPlainArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4617 {
4618 DISALLOW_GARBAGE_COLLECTION;
4619 TaggedArray *keys = TaggedArray::Cast(GetKeys(thread).GetTaggedObject());
4620 TaggedArray *values = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
4621 uint32_t len = static_cast<uint32_t>(GetLength());
4622 vec.reserve(vec.size() + len);
4623 for (uint32_t i = 0; i < len; i++) {
4624 CString str;
4625 KeyToStd(thread, str, keys->Get(thread, i));
4626 vec.emplace_back(str, values->Get(thread, i));
4627 }
4628 JSObject::DumpForSnapshot(thread, vec);
4629 }
4630
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec,bool isVmMode) const4631 void JSTaggedValue::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec, bool isVmMode) const
4632 {
4633 if (IsHeapObject()) {
4634 return DumpObject(thread, GetTaggedObject(), vec, isVmMode);
4635 }
4636 LOG_ECMA(FATAL) << "this branch is unreachable";
4637 UNREACHABLE();
4638 }
4639
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4640 void NumberDictionary::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4641 {
4642 DISALLOW_GARBAGE_COLLECTION;
4643 int size = Size();
4644 vec.reserve(vec.size() + size);
4645 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4646 JSTaggedValue key(GetKey(thread, hashIndex));
4647 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4648 JSTaggedValue val(GetValue(thread, hashIndex));
4649 vec.emplace_back(
4650 static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()), val, Reference::ReferenceType::ELEMENT);
4651 }
4652 }
4653 }
4654
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4655 void NameDictionary::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4656 {
4657 DISALLOW_GARBAGE_COLLECTION;
4658 int size = Size();
4659 vec.reserve(vec.size() + size);
4660 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4661 JSTaggedValue key(GetKey(thread, hashIndex));
4662 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4663 JSTaggedValue val(GetValue(thread, hashIndex));
4664 CString str;
4665 KeyToStd(thread, str, key);
4666 vec.emplace_back(str, val);
4667 }
4668 }
4669 }
4670
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4671 void GlobalDictionary::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4672 {
4673 DISALLOW_GARBAGE_COLLECTION;
4674 int size = Size();
4675 vec.reserve(vec.size() + size);
4676 for (int hashIndex = 0; hashIndex < size; hashIndex++) {
4677 JSTaggedValue key(GetKey(thread, hashIndex));
4678 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4679 CString str;
4680 KeyToStd(thread, str, key);
4681 JSTaggedValue val = GetValue(thread, hashIndex);
4682 vec.emplace_back(str, val);
4683 }
4684 }
4685 }
4686
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4687 void LinkedHashSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4688 {
4689 DISALLOW_GARBAGE_COLLECTION;
4690 int capacity = NumberOfElements() + NumberOfDeletedElements();
4691 vec.reserve(vec.size() + capacity);
4692 for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
4693 JSTaggedValue key(GetKey(thread, hashIndex));
4694 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4695 CString str;
4696 KeyToStd(thread, str, key);
4697 vec.emplace_back(str, JSTaggedValue::Hole());
4698 }
4699 }
4700 }
4701
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4702 void LinkedHashMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4703 {
4704 DISALLOW_GARBAGE_COLLECTION;
4705 int capacity = NumberOfElements() + NumberOfDeletedElements();
4706 vec.reserve(vec.size() + capacity);
4707 for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
4708 JSTaggedValue key(GetKey(thread, hashIndex));
4709 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4710 JSTaggedValue val = GetValue(thread, hashIndex);
4711 CString str;
4712 KeyToStd(thread, str, key);
4713 vec.emplace_back(str, val);
4714 }
4715 }
4716 }
4717
Dump(const JSThread * thread,std::ostream & os) const4718 void TaggedHashArray::Dump(const JSThread *thread, std::ostream &os) const
4719 {
4720 DumpArrayClass(thread, this, os);
4721 }
4722
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4723 void TaggedHashArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4724 {
4725 DISALLOW_GARBAGE_COLLECTION;
4726 int capacity = static_cast<int>(GetLength());
4727 vec.reserve(vec.size() + capacity);
4728 for (int hashIndex = 0; hashIndex < capacity; hashIndex++) {
4729 JSTaggedValue value = Get(thread, hashIndex);
4730 if (!value.IsUndefined() && !value.IsHole() && !value.IsNull()) {
4731 LinkedNode *node = LinkedNode::Cast(value.GetTaggedObject());
4732 node->DumpForSnapshot(thread, vec);
4733 }
4734 }
4735 }
4736
4737 template <typename T>
DumpForSnapshotTaggedTreeEntry(const JSThread * thread,T tree,int index,std::vector<Reference> & vec,bool isMap=false)4738 void DumpForSnapshotTaggedTreeEntry(const JSThread *thread, T tree, int index, std::vector<Reference> &vec,
4739 bool isMap = false)
4740 {
4741 DISALLOW_GARBAGE_COLLECTION;
4742 if (isMap) {
4743 vec.emplace_back("key", JSTaggedValue(tree->GetKey(thread, index)));
4744 }
4745 vec.emplace_back("value", JSTaggedValue(tree->GetValue(thread, index)));
4746 vec.emplace_back("parent", JSTaggedValue(tree->GetParent(index)));
4747 vec.emplace_back("color", JSTaggedValue(static_cast<int>(tree->GetColor(index))));
4748 vec.emplace_back("left", tree->GetLeftChild(index));
4749 vec.emplace_back("right", tree->GetRightChild(index));
4750 }
4751
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4752 void TaggedTreeMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4753 {
4754 DISALLOW_GARBAGE_COLLECTION;
4755 vec.emplace_back("Elements", TaggedArray::Get(thread, NUMBER_OF_ELEMENTS_INDEX));
4756 vec.emplace_back("Delete", TaggedArray::Get(thread, NUMBER_OF_HOLE_ENTRIES_INDEX));
4757 vec.emplace_back("Capacity", TaggedArray::Get(thread, CAPACITY_INDEX));
4758 vec.emplace_back("RootNode", TaggedArray::Get(thread, ROOT_INDEX));
4759 vec.emplace_back("CompareFunction", TaggedArray::Get(thread, COMPARE_FUNCTION_INDEX));
4760 uint32_t capacity = NumberOfElements() + NumberOfDeletedElements();
4761 vec.reserve(vec.size() + capacity);
4762 for (uint32_t index = 0; index < capacity; index++) {
4763 JSTaggedValue key(GetKey(thread, index));
4764 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4765 JSTaggedValue val = GetValue(thread, index);
4766 CString str;
4767 KeyToStd(thread, str, key);
4768 vec.emplace_back(str, val);
4769 } else {
4770 DumpForSnapshotTaggedTreeEntry(thread, const_cast<TaggedTreeMap *>(this), index, vec, true);
4771 }
4772 }
4773 }
4774
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4775 void TaggedTreeSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4776 {
4777 DISALLOW_GARBAGE_COLLECTION;
4778 vec.emplace_back("Elements", TaggedArray::Get(thread, NUMBER_OF_ELEMENTS_INDEX));
4779 vec.emplace_back("Delete", TaggedArray::Get(thread, NUMBER_OF_HOLE_ENTRIES_INDEX));
4780 vec.emplace_back("Capacity", TaggedArray::Get(thread, CAPACITY_INDEX));
4781 vec.emplace_back("RootNode", TaggedArray::Get(thread, ROOT_INDEX));
4782 vec.emplace_back("CompareFunction", TaggedArray::Get(thread, COMPARE_FUNCTION_INDEX));
4783 uint32_t capacity = NumberOfElements() + NumberOfDeletedElements();
4784 vec.reserve(vec.size() + capacity);
4785 for (uint32_t index = 0; index < capacity; index++) {
4786 JSTaggedValue key(GetKey(thread, index));
4787 if (!key.IsUndefined() && !key.IsHole() && !key.IsNull()) {
4788 CString str;
4789 KeyToStd(thread, str, key);
4790 vec.emplace_back(str, JSTaggedValue::Hole());
4791 } else {
4792 DumpForSnapshotTaggedTreeEntry(thread, const_cast<TaggedTreeSet *>(this), index, vec, true);
4793 }
4794 }
4795 }
4796
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4797 void TaggedDoubleList::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4798 {
4799 DISALLOW_GARBAGE_COLLECTION;
4800 int capacity = NumberOfNodes();
4801 vec.reserve(vec.size() + capacity);
4802 for (int index = 0; index < capacity; index++) {
4803 JSTaggedValue val = GetElement(thread, index);
4804 CString str;
4805 KeyToStd(thread, str, JSTaggedValue(index));
4806 vec.emplace_back(str, val);
4807 }
4808 }
4809
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4810 void TaggedSingleList::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4811 {
4812 DISALLOW_GARBAGE_COLLECTION;
4813 int capacity = NumberOfNodes();
4814 vec.reserve(vec.size() + capacity);
4815 for (int index = 0; index < capacity; index++) {
4816 JSTaggedValue val = GetElement(thread, index);
4817 CString str;
4818 KeyToStd(thread, str, JSTaggedValue(index));
4819 vec.emplace_back(str, val);
4820 }
4821 }
4822
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4823 void JSObject::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4824 {
4825 DISALLOW_GARBAGE_COLLECTION;
4826 JSHClass *jshclass = GetJSHClass();
4827 if (jshclass != nullptr) {
4828 vec.emplace_back(CString("__proto__"), jshclass->GetPrototype(thread));
4829 }
4830 vec.emplace_back(CString("ArkInternalHash"), JSTaggedValue(GetHash(thread)));
4831 JSTaggedType hashField = Barriers::GetTaggedValue(thread, this, HASH_OFFSET);
4832 if (JSTaggedValue(hashField).IsHeapObject()) {
4833 vec.emplace_back(CString("HashField"), JSTaggedValue(hashField));
4834 }
4835
4836 TaggedArray *elements = TaggedArray::Cast(GetElements(thread).GetTaggedObject());
4837 vec.emplace_back("(object elements)", JSTaggedValue(elements));
4838 if (elements->GetLength() == 0) {
4839 } else if (!elements->IsDictionaryMode()) {
4840 DumpElementClass(thread, elements, vec);
4841 } else {
4842 NumberDictionary *dict = NumberDictionary::Cast(elements);
4843 dict->DumpForSnapshot(thread, vec);
4844 }
4845
4846 TaggedArray *properties = TaggedArray::Cast(GetProperties(thread).GetTaggedObject());
4847 if (IsJSGlobalObject()) {
4848 GlobalDictionary *dict = GlobalDictionary::Cast(properties);
4849 dict->DumpForSnapshot(thread, vec);
4850 return;
4851 }
4852 vec.emplace_back("(object properties)", JSTaggedValue(properties));
4853 if ((!properties->IsDictionaryMode()) && (jshclass != nullptr)) {
4854 JSTaggedValue attrs = jshclass->GetLayout(thread);
4855 if (attrs.IsNull()) {
4856 return;
4857 }
4858
4859 LayoutInfo *layoutInfo = LayoutInfo::Cast(attrs.GetTaggedObject());
4860 int propNumber = static_cast<int>(jshclass->NumberOfProps());
4861 vec.reserve(vec.size() + propNumber);
4862 for (int i = 0; i < propNumber; i++) {
4863 JSTaggedValue key = layoutInfo->GetKey(thread, i);
4864 PropertyAttributes attr = layoutInfo->GetAttr(thread, i);
4865 ASSERT(i == static_cast<int>(attr.GetOffset()));
4866 JSTaggedValue val;
4867 if (attr.IsInlinedProps()) {
4868 val = GetPropertyInlinedPropsWithRep(thread, i, attr);
4869 } else {
4870 val = properties->Get(thread, i - static_cast<int>(jshclass->GetInlinedProperties()));
4871 }
4872
4873 CString str;
4874 KeyToStd(thread, str, key);
4875 vec.emplace_back(str, val);
4876 }
4877 } else {
4878 NameDictionary *dict = NameDictionary::Cast(properties);
4879 dict->DumpForSnapshot(thread, vec);
4880 }
4881 }
4882
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4883 void JSHClass::DumpForSnapshot(const JSThread *thread, [[maybe_unused]] std::vector<Reference> &vec) const
4884 {
4885 if (!IsCompositeHClass()) {
4886 vec.emplace_back(CString("__proto__"), GetPrototype(thread));
4887 vec.emplace_back(CString("Layout"), GetLayout(thread));
4888 vec.emplace_back(CString("Transitions"), GetTransitions(thread));
4889 vec.emplace_back(CString("Parent"), GetParent(thread));
4890 vec.emplace_back(CString("ProtoChangeMarker"), GetProtoChangeMarker(thread));
4891 vec.emplace_back(CString("ProtoChangeDetails"), GetProtoChangeDetails(thread));
4892 vec.emplace_back(CString("EnumCache"), GetEnumCache(thread));
4893 }
4894 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
4895 vec.emplace_back(CString("BitField1"), JSTaggedValue(GetBitField1()));
4896 }
4897
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4898 void JSFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4899 {
4900 vec.emplace_back(CString("ProtoOrHClass"), GetProtoOrHClass(thread));
4901 vec.emplace_back(CString("LexicalEnv"), GetLexicalEnv(thread));
4902 vec.emplace_back(CString("RawProfileTypeInfo"), GetRawProfileTypeInfo(thread));
4903 vec.emplace_back(CString("HomeObject"), GetHomeObject(thread));
4904 vec.emplace_back(CString("Module"), GetModule(thread));
4905 vec.emplace_back(CString("Method"), GetMethod(thread));
4906 if ((!GetMethod(thread).IsNull()) && (!GetMethod(thread).IsUndefined())) {
4907 vec.emplace_back(CString("FunctionKind"), JSTaggedValue(static_cast<int>(GetFunctionKind(thread))));
4908 }
4909 vec.emplace_back(CString("FunctionExtraInfo"), GetFunctionExtraInfo(thread));
4910 vec.emplace_back(CString("Method"), GetMethod(thread));
4911 JSObject::DumpForSnapshot(thread, vec);
4912 }
4913
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4914 void Method::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4915 {
4916 vec.emplace_back(CString("MethodName"), JSTaggedValue(GetMethodName(thread)));
4917 vec.emplace_back(CString("ConstantPool"), GetConstantPool(thread));
4918 }
4919
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4920 void Program::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4921 {
4922 vec.emplace_back(CString("MainFunction"), GetMainFunction(thread));
4923 }
4924
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4925 void LinkedNode::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4926 {
4927 JSTaggedValue next = GetNext(thread);
4928 if (!next.IsUndefined() && !next.IsHole() && !next.IsNull()) {
4929 LinkedNode *nextNode = LinkedNode::Cast(next.GetTaggedObject());
4930 vec.emplace_back(CString("Next"), next);
4931 nextNode->DumpForSnapshot(thread, vec);
4932 }
4933 vec.emplace_back(CString("Key"), GetKey(thread));
4934 JSTaggedValue key = GetKey(thread);
4935 CString str;
4936 KeyToStd(thread, str, key);
4937 vec.emplace_back(str, GetValue(thread));
4938 }
4939
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4940 void ConstantPool::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4941 {
4942 DumpArrayClass(thread, this, vec);
4943 }
4944
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4945 void ProfileTypeInfoCell::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4946 {
4947 vec.emplace_back(CString("Value"), GetValue(thread));
4948 vec.emplace_back(CString("Handle"), GetHandle(thread));
4949 }
4950
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4951 void FunctionTemplate::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4952 {
4953 vec.emplace_back(CString("Method"), GetMethod(thread));
4954 vec.emplace_back(CString("Module"), GetModule(thread));
4955 vec.emplace_back(CString("RawProfileTypeInfo"), GetRawProfileTypeInfo(thread));
4956 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength()));
4957 }
4958
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4959 void ExtraProfileTypeInfo::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4960 {
4961 vec.emplace_back(CString("Receiver"), GetReceiverObject(thread));
4962 vec.emplace_back(CString("Holder"), GetHolderObject(thread));
4963 }
4964
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4965 void VTable::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4966 {
4967 DumpArrayClass(thread, this, vec);
4968 }
4969
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4970 void ProfileTypeInfo::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4971 {
4972 DISALLOW_GARBAGE_COLLECTION;
4973 uint32_t len = GetIcSlotLength();
4974 vec.reserve(vec.size() + len);
4975 for (uint32_t i = 0; i < len; i++) {
4976 JSTaggedValue val(Get(thread, i));
4977 CString str = ToCString(i);
4978 vec.emplace_back(str, val);
4979 }
4980 }
4981
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4982 void COWTaggedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4983 {
4984 DumpArrayClass(thread, this, vec);
4985 }
4986
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4987 void MutantTaggedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4988 {
4989 DumpMutantTaggedArrayClass(thread, this, vec);
4990 }
4991
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4992 void COWMutantTaggedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4993 {
4994 DumpCOWMutantTaggedArrayClass(thread, this, vec);
4995 }
4996
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const4997 void JSBoundFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
4998 {
4999 JSObject::DumpForSnapshot(thread, vec);
5000 vec.emplace_back(CString("Method"), GetMethod(thread));
5001 vec.emplace_back(CString("BoundTarget"), GetBoundTarget(thread));
5002 vec.emplace_back(CString("BoundThis"), GetBoundThis(thread));
5003 vec.emplace_back(CString("BoundArguments"), GetBoundArguments(thread));
5004 }
5005
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5006 void JSPrimitiveRef::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5007 {
5008 vec.emplace_back(CString("subValue"), GetValue(thread));
5009 JSObject::DumpForSnapshot(thread, vec);
5010 }
5011
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5012 void BigInt::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5013 {
5014 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength()));
5015 vec.emplace_back(CString("Sign"), JSTaggedValue(GetSign()));
5016 }
5017
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5018 void JSDate::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5019 {
5020 vec.emplace_back(CString("time"), GetTime(thread));
5021 vec.emplace_back(CString("localOffset"), GetLocalOffset(thread));
5022
5023 JSObject::DumpForSnapshot(thread, vec);
5024 }
5025
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5026 void JSMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5027 {
5028 if (!(GetLinkedMap(thread).IsInvalidValue())) {
5029 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
5030 vec.emplace_back("linkedmap", GetLinkedMap(thread));
5031 map->DumpForSnapshot(thread, vec);
5032 }
5033
5034 JSObject::DumpForSnapshot(thread, vec);
5035 }
5036
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5037 void JSSharedMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5038 {
5039 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
5040 vec.emplace_back("linkedmap", GetLinkedMap(thread));
5041 vec.emplace_back("ModRecord", JSTaggedValue(GetModRecord()));
5042 map->DumpForSnapshot(thread, vec);
5043
5044 JSObject::DumpForSnapshot(thread, vec);
5045 }
5046
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5047 void JSForInIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5048 {
5049 vec.emplace_back(CString("Object"), GetObject(thread));
5050 vec.emplace_back(CString("CachedHclass"), GetCachedHClass(thread));
5051 vec.emplace_back(CString("Keys"), GetKeys(thread));
5052 vec.emplace_back(CString("Index"), JSTaggedValue(GetIndex()));
5053 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength()));
5054 JSObject::DumpForSnapshot(thread, vec);
5055 }
5056
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5057 void JSMapIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5058 {
5059 if (!(GetIteratedMap(thread).IsInvalidValue())) {
5060 LinkedHashMap *map = LinkedHashMap::Cast(GetIteratedMap(thread).GetTaggedObject());
5061 vec.emplace_back("iteratedmap", GetIteratedMap(thread));
5062 map->DumpForSnapshot(thread, vec);
5063 }
5064
5065 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5066 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5067 JSObject::DumpForSnapshot(thread, vec);
5068 }
5069
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5070 void JSSharedMapIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5071 {
5072 JSSharedMap *iteratedMap = JSSharedMap::Cast(GetIteratedMap(thread).GetTaggedObject());
5073 LinkedHashMap *map = LinkedHashMap::Cast(iteratedMap->GetLinkedMap(thread).GetTaggedObject());
5074 vec.emplace_back("iteratedmap", GetIteratedMap(thread));
5075 map->DumpForSnapshot(thread, vec);
5076 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5077 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5078 JSObject::DumpForSnapshot(thread, vec);
5079 }
5080
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5081 void JSSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5082 {
5083 if (!(GetLinkedSet(thread).IsInvalidValue())) {
5084 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
5085 vec.emplace_back("linkedset", GetLinkedSet(thread));
5086 set->DumpForSnapshot(thread, vec);
5087 }
5088
5089 JSObject::DumpForSnapshot(thread, vec);
5090 }
5091
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5092 void JSSharedSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5093 {
5094 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
5095 vec.emplace_back("linkedset", GetLinkedSet(thread));
5096 vec.emplace_back("ModRecord", JSTaggedValue(GetModRecord()));
5097 set->DumpForSnapshot(thread, vec);
5098
5099 JSObject::DumpForSnapshot(thread, vec);
5100 }
5101
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5102 void JSWeakMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5103 {
5104 if (!(GetLinkedMap(thread).IsInvalidValue())) {
5105 LinkedHashMap *map = LinkedHashMap::Cast(GetLinkedMap(thread).GetTaggedObject());
5106 vec.emplace_back("linkedmap", GetLinkedMap(thread));
5107 map->DumpForSnapshot(thread, vec);
5108 }
5109
5110 JSObject::DumpForSnapshot(thread, vec);
5111 }
5112
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5113 void JSWeakSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5114 {
5115 if (!(GetLinkedSet(thread).IsInvalidValue())) {
5116 LinkedHashSet *set = LinkedHashSet::Cast(GetLinkedSet(thread).GetTaggedObject());
5117 vec.emplace_back("linkeset", GetLinkedSet(thread));
5118 set->DumpForSnapshot(thread, vec);
5119 }
5120
5121 JSObject::DumpForSnapshot(thread, vec);
5122 }
5123
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5124 void JSWeakRef::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5125 {
5126 vec.emplace_back(CString("WeakObject"), GetWeakObject(thread));
5127 JSObject::DumpForSnapshot(thread, vec);
5128 }
5129
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5130 void JSFinalizationRegistry::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5131 {
5132 vec.emplace_back(CString("CleanupCallback"), GetCleanupCallback(thread));
5133 if (!(GetMaybeUnregister(thread).IsInvalidValue())) {
5134 vec.emplace_back(CString("MaybeUnregister"), GetMaybeUnregister(thread));
5135 }
5136 if (!(GetNoUnregister(thread).IsInvalidValue())) {
5137 vec.emplace_back(CString("NoUnregister"), GetNoUnregister(thread));
5138 }
5139
5140 vec.emplace_back(CString("Next"), GetNext(thread));
5141 vec.emplace_back(CString("Prev"), GetPrev(thread));
5142 JSObject::DumpForSnapshot(thread, vec);
5143 }
5144
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5145 void CellRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5146 {
5147 vec.emplace_back(CString("WeakRefTarget"), GetWeakRefTarget(thread));
5148 vec.emplace_back(CString("HeldValue"), GetHeldValue(thread));
5149 }
5150
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5151 void JSSetIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5152 {
5153 if (!(GetIteratedSet(thread).IsInvalidValue())) {
5154 LinkedHashSet *set = LinkedHashSet::Cast(GetIteratedSet(thread).GetTaggedObject());
5155 vec.emplace_back("iteratedset", GetIteratedSet(thread));
5156 set->DumpForSnapshot(thread, vec);
5157 }
5158
5159 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5160 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5161 JSObject::DumpForSnapshot(thread, vec);
5162 }
5163
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5164 void JSSharedSetIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5165 {
5166 JSSharedSet *iteratedSet = JSSharedSet::Cast(GetIteratedSet(thread).GetTaggedObject());
5167 LinkedHashSet *set = LinkedHashSet::Cast(iteratedSet->GetLinkedSet(thread).GetTaggedObject());
5168 vec.emplace_back("iteratedset", GetIteratedSet(thread));
5169 set->DumpForSnapshot(thread, vec);
5170 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5171 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5172 JSObject::DumpForSnapshot(thread, vec);
5173 }
5174
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5175 void JSArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5176 {
5177 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength()));
5178 JSObject::DumpForSnapshot(thread, vec);
5179 }
5180
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5181 void JSSharedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5182 {
5183 vec.emplace_back("ModRecord: ", JSTaggedValue(GetModRecord()));
5184 JSObject::DumpForSnapshot(thread, vec);
5185 }
5186
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5187 void JSAPIArrayList::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5188 {
5189 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength(thread)));
5190 JSObject::DumpForSnapshot(thread, vec);
5191 }
5192
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5193 void JSAPIArrayListIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5194 {
5195 if (!(GetIteratedArrayList(thread).IsInvalidValue())) {
5196 JSAPIArrayList *arraylist = JSAPIArrayList::Cast(GetIteratedArrayList(thread).GetTaggedObject());
5197 vec.emplace_back("iteratedlist", GetIteratedArrayList(thread));
5198 arraylist->DumpForSnapshot(thread, vec);
5199 }
5200 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5201 JSObject::DumpForSnapshot(thread, vec);
5202 }
5203
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5204 void JSAPILightWeightMap::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5205 {
5206 DISALLOW_GARBAGE_COLLECTION;
5207 vec.emplace_back("Hashes", GetHashes(thread));
5208 vec.emplace_back("Keys", GetKeys(thread));
5209 TaggedArray *keys = TaggedArray::Cast(GetKeys(thread).GetTaggedObject());
5210 TaggedArray *values = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
5211 uint32_t len = static_cast<uint32_t>(GetLength());
5212 vec.reserve(vec.size() + len);
5213 for (uint32_t i = 0; i < len; i++) {
5214 CString str;
5215 KeyToStd(thread, str, keys->Get(thread, i));
5216 vec.emplace_back(str, values->Get(thread, i));
5217 }
5218 JSObject::DumpForSnapshot(thread, vec);
5219 }
5220
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5221 void JSAPILightWeightMapIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5222 {
5223 if (!(GetIteratedLightWeightMap(thread).IsInvalidValue())) {
5224 JSAPILightWeightMap *map =
5225 JSAPILightWeightMap::Cast(GetIteratedLightWeightMap(thread).GetTaggedObject());
5226 vec.emplace_back("iteratedmap", GetIteratedLightWeightMap(thread));
5227 map->DumpForSnapshot(thread, vec);
5228 }
5229
5230 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5231 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5232 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
5233 JSObject::DumpForSnapshot(thread, vec);
5234 }
5235
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5236 void JSAPIQueue::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5237 {
5238 vec.emplace_back(CString("Length"), JSTaggedValue(GetLength(thread)));
5239 JSObject::DumpForSnapshot(thread, vec);
5240 }
5241
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5242 void JSAPIQueueIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5243 {
5244 if (!(GetIteratedQueue(thread).IsInvalidValue())) {
5245 JSAPIQueue *queue = JSAPIQueue::Cast(GetIteratedQueue(thread).GetTaggedObject());
5246 vec.emplace_back("iteratedqueue", GetIteratedQueue(thread));
5247 queue->DumpForSnapshot(thread, vec);
5248 }
5249
5250 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5251 JSObject::DumpForSnapshot(thread, vec);
5252 }
5253
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5254 void JSAPIDeque::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5255 {
5256 JSObject::DumpForSnapshot(thread, vec);
5257 }
5258
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5259 void JSAPIDequeIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5260 {
5261 if (!(GetIteratedDeque(thread).IsInvalidValue())) {
5262 JSAPIDeque *deque = JSAPIDeque::Cast(GetIteratedDeque(thread).GetTaggedObject());
5263 vec.emplace_back("iterateddeque", GetIteratedDeque(thread));
5264 deque->DumpForSnapshot(thread, vec);
5265 }
5266
5267 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5268 JSObject::DumpForSnapshot(thread, vec);
5269 }
5270
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5271 void JSAPILightWeightSet::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5272 {
5273 DISALLOW_GARBAGE_COLLECTION;
5274 TaggedArray *hashes = TaggedArray::Cast(GetHashes(thread).GetTaggedObject());
5275 TaggedArray *values = TaggedArray::Cast(GetValues(thread).GetTaggedObject());
5276 uint32_t len = GetLength();
5277 vec.reserve(vec.size() + len);
5278 for (uint32_t i = 0; i < len; i++) {
5279 CString str;
5280 KeyToStd(thread, str, hashes->Get(thread, i));
5281 vec.emplace_back(str, values->Get(thread, i));
5282 }
5283 JSObject::DumpForSnapshot(thread, vec);
5284 }
5285
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5286 void JSAPILightWeightSetIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5287 {
5288 if (!(GetIteratedLightWeightSet(thread).IsInvalidValue())) {
5289 JSAPILightWeightSet *set =
5290 JSAPILightWeightSet::Cast(GetIteratedLightWeightSet(thread).GetTaggedObject());
5291 vec.emplace_back("iteratedset", GetIteratedLightWeightSet(thread));
5292 set->DumpForSnapshot(thread, vec);
5293 }
5294
5295 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5296 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5297 JSObject::DumpForSnapshot(thread, vec);
5298 }
5299
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5300 void JSAPIStack::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5301 {
5302 JSObject::DumpForSnapshot(thread, vec);
5303 }
5304
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5305 void JSAPIStackIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5306 {
5307 if (!(GetIteratedStack(thread).IsInvalidValue())) {
5308 JSAPIStack *stack = JSAPIStack::Cast(GetIteratedStack(thread).GetTaggedObject());
5309 vec.emplace_back("iteratedstack", GetIteratedStack(thread));
5310 stack->DumpForSnapshot(thread, vec);
5311 }
5312
5313 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5314 JSObject::DumpForSnapshot(thread, vec);
5315 }
5316
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5317 void JSArrayIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5318 {
5319 if (!(GetIteratedArray(thread).IsInvalidValue())) {
5320 JSArray *array = JSArray::Cast(GetIteratedArray(thread).GetTaggedObject());
5321 vec.emplace_back("iteratedarray", GetIteratedArray(thread));
5322 array->DumpForSnapshot(thread, vec);
5323 }
5324
5325 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5326 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5327 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
5328 JSObject::DumpForSnapshot(thread, vec);
5329 }
5330
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5331 void JSSharedArrayIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5332 {
5333 JSSharedArray *array = JSSharedArray::Cast(GetIteratedArray(thread).GetTaggedObject());
5334 vec.emplace_back("iteratedarray", GetIteratedArray(thread));
5335 array->DumpForSnapshot(thread, vec);
5336 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5337 vec.emplace_back(CString("IterationKind"), JSTaggedValue(static_cast<int>(GetIterationKind())));
5338 JSObject::DumpForSnapshot(thread, vec);
5339 }
5340
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5341 void JSAPIVector::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5342 {
5343 JSObject::DumpForSnapshot(thread, vec);
5344 }
5345
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5346 void JSAPIVectorIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5347 {
5348 if (!(GetIteratedVector(thread).IsInvalidValue())) {
5349 JSAPIVector *vector = JSAPIVector::Cast(GetIteratedVector(thread).GetTaggedObject());
5350 vec.emplace_back("iteratedvector", GetIteratedVector(thread));
5351 vector->DumpForSnapshot(thread, vec);
5352 }
5353
5354 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5355 JSObject::DumpForSnapshot(thread, vec);
5356 }
5357
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5358 void JSAPIBitVector::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5359 {
5360 JSObject::DumpForSnapshot(thread, vec);
5361 }
5362
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5363 void JSAPIBitVectorIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5364 {
5365 JSAPIVector *vector = JSAPIVector::Cast(GetIteratedBitVector(thread).GetTaggedObject());
5366 vec.emplace_back("iteratedbitvector", GetIteratedBitVector(thread));
5367 vector->DumpForSnapshot(thread, vec);
5368 vec.emplace_back(CString("NextIndex"), JSTaggedValue(GetNextIndex()));
5369 JSObject::DumpForSnapshot(thread, vec);
5370 }
5371
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5372 void JSAPIFastBuffer::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5373 {
5374 JSObject::DumpForSnapshot(thread, vec);
5375 }
5376
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5377 void JSStringIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5378 {
5379 vec.emplace_back(CString("IteratedString"), GetIteratedString(thread));
5380 vec.emplace_back(CString("StringIteratorNextIndex"), JSTaggedValue(GetStringIteratorNextIndex()));
5381 JSObject::DumpForSnapshot(thread, vec);
5382 }
5383
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5384 void JSTypedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5385 {
5386 // please update the NUM_OF_ITEMS if you change the items below
5387 constexpr int16_t NUM_OF_ITEMS = 5;
5388 vec.reserve(vec.size() + NUM_OF_ITEMS);
5389 vec.emplace_back(CString("viewed-array-buffer"), GetViewedArrayBufferOrByteArray(thread));
5390 vec.emplace_back(CString("typed-array-name"), GetTypedArrayName(thread));
5391 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetByteLength()));
5392 vec.emplace_back(CString("byte-offset"), JSTaggedValue(GetByteOffset()));
5393 vec.emplace_back(CString("array-length"), JSTaggedValue(GetArrayLength()));
5394 JSObject::DumpForSnapshot(thread, vec);
5395 }
5396
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5397 void JSSharedTypedArray::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5398 {
5399 // please update the NUM_OF_ITEMS if you change the items below
5400 constexpr int16_t NUM_OF_ITEMS = 5;
5401 vec.reserve(vec.size() + NUM_OF_ITEMS);
5402 vec.emplace_back(CString("viewed-array-buffer"), GetViewedArrayBufferOrByteArray(thread));
5403 vec.emplace_back(CString("typed-array-name"), GetTypedArrayName(thread));
5404 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetByteLength()));
5405 vec.emplace_back(CString("byte-offset"), JSTaggedValue(GetByteOffset()));
5406 vec.emplace_back(CString("array-length"), JSTaggedValue(GetArrayLength()));
5407 JSObject::DumpForSnapshot(thread, vec);
5408 }
5409
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5410 void ByteArray::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5411 {
5412 vec.emplace_back(CString("array-length"), JSTaggedValue(GetArrayLength()));
5413 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetByteLength()));
5414 }
5415
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5416 void JSRegExp::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5417 {
5418 vec.emplace_back(CString("ByteCodeBuffer"), GetByteCodeBuffer(thread));
5419 vec.emplace_back(CString("originalSource"), GetOriginalSource(thread));
5420 vec.emplace_back(CString("originalFlags"), GetOriginalFlags(thread));
5421 vec.emplace_back(CString("groupName"), GetGroupName(thread));
5422 JSObject::DumpForSnapshot(thread, vec);
5423 }
5424
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5425 void JSRegExpIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5426 {
5427 vec.emplace_back(CString("IteratingRegExp"), GetIteratingRegExp(thread));
5428 vec.emplace_back(CString("IteratedString"), GetIteratedString(thread));
5429 vec.emplace_back(CString("Global"), JSTaggedValue(GetGlobal()));
5430 vec.emplace_back(CString("Unicode"), JSTaggedValue(GetUnicode()));
5431 vec.emplace_back(CString("Done"), JSTaggedValue(GetDone()));
5432 JSObject::DumpForSnapshot(thread, vec);
5433 }
5434
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5435 void JSProxy::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5436 {
5437 vec.emplace_back(CString("target"), GetTarget(thread));
5438 vec.emplace_back(CString("handler"), GetHandler(thread));
5439 vec.emplace_back(CString("Method"), GetMethod(thread));
5440 vec.emplace_back(CString("PrivateField"), GetPrivateField(thread));
5441 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
5442 }
5443
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5444 void JSSymbol::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5445 {
5446 vec.emplace_back(CString("hash-field"), JSTaggedValue(GetHashField()));
5447 vec.emplace_back(CString("flags"), JSTaggedValue(GetFlags()));
5448 vec.emplace_back(CString("description"), GetDescription(thread));
5449 }
5450
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5451 void AccessorData::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5452 {
5453 if (GetClass()->GetObjectType() == JSType::INTERNAL_ACCESSOR) {
5454 vec.emplace_back(CString("getter"), JSTaggedValue(InternalAccessor::ConstCast(this)->GetGetter()));
5455 vec.emplace_back(CString("setter"), JSTaggedValue(InternalAccessor::ConstCast(this)->GetSetter()));
5456 return;
5457 }
5458
5459 vec.emplace_back(CString("getter"), GetGetter(thread));
5460 vec.emplace_back(CString("setter"), GetSetter(thread));
5461 }
5462
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5463 void LexicalEnv::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5464 {
5465 DumpArrayClass(thread, this, vec);
5466 }
5467
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5468 void SFunctionEnv::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5469 {
5470 DumpArrayClass(thread, this, vec);
5471 }
5472
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5473 void SendableEnv::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5474 {
5475 DumpArrayClass(thread, this, vec);
5476 }
5477
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5478 void GlobalEnv::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5479 {
5480 auto globalConst = GetJSThread()->GlobalConstants();
5481 #define DUMP_ENV_FIELD(type, name, _) vec.emplace_back(#name, GetRaw##name().GetTaggedValue());
5482 #define DUMP_CONST_FIELD(type, name, ...) vec.emplace_back(#name, globalConst->Get##name());
5483 #define DUMP_CONST_STRING(name, ...) vec.emplace_back(#name, globalConst->Get##name());
5484
5485 GLOBAL_ENV_FIELDS(DUMP_ENV_FIELD)
5486
5487 GLOBAL_ENV_CONSTANT_CLASS(DUMP_CONST_FIELD)
5488
5489 GLOBAL_ENV_CONSTANT_SPECIAL(DUMP_CONST_FIELD)
5490
5491 GLOBAL_ENV_CACHES(DUMP_CONST_FIELD)
5492
5493 #undef DUMP_FIELD
5494 #undef DUMP_CONST_FIELD
5495 #undef DUMP_CONST_STRING
5496 }
5497
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5498 void JSDataView::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5499 {
5500 vec.emplace_back(CString("data-view"), GetDataView(thread));
5501 vec.emplace_back(CString("buffer"), GetViewedArrayBuffer(thread));
5502 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetByteLength()));
5503 vec.emplace_back(CString("byte-offset"), JSTaggedValue(GetByteOffset()));
5504 JSObject::DumpForSnapshot(thread, vec);
5505 }
5506
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5507 void JSArrayBuffer::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5508 {
5509 vec.emplace_back(CString("buffer-data"), GetArrayBufferData(thread));
5510 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetArrayBufferByteLength()));
5511 vec.emplace_back(CString("shared"), JSTaggedValue(GetShared()));
5512 JSObject::DumpForSnapshot(thread, vec);
5513 }
5514
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5515 void JSSendableArrayBuffer::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5516 {
5517 vec.emplace_back(CString("buffer-data"), GetArrayBufferData(thread));
5518 vec.emplace_back(CString("byte-length"), JSTaggedValue(GetArrayBufferByteLength()));
5519 vec.emplace_back(CString("shared"), JSTaggedValue(GetShared()));
5520 JSObject::DumpForSnapshot(thread, vec);
5521 }
5522
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5523 void PromiseReaction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5524 {
5525 vec.emplace_back(CString("promise-capability"), GetPromiseCapability(thread));
5526 vec.emplace_back(CString("handler"), GetHandler(thread));
5527 vec.emplace_back(CString("type"), JSTaggedValue(static_cast<int>(GetType())));
5528 }
5529
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5530 void PromiseCapability::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5531 {
5532 vec.emplace_back(CString("promise"), GetPromise(thread));
5533 vec.emplace_back(CString("resolve"), GetResolve(thread));
5534 vec.emplace_back(CString("reject"), GetReject(thread));
5535 }
5536
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5537 void PromiseIteratorRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5538 {
5539 vec.emplace_back(CString("iterator"), GetIterator(thread));
5540 vec.emplace_back(CString("done"), JSTaggedValue(GetDone()));
5541 }
5542
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5543 void PromiseRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5544 {
5545 vec.emplace_back(CString("value"), GetValue(thread));
5546 }
5547
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5548 void ResolvingFunctionsRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5549 {
5550 vec.emplace_back(CString("resolve-function"), GetResolveFunction(thread));
5551 vec.emplace_back(CString("reject-function"), GetRejectFunction(thread));
5552 }
5553
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5554 void AsyncGeneratorRequest::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5555 {
5556 vec.emplace_back(CString("completion"), GetCompletion(thread));
5557 vec.emplace_back(CString("capability"), GetCapability(thread));
5558 }
5559
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5560 void AsyncIteratorRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5561 {
5562 vec.emplace_back(CString("iterator"), GetIterator(thread));
5563 vec.emplace_back(CString("nextmethod"), GetNextMethod(thread));
5564 vec.emplace_back(CString("done"), JSTaggedValue(GetDone()));
5565 }
5566
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5567 void JSAsyncFromSyncIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5568 {
5569 vec.emplace_back(CString("synciteratorrecord"), GetSyncIteratorRecord(thread));
5570 JSObject::DumpForSnapshot(thread, vec);
5571 }
5572
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5573 void JSAsyncFromSyncIterUnwarpFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5574 {
5575 vec.emplace_back(CString("done"), JSTaggedValue(GetDone(thread)));
5576 JSFunction::DumpForSnapshot(thread, vec);
5577 }
5578
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5579 void JSPromise::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5580 {
5581 vec.emplace_back(CString("promise-state"), JSTaggedValue(static_cast<int>(GetPromiseState())));
5582 vec.emplace_back(CString("promise-result"), GetPromiseResult(thread));
5583 vec.emplace_back(CString("promise-fulfill-reactions"), GetPromiseFulfillReactions(thread));
5584 vec.emplace_back(CString("promise-reject-reactions"), GetPromiseRejectReactions(thread));
5585 vec.emplace_back(CString("promise-is-handled"), JSTaggedValue(GetPromiseIsHandled()));
5586 JSObject::DumpForSnapshot(thread, vec);
5587 }
5588
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5589 void JSPromiseReactionsFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5590 {
5591 vec.emplace_back(CString("promise"), GetPromise(thread));
5592 vec.emplace_back(CString("already-resolved"), GetAlreadyResolved(thread));
5593 JSFunction::DumpForSnapshot(thread, vec);
5594 }
5595
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5596 void JSAsyncGeneratorResNextRetProRstFtn::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5597 {
5598 vec.emplace_back(CString("async-generator-object"), GetAsyncGeneratorObject(thread));
5599 JSFunction::DumpForSnapshot(thread, vec);
5600 }
5601
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5602 void JSPromiseExecutorFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5603 {
5604 vec.emplace_back(CString("capability"), GetCapability(thread));
5605 JSFunction::DumpForSnapshot(thread, vec);
5606 }
5607
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5608 void JSAsyncModuleFulfilledFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5609 {
5610 vec.emplace_back(CString("module"), GetModule(thread));
5611 JSFunction::DumpForSnapshot(thread, vec);
5612 }
5613
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5614 void JSAsyncModuleRejectedFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5615 {
5616 vec.emplace_back(CString("module"), GetModule(thread));
5617 JSFunction::DumpForSnapshot(thread, vec);
5618 }
5619
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5620 void JSPromiseAllResolveElementFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5621 {
5622 vec.emplace_back(CString("index"), GetIndex(thread));
5623 vec.emplace_back(CString("values"), GetValues(thread));
5624 vec.emplace_back(CString("capabilities"), GetCapabilities(thread));
5625 vec.emplace_back(CString("remaining-elements"), GetRemainingElements(thread));
5626 vec.emplace_back(CString("already-called"), GetAlreadyCalled(thread));
5627 JSFunction::DumpForSnapshot(thread, vec);
5628 }
5629
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5630 void JSPromiseAnyRejectElementFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5631 {
5632 vec.emplace_back(CString("index"), JSTaggedValue(GetIndex()));
5633 vec.emplace_back(CString("errors"), GetErrors(thread));
5634 vec.emplace_back(CString("capability"), GetCapability(thread));
5635 vec.emplace_back(CString("remaining-elements"), GetRemainingElements(thread));
5636 vec.emplace_back(CString("already-called"), GetAlreadyCalled(thread));
5637 JSFunction::DumpForSnapshot(thread, vec);
5638 }
5639
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5640 void JSPromiseAllSettledElementFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5641 {
5642 vec.emplace_back(CString("already-called"), GetAlreadyCalled(thread));
5643 vec.emplace_back(CString("index"), JSTaggedValue(GetIndex()));
5644 vec.emplace_back(CString("values"), GetValues(thread));
5645 vec.emplace_back(CString("capability"), GetCapability(thread));
5646 vec.emplace_back(CString("remaining-elements"), GetRemainingElements(thread));
5647 JSFunction::DumpForSnapshot(thread, vec);
5648 }
5649
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5650 void JSPromiseFinallyFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5651 {
5652 vec.emplace_back(CString("constructor"), GetConstructor(thread));
5653 vec.emplace_back(CString("onFinally"), GetOnFinally(thread));
5654 JSFunction::DumpForSnapshot(thread, vec);
5655 }
5656
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5657 void JSPromiseValueThunkOrThrowerFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5658 {
5659 vec.emplace_back(CString("result"), GetResult(thread));
5660 JSFunction::DumpForSnapshot(thread, vec);
5661 }
5662
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5663 void MicroJobQueue::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5664 {
5665 vec.emplace_back(CString("promise-job-queue"), GetPromiseJobQueue(thread));
5666 vec.emplace_back(CString("script-job-queue"), GetScriptJobQueue(thread));
5667 }
5668
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5669 void PendingJob::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5670 {
5671 vec.emplace_back(CString("job"), GetJob(thread));
5672 vec.emplace_back(CString("arguments"), GetArguments(thread));
5673 }
5674
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5675 void CompletionRecord::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5676 {
5677 vec.emplace_back(CString("value"), GetValue(thread));
5678 vec.emplace_back(CString("type"), JSTaggedValue(static_cast<int>(GetType())));
5679 }
5680
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5681 void JSProxyRevocFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5682 {
5683 vec.emplace_back(CString("RevocableProxy"), GetRevocableProxy(thread));
5684 JSFunction::DumpForSnapshot(thread, vec);
5685 }
5686
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5687 void JSAsyncFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5688 {
5689 JSFunction::DumpForSnapshot(thread, vec);
5690 }
5691
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5692 void JSAsyncAwaitStatusFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5693 {
5694 vec.emplace_back(CString("AsyncContext"), GetAsyncContext(thread));
5695 JSFunction::DumpForSnapshot(thread, vec);
5696 }
5697
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5698 void JSGeneratorFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5699 {
5700 JSFunction::DumpForSnapshot(thread, vec);
5701 }
5702
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5703 void JSAsyncGeneratorFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5704 {
5705 JSFunction::DumpForSnapshot(thread, vec);
5706 }
5707
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5708 void JSIntlBoundFunction::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5709 {
5710 vec.emplace_back(CString("NumberFormat"), GetNumberFormat(thread));
5711 vec.emplace_back(CString("DateTimeFormat"), GetDateTimeFormat(thread));
5712 vec.emplace_back(CString("Collator"), GetCollator(thread));
5713 JSFunction::DumpForSnapshot(thread, vec);
5714 }
5715
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5716 void PropertyBox::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5717 {
5718 vec.emplace_back(CString("Value"), GetValue(thread));
5719 }
5720
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5721 void PrototypeHandler::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5722 {
5723 vec.emplace_back(CString("HandlerInfo"), GetHandlerInfo(thread));
5724 vec.emplace_back(CString("ProtoCell"), GetProtoCell(thread));
5725 vec.emplace_back(CString("Holder"), GetHolder(thread));
5726 }
5727
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5728 void TransitionHandler::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5729 {
5730 vec.emplace_back(CString("HandlerInfo"), GetHandlerInfo(thread));
5731 vec.emplace_back(CString("TransitionHClass"), GetTransitionHClass(thread));
5732 }
5733
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5734 void TransWithProtoHandler::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5735 {
5736 vec.emplace_back(CString("HandlerInfo"), GetHandlerInfo(thread));
5737 vec.emplace_back(CString("TransitionHClass"), GetTransitionHClass(thread));
5738 vec.emplace_back(CString("ProtoCell"), GetProtoCell(thread));
5739 }
5740
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5741 void StoreAOTHandler::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5742 {
5743 vec.emplace_back(CString("HandlerInfo"), GetHandlerInfo(thread));
5744 vec.emplace_back(CString("ProtoCell"), GetProtoCell(thread));
5745 vec.emplace_back(CString("Holder"), GetHolder(thread));
5746 }
5747
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5748 void JSRealm::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5749 {
5750 vec.emplace_back(CString("Value"), GetValue(thread));
5751 vec.emplace_back(CString("GLobalEnv"), GetGlobalEnv(thread));
5752 JSObject::DumpForSnapshot(thread, vec);
5753 }
5754 #ifdef ARK_SUPPORT_INTL
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5755 void JSIntl::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5756 {
5757 vec.emplace_back(CString("FallbackSymbol"), GetFallbackSymbol(thread));
5758 JSObject::DumpForSnapshot(thread, vec);
5759 }
5760
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5761 void JSLocale::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5762 {
5763 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5764 JSObject::DumpForSnapshot(thread, vec);
5765 }
5766
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5767 void JSDateTimeFormat::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5768 {
5769 // please update the NUM_OF_ITEMS if you change the items below
5770 constexpr int16_t NUM_OF_ITEMS = 11;
5771 vec.reserve(vec.size() + NUM_OF_ITEMS);
5772 vec.emplace_back(CString("Locale"), GetLocale(thread));
5773 vec.emplace_back(CString("Calendar"), GetCalendar(thread));
5774 vec.emplace_back(CString("NumberingSystem"), GetNumberingSystem(thread));
5775 vec.emplace_back(CString("TimeZone"), GetTimeZone(thread));
5776 vec.emplace_back(CString("HourCycle"), JSTaggedValue(static_cast<int>(GetHourCycle())));
5777 vec.emplace_back(CString("LocaleIcu"), GetLocaleIcu(thread));
5778 vec.emplace_back(CString("SimpleDateTimeFormatIcu"), GetSimpleDateTimeFormatIcu(thread));
5779 vec.emplace_back(CString("Iso8601"), GetIso8601(thread));
5780 vec.emplace_back(CString("DateStyle"), JSTaggedValue(static_cast<int>(GetDateStyle())));
5781 vec.emplace_back(CString("TimeStyle"), JSTaggedValue(static_cast<int>(GetTimeStyle())));
5782 vec.emplace_back(CString("BoundFormat"), GetBoundFormat(thread));
5783 JSObject::DumpForSnapshot(thread, vec);
5784 }
5785
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5786 void JSRelativeTimeFormat::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5787 {
5788 vec.emplace_back(CString("Locale"), GetLocale(thread));
5789 vec.emplace_back(CString("NumberingSystem"), GetNumberingSystem(thread));
5790 vec.emplace_back(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle())));
5791 vec.emplace_back(CString("Numeric"), JSTaggedValue(static_cast<int>(GetNumeric())));
5792 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5793 JSObject::DumpForSnapshot(thread, vec);
5794 }
5795
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5796 void JSNumberFormat::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5797 {
5798 // please update the NUM_OF_ITEMS if you change the items below
5799 constexpr int16_t NUM_OF_ITEMS = 20;
5800 vec.reserve(vec.size() + NUM_OF_ITEMS);
5801 vec.emplace_back(CString("Locale"), GetLocale(thread));
5802 vec.emplace_back(CString("NumberingSystem"), GetNumberingSystem(thread));
5803 vec.emplace_back(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle())));
5804 vec.emplace_back(CString("Currency"), GetCurrency(thread));
5805 vec.emplace_back(CString("CurrencyDisplay"), JSTaggedValue(static_cast<int>(GetCurrencyDisplay())));
5806 vec.emplace_back(CString("CurrencySign"), JSTaggedValue(static_cast<int>(GetCurrencySign())));
5807 vec.emplace_back(CString("Unit"), GetUnit(thread));
5808 vec.emplace_back(CString("UnitDisplay"), JSTaggedValue(static_cast<int>(GetUnitDisplay())));
5809 vec.emplace_back(CString("MinimumIntegerDigits"), GetMinimumIntegerDigits(thread));
5810 vec.emplace_back(CString("MinimumFractionDigits"), GetMinimumFractionDigits(thread));
5811 vec.emplace_back(CString("MaximumFractionDigits"), GetMaximumFractionDigits(thread));
5812 vec.emplace_back(CString("MinimumSignificantDigits"), GetMinimumSignificantDigits(thread));
5813 vec.emplace_back(CString("MaximumSignificantDigits"), GetMaximumSignificantDigits(thread));
5814 vec.emplace_back(CString("UseGrouping"), GetUseGrouping(thread));
5815 vec.emplace_back(CString("RoundingType"), JSTaggedValue(static_cast<int>(GetRoundingType())));
5816 vec.emplace_back(CString("Notation"), JSTaggedValue(static_cast<int>(GetNotation())));
5817 vec.emplace_back(CString("CompactDisplay"), JSTaggedValue(static_cast<int>(GetCompactDisplay())));
5818 vec.emplace_back(CString("SignDisplay"), JSTaggedValue(static_cast<int>(GetSignDisplay())));
5819 vec.emplace_back(CString("BoundFormat"), GetBoundFormat(thread));
5820 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5821 JSObject::DumpForSnapshot(thread, vec);
5822 }
5823
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5824 void JSCollator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5825 {
5826 // please update the NUM_OF_ITEMS if you change the items below
5827 constexpr int16_t NUM_OF_ITEMS = 9;
5828 vec.reserve(vec.size() + NUM_OF_ITEMS);
5829 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5830 vec.emplace_back(CString("Locale"), GetLocale(thread));
5831 vec.emplace_back(CString("Collation"), GetCollation(thread));
5832 vec.emplace_back(CString("BoundCompare"), GetBoundCompare(thread));
5833 vec.emplace_back(CString("CaseFirst"), JSTaggedValue(static_cast<int>(GetCaseFirst())));
5834 vec.emplace_back(CString("Usage"), JSTaggedValue(static_cast<int>(GetUsage())));
5835 vec.emplace_back(CString("Sensitivity"), JSTaggedValue(static_cast<int>(GetSensitivity())));
5836 vec.emplace_back(CString("IgnorePunctuation"), JSTaggedValue(GetIgnorePunctuation()));
5837 vec.emplace_back(CString("Numeric"), JSTaggedValue(GetNumeric()));
5838 JSObject::DumpForSnapshot(thread, vec);
5839 }
5840
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5841 void JSPluralRules::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5842 {
5843 // please update the NUM_OF_ITEMS if you change the items below
5844 constexpr int16_t NUM_OF_ITEMS = 10;
5845 vec.reserve(vec.size() + NUM_OF_ITEMS);
5846 vec.emplace_back(CString("Locale"), GetLocale(thread));
5847 vec.emplace_back(CString("MinimumIntegerDigits"), GetMinimumIntegerDigits(thread));
5848 vec.emplace_back(CString("MinimumFractionDigits"), GetMinimumFractionDigits(thread));
5849 vec.emplace_back(CString("MaximumFractionDigits"), GetMaximumFractionDigits(thread));
5850 vec.emplace_back(CString("MinimumSignificantDigits"), GetMinimumSignificantDigits(thread));
5851 vec.emplace_back(CString("MaximumSignificantDigits"), GetMaximumSignificantDigits(thread));
5852 vec.emplace_back(CString("RoundingType"), JSTaggedValue(static_cast<int>(GetRoundingType())));
5853 vec.emplace_back(CString("IcuPR"), GetIcuPR(thread));
5854 vec.emplace_back(CString("IcuNF"), GetIcuNF(thread));
5855 vec.emplace_back(CString("Type"), JSTaggedValue(static_cast<int>(GetType())));
5856 JSObject::DumpForSnapshot(thread, vec);
5857 }
5858
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5859 void JSDisplayNames::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5860 {
5861 vec.emplace_back(CString("Locale"), GetLocale(thread));
5862 vec.emplace_back(CString("Type"), JSTaggedValue(static_cast<int>(GetType())));
5863 vec.emplace_back(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle())));
5864 vec.emplace_back(CString("Fallback"), JSTaggedValue(static_cast<int>(GetFallback())));
5865 vec.emplace_back(CString("IcuLDN"), GetIcuLDN(thread));
5866 JSObject::DumpForSnapshot(thread, vec);
5867 }
5868
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5869 void JSSegmenter::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5870 {
5871 vec.emplace_back(CString("Locale"), GetLocale(thread));
5872 vec.emplace_back(CString("Granularity"), JSTaggedValue(static_cast<int>(GetGranularity())));
5873 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5874 JSObject::DumpForSnapshot(thread, vec);
5875 }
5876
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5877 void JSSegments::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5878 {
5879 vec.emplace_back(CString("SegmentsString"), GetSegmentsString(thread));
5880 vec.emplace_back(CString("UnicodeString"), GetUnicodeString(thread));
5881 vec.emplace_back(CString("Granularity"), JSTaggedValue(static_cast<int>(GetGranularity())));
5882 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5883 JSObject::DumpForSnapshot(thread, vec);
5884 }
5885
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5886 void JSSegmentIterator::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5887 {
5888 vec.emplace_back(CString("IteratedString"), GetIteratedString(thread));
5889 vec.emplace_back(CString("UnicodeString"), GetUnicodeString(thread));
5890 vec.emplace_back(CString("Granularity"), JSTaggedValue(static_cast<int>(GetGranularity())));
5891 vec.emplace_back(CString("IcuField"), GetIcuField(thread));
5892 JSObject::DumpForSnapshot(thread, vec);
5893 }
5894
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5895 void JSListFormat::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5896 {
5897 vec.emplace_back(CString("Locale"), GetLocale(thread));
5898 vec.emplace_back(CString("Type"), JSTaggedValue(static_cast<int>(GetType())));
5899 vec.emplace_back(CString("Style"), JSTaggedValue(static_cast<int>(GetStyle())));
5900 vec.emplace_back(CString("IcuLF"), GetIcuLF(thread));
5901 JSObject::DumpForSnapshot(thread, vec);
5902 }
5903 #endif
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5904 void JSGeneratorObject::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5905 {
5906 vec.emplace_back(CString("GeneratorContext"), GetGeneratorContext(thread));
5907 vec.emplace_back(CString("ResumeResult"), GetResumeResult(thread));
5908 vec.emplace_back(CString("GeneratorState"), JSTaggedValue(static_cast<int>(GetGeneratorState())));
5909 vec.emplace_back(CString("ResumeMode"), JSTaggedValue(static_cast<int>(GetResumeMode())));
5910 JSObject::DumpForSnapshot(thread, vec);
5911 }
5912
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5913 void JSAsyncGeneratorObject::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5914 {
5915 vec.emplace_back(CString("GeneratorContext"), GetGeneratorContext(thread));
5916 vec.emplace_back(CString("AsyncGeneratorQueue"), GetAsyncGeneratorQueue(thread));
5917 vec.emplace_back(CString("GeneratorBrand"), GetGeneratorBrand(thread));
5918 vec.emplace_back(CString("ResumeResult"), GetResumeResult(thread));
5919 vec.emplace_back(CString("AsyncGeneratorState"), JSTaggedValue(static_cast<int>(GetAsyncGeneratorState())));
5920 vec.emplace_back(CString("ResumeMode"), JSTaggedValue(static_cast<int>(GetResumeMode())));
5921 JSObject::DumpForSnapshot(thread, vec);
5922 }
5923
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5924 void JSAsyncFuncObject::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5925 {
5926 vec.emplace_back(CString("Promise"), GetPromise(thread));
5927 JSObject::DumpForSnapshot(thread, vec);
5928 }
5929
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5930 void GeneratorContext::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5931 {
5932 // please update the NUM_OF_ITEMS if you change the items below
5933 constexpr int16_t NUM_OF_ITEMS = 8;
5934 vec.reserve(vec.size() + NUM_OF_ITEMS);
5935 vec.emplace_back(CString("RegsArray"), GetRegsArray(thread));
5936 vec.emplace_back(CString("Method"), GetMethod(thread));
5937 vec.emplace_back(CString("This"), GetThis(thread));
5938 vec.emplace_back(CString("Acc"), GetAcc(thread));
5939 vec.emplace_back(CString("GeneratorObject"), GetGeneratorObject(thread));
5940 vec.emplace_back(CString("LexicalEnv"), GetLexicalEnv(thread));
5941 vec.emplace_back(CString("NRegs"), JSTaggedValue(GetNRegs()));
5942 vec.emplace_back(CString("BCOffset"), JSTaggedValue(GetBCOffset()));
5943 }
5944
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5945 void EnumCache::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5946 {
5947 constexpr int16_t NUM_OF_ITEMS = 4;
5948 vec.reserve(vec.size() + NUM_OF_ITEMS);
5949 vec.emplace_back(CString("EnumCacheOwn"), GetEnumCacheOwn(thread));
5950 vec.emplace_back(CString("EnumCacheAll"), GetEnumCacheAll(thread));
5951 vec.emplace_back(CString("ProtoChainInfoEnumCache"), GetProtoChainInfoEnumCache(thread));
5952 vec.emplace_back(CString("EnumCacheKind"), JSTaggedValue(GetEnumCacheKind()));
5953 }
5954
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5955 void ProtoChangeMarker::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5956 {
5957 vec.emplace_back(CString("HasChanged"), JSTaggedValue(GetHasChanged()));
5958 }
5959
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5960 void MarkerCell::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5961 {
5962 vec.emplace_back(CString("IsDetectorInvalid"), JSTaggedValue(GetIsDetectorInvalid()));
5963 }
5964
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5965 void ProtoChangeDetails::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5966 {
5967 vec.emplace_back(CString("ChangeListener"), GetChangeListener(thread));
5968 vec.emplace_back(CString("RegisterIndex"), JSTaggedValue(GetRegisterIndex()));
5969 }
5970
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5971 void MachineCode::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
5972 {
5973 vec.emplace_back(CString("InstructionSizeInBytes"), JSTaggedValue(GetInstructionSizeInBytes()));
5974 }
5975
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5976 void TrackInfo::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5977 {
5978 vec.emplace_back("ElementsKind", JSTaggedValue(static_cast<uint32_t>(GetElementsKind())));
5979
5980 vec.emplace_back(CString("CachedHClass"), GetCachedHClass(thread));
5981 vec.emplace_back(CString("CachedFunc"), GetCachedFunc(thread));
5982 vec.emplace_back(CString("ArrayLength"), JSTaggedValue(GetArrayLength()));
5983 }
5984
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const5985 void ClassInfoExtractor::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
5986 {
5987 // please update the NUM_OF_ITEMS if you change the items below
5988 constexpr int16_t NUM_OF_ITEMS = 6;
5989 vec.reserve(vec.size() + NUM_OF_ITEMS);
5990 vec.emplace_back(CString("NonStaticKeys"), GetNonStaticKeys(thread));
5991 vec.emplace_back(CString("NonStaticProperties"), GetNonStaticProperties(thread));
5992 vec.emplace_back(CString("NonStaticElements"), GetNonStaticElements(thread));
5993 vec.emplace_back(CString("StaticKeys"), GetStaticKeys(thread));
5994 vec.emplace_back(CString("StaticProperties"), GetStaticProperties(thread));
5995 vec.emplace_back(CString("StaticElements"), GetStaticElements(thread));
5996 vec.emplace_back(CString("ConstructorMethod"), GetConstructorMethod(thread));
5997 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
5998 }
5999
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6000 void SourceTextModule::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6001 {
6002 // please update the NUM_OF_ITEMS if you change the items below
6003 constexpr int16_t NUM_OF_ITEMS = 14;
6004 vec.reserve(vec.size() + NUM_OF_ITEMS);
6005 vec.emplace_back(CString("Environment"), GetEnvironment(thread));
6006 vec.emplace_back(CString("Namespace"), GetNamespace(thread));
6007 vec.emplace_back(CString("ModuleRequests"), GetModuleRequests(thread));
6008 vec.emplace_back(CString("RequestedModules"), GetRequestedModules(thread));
6009 vec.emplace_back(CString("ImportEntries"), GetImportEntries(thread));
6010 vec.emplace_back(CString("LocalExportEntries"), GetLocalExportEntries(thread));
6011 vec.emplace_back(CString("IndirectExportEntries"), GetIndirectExportEntries(thread));
6012 vec.emplace_back(CString("StarExportEntries"), GetStarExportEntries(thread));
6013 vec.emplace_back(CString("Status"), JSTaggedValue(static_cast<int32_t>(GetStatus())));
6014 vec.emplace_back(CString("Exception"), GetException(thread));
6015 vec.emplace_back(CString("DFSIndex"), JSTaggedValue(GetDFSIndex()));
6016 vec.emplace_back(CString("DFSAncestorIndex"), JSTaggedValue(GetDFSAncestorIndex()));
6017 vec.emplace_back(CString("NameDictionary"), GetNameDictionary(thread));
6018 vec.emplace_back(CString("CycleRoot"), GetCycleRoot(thread));
6019 vec.emplace_back(CString("TopLevelCapability"), GetTopLevelCapability(thread));
6020 vec.emplace_back(CString("AsyncParentModules"), GetAsyncParentModules(thread));
6021 vec.emplace_back(CString("SendableEnv"), GetSendableEnv(thread));
6022 vec.emplace_back(CString("HasTLA"), JSTaggedValue(GetHasTLA()));
6023 vec.emplace_back(CString("AsyncEvaluatingOrdinal"), JSTaggedValue(GetAsyncEvaluatingOrdinal()));
6024 vec.emplace_back(CString("PendingAsyncDependencies"), JSTaggedValue(GetPendingAsyncDependencies()));
6025 }
6026
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6027 void ImportEntry::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6028 {
6029 vec.emplace_back(CString("ModuleRequestIndex"), JSTaggedValue(GetModuleRequestIndex()));
6030 vec.emplace_back(CString("ImportName"), GetImportName(thread));
6031 vec.emplace_back(CString("LocalName"), GetLocalName(thread));
6032 }
6033
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6034 void LocalExportEntry::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6035 {
6036 vec.emplace_back(CString("ExportName"), GetExportName(thread));
6037 vec.emplace_back(CString("LocalName"), GetLocalName(thread));
6038 }
6039
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6040 void IndirectExportEntry::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6041 {
6042 vec.emplace_back(CString("ExportName"), GetExportName(thread));
6043 vec.emplace_back(CString("ModuleRequest"), JSTaggedValue(GetModuleRequestIndex()));
6044 vec.emplace_back(CString("ImportName"), GetImportName(thread));
6045 }
6046
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6047 void StarExportEntry::DumpForSnapshot([[maybe_unused]] const JSThread *thread, std::vector<Reference> &vec) const
6048 {
6049 vec.emplace_back(CString("ModuleRequest"), JSTaggedValue(GetModuleRequestIndex()));
6050 }
6051
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6052 void ResolvedBinding::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6053 {
6054 vec.emplace_back(CString("Module"), GetModule(thread));
6055 vec.emplace_back(CString("BindingName"), GetBindingName(thread));
6056 }
6057
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6058 void ResolvedIndexBinding::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6059 {
6060 vec.emplace_back(CString("Module"), GetModule(thread));
6061 vec.emplace_back(CString("Index"), JSTaggedValue(GetIndex()));
6062 vec.emplace_back(CString("IsUpdatedFromResolvedBinding"), JSTaggedValue(GetIsUpdatedFromResolvedBinding()));
6063 }
6064
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6065 void ResolvedRecordIndexBinding::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6066 {
6067 vec.emplace_back(CString("ModuleRecord"), GetModuleRecord(thread));
6068 vec.emplace_back(CString("AbcFileName"), GetAbcFileName(thread));
6069 vec.emplace_back(CString("Index"), JSTaggedValue(GetIndex()));
6070 }
6071
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6072 void ResolvedRecordBinding::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6073 {
6074 vec.emplace_back(CString("ModuleRecord"), GetModuleRecord(thread));
6075 vec.emplace_back(CString("BindingName"), GetBindingName(thread));
6076 }
6077
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6078 void ModuleNamespace::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6079 {
6080 vec.emplace_back(CString("Module"), GetModule(thread));
6081 vec.emplace_back(CString("Exports"), GetExports(thread));
6082 vec.emplace_back(CString("DeregisterProcession"), GetDeregisterProcession(thread));
6083 JSObject::DumpForSnapshot(thread, vec);
6084 }
6085
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6086 void NativeModuleFailureInfo::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6087 {
6088 vec.emplace_back(CString("ArkNativeModuleFailureInfo"), GetArkNativeModuleFailureInfo(thread));
6089 JSObject::DumpForSnapshot(thread, vec);
6090 }
6091
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6092 void CjsModule::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6093 {
6094 vec.emplace_back(CString("Id"), GetId(thread));
6095 vec.emplace_back(CString("Path"), GetPath(thread));
6096 vec.emplace_back(CString("Exports"), GetExports(thread));
6097 vec.emplace_back(CString("Filename"), GetFilename(thread));
6098 vec.emplace_back(CString("BitField"), JSTaggedValue(GetBitField()));
6099 JSObject::DumpForSnapshot(thread, vec);
6100 }
6101
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6102 void CjsExports::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6103 {
6104 vec.emplace_back(CString("Exports"), GetExports(thread));
6105 JSObject::DumpForSnapshot(thread, vec);
6106 }
6107
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6108 void CjsRequire::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6109 {
6110 vec.emplace_back(CString("Cache"), GetCache(thread));
6111 vec.emplace_back(CString("Parent"), GetParent(thread));
6112 JSObject::DumpForSnapshot(thread, vec);
6113 }
6114
DumpForSnapshot(const JSThread * thread,std::vector<Reference> & vec) const6115 void ClassLiteral::DumpForSnapshot(const JSThread *thread, std::vector<Reference> &vec) const
6116 {
6117 vec.emplace_back(CString("Array"), GetArray(thread));
6118 vec.emplace_back(CString("IsAOTUsed"), JSTaggedValue(GetIsAOTUsed()));
6119 if (!GetArray(thread).IsUndefined()) {
6120 DumpArrayClass(thread, TaggedArray::Cast(GetArray(thread).GetTaggedObject()), vec);
6121 }
6122 }
6123 } // namespace panda::ecmascript
6124