• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ecmascript/accessor_data.h"
17 #include "ecmascript/builtins/builtins_array.h"
18 #include "ecmascript/dfx/hprof/heap_profiler.h"
19 #include "ecmascript/dfx/hprof/heap_profiler_interface.h"
20 #include "ecmascript/dfx/hprof/heap_snapshot.h"
21 #include "ecmascript/dfx/hprof/heap_snapshot_json_serializer.h"
22 #include "ecmascript/dfx/hprof/string_hashmap.h"
23 #include "ecmascript/dfx/native_module_failure_info.h"
24 #include "ecmascript/ecma_vm.h"
25 #include "ecmascript/global_dictionary-inl.h"
26 #include "ecmascript/global_env.h"
27 #include "ecmascript/ic/ic_handler.h"
28 #include "ecmascript/ic/property_box.h"
29 #include "ecmascript/ic/proto_change_details.h"
30 #include "ecmascript/jobs/micro_job_queue.h"
31 #include "ecmascript/jobs/pending_job.h"
32 #include "ecmascript/jspandafile/class_info_extractor.h"
33 #include "ecmascript/jspandafile/class_literal.h"
34 #include "ecmascript/jspandafile/program_object.h"
35 #include "ecmascript/js_api/js_api_arraylist.h"
36 #include "ecmascript/js_api/js_api_arraylist_iterator.h"
37 #include "ecmascript/js_api/js_api_deque.h"
38 #include "ecmascript/js_api/js_api_deque_iterator.h"
39 #include "ecmascript/js_api/js_api_lightweightmap.h"
40 #include "ecmascript/js_api/js_api_lightweightmap_iterator.h"
41 #include "ecmascript/js_api/js_api_lightweightset.h"
42 #include "ecmascript/js_api/js_api_lightweightset_iterator.h"
43 #include "ecmascript/js_api/js_api_linked_list.h"
44 #include "ecmascript/js_api/js_api_linked_list_iterator.h"
45 #include "ecmascript/js_api/js_api_list.h"
46 #include "ecmascript/js_api/js_api_list_iterator.h"
47 #include "ecmascript/js_api/js_api_plain_array.h"
48 #include "ecmascript/js_api/js_api_plain_array_iterator.h"
49 #include "ecmascript/js_api/js_api_queue.h"
50 #include "ecmascript/js_api/js_api_queue_iterator.h"
51 #include "ecmascript/js_api/js_api_stack.h"
52 #include "ecmascript/js_api/js_api_stack_iterator.h"
53 #include "ecmascript/js_api/js_api_tree_map.h"
54 #include "ecmascript/js_api/js_api_tree_map_iterator.h"
55 #include "ecmascript/js_api/js_api_tree_set.h"
56 #include "ecmascript/js_api/js_api_tree_set_iterator.h"
57 #include "ecmascript/js_api/js_api_vector.h"
58 #include "ecmascript/js_api/js_api_vector_iterator.h"
59 #include "ecmascript/js_arguments.h"
60 #include "ecmascript/js_array.h"
61 #include "ecmascript/js_array_iterator.h"
62 #include "ecmascript/js_arraybuffer.h"
63 #include "ecmascript/js_async_from_sync_iterator.h"
64 #include "ecmascript/js_async_function.h"
65 #include "ecmascript/js_async_generator_object.h"
66 #include "ecmascript/js_bigint.h"
67 #include "ecmascript/js_collator.h"
68 #include "ecmascript/js_dataview.h"
69 #include "ecmascript/js_date.h"
70 #include "ecmascript/js_date_time_format.h"
71 #include "ecmascript/js_finalization_registry.h"
72 #include "ecmascript/js_for_in_iterator.h"
73 #include "ecmascript/js_function.h"
74 #include "ecmascript/js_generator_object.h"
75 #include "ecmascript/js_global_object.h"
76 #include "ecmascript/js_handle.h"
77 #include "ecmascript/js_api/js_api_hashmap.h"
78 #include "ecmascript/js_api/js_api_hashmap_iterator.h"
79 #include "ecmascript/js_api/js_api_hashset.h"
80 #include "ecmascript/js_api/js_api_hashset_iterator.h"
81 #include "ecmascript/js_intl.h"
82 #include "ecmascript/js_locale.h"
83 #include "ecmascript/js_map.h"
84 #include "ecmascript/js_map_iterator.h"
85 #include "ecmascript/js_number_format.h"
86 #include "ecmascript/js_object-inl.h"
87 #include "ecmascript/js_plural_rules.h"
88 #include "ecmascript/js_displaynames.h"
89 #include "ecmascript/js_list_format.h"
90 #include "ecmascript/js_primitive_ref.h"
91 #include "ecmascript/js_promise.h"
92 #include "ecmascript/js_realm.h"
93 #include "ecmascript/js_regexp.h"
94 #include "ecmascript/js_regexp_iterator.h"
95 #include "ecmascript/js_relative_time_format.h"
96 #include "ecmascript/js_segmenter.h"
97 #include "ecmascript/js_segments.h"
98 #include "ecmascript/js_segment_iterator.h"
99 #include "ecmascript/js_set.h"
100 #include "ecmascript/js_set_iterator.h"
101 #include "ecmascript/js_string_iterator.h"
102 #include "ecmascript/js_tagged_number.h"
103 #include "ecmascript/js_tagged_value-inl.h"
104 #include "ecmascript/js_thread.h"
105 #include "ecmascript/js_typed_array.h"
106 #include "ecmascript/js_weak_container.h"
107 #include "ecmascript/js_weak_ref.h"
108 #include "ecmascript/layout_info-inl.h"
109 #include "ecmascript/lexical_env.h"
110 #include "ecmascript/linked_hash_table.h"
111 #include "ecmascript/marker_cell.h"
112 #include "ecmascript/mem/assert_scope.h"
113 #include "ecmascript/mem/c_containers.h"
114 #include "ecmascript/mem/machine_code.h"
115 #include "ecmascript/module/js_module_source_text.h"
116 #include "ecmascript/object_factory.h"
117 #include "ecmascript/shared_objects/js_shared_array.h"
118 #include "ecmascript/shared_objects/js_sendable_arraybuffer.h"
119 #include "ecmascript/shared_objects/js_shared_array_iterator.h"
120 #include "ecmascript/shared_objects/js_shared_map.h"
121 #include "ecmascript/shared_objects/js_shared_map_iterator.h"
122 #include "ecmascript/shared_objects/js_shared_set.h"
123 #include "ecmascript/shared_objects/js_shared_set_iterator.h"
124 #include "ecmascript/shared_objects/js_shared_typed_array.h"
125 #include "ecmascript/stubs/runtime_stubs.h"
126 #include "ecmascript/tagged_array.h"
127 #include "ecmascript/tagged_dictionary.h"
128 #include "ecmascript/tagged_hash_array.h"
129 #include "ecmascript/tagged_list.h"
130 #include "ecmascript/tagged_node.h"
131 #include "ecmascript/tagged_tree.h"
132 #include "ecmascript/template_map.h"
133 #include "ecmascript/tests/test_helper.h"
134 #include "ecmascript/transitions_dictionary.h"
135 #include "ecmascript/require/js_cjs_module.h"
136 #include "ecmascript/require/js_cjs_require.h"
137 #include "ecmascript/require/js_cjs_exports.h"
138 #include <sstream>
139 
140 using namespace panda::ecmascript;
141 using namespace panda::ecmascript::base;
142 using Array = panda::ecmascript::builtins::BuiltinsArray;
143 
144 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
145 #define CHECK_DUMP_FIELDS(begin, end, num);                                                                     \
146     LOG_ECMA_IF((num) != ((end) - (begin)) / JSTaggedValue::TaggedTypeSize() && sizeof(uintptr_t) == 8, FATAL)  \
147         << "Fields in obj are not in dump list. "
148 
149 namespace panda::test {
150 class EcmaDumpTest : public BaseTestWithScope<false> {
151 };
152 
153 #ifndef NDEBUG
HWTEST_F_L0(EcmaDumpTest,Dump)154 HWTEST_F_L0(EcmaDumpTest, Dump)
155 {
156     std::ostringstream os;
157 
158     JSTaggedValue value1(100);
159     value1.Dump(os);
160 
161     JSTaggedValue value2(100.0);
162     JSTaggedValue(value2.GetRawData()).Dump(os);
163 
164     JSTaggedValue::Undefined().Dump(os);
165     JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
166     env.GetTaggedValue().Dump(os);
167 
168     JSHandle<JSFunction> objFunc(env->GetObjectFunction());
169     objFunc.GetTaggedValue().Dump(os);
170 }
171 #endif  // #ifndef NDEBUG
172 
HWTEST_F_L0(EcmaDumpTest,DumpTaggedValueType)173 HWTEST_F_L0(EcmaDumpTest, DumpTaggedValueType)
174 {
175     std::vector<JSHandle<JSTaggedValue>> loopVal {};
176     std::vector<std::string> loopRes {};
177     // [Int]
178     int32_t a = 1;
179     JSTaggedValue intVal = JSTaggedValue(a);
180     loopVal.push_back(JSHandle<JSTaggedValue>(thread, intVal));
181     loopRes.push_back("[Int]");
182     // [Double]
183     double b = 3.14;
184     JSTaggedValue doubleVal = JSTaggedValue(b);
185     loopVal.push_back(JSHandle<JSTaggedValue>(thread, doubleVal));
186     loopRes.push_back("[Double]");
187     // [Undefine]
188     JSTaggedValue undefineVal = JSTaggedValue::Undefined();
189     loopVal.push_back(JSHandle<JSTaggedValue>(thread, undefineVal));
190     loopRes.push_back("[Special Value] : Undefined");
191     // [Null]
192     JSTaggedValue nullVal = JSTaggedValue::Null();
193     loopVal.push_back(JSHandle<JSTaggedValue>(thread, nullVal));
194     loopRes.push_back("[Special Value] : Null");
195     // JSArray
196     JSHandle<JSFunction> array(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction());
197     JSHandle<JSObject> globalObject(thread, thread->GetEcmaVM()->GetGlobalEnv()->GetGlobalObject());
198     auto ecmaRuntimeCallInfo1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10);
199     ecmaRuntimeCallInfo1->SetFunction(array.GetTaggedValue());
200     ecmaRuntimeCallInfo1->SetThis(globalObject.GetTaggedValue());
201     [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo1);
202     JSTaggedValue arrVal = Array::ArrayConstructor(ecmaRuntimeCallInfo1);
203     TestHelper::TearDownFrame(thread, prev);
204     loopVal.push_back(JSHandle<JSTaggedValue>(thread, arrVal));
205     loopRes.push_back("[Array]");
206     // Object
207     JSHandle<GlobalEnv> globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
208     JSHandle<JSTaggedValue> objFun = globalEnv->GetObjectFunction();
209     ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
210     JSHandle<JSTaggedValue> obj(factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun));
211     loopVal.push_back(obj);
212     loopRes.push_back("[Object]");
213 
214     for (int i = 0; i < loopVal.size(); i++) {
215         std::stringstream oss;
216         loopVal[i].GetTaggedValue().DumpTaggedValueType(oss);
217         ASSERT_EQ(oss.str(), loopRes[i]);
218     }
219 }
220 
NewJSMap(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)221 static JSHandle<JSMap> NewJSMap(JSThread *thread, ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
222 {
223     JSHandle<JSHClass> mapClass = factory->NewEcmaHClass(JSMap::SIZE, JSType::JS_MAP, proto);
224     JSHandle<JSMap> jsMap = JSHandle<JSMap>::Cast(factory->NewJSObjectWithInit(mapClass));
225     JSHandle<LinkedHashMap> linkedMap(LinkedHashMap::Create(thread));
226     jsMap->SetLinkedMap(thread, linkedMap);
227     return jsMap;
228 }
229 
NewJSSharedMap(JSThread * thread,ObjectFactory * factory)230 static JSHandle<JSSharedMap> NewJSSharedMap(JSThread *thread, ObjectFactory *factory)
231 {
232     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
233     JSHandle<JSTaggedValue> proto = globalEnv->GetSFunctionPrototype();
234     auto emptySLayout = thread->GlobalConstants()->GetHandledEmptySLayoutInfo();
235     JSHandle<JSHClass> mapClass = factory->NewSEcmaHClass(JSSharedMap::SIZE, 0,
236         JSType::JS_SHARED_MAP, proto, emptySLayout);
237     JSHandle<JSSharedMap> jsMap = JSHandle<JSSharedMap>::Cast(factory->NewJSObjectWithInit(mapClass));
238     JSHandle<LinkedHashMap> linkedMap(
239         LinkedHashMap::Create(thread, LinkedHashMap::MIN_CAPACITY, MemSpaceKind::SHARED));
240     jsMap->SetLinkedMap(thread, linkedMap);
241     jsMap->SetModRecord(0);
242     return jsMap;
243 }
244 
NewJSSet(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)245 static JSHandle<JSSet> NewJSSet(JSThread *thread, ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
246 {
247     JSHandle<JSHClass> setClass = factory->NewEcmaHClass(JSSet::SIZE, JSType::JS_SET, proto);
248     JSHandle<JSSet> jsSet = JSHandle<JSSet>::Cast(factory->NewJSObjectWithInit(setClass));
249     JSHandle<LinkedHashSet> linkedSet(LinkedHashSet::Create(thread));
250     jsSet->SetLinkedSet(thread, linkedSet);
251     return jsSet;
252 }
253 
NewJSSharedSet(JSThread * thread,ObjectFactory * factory)254 static JSHandle<JSSharedSet> NewJSSharedSet(JSThread *thread, ObjectFactory *factory)
255 {
256     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
257     JSHandle<JSTaggedValue> proto = globalEnv->GetSFunctionPrototype();
258     auto emptySLayout = thread->GlobalConstants()->GetHandledEmptySLayoutInfo();
259     JSHandle<JSHClass> setClass = factory->NewSEcmaHClass(JSSharedSet::SIZE, 0,
260         JSType::JS_SHARED_SET, proto, emptySLayout);
261     JSHandle<JSSharedSet> jsSet = JSHandle<JSSharedSet>::Cast(factory->NewJSObjectWithInit(setClass));
262     JSHandle<LinkedHashSet> linkedSet(
263         LinkedHashSet::Create(thread, LinkedHashSet::MIN_CAPACITY, MemSpaceKind::SHARED));
264     jsSet->SetLinkedSet(thread, linkedSet);
265     jsSet->SetModRecord(0);
266     return jsSet;
267 }
268 
NewJSAPIHashMap(JSThread * thread,ObjectFactory * factory)269 static JSHandle<JSAPIHashMap> NewJSAPIHashMap(JSThread *thread, ObjectFactory *factory)
270 {
271     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
272     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
273     JSHandle<JSHClass> mapClass = factory->NewEcmaHClass(JSAPIHashMap::SIZE, JSType::JS_API_HASH_MAP, proto);
274     JSHandle<JSAPIHashMap> jsHashMap = JSHandle<JSAPIHashMap>::Cast(factory->NewJSObjectWithInit(mapClass));
275     jsHashMap->SetTable(thread, TaggedHashArray::Create(thread));
276     jsHashMap->SetSize(0);
277     return jsHashMap;
278 }
279 
NewJSAPIHashSet(JSThread * thread,ObjectFactory * factory)280 static JSHandle<JSAPIHashSet> NewJSAPIHashSet(JSThread *thread, ObjectFactory *factory)
281 {
282     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
283     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
284     JSHandle<JSHClass> setClass = factory->NewEcmaHClass(JSAPIHashSet::SIZE, JSType::JS_API_HASH_SET, proto);
285     JSHandle<JSAPIHashSet> jsHashSet = JSHandle<JSAPIHashSet>::Cast(factory->NewJSObjectWithInit(setClass));
286     jsHashSet->SetTable(thread, TaggedHashArray::Create(thread));
287     jsHashSet->SetSize(0);
288     return jsHashSet;
289 }
290 
NewJSAPITreeMap(JSThread * thread,ObjectFactory * factory)291 static JSHandle<JSAPITreeMap> NewJSAPITreeMap(JSThread *thread, ObjectFactory *factory)
292 {
293     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
294     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
295     JSHandle<JSHClass> mapClass = factory->NewEcmaHClass(JSAPITreeMap::SIZE, JSType::JS_API_TREE_MAP, proto);
296     JSHandle<JSAPITreeMap> jsTreeMap = JSHandle<JSAPITreeMap>::Cast(factory->NewJSObjectWithInit(mapClass));
297     JSHandle<TaggedTreeMap> treeMap(thread, TaggedTreeMap::Create(thread));
298     jsTreeMap->SetTreeMap(thread, treeMap);
299     return jsTreeMap;
300 }
301 
NewJSAPITreeSet(JSThread * thread,ObjectFactory * factory)302 static JSHandle<JSAPITreeSet> NewJSAPITreeSet(JSThread *thread, ObjectFactory *factory)
303 {
304     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
305     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
306     JSHandle<JSHClass> setClass = factory->NewEcmaHClass(JSAPITreeSet::SIZE, JSType::JS_API_TREE_SET, proto);
307     JSHandle<JSAPITreeSet> jsTreeSet = JSHandle<JSAPITreeSet>::Cast(factory->NewJSObjectWithInit(setClass));
308     JSHandle<TaggedTreeSet> treeSet(thread, TaggedTreeSet::Create(thread));
309     jsTreeSet->SetTreeSet(thread, treeSet);
310     return jsTreeSet;
311 }
312 
NewJSAPIPlainArray(JSThread * thread,ObjectFactory * factory)313 static JSHandle<JSAPIPlainArray> NewJSAPIPlainArray(JSThread *thread, ObjectFactory *factory)
314 {
315     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
316     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
317     JSHandle<JSHClass> mapClass = factory->NewEcmaHClass(JSAPIPlainArray::SIZE, JSType::JS_API_PLAIN_ARRAY, proto);
318     JSHandle<JSAPIPlainArray> jSAPIPlainArray = JSHandle<JSAPIPlainArray>::Cast(factory->NewJSObjectWithInit(mapClass));
319     JSHandle<TaggedArray> keys =
320             JSAPIPlainArray::CreateSlot(thread, JSAPIPlainArray::DEFAULT_CAPACITY_LENGTH);
321     JSHandle<TaggedArray> values =
322             JSAPIPlainArray::CreateSlot(thread, JSAPIPlainArray::DEFAULT_CAPACITY_LENGTH);
323     jSAPIPlainArray->SetKeys(thread, keys);
324     jSAPIPlainArray->SetValues(thread, values);
325     jSAPIPlainArray->SetLength(0);
326     return jSAPIPlainArray;
327 }
328 
NewJSAPIList(JSThread * thread,ObjectFactory * factory)329 static JSHandle<JSAPIList> NewJSAPIList(JSThread *thread, ObjectFactory *factory)
330 {
331     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
332     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
333     JSHandle<JSHClass> listClass = factory->NewEcmaHClass(JSAPIList::SIZE, JSType::JS_API_LIST, proto);
334     JSHandle<JSAPIList> jsAPIList = JSHandle<JSAPIList>::Cast(factory->NewJSObjectWithInit(listClass));
335     JSHandle<JSTaggedValue> taggedSingleList(thread, TaggedSingleList::Create(thread));
336     jsAPIList->SetSingleList(thread, taggedSingleList);
337     return jsAPIList;
338 }
339 
NewJSAPILinkedList(JSThread * thread,ObjectFactory * factory)340 static JSHandle<JSAPILinkedList> NewJSAPILinkedList(JSThread *thread, ObjectFactory *factory)
341 {
342     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
343     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
344     JSHandle<JSHClass> mapClass = factory->NewEcmaHClass(JSAPILinkedList::SIZE, JSType::JS_API_LINKED_LIST, proto);
345     JSHandle<JSAPILinkedList> jsAPILinkedList = JSHandle<JSAPILinkedList>::Cast(factory->NewJSObjectWithInit(mapClass));
346     JSHandle<JSTaggedValue> linkedlist(thread, TaggedDoubleList::Create(thread));
347     jsAPILinkedList->SetDoubleList(thread, linkedlist);
348     return jsAPILinkedList;
349 }
350 
NewJSObject(JSThread * thread,ObjectFactory * factory,JSHandle<GlobalEnv> globalEnv)351 static JSHandle<JSObject> NewJSObject(JSThread *thread, ObjectFactory *factory, JSHandle<GlobalEnv> globalEnv)
352 {
353     JSFunction *jsFunc = globalEnv->GetObjectFunction().GetObject<JSFunction>();
354     JSHandle<JSTaggedValue> jsFunc1(thread, jsFunc);
355     JSHandle<JSObject> jsObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(jsFunc1), jsFunc1);
356     return jsObj;
357 }
358 
NewJSAPIArrayList(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)359 static JSHandle<JSAPIArrayList> NewJSAPIArrayList(JSThread *thread, ObjectFactory *factory,
360                                                   JSHandle<JSTaggedValue> proto)
361 {
362     JSHandle<JSHClass> arrayListClass =
363         factory->NewEcmaHClass(JSAPIArrayList::SIZE, JSType::JS_API_ARRAY_LIST, proto);
364     JSHandle<JSAPIArrayList> jsArrayList = JSHandle<JSAPIArrayList>::Cast(factory->NewJSObjectWithInit(arrayListClass));
365     jsArrayList->SetLength(thread, JSTaggedValue(0));
366     return jsArrayList;
367 }
368 
NewJSAPIStack(ObjectFactory * factory,JSHandle<JSTaggedValue> proto)369 static JSHandle<JSAPIStack> NewJSAPIStack(ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
370 {
371     JSHandle<JSHClass> stackClass = factory->NewEcmaHClass(JSAPIStack::SIZE, JSType::JS_API_STACK, proto);
372     JSHandle<JSAPIStack> jsStack = JSHandle<JSAPIStack>::Cast(factory->NewJSObjectWithInit(stackClass));
373     jsStack->SetTop(0);
374     return jsStack;
375 }
376 
NewJSRegExp(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)377 static JSHandle<JSRegExp> NewJSRegExp(JSThread *thread, ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
378 {
379     JSHandle<JSHClass> jSRegExpClass =
380         factory->NewEcmaHClass(JSRegExp::SIZE, JSType::JS_REG_EXP, proto);
381     JSHandle<JSRegExp> jSRegExp = JSHandle<JSRegExp>::Cast(factory->NewJSObject(jSRegExpClass));
382     jSRegExp->SetByteCodeBuffer(thread, JSTaggedValue::Undefined());
383     jSRegExp->SetOriginalSource(thread, JSTaggedValue::Undefined());
384     jSRegExp->SetGroupName(thread, JSTaggedValue::Undefined());
385     jSRegExp->SetOriginalFlags(thread, JSTaggedValue(0));
386     jSRegExp->SetLength(0);
387     return jSRegExp;
388 }
389 
NewJSAPILightWeightMap(JSThread * thread,ObjectFactory * factory)390 static JSHandle<JSAPILightWeightMap> NewJSAPILightWeightMap(JSThread *thread, ObjectFactory *factory)
391 {
392     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
393     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
394     JSHandle<JSHClass> lwmapClass =
395         factory->NewEcmaHClass(JSAPILightWeightMap::SIZE, JSType::JS_API_LIGHT_WEIGHT_MAP, proto);
396     JSHandle<JSAPILightWeightMap> jSAPILightWeightMap =
397         JSHandle<JSAPILightWeightMap>::Cast(factory->NewJSObjectWithInit(lwmapClass));
398     JSHandle<JSTaggedValue> hashArray =
399         JSHandle<JSTaggedValue>(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH));
400     JSHandle<JSTaggedValue> keyArray =
401         JSHandle<JSTaggedValue>(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH));
402     JSHandle<JSTaggedValue> valueArray =
403         JSHandle<JSTaggedValue>(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH));
404     jSAPILightWeightMap->SetHashes(thread, hashArray);
405     jSAPILightWeightMap->SetKeys(thread, keyArray);
406     jSAPILightWeightMap->SetValues(thread, valueArray);
407     jSAPILightWeightMap->SetLength(0);
408     return jSAPILightWeightMap;
409 }
410 
NewJSAPILightWeightSet(JSThread * thread,ObjectFactory * factory)411 static JSHandle<JSAPILightWeightSet> NewJSAPILightWeightSet(JSThread *thread, ObjectFactory *factory)
412 {
413     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
414     JSHandle<JSTaggedValue> proto = globalEnv->GetObjectFunctionPrototype();
415     JSHandle<JSHClass> setClass =
416         factory->NewEcmaHClass(JSAPILightWeightSet::SIZE, JSType::JS_API_LIGHT_WEIGHT_SET, proto);
417     JSHandle<JSAPILightWeightSet> jSAPILightWeightSet =
418         JSHandle<JSAPILightWeightSet>::Cast(factory->NewJSObjectWithInit(setClass));
419     JSHandle<TaggedArray> hashes =
420         JSAPILightWeightSet::CreateSlot(thread, JSAPILightWeightSet::DEFAULT_CAPACITY_LENGTH);
421     JSHandle<TaggedArray> values =
422         JSAPILightWeightSet::CreateSlot(thread, JSAPILightWeightSet::DEFAULT_CAPACITY_LENGTH);
423     jSAPILightWeightSet->SetHashes(thread, hashes);
424     jSAPILightWeightSet->SetValues(thread, values);
425     jSAPILightWeightSet->SetLength(0);
426     return jSAPILightWeightSet;
427 }
428 
NewJSAPIQueue(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)429 static JSHandle<JSAPIQueue> NewJSAPIQueue(JSThread *thread, ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
430 {
431     JSHandle<JSHClass> queueClass = factory->NewEcmaHClass(JSAPIQueue::SIZE, JSType::JS_API_QUEUE, proto);
432     JSHandle<JSAPIQueue> jsQueue = JSHandle<JSAPIQueue>::Cast(factory->NewJSObjectWithInit(queueClass));
433     JSHandle<TaggedArray> newElements = factory->NewTaggedArray(JSAPIQueue::DEFAULT_CAPACITY_LENGTH);
434     jsQueue->SetLength(thread, JSTaggedValue(0));
435     jsQueue->SetFront(0);
436     jsQueue->SetTail(0);
437     jsQueue->SetElements(thread, newElements);
438     return jsQueue;
439 }
440 
NewJSAPIDeque(JSThread * thread,ObjectFactory * factory,JSHandle<JSTaggedValue> proto)441 static JSHandle<JSAPIDeque> NewJSAPIDeque(JSThread *thread, ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
442 {
443     JSHandle<JSHClass> dequeClass = factory->NewEcmaHClass(JSAPIDeque::SIZE, JSType::JS_API_DEQUE, proto);
444     JSHandle<JSAPIDeque> jsDeque = JSHandle<JSAPIDeque>::Cast(factory->NewJSObjectWithInit(dequeClass));
445     JSHandle<TaggedArray> newElements = factory->NewTaggedArray(JSAPIDeque::DEFAULT_CAPACITY_LENGTH);
446     jsDeque->SetFirst(0);
447     jsDeque->SetLast(0);
448     jsDeque->SetElements(thread, newElements);
449     return jsDeque;
450 }
451 
NewJSAPIVector(ObjectFactory * factory,JSHandle<JSTaggedValue> proto)452 static JSHandle<JSAPIVector> NewJSAPIVector(ObjectFactory *factory, JSHandle<JSTaggedValue> proto)
453 {
454     JSHandle<JSHClass> vectorClass = factory->NewEcmaHClass(JSAPIVector::SIZE, JSType::JS_API_VECTOR, proto);
455     JSHandle<JSAPIVector> jsVector = JSHandle<JSAPIVector>::Cast(factory->NewJSObjectWithInit(vectorClass));
456     jsVector->SetLength(0);
457     return jsVector;
458 }
459 
HWTEST_F_L0(EcmaDumpTest,HeapProfileDump)460 HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
461 {
462     [[maybe_unused]] ecmascript::EcmaHandleScope scope(thread);
463     auto factory = thread->GetEcmaVM()->GetFactory();
464     auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
465     auto globalConst = const_cast<GlobalEnvConstants *>(thread->GlobalConstants());
466     JSHandle<JSTaggedValue> proto = globalEnv->GetFunctionPrototype();
467     std::vector<Reference> snapshotVector;
468     std::ostringstream os;
469 
470 #define DUMP_FOR_HANDLE(dumpHandle)                                                     \
471     do {                                                                                \
472         JSTaggedValue dumpValue = (dumpHandle).GetTaggedValue();                         \
473         dumpValue.Dump(os);                                                             \
474         dumpValue.DumpForSnapshot(snapshotVector);                                      \
475         /* Testing runtime stubs: */                                                    \
476         JSTaggedType dumpRawData = dumpValue.GetRawData();                              \
477         uintptr_t hintStr = reinterpret_cast<uintptr_t>("Testing with: " #dumpHandle);  \
478         RuntimeStubs::Dump(dumpRawData);                                                \
479         RuntimeStubs::DebugDump(dumpRawData);                                           \
480         RuntimeStubs::DumpWithHint(hintStr, dumpRawData);                               \
481         RuntimeStubs::DebugDumpWithHint(hintStr, dumpRawData);                          \
482     } while (false)
483 
484 #if defined(PANDA_TARGET_AMD64) || defined(PANDA_TARGET_ARM64)
485     static const unsigned int machineCodeSize = 39;
486 #else
487     static const unsigned int machineCodeSize = 23;
488 #endif
489 
490 #define NEW_OBJECT_AND_DUMP(ClassName, TypeName)                                                \
491     do {                                                                                        \
492         JSHandle<JSHClass> class##ClassName =                                                   \
493             factory->NewEcmaHClass(ClassName::SIZE, JSType::TypeName, proto);                   \
494         JSHandle<JSObject> object##ClassName = factory->NewJSObjectWithInit(class##ClassName);  \
495         DUMP_FOR_HANDLE(object##ClassName);                                                     \
496     } while (false)
497 
498     for (JSType type = JSType::JS_OBJECT; type <= JSType::TYPE_LAST; type = JSType(static_cast<int>(type) + 1)) {
499         switch (type) {
500             case JSType::JS_ERROR:
501             case JSType::JS_EVAL_ERROR:
502             case JSType::JS_RANGE_ERROR:
503             case JSType::JS_TYPE_ERROR:
504             case JSType::JS_AGGREGATE_ERROR:
505             case JSType::JS_REFERENCE_ERROR:
506             case JSType::JS_URI_ERROR:
507             case JSType::JS_ARGUMENTS:
508             case JSType::JS_SYNTAX_ERROR:
509             case JSType::JS_OOM_ERROR:
510             case JSType::JS_TERMINATION_ERROR:
511             case JSType::JS_OBJECT:
512             case JSType::JS_SHARED_OBJECT: {
513                 CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U);
514                 JSHandle<JSObject> jsObj = NewJSObject(thread, factory, globalEnv);
515                 DUMP_FOR_HANDLE(jsObj);
516                 break;
517             }
518             case JSType::JS_REALM: {
519                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRealm::SIZE, 2U);
520                 JSHandle<JSRealm> jsRealm = factory->NewJSRealm();
521                 DUMP_FOR_HANDLE(jsRealm);
522                 break;
523             }
524             case JSType::METHOD: {
525 #ifdef PANDA_TARGET_64
526                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U);
527 #else
528                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U);
529 #endif
530                 break;
531             }
532             case JSType::JS_FUNCTION_BASE: {
533                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 3U);
534                 break;
535             }
536             case JSType::JS_FUNCTION:
537             case JSType::JS_SHARED_FUNCTION: {
538                 CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 8U);
539                 JSHandle<JSTaggedValue> jsFunc = globalEnv->GetFunctionFunction();
540                 DUMP_FOR_HANDLE(jsFunc);
541                 break;
542             }
543             case JSType::JS_PROXY_REVOC_FUNCTION: {
544                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSProxyRevocFunction::SIZE, 1U);
545                 JSHandle<JSHClass> proxyRevocClass =
546                     JSHandle<JSHClass>::Cast(globalEnv->GetProxyRevocFunctionClass());
547                 JSHandle<JSObject> proxyRevocFunc = factory->NewJSObjectWithInit(proxyRevocClass);
548                 DUMP_FOR_HANDLE(proxyRevocFunc);
549                 break;
550             }
551             case JSType::JS_PROMISE_REACTIONS_FUNCTION: {
552                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseReactionsFunction::SIZE, 2U);
553                 JSHandle<JSHClass> promiseReactClass =
554                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseReactionFunctionClass());
555                 JSHandle<JSObject> promiseReactFunc = factory->NewJSObjectWithInit(promiseReactClass);
556                 DUMP_FOR_HANDLE(promiseReactFunc);
557                 break;
558             }
559             case JSType::JS_PROMISE_EXECUTOR_FUNCTION: {
560                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseExecutorFunction::SIZE, 1U);
561                 JSHandle<JSHClass> promiseExeClass =
562                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseExecutorFunctionClass());
563                 JSHandle<JSObject> promiseExeFunc = factory->NewJSObjectWithInit(promiseExeClass);
564                 DUMP_FOR_HANDLE(promiseExeFunc);
565                 break;
566             }
567             case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION: {
568                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleFulfilledFunction::SIZE, 0U);
569                 JSHandle<JSHClass> moduleFulfilledClass =
570                     JSHandle<JSHClass>::Cast(globalEnv->GetAsyncModuleFulfilledFunctionClass());
571                 JSHandle<JSObject> moduleFulfilledFunc = factory->NewJSObjectWithInit(moduleFulfilledClass);
572                 DUMP_FOR_HANDLE(moduleFulfilledFunc);
573                 break;
574             }
575             case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION: {
576                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleRejectedFunction::SIZE, 0U);
577                 JSHandle<JSHClass> moduleRejectedClass =
578                     JSHandle<JSHClass>::Cast(globalEnv->GetAsyncModuleRejectedFunctionClass());
579                 JSHandle<JSObject> moduleRejectedFunc = factory->NewJSObjectWithInit(moduleRejectedClass);
580                 DUMP_FOR_HANDLE(moduleRejectedFunc);
581                 break;
582             }
583             case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION: {
584                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllResolveElementFunction::SIZE, 5U);
585                 JSHandle<JSHClass> promiseAllClass =
586                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAllResolveElementFunctionClass());
587                 JSHandle<JSObject> promiseAllFunc = factory->NewJSObjectWithInit(promiseAllClass);
588                 DUMP_FOR_HANDLE(promiseAllFunc);
589                 break;
590             }
591             case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION: {
592                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAnyRejectElementFunction::SIZE, 5U);
593                 JSHandle<JSHClass> promiseAnyClass =
594                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAnyRejectElementFunctionClass());
595                 JSHandle<JSObject> promiseAnyFunc = factory->NewJSObjectWithInit(promiseAnyClass);
596                 DUMP_FOR_HANDLE(promiseAnyFunc);
597                 break;
598             }
599             case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION: {
600                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllSettledElementFunction::SIZE, 5U);
601                 JSHandle<JSHClass> promiseAllSettledClass =
602                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAllSettledElementFunctionClass());
603                 JSHandle<JSObject> promiseAllSettledFunc = factory->NewJSObjectWithInit(promiseAllSettledClass);
604                 DUMP_FOR_HANDLE(promiseAllSettledFunc);
605                 break;
606             }
607             case JSType::JS_PROMISE_FINALLY_FUNCTION: {
608                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseFinallyFunction::SIZE, 2U);
609                 JSHandle<JSHClass> promiseFinallyClass =
610                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseFinallyFunctionClass());
611                 JSHandle<JSObject> promiseFinallyFunc = factory->NewJSObjectWithInit(promiseFinallyClass);
612                 DUMP_FOR_HANDLE(promiseFinallyFunc);
613                 break;
614             }
615             case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION: {
616                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseValueThunkOrThrowerFunction::SIZE, 1U);
617                 JSHandle<JSHClass> promiseValueClass =
618                     JSHandle<JSHClass>::Cast(globalEnv->GetPromiseValueThunkOrThrowerFunctionClass());
619                 JSHandle<JSObject> promiseValueFunc = factory->NewJSObjectWithInit(promiseValueClass);
620                 DUMP_FOR_HANDLE(promiseValueFunc);
621                 break;
622             }
623             case JSType::JS_ASYNC_GENERATOR_FUNCTION: {
624                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorFunction::SIZE, 0U);
625                 break;
626             }
627             case JSType::JS_GENERATOR_FUNCTION: {
628                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSGeneratorFunction::SIZE, 0U);
629                 break;
630             }
631             case JSType::JS_ASYNC_FUNCTION:
632             case JSType::JS_SHARED_ASYNC_FUNCTION: {
633                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFunction::SIZE, 0U);
634                 break;
635             }
636             case JSType::JS_INTL_BOUND_FUNCTION: {
637                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSIntlBoundFunction::SIZE, 3U);
638                 JSHandle<JSIntlBoundFunction> intlBoundFunc = factory->NewJSIntlBoundFunction(
639                     MethodIndex::BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER);
640                 DUMP_FOR_HANDLE(intlBoundFunc);
641                 break;
642             }
643             case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION: {
644                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncAwaitStatusFunction::SIZE, 1U);
645                 JSHandle<JSAsyncAwaitStatusFunction> asyncAwaitFunc = factory->NewJSAsyncAwaitStatusFunction(
646                     MethodIndex::BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED);
647                 DUMP_FOR_HANDLE(asyncAwaitFunc);
648                 break;
649             }
650             case JSType::JS_BOUND_FUNCTION: {
651                 CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSBoundFunction::SIZE, 3U);
652                 NEW_OBJECT_AND_DUMP(JSBoundFunction, JS_BOUND_FUNCTION);
653                 break;
654             }
655             case JSType::JS_REG_EXP: {
656                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExp::SIZE, 5U);
657                 NEW_OBJECT_AND_DUMP(JSRegExp, JS_REG_EXP);
658                 break;
659             }
660             case JSType::JS_SET: {
661                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSet::SIZE, 1U);
662                 JSHandle<JSSet> jsSet = NewJSSet(thread, factory, proto);
663                 DUMP_FOR_HANDLE(jsSet);
664                 break;
665             }
666             case JSType::JS_SHARED_SET: {
667                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSet::SIZE, 2U);
668                 JSHandle<JSSharedSet> jsSet = NewJSSharedSet(thread, factory);
669                 DUMP_FOR_HANDLE(jsSet);
670                 break;
671             }
672             case JSType::JS_MAP: {
673                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSMap::SIZE, 1U);
674                 JSHandle<JSMap> jsMap = NewJSMap(thread, factory, proto);
675                 DUMP_FOR_HANDLE(jsMap);
676                 break;
677             }
678             case JSType::JS_SHARED_MAP: {
679                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMap::SIZE, 2U);
680                 JSHandle<JSSharedMap> jsMap = NewJSSharedMap(thread, factory);
681                 DUMP_FOR_HANDLE(jsMap);
682                 break;
683             }
684             case JSType::JS_WEAK_MAP: {
685                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakMap::SIZE, 1U);
686                 JSHandle<JSHClass> weakMapClass = factory->NewEcmaHClass(JSWeakMap::SIZE, JSType::JS_WEAK_MAP, proto);
687                 JSHandle<JSWeakMap> jsWeakMap = JSHandle<JSWeakMap>::Cast(factory->NewJSObjectWithInit(weakMapClass));
688                 JSHandle<LinkedHashMap> weakLinkedMap(LinkedHashMap::Create(thread));
689                 jsWeakMap->SetLinkedMap(thread, weakLinkedMap);
690                 DUMP_FOR_HANDLE(jsWeakMap);
691                 break;
692             }
693             case JSType::JS_WEAK_SET: {
694                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakSet::SIZE, 1U);
695                 JSHandle<JSHClass> weakSetClass = factory->NewEcmaHClass(JSWeakSet::SIZE, JSType::JS_WEAK_SET, proto);
696                 JSHandle<JSWeakSet> jsWeakSet = JSHandle<JSWeakSet>::Cast(factory->NewJSObjectWithInit(weakSetClass));
697                 JSHandle<LinkedHashSet> weakLinkedSet(LinkedHashSet::Create(thread));
698                 jsWeakSet->SetLinkedSet(thread, weakLinkedSet);
699                 DUMP_FOR_HANDLE(jsWeakSet);
700                 break;
701             }
702             case JSType::JS_WEAK_REF: {
703                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakRef::SIZE, 1U);
704                 JSHandle<JSHClass> weakRefClass = factory->NewEcmaHClass(JSWeakRef::SIZE, JSType::JS_WEAK_REF, proto);
705                 JSHandle<JSWeakRef> jsWeakRef = JSHandle<JSWeakRef>::Cast(factory->NewJSObjectWithInit(weakRefClass));
706                 jsWeakRef->SetWeakObject(thread, JSTaggedValue::Undefined());
707                 DUMP_FOR_HANDLE(jsWeakRef);
708                 break;
709             }
710             case JSType::JS_FINALIZATION_REGISTRY: {
711                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSFinalizationRegistry::SIZE, 5U);
712                 JSHandle<JSHClass> finalizationRegistryClass =
713                     factory->NewEcmaHClass(JSFinalizationRegistry::SIZE, JSType::JS_FINALIZATION_REGISTRY, proto);
714                 JSHandle<JSFinalizationRegistry> jsFinalizationRegistry =
715                     JSHandle<JSFinalizationRegistry>::Cast(factory->NewJSObjectWithInit(finalizationRegistryClass));
716                 JSHandle<LinkedHashMap> weakLinkedMap(LinkedHashMap::Create(thread));
717                 jsFinalizationRegistry->SetMaybeUnregister(thread, weakLinkedMap);
718                 DUMP_FOR_HANDLE(jsFinalizationRegistry);
719                 break;
720             }
721             case JSType::CELL_RECORD: {
722                 CHECK_DUMP_FIELDS(Record::SIZE, CellRecord::SIZE, 2U);
723                 JSHandle<CellRecord> cellRecord = factory->NewCellRecord();
724                 DUMP_FOR_HANDLE(cellRecord);
725                 break;
726             }
727             case JSType::JS_DATE: {
728                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDate::SIZE, 2U);
729                 JSHandle<JSHClass> dateClass = factory->NewEcmaHClass(JSDate::SIZE, JSType::JS_DATE, proto);
730                 JSHandle<JSDate> date = JSHandle<JSDate>::Cast(factory->NewJSObjectWithInit(dateClass));
731                 date->SetTimeValue(thread, JSTaggedValue(0.0));
732                 date->SetLocalOffset(thread, JSTaggedValue(0.0));
733                 DUMP_FOR_HANDLE(date);
734                 break;
735             }
736             case JSType::JS_FORIN_ITERATOR: {
737                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 4U);
738                 JSHandle<JSTaggedValue> array(thread, factory->NewJSArray().GetTaggedValue());
739                 JSHandle<JSTaggedValue> keys(thread, factory->EmptyArray().GetTaggedValue());
740                 JSHandle<JSTaggedValue> hclass(thread, JSTaggedValue::Undefined());
741                 JSHandle<JSForInIterator> forInIter = factory->NewJSForinIterator(array, keys, hclass);
742                 DUMP_FOR_HANDLE(forInIter);
743                 break;
744             }
745             case JSType::JS_MAP_ITERATOR: {
746                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSMapIterator::SIZE, 2U);
747                 JSHandle<JSMapIterator> jsMapIter =
748                     factory->NewJSMapIterator(NewJSMap(thread, factory, proto), IterationKind::KEY);
749                 DUMP_FOR_HANDLE(jsMapIter);
750                 break;
751             }
752             case JSType::JS_SHARED_MAP_ITERATOR: {
753                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMapIterator::SIZE, 2U);
754                 JSHandle<JSSharedMapIterator> jsMapIter =
755                     factory->NewJSMapIterator(NewJSSharedMap(thread, factory), IterationKind::KEY);
756                 DUMP_FOR_HANDLE(jsMapIter);
757                 break;
758             }
759             case JSType::JS_SET_ITERATOR: {
760                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSetIterator::SIZE, 2U);
761                 JSHandle<JSSetIterator> jsSetIter =
762                     factory->NewJSSetIterator(NewJSSet(thread, factory, proto), IterationKind::KEY);
763                 DUMP_FOR_HANDLE(jsSetIter);
764                 break;
765             }
766             case JSType::JS_SHARED_SET_ITERATOR: {
767                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSetIterator::SIZE, 2U);
768                 JSHandle<JSSharedSetIterator> jsSetIter =
769                     factory->NewJSSetIterator(NewJSSharedSet(thread, factory), IterationKind::KEY);
770                 DUMP_FOR_HANDLE(jsSetIter);
771                 break;
772             }
773             case JSType::JS_REG_EXP_ITERATOR: {
774                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExpIterator::SIZE, 3U);
775                 JSHandle<EcmaString> emptyString(thread->GlobalConstants()->GetHandledEmptyString());
776                 JSHandle<JSTaggedValue> jsRegExp(NewJSRegExp(thread, factory, proto));
777                 JSHandle<JSRegExpIterator> jsRegExpIter =
778                     factory->NewJSRegExpIterator(jsRegExp, emptyString, false, false);
779                 DUMP_FOR_HANDLE(jsRegExpIter);
780                 break;
781             }
782             case JSType::JS_ARRAY_ITERATOR: {
783                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U);
784                 JSHandle<JSArrayIterator> arrayIter =
785                     factory->NewJSArrayIterator(JSHandle<JSObject>::Cast(factory->NewJSArray()), IterationKind::KEY);
786                 DUMP_FOR_HANDLE(arrayIter);
787                 break;
788             }
789             case JSType::JS_SHARED_ARRAY_ITERATOR: {
790                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U);
791                 JSHandle<JSSharedArrayIterator> arrayIter = factory->NewJSSharedArrayIterator(
792                     JSHandle<JSObject>::Cast(factory->NewJSSArray()), IterationKind::KEY);
793                 DUMP_FOR_HANDLE(arrayIter);
794                 break;
795             }
796             case JSType::JS_STRING_ITERATOR: {
797                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSStringIterator::SIZE, 2U);
798                 JSHandle<JSTaggedValue> stringIter = globalEnv->GetStringIterator();
799                 DUMP_FOR_HANDLE(stringIter);
800                 break;
801             }
802             case JSType::JS_INTL: {
803                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSIntl::SIZE, 1U);
804                 NEW_OBJECT_AND_DUMP(JSIntl, JS_INTL);
805                 break;
806             }
807             case JSType::JS_LOCALE: {
808                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSLocale::SIZE, 1U);
809                 NEW_OBJECT_AND_DUMP(JSLocale, JS_LOCALE);
810                 break;
811             }
812             case JSType::JS_DATE_TIME_FORMAT: {
813                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDateTimeFormat::SIZE, 9U);
814                 NEW_OBJECT_AND_DUMP(JSDateTimeFormat, JS_DATE_TIME_FORMAT);
815                 break;
816             }
817             case JSType::JS_RELATIVE_TIME_FORMAT: {
818                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRelativeTimeFormat::SIZE, 4U);
819                 NEW_OBJECT_AND_DUMP(JSRelativeTimeFormat, JS_RELATIVE_TIME_FORMAT);
820                 break;
821             }
822             case JSType::JS_NUMBER_FORMAT: {
823                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSNumberFormat::SIZE, 13U);
824                 NEW_OBJECT_AND_DUMP(JSNumberFormat, JS_NUMBER_FORMAT);
825                 break;
826             }
827             case JSType::JS_COLLATOR: {
828                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSCollator::SIZE, 5U);
829                 NEW_OBJECT_AND_DUMP(JSCollator, JS_COLLATOR);
830                 break;
831             }
832             case JSType::JS_PLURAL_RULES: {
833                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPluralRules::SIZE, 9U);
834                 NEW_OBJECT_AND_DUMP(JSPluralRules, JS_PLURAL_RULES);
835                 break;
836             }
837             case JSType::JS_DISPLAYNAMES: {
838                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDisplayNames::SIZE, 3U);
839                 NEW_OBJECT_AND_DUMP(JSDisplayNames, JS_DISPLAYNAMES);
840                 break;
841             }
842             case JSType::JS_SEGMENTER: {
843                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmenter::SIZE, 3U);
844                 NEW_OBJECT_AND_DUMP(JSSegmenter, JS_SEGMENTER);
845                 break;
846             }
847             case JSType::JS_SEGMENTS: {
848                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegments::SIZE, 4U);
849                 NEW_OBJECT_AND_DUMP(JSSegments, JS_SEGMENTS);
850                 break;
851             }
852             case JSType::JS_SEGMENT_ITERATOR: {
853                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmentIterator::SIZE, 4U);
854                 NEW_OBJECT_AND_DUMP(JSSegmentIterator, JS_SEGMENTS);
855                 break;
856             }
857             case JSType::JS_LIST_FORMAT: {
858                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSListFormat::SIZE, 3U);
859                 NEW_OBJECT_AND_DUMP(JSListFormat, JS_LIST_FORMAT);
860                 break;
861             }
862             case JSType::JS_SHARED_ARRAY_BUFFER:
863             case JSType::JS_ARRAY_BUFFER: {
864                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayBuffer::SIZE, 2U);
865                 NEW_OBJECT_AND_DUMP(JSArrayBuffer, JS_ARRAY_BUFFER);
866                 break;
867             }
868             case JSType::JS_SENDABLE_ARRAY_BUFFER: {
869                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSendableArrayBuffer::SIZE, 2U);
870                 NEW_OBJECT_AND_DUMP(JSSendableArrayBuffer, JS_SENDABLE_ARRAY_BUFFER);
871                 break;
872             }
873             case JSType::JS_PROMISE: {
874                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPromise::SIZE, 4U);
875                 NEW_OBJECT_AND_DUMP(JSPromise, JS_PROMISE);
876                 break;
877             }
878             case JSType::JS_DATA_VIEW: {
879                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDataView::SIZE, 3U);
880                 NEW_OBJECT_AND_DUMP(JSDataView, JS_DATA_VIEW);
881                 break;
882             }
883             case JSType::JS_GENERATOR_OBJECT: {
884                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 4U);
885                 NEW_OBJECT_AND_DUMP(JSGeneratorObject, JS_GENERATOR_OBJECT);
886                 break;
887             }
888             case JSType::JS_ASYNC_GENERATOR_OBJECT: {
889                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncGeneratorObject::SIZE, 5U);
890                 NEW_OBJECT_AND_DUMP(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT);
891                 break;
892             }
893             case JSType::JS_ASYNC_FUNC_OBJECT: {
894                 CHECK_DUMP_FIELDS(JSGeneratorObject::SIZE, JSAsyncFuncObject::SIZE, 1U);
895                 JSHandle<JSAsyncFuncObject> asyncFuncObject = factory->NewJSAsyncFuncObject();
896                 DUMP_FOR_HANDLE(asyncFuncObject);
897                 break;
898             }
899             case JSType::JS_ARRAY: {
900                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U);
901                 JSHandle<JSArray> jsArray = factory->NewJSArray();
902                 DUMP_FOR_HANDLE(jsArray);
903                 break;
904             }
905             case JSType::JS_SHARED_ARRAY: {
906                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U);
907                 JSHandle<JSSharedArray> jsArray = factory->NewJSSArray();
908                 DUMP_FOR_HANDLE(jsArray);
909                 break;
910             }
911             case JSType::JS_TYPED_ARRAY:
912             case JSType::JS_INT8_ARRAY:
913             case JSType::JS_UINT8_ARRAY:
914             case JSType::JS_UINT8_CLAMPED_ARRAY:
915             case JSType::JS_INT16_ARRAY:
916             case JSType::JS_UINT16_ARRAY:
917             case JSType::JS_INT32_ARRAY:
918             case JSType::JS_UINT32_ARRAY:
919             case JSType::JS_FLOAT32_ARRAY:
920             case JSType::JS_FLOAT64_ARRAY:
921             case JSType::JS_BIGINT64_ARRAY:
922             case JSType::JS_BIGUINT64_ARRAY: {
923                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSTypedArray::SIZE, 4U);
924                 NEW_OBJECT_AND_DUMP(JSTypedArray, JS_TYPED_ARRAY);
925                 break;
926             }
927             case JSType::JS_SHARED_TYPED_ARRAY:
928             case JSType::JS_SHARED_INT8_ARRAY:
929             case JSType::JS_SHARED_UINT8_ARRAY:
930             case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY:
931             case JSType::JS_SHARED_INT16_ARRAY:
932             case JSType::JS_SHARED_UINT16_ARRAY:
933             case JSType::JS_SHARED_INT32_ARRAY:
934             case JSType::JS_SHARED_UINT32_ARRAY:
935             case JSType::JS_SHARED_FLOAT32_ARRAY:
936             case JSType::JS_SHARED_FLOAT64_ARRAY:
937             case JSType::JS_SHARED_BIGINT64_ARRAY:
938             case JSType::JS_SHARED_BIGUINT64_ARRAY: {
939                 // Fixme(Gymee) Add test later
940                 break;
941             }
942             case JSType::JS_PRIMITIVE_REF: {
943                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPrimitiveRef::SIZE, 1U);
944                 NEW_OBJECT_AND_DUMP(JSPrimitiveRef, JS_PRIMITIVE_REF);
945                 break;
946             }
947             case JSType::JS_GLOBAL_OBJECT: {
948                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSGlobalObject::SIZE, 0U);
949                 JSHandle<JSTaggedValue> globalObject = globalEnv->GetJSGlobalObject();
950                 DUMP_FOR_HANDLE(globalObject);
951                 break;
952             }
953             case JSType::JS_PROXY: {
954                 CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSProxy::SIZE, 5U);
955                 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
956                 JSHandle<JSProxy> proxy = factory->NewJSProxy(emptyObj, emptyObj);
957                 DUMP_FOR_HANDLE(proxy);
958                 break;
959             }
960             case JSType::HCLASS: {
961                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSHClass::SIZE, 9U);
962                 JSHandle<JSHClass> hclass = factory->NewEcmaHClass(JSHClass::SIZE, JSType::HCLASS, proto);
963                 DUMP_FOR_HANDLE(hclass);
964                 break;
965             }
966             case JSType::LINE_STRING:
967             case JSType::CONSTANT_STRING:
968             case JSType::TREE_STRING:
969             case JSType::SLICED_STRING: {
970                 DUMP_FOR_HANDLE(globalEnv->GetObjectFunction());
971                 break;
972             }
973             case JSType::BIGINT: {
974                 DUMP_FOR_HANDLE(globalEnv->GetBigIntFunction());
975                 break;
976             }
977             case JSType::PROFILE_TYPE_INFO_CELL_0:
978             case JSType::PROFILE_TYPE_INFO_CELL_1:
979             case JSType::PROFILE_TYPE_INFO_CELL_N: {
980                 JSHandle<JSTaggedValue> handleUndefined(thread, JSTaggedValue::Undefined());
981                 JSHandle<ProfileTypeInfoCell> profileTypeInfoCell = factory->NewProfileTypeInfoCell(handleUndefined);
982                 DUMP_FOR_HANDLE(profileTypeInfoCell);
983                 break;
984             }
985             case JSType::FUNCTION_TEMPLATE: {
986                 auto method = JSFunction::Cast(globalEnv->GetTaggedObjectFunction())->GetMethod();
987                 JSHandle<Method> methodHandle(thread, method);
988                 JSHandle<JSTaggedValue> handleUndefined(thread, JSTaggedValue::Undefined());
989                 JSHandle<FunctionTemplate> funcTemp = factory->NewFunctionTemplate(methodHandle, handleUndefined, 0);
990                 DUMP_FOR_HANDLE(funcTemp);
991                 break;
992             }
993             case JSType::TAGGED_ARRAY:
994             case JSType::VTABLE:
995             case JSType::LEXICAL_ENV:
996             case JSType::SENDABLE_ENV:
997             case JSType::AOT_LITERAL_INFO: {
998                 JSHandle<TaggedArray> taggedArray = factory->NewTaggedArray(4);
999                 DUMP_FOR_HANDLE(taggedArray);
1000                 break;
1001             }
1002             case JSType::CONSTANT_POOL: {
1003                 JSHandle<ConstantPool> constantPool = factory->NewConstantPool(4);
1004                 DUMP_FOR_HANDLE(constantPool);
1005                 break;
1006             }
1007             case JSType::PROFILE_TYPE_INFO: {
1008                 JSHandle<ProfileTypeInfo> info = factory->NewProfileTypeInfo(4);
1009                 DUMP_FOR_HANDLE(info);
1010                 break;
1011             }
1012             case JSType::EXTRA_PROFILE_TYPE_INFO: {
1013                 JSHandle<ExtraProfileTypeInfo> info = factory->NewExtraProfileTypeInfo();
1014                 DUMP_FOR_HANDLE(info);
1015                 break;
1016             }
1017             case JSType::TAGGED_DICTIONARY: {
1018                 JSHandle<TaggedArray> dict = factory->NewDictionaryArray(4);
1019                 DUMP_FOR_HANDLE(dict);
1020                 break;
1021             }
1022             case JSType::BYTE_ARRAY: {
1023                 JSHandle<ByteArray> byteArray = factory->NewByteArray(4, 8);
1024                 DUMP_FOR_HANDLE(byteArray);
1025                 break;
1026             }
1027             case JSType::COW_TAGGED_ARRAY: {
1028                 JSHandle<COWTaggedArray> dict = factory->NewCOWTaggedArray(4);
1029                 DUMP_FOR_HANDLE(dict);
1030                 break;
1031             }
1032             case JSType::MUTANT_TAGGED_ARRAY: {
1033                 JSHandle<MutantTaggedArray> array = factory->NewMutantTaggedArray(4);
1034                 DUMP_FOR_HANDLE(array);
1035                 break;
1036             }
1037             case JSType::COW_MUTANT_TAGGED_ARRAY: {
1038                 JSHandle<COWMutantTaggedArray> array = factory->NewCOWMutantTaggedArray(4);
1039                 DUMP_FOR_HANDLE(array);
1040                 break;
1041             }
1042             case JSType::GLOBAL_ENV: {
1043                 DUMP_FOR_HANDLE(globalEnv);
1044                 break;
1045             }
1046             case JSType::ACCESSOR_DATA:
1047             case JSType::INTERNAL_ACCESSOR: {
1048                 CHECK_DUMP_FIELDS(Record::SIZE, AccessorData::SIZE, 2U);
1049                 JSHandle<AccessorData> accessor = factory->NewAccessorData();
1050                 DUMP_FOR_HANDLE(accessor);
1051                 break;
1052             }
1053             case JSType::SYMBOL: {
1054                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSSymbol::SIZE, 3U);
1055                 JSHandle<JSSymbol> symbol = factory->NewJSSymbol();
1056                 DUMP_FOR_HANDLE(symbol);
1057                 break;
1058             }
1059             case JSType::JS_GENERATOR_CONTEXT: {
1060                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), GeneratorContext::SIZE, 7U);
1061                 JSHandle<GeneratorContext> genContext = factory->NewGeneratorContext();
1062                 DUMP_FOR_HANDLE(genContext);
1063                 break;
1064             }
1065             case JSType::PROTOTYPE_HANDLER: {
1066                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PrototypeHandler::SIZE, 5U);
1067                 JSHandle<PrototypeHandler> protoHandler = factory->NewPrototypeHandler();
1068                 DUMP_FOR_HANDLE(protoHandler);
1069                 break;
1070             }
1071             case JSType::TRANSITION_HANDLER: {
1072                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransitionHandler::SIZE, 2U);
1073                 JSHandle<TransitionHandler> transitionHandler = factory->NewTransitionHandler();
1074                 DUMP_FOR_HANDLE(transitionHandler);
1075                 break;
1076             }
1077             case JSType::TRANS_WITH_PROTO_HANDLER: {
1078                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransWithProtoHandler::SIZE, 3U);
1079                 JSHandle<TransWithProtoHandler> transWithProtoHandler = factory->NewTransWithProtoHandler();
1080                 DUMP_FOR_HANDLE(transWithProtoHandler);
1081                 break;
1082             }
1083             case JSType::STORE_TS_HANDLER: {
1084                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), StoreAOTHandler::SIZE, 3U);
1085                 JSHandle<StoreAOTHandler> storeAOTHandler = factory->NewStoreAOTHandler();
1086                 DUMP_FOR_HANDLE(storeAOTHandler);
1087                 break;
1088             }
1089             case JSType::PROPERTY_BOX: {
1090                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PropertyBox::SIZE, 1U);
1091                 JSHandle<PropertyBox> PropertyBox = factory->NewPropertyBox(globalConst->GetHandledEmptyArray());
1092                 DUMP_FOR_HANDLE(PropertyBox);
1093                 break;
1094             }
1095             case JSType::PROTO_CHANGE_MARKER: {
1096                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeMarker::SIZE, 1U);
1097                 JSHandle<ProtoChangeMarker> protoMaker = factory->NewProtoChangeMarker();
1098                 DUMP_FOR_HANDLE(protoMaker);
1099                 break;
1100             }
1101             case JSType::MARKER_CELL: {
1102                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MarkerCell::SIZE, 1U);
1103                 JSHandle<MarkerCell> markerCell = factory->NewMarkerCell();
1104                 DUMP_FOR_HANDLE(markerCell);
1105                 break;
1106             }
1107             case JSType::TRACK_INFO: {
1108                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TrackInfo::SIZE, 3U);
1109                 break;
1110             }
1111             case JSType::PROTOTYPE_INFO: {
1112                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeDetails::SIZE, 2U);
1113                 JSHandle<ProtoChangeDetails> protoDetails = factory->NewProtoChangeDetails();
1114                 DUMP_FOR_HANDLE(protoDetails);
1115                 break;
1116             }
1117             case JSType::TEMPLATE_MAP: {
1118                 JSHandle<JSTaggedValue> templateMap = globalEnv->GetTemplateMap();
1119                 DUMP_FOR_HANDLE(templateMap);
1120                 break;
1121             }
1122             case JSType::PROGRAM: {
1123                 CHECK_DUMP_FIELDS(ECMAObject::SIZE, Program::SIZE, 1U);
1124                 JSHandle<Program> program = factory->NewProgram();
1125                 DUMP_FOR_HANDLE(program);
1126                 break;
1127             }
1128             case JSType::PROMISE_CAPABILITY: {
1129                 CHECK_DUMP_FIELDS(Record::SIZE, PromiseCapability::SIZE, 3U);
1130                 JSHandle<PromiseCapability> promiseCapa = factory->NewPromiseCapability();
1131                 DUMP_FOR_HANDLE(promiseCapa);
1132                 break;
1133             }
1134             case JSType::PROMISE_RECORD: {
1135                 CHECK_DUMP_FIELDS(Record::SIZE, PromiseRecord::SIZE, 1U);
1136                 JSHandle<PromiseRecord> promiseRecord = factory->NewPromiseRecord();
1137                 DUMP_FOR_HANDLE(promiseRecord);
1138                 break;
1139             }
1140             case JSType::RESOLVING_FUNCTIONS_RECORD: {
1141                 CHECK_DUMP_FIELDS(Record::SIZE, ResolvingFunctionsRecord::SIZE, 2U);
1142                 JSHandle<ResolvingFunctionsRecord> ResolvingFunc = factory->NewResolvingFunctionsRecord();
1143                 DUMP_FOR_HANDLE(ResolvingFunc);
1144                 break;
1145             }
1146             case JSType::ASYNC_GENERATOR_REQUEST: {
1147                 CHECK_DUMP_FIELDS(Record::SIZE, AsyncGeneratorRequest::SIZE, 2U);
1148                 JSHandle<AsyncGeneratorRequest> asyncGeneratorRequest = factory->NewAsyncGeneratorRequest();
1149                 DUMP_FOR_HANDLE(asyncGeneratorRequest);
1150                 break;
1151             }
1152             case JSType::ASYNC_ITERATOR_RECORD: {
1153                 CHECK_DUMP_FIELDS(Record::SIZE, AsyncIteratorRecord::SIZE, 3U);
1154                 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1155                 JSHandle<JSTaggedValue> emptyMethod(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1156                 JSHandle<AsyncIteratorRecord> asyncIteratorRecord =
1157                     factory->NewAsyncIteratorRecord(emptyObj, emptyMethod, false);
1158                 DUMP_FOR_HANDLE(asyncIteratorRecord);
1159                 break;
1160             }
1161             case JSType::JS_ASYNC_FROM_SYNC_ITERATOR: {
1162                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncFromSyncIterator::SIZE, 1U);
1163                 NEW_OBJECT_AND_DUMP(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR);
1164                 break;
1165             }
1166             case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION: {
1167                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFromSyncIterUnwarpFunction::SIZE, 1U);
1168                 break;
1169             }
1170             case JSType::PROMISE_REACTIONS: {
1171                 CHECK_DUMP_FIELDS(Record::SIZE, PromiseReaction::SIZE, 3U);
1172                 JSHandle<PromiseReaction> promiseReact = factory->NewPromiseReaction();
1173                 DUMP_FOR_HANDLE(promiseReact);
1174                 break;
1175             }
1176             case JSType::PROMISE_ITERATOR_RECORD: {
1177                 CHECK_DUMP_FIELDS(Record::SIZE, PromiseIteratorRecord::SIZE, 2U);
1178                 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1179                 JSHandle<PromiseIteratorRecord> promiseIter = factory->NewPromiseIteratorRecord(emptyObj, false);
1180                 DUMP_FOR_HANDLE(promiseIter);
1181                 break;
1182             }
1183             case JSType::MICRO_JOB_QUEUE: {
1184                 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::MicroJobQueue::SIZE, 2U);
1185                 JSHandle<ecmascript::job::MicroJobQueue> microJob = factory->NewMicroJobQueue();
1186                 DUMP_FOR_HANDLE(microJob);
1187                 break;
1188             }
1189             case JSType::PENDING_JOB: {
1190 #if defined(ENABLE_HITRACE)
1191                 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 7U);
1192 #else
1193                 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 2U);
1194 #endif
1195                 JSHandle<JSHClass> pendingClass(thread,
1196                     JSHClass::Cast(globalConst->GetPendingJobClass().GetTaggedObject()));
1197                 JSHandle<TaggedObject> pendingJob(thread, factory->NewObject(pendingClass));
1198                 ecmascript::job::PendingJob::Cast(*pendingJob)->SetJob(thread, JSTaggedValue::Undefined());
1199                 ecmascript::job::PendingJob::Cast(*pendingJob)->SetArguments(thread, JSTaggedValue::Undefined());
1200                 DUMP_FOR_HANDLE(pendingJob);
1201                 break;
1202             }
1203             case JSType::COMPLETION_RECORD: {
1204                 CHECK_DUMP_FIELDS(Record::SIZE, CompletionRecord::SIZE, 2U);
1205                 JSHandle<CompletionRecord> comRecord =
1206                     factory->NewCompletionRecord(CompletionRecordType::NORMAL, globalConst->GetHandledEmptyArray());
1207                 DUMP_FOR_HANDLE(comRecord);
1208                 break;
1209             }
1210             case JSType::MACHINE_CODE_OBJECT: {
1211                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MachineCode::SIZE, machineCodeSize);
1212                 GTEST_LOG_(INFO) << "MACHINE_CODE_OBJECT not support new in MachineCodeSpace";
1213                 break;
1214             }
1215             case JSType::CLASS_INFO_EXTRACTOR: {
1216                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 8U);
1217                 JSHandle<ClassInfoExtractor> classInfoExtractor = factory->NewClassInfoExtractor(
1218                     JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
1219                 DUMP_FOR_HANDLE(classInfoExtractor);
1220                 break;
1221             }
1222             case JSType::JS_API_ARRAY_LIST: {
1223                 // 1 : 1 dump fileds number
1224                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayList::SIZE, 1U);
1225                 JSHandle<JSAPIArrayList> jsArrayList = NewJSAPIArrayList(thread, factory, proto);
1226                 DUMP_FOR_HANDLE(jsArrayList);
1227                 break;
1228             }
1229             case JSType::JS_API_ARRAYLIST_ITERATOR: {
1230                 // 2 : 2 dump fileds number
1231                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayListIterator::SIZE, 2U);
1232                 JSHandle<JSAPIArrayList> jsArrayList = NewJSAPIArrayList(thread, factory, proto);
1233                 JSHandle<JSAPIArrayListIterator> jsArrayListIter = factory->NewJSAPIArrayListIterator(jsArrayList);
1234                 DUMP_FOR_HANDLE(jsArrayListIter);
1235                 break;
1236             }
1237             case JSType::JS_API_BITVECTOR: {
1238                 break;
1239             }
1240             case JSType::JS_API_BITVECTOR_ITERATOR: {
1241                 break;
1242             }
1243             case JSType::LINKED_NODE: {
1244                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), LinkedNode::SIZE, 4U);
1245                 break;
1246             }
1247             case JSType::RB_TREENODE: {
1248                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), RBTreeNode::SIZE, 7U);
1249                 break;
1250             }
1251             case JSType::JS_API_HASH_MAP: {
1252                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMap::SIZE, 2U);
1253                 JSHandle<JSAPIHashMap> jsHashMap = NewJSAPIHashMap(thread, factory);
1254                 DUMP_FOR_HANDLE(jsHashMap);
1255                 break;
1256             }
1257             case JSType::JS_API_HASH_SET: {
1258                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSet::SIZE, 2U);
1259                 JSHandle<JSAPIHashSet> jsHashSet = NewJSAPIHashSet(thread, factory);
1260                 DUMP_FOR_HANDLE(jsHashSet);
1261                 break;
1262             }
1263             case JSType::JS_API_HASHMAP_ITERATOR: {
1264                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMapIterator::SIZE, 4U);
1265                 JSHandle<JSAPIHashMap> jsHashMap = NewJSAPIHashMap(thread, factory);
1266                 JSHandle<JSAPIHashMapIterator> jsHashMapIter =
1267                     factory->NewJSAPIHashMapIterator(jsHashMap, IterationKind::KEY);
1268                 DUMP_FOR_HANDLE(jsHashMapIter);
1269                 break;
1270             }
1271             case JSType::JS_API_HASHSET_ITERATOR: {
1272                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSetIterator::SIZE, 5U);
1273                 JSHandle<JSAPIHashSet> jsHashSet = NewJSAPIHashSet(thread, factory);
1274                 JSHandle<JSAPIHashSetIterator> jsHashSetIter =
1275                     factory->NewJSAPIHashSetIterator(jsHashSet, IterationKind::KEY);
1276                 DUMP_FOR_HANDLE(jsHashSetIter);
1277                 break;
1278             }
1279             case JSType::JS_API_LIGHT_WEIGHT_MAP: {
1280                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMap::SIZE, 4U);
1281                 JSHandle<JSAPILightWeightMap> jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory);
1282                 DUMP_FOR_HANDLE(jSAPILightWeightMap);
1283                 break;
1284             }
1285             case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR: {
1286                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMapIterator::SIZE, 2U);
1287                 JSHandle<JSAPILightWeightMap> jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory);
1288                 JSHandle<JSAPILightWeightMapIterator> jSAPILightWeightMapIterator =
1289                     factory->NewJSAPILightWeightMapIterator(jSAPILightWeightMap, IterationKind::KEY);
1290                 DUMP_FOR_HANDLE(jSAPILightWeightMapIterator);
1291                 break;
1292             }
1293             case JSType::JS_API_LIGHT_WEIGHT_SET: {
1294                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSet::SIZE, 3U);
1295                 JSHandle<JSAPILightWeightSet> jSAPILightWeightSet = NewJSAPILightWeightSet(thread, factory);
1296                 DUMP_FOR_HANDLE(jSAPILightWeightSet);
1297                 break;
1298             }
1299             case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR: {
1300                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSetIterator::SIZE, 2U);
1301                 JSHandle<JSAPILightWeightSetIterator> jSAPILightWeightSetIter =
1302                     factory->NewJSAPILightWeightSetIterator(NewJSAPILightWeightSet(thread, factory),
1303                                                             IterationKind::KEY);
1304                 DUMP_FOR_HANDLE(jSAPILightWeightSetIter);
1305                 break;
1306             }
1307             case JSType::JS_API_QUEUE: {
1308                 // 2 : 2 dump fileds number
1309                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueue::SIZE, 2U);
1310                 JSHandle<JSAPIQueue> jsQueue = NewJSAPIQueue(thread, factory, proto);
1311                 DUMP_FOR_HANDLE(jsQueue);
1312                 break;
1313             }
1314             case JSType::JS_API_QUEUE_ITERATOR: {
1315                 // 2 : 2 dump fileds number
1316                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueueIterator::SIZE, 2U);
1317                 JSHandle<JSAPIQueue> jsQueue = NewJSAPIQueue(thread, factory, proto);
1318                 JSHandle<JSAPIQueueIterator> jsQueueIter =
1319                     factory->NewJSAPIQueueIterator(jsQueue);
1320                 DUMP_FOR_HANDLE(jsQueueIter);
1321                 break;
1322             }
1323             case JSType::JS_API_PLAIN_ARRAY: {
1324                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArray::SIZE, 3U);
1325                 JSHandle<JSAPIPlainArray> jSAPIPlainArray = NewJSAPIPlainArray(thread, factory);
1326                 DUMP_FOR_HANDLE(jSAPIPlainArray);
1327                 break;
1328             }
1329             case JSType::JS_API_PLAIN_ARRAY_ITERATOR: {
1330                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArrayIterator::SIZE, 2U);
1331                 JSHandle<JSAPIPlainArray> jSAPIPlainArray = NewJSAPIPlainArray(thread, factory);
1332                 JSHandle<JSAPIPlainArrayIterator> jSAPIPlainArrayIter =
1333                     factory->NewJSAPIPlainArrayIterator(jSAPIPlainArray, IterationKind::KEY);
1334                 DUMP_FOR_HANDLE(jSAPIPlainArrayIter);
1335                 break;
1336             }
1337             case JSType::JS_API_TREE_MAP: {
1338                 // 1 : 1 dump fileds number
1339                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMap::SIZE, 1U);
1340                 JSHandle<JSAPITreeMap> jsTreeMap = NewJSAPITreeMap(thread, factory);
1341                 DUMP_FOR_HANDLE(jsTreeMap);
1342                 break;
1343             }
1344             case JSType::JS_API_TREE_SET: {
1345                 // 1 : 1 dump fileds number
1346                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSet::SIZE, 1U);
1347                 JSHandle<JSAPITreeSet> jsTreeSet = NewJSAPITreeSet(thread, factory);
1348                 DUMP_FOR_HANDLE(jsTreeSet);
1349                 break;
1350             }
1351             case JSType::JS_API_TREEMAP_ITERATOR: {
1352                 // 3 : 3 dump fileds number
1353                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMapIterator::SIZE, 3U);
1354                 JSHandle<JSAPITreeMap> jsTreeMap = NewJSAPITreeMap(thread, factory);
1355                 JSHandle<JSAPITreeMapIterator> jsTreeMapIter =
1356                     factory->NewJSAPITreeMapIterator(jsTreeMap, IterationKind::KEY);
1357                 DUMP_FOR_HANDLE(jsTreeMapIter);
1358                 break;
1359             }
1360             case JSType::JS_API_TREESET_ITERATOR: {
1361                 // 3 : 3 dump fileds number
1362                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSetIterator::SIZE, 3U);
1363                 JSHandle<JSAPITreeSet> jsTreeSet = NewJSAPITreeSet(thread, factory);
1364                 JSHandle<JSAPITreeSetIterator> jsTreeSetIter =
1365                     factory->NewJSAPITreeSetIterator(jsTreeSet, IterationKind::KEY);
1366                 DUMP_FOR_HANDLE(jsTreeSetIter);
1367                 break;
1368             }
1369             case JSType::JS_API_DEQUE: {
1370                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDeque::SIZE, 1U);
1371                 JSHandle<JSAPIDeque> jsDeque = NewJSAPIDeque(thread, factory, proto);
1372                 DUMP_FOR_HANDLE(jsDeque);
1373                 break;
1374             }
1375             case JSType::JS_API_DEQUE_ITERATOR: {
1376                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDequeIterator::SIZE, 2U);
1377                 JSHandle<JSAPIDequeIterator> jsDequeIter =
1378                     factory->NewJSAPIDequeIterator(NewJSAPIDeque(thread, factory, proto));
1379                 DUMP_FOR_HANDLE(jsDequeIter);
1380                 break;
1381             }
1382             case JSType::JS_API_STACK: {
1383                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStack::SIZE, 1U);
1384                 JSHandle<JSAPIStack> jsStack = NewJSAPIStack(factory, proto);
1385                 DUMP_FOR_HANDLE(jsStack);
1386                 break;
1387             }
1388             case JSType::JS_API_STACK_ITERATOR: {
1389                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStackIterator::SIZE, 2U);
1390                 JSHandle<JSAPIStackIterator> jsStackIter =
1391                     factory->NewJSAPIStackIterator(NewJSAPIStack(factory, proto));
1392                 DUMP_FOR_HANDLE(jsStackIter);
1393                 break;
1394             }
1395             case JSType::JS_API_VECTOR: {
1396                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVector::SIZE, 1U);
1397                 JSHandle<JSAPIVector> jsVector = NewJSAPIVector(factory, proto);
1398                 DUMP_FOR_HANDLE(jsVector);
1399                 break;
1400             }
1401             case JSType::JS_API_VECTOR_ITERATOR: {
1402                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVectorIterator::SIZE, 2U);
1403                 JSHandle<JSAPIVectorIterator> jsVectorIter =
1404                     factory->NewJSAPIVectorIterator(NewJSAPIVector(factory, proto));
1405                 DUMP_FOR_HANDLE(jsVectorIter);
1406                 break;
1407             }
1408             case JSType::JS_API_LIST: {
1409                 // 1 : 1 dump fileds number
1410                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIList::SIZE, 2U);
1411                 JSHandle<JSAPIList> jsAPIList = NewJSAPIList(thread, factory);
1412                 DUMP_FOR_HANDLE(jsAPIList);
1413                 break;
1414             }
1415             case JSType::JS_API_LINKED_LIST: {
1416                 // 1 : 1 dump fileds number
1417                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedList::SIZE, 1U);
1418                 JSHandle<JSAPILinkedList> jsAPILinkedList = NewJSAPILinkedList(thread, factory);
1419                 DUMP_FOR_HANDLE(jsAPILinkedList);
1420                 break;
1421             }
1422             case JSType::JS_API_LIST_ITERATOR: {
1423                 // 2 : 2 dump fileds number
1424                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U);
1425                 JSHandle<JSAPIList> jsAPIList = NewJSAPIList(thread, factory);
1426                 JSHandle<JSAPIListIterator> jsAPIListIter = factory->NewJSAPIListIterator(jsAPIList);
1427                 DUMP_FOR_HANDLE(jsAPIListIter);
1428                 break;
1429             }
1430             case JSType::JS_API_LINKED_LIST_ITERATOR: {
1431                 // 2 : 2 dump fileds number
1432                 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedListIterator::SIZE, 2U);
1433                 JSHandle<JSAPILinkedList> jsAPILinkedList = NewJSAPILinkedList(thread, factory);
1434                 JSHandle<JSAPILinkedListIterator> jsAPILinkedListIter =
1435                     factory->NewJSAPILinkedListIterator(jsAPILinkedList);
1436                 DUMP_FOR_HANDLE(jsAPILinkedListIter);
1437                 break;
1438             }
1439             case JSType::MODULE_RECORD: {
1440                 CHECK_DUMP_FIELDS(Record::SIZE, ModuleRecord::SIZE, 0U);
1441                 break;
1442             }
1443             case JSType::SOURCE_TEXT_MODULE_RECORD: {
1444                 CHECK_DUMP_FIELDS(ModuleRecord::SIZE, SourceTextModule::SIZE, 20U);
1445                 JSHandle<SourceTextModule> moduleSourceRecord = factory->NewSourceTextModule();
1446                 DUMP_FOR_HANDLE(moduleSourceRecord);
1447                 break;
1448             }
1449             case JSType::IMPORTENTRY_RECORD: {
1450                 CHECK_DUMP_FIELDS(Record::SIZE, ImportEntry::SIZE, 3U);
1451                 JSHandle<ImportEntry> importEntry = factory->NewImportEntry();
1452                 DUMP_FOR_HANDLE(importEntry);
1453                 break;
1454             }
1455             case JSType::LOCAL_EXPORTENTRY_RECORD: {
1456                 CHECK_DUMP_FIELDS(Record::SIZE, LocalExportEntry::SIZE, 3U);
1457                 JSHandle<LocalExportEntry> localExportEntry = factory->NewLocalExportEntry();
1458                 DUMP_FOR_HANDLE(localExportEntry);
1459                 break;
1460             }
1461             case JSType::INDIRECT_EXPORTENTRY_RECORD: {
1462                 CHECK_DUMP_FIELDS(Record::SIZE, IndirectExportEntry::SIZE, 3U);
1463                 JSHandle<IndirectExportEntry> indirectExportEntry = factory->NewIndirectExportEntry();
1464                 DUMP_FOR_HANDLE(indirectExportEntry);
1465                 break;
1466             }
1467             case JSType::STAR_EXPORTENTRY_RECORD: {
1468                 CHECK_DUMP_FIELDS(Record::SIZE, StarExportEntry::SIZE, 1U);
1469                 break;
1470             }
1471             case JSType::RESOLVEDBINDING_RECORD: {
1472                 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedBinding::SIZE, 2U);
1473                 JSHandle<ResolvedBinding> resolvedBinding = factory->NewResolvedBindingRecord();
1474                 DUMP_FOR_HANDLE(resolvedBinding);
1475                 break;
1476             }
1477             case JSType::RESOLVEDINDEXBINDING_RECORD: {
1478                 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedIndexBinding::SIZE, 2U);
1479                 JSHandle<ResolvedIndexBinding> resolvedBinding = factory->NewResolvedIndexBindingRecord();
1480                 DUMP_FOR_HANDLE(resolvedBinding);
1481                 break;
1482             }
1483             case JSType::RESOLVEDRECORDINDEXBINDING_RECORD: {
1484                 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordIndexBinding::SIZE, 3U);
1485                 JSHandle<ResolvedRecordIndexBinding> recordBinding = factory->NewSResolvedRecordIndexBindingRecord();
1486                 DUMP_FOR_HANDLE(recordBinding);
1487                 break;
1488             }
1489             case JSType::RESOLVEDRECORDBINDING_RECORD: {
1490                 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordBinding::SIZE, 2U);
1491                 JSHandle<ResolvedRecordBinding> recordBinding = factory->NewSResolvedRecordBindingRecord();
1492                 DUMP_FOR_HANDLE(recordBinding);
1493                 break;
1494             }
1495             case JSType::JS_MODULE_NAMESPACE: {
1496                 CHECK_DUMP_FIELDS(JSObject::SIZE, ModuleNamespace::SIZE, 3U);
1497                 JSHandle<ModuleNamespace> moduleNamespace = factory->NewModuleNamespace();
1498                 DUMP_FOR_HANDLE(moduleNamespace);
1499                 break;
1500             }
1501             case JSType::NATIVE_MODULE_FAILURE_INFO: {
1502                 CHECK_DUMP_FIELDS(JSObject::SIZE, NativeModuleFailureInfo::SIZE, 1U);
1503                 JSHandle<NativeModuleFailureInfo> nativeFailureInfo = factory->NewNativeModuleFailureInfo();
1504                 DUMP_FOR_HANDLE(nativeFailureInfo);
1505                 break;
1506             }
1507             case JSType::JS_CJS_EXPORTS: {
1508                 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsExports::SIZE, 1U);
1509                 JSHandle<CjsExports> cjsExports = factory->NewCjsExports();
1510                 DUMP_FOR_HANDLE(cjsExports);
1511                 break;
1512             }
1513             case JSType::JS_CJS_MODULE: {
1514                 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsModule::SIZE, 5U);
1515                 JSHandle<CjsModule> cjsModule = factory->NewCjsModule();
1516                 DUMP_FOR_HANDLE(cjsModule);
1517                 break;
1518             }
1519             case JSType::JS_CJS_REQUIRE: {
1520                 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsRequire::SIZE, 2U);
1521                 JSHandle<CjsRequire> cjsRequire = factory->NewCjsRequire();
1522                 DUMP_FOR_HANDLE(cjsRequire);
1523                 break;
1524             }
1525             case JSType::JS_ITERATOR:
1526             case JSType::JS_ASYNCITERATOR:
1527             case JSType::FREE_OBJECT_WITH_ONE_FIELD:
1528             case JSType::FREE_OBJECT_WITH_NONE_FIELD:
1529             case JSType::FREE_OBJECT_WITH_TWO_FIELD:
1530             case JSType::JS_NATIVE_POINTER: {
1531                 break;
1532             }
1533             case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN: {
1534                 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorResNextRetProRstFtn::SIZE, 1U);
1535                 break;
1536             }
1537             case JSType::CLASS_LITERAL: {
1538                 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassLiteral::SIZE, 2U);
1539                 JSHandle<ClassLiteral> classLiteral = factory->NewClassLiteral();
1540                 DUMP_FOR_HANDLE(classLiteral);
1541                 break;
1542             }
1543             default:
1544                 LOG_ECMA_MEM(FATAL) << "JSType " << static_cast<int>(type) << " cannot be dumped.";
1545                 UNREACHABLE();
1546                 break;
1547         }
1548     }
1549 #undef NEW_OBJECT_AND_DUMP
1550 #undef DUMP_FOR_HANDLE
1551 }
1552 }  // namespace panda::test
1553