1 /*
2 * Copyright (c) 2021-2025 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(thread, os);
160
161 JSTaggedValue value2(100.0);
162 JSTaggedValue(value2.GetRawData()).Dump(thread, os);
163
164 JSTaggedValue::Undefined().Dump(thread, os);
165 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
166 env.GetTaggedValue().Dump(thread, os);
167
168 JSHandle<JSFunction> objFunc(env->GetObjectFunction());
169 objFunc.GetTaggedValue().Dump(thread, 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->NewSharedOldSpaceJSObjectWithInit(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->NewSharedOldSpaceJSObjectWithInit(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(thread, os); \
474 dumpValue.DumpForSnapshot(thread, 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 = 42;
486 #else
487 static const unsigned int machineCodeSize = 26;
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_XREF_OBJECT: {
519 CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U);
520 JSHandle<JSTaggedValue> jsXRefObject(factory->NewJSXRefObject());
521 DUMP_FOR_HANDLE(jsXRefObject);
522 break;
523 }
524 case JSType::JS_REALM: {
525 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRealm::SIZE, 2U);
526 JSHandle<JSRealm> jsRealm = factory->NewJSRealm();
527 DUMP_FOR_HANDLE(jsRealm);
528 break;
529 }
530 case JSType::METHOD: {
531 #ifdef PANDA_TARGET_64
532 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U);
533 #else
534 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U);
535 #endif
536 break;
537 }
538 case JSType::JS_FUNCTION_BASE: {
539 CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 3U);
540 break;
541 }
542 case JSType::JS_FUNCTION:
543 case JSType::JS_SHARED_FUNCTION: {
544 CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 8U);
545 JSHandle<JSTaggedValue> jsFunc = globalEnv->GetFunctionFunction();
546 DUMP_FOR_HANDLE(jsFunc);
547 break;
548 }
549 case JSType::JS_PROXY_REVOC_FUNCTION: {
550 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSProxyRevocFunction::SIZE, 1U);
551 JSHandle<JSHClass> proxyRevocClass =
552 JSHandle<JSHClass>::Cast(globalEnv->GetProxyRevocFunctionClass());
553 JSHandle<JSObject> proxyRevocFunc = factory->NewJSObjectWithInit(proxyRevocClass);
554 DUMP_FOR_HANDLE(proxyRevocFunc);
555 break;
556 }
557 case JSType::JS_PROMISE_REACTIONS_FUNCTION: {
558 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseReactionsFunction::SIZE, 2U);
559 JSHandle<JSHClass> promiseReactClass =
560 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseReactionFunctionClass());
561 JSHandle<JSObject> promiseReactFunc = factory->NewJSObjectWithInit(promiseReactClass);
562 DUMP_FOR_HANDLE(promiseReactFunc);
563 break;
564 }
565 case JSType::JS_PROMISE_EXECUTOR_FUNCTION: {
566 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseExecutorFunction::SIZE, 1U);
567 JSHandle<JSHClass> promiseExeClass =
568 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseExecutorFunctionClass());
569 JSHandle<JSObject> promiseExeFunc = factory->NewJSObjectWithInit(promiseExeClass);
570 DUMP_FOR_HANDLE(promiseExeFunc);
571 break;
572 }
573 case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION: {
574 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleFulfilledFunction::SIZE, 0U);
575 JSHandle<JSHClass> moduleFulfilledClass =
576 JSHandle<JSHClass>::Cast(globalEnv->GetAsyncModuleFulfilledFunctionClass());
577 JSHandle<JSObject> moduleFulfilledFunc = factory->NewJSObjectWithInit(moduleFulfilledClass);
578 DUMP_FOR_HANDLE(moduleFulfilledFunc);
579 break;
580 }
581 case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION: {
582 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleRejectedFunction::SIZE, 0U);
583 JSHandle<JSHClass> moduleRejectedClass =
584 JSHandle<JSHClass>::Cast(globalEnv->GetAsyncModuleRejectedFunctionClass());
585 JSHandle<JSObject> moduleRejectedFunc = factory->NewJSObjectWithInit(moduleRejectedClass);
586 DUMP_FOR_HANDLE(moduleRejectedFunc);
587 break;
588 }
589 case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION: {
590 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllResolveElementFunction::SIZE, 5U);
591 JSHandle<JSHClass> promiseAllClass =
592 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAllResolveElementFunctionClass());
593 JSHandle<JSObject> promiseAllFunc = factory->NewJSObjectWithInit(promiseAllClass);
594 DUMP_FOR_HANDLE(promiseAllFunc);
595 break;
596 }
597 case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION: {
598 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAnyRejectElementFunction::SIZE, 5U);
599 JSHandle<JSHClass> promiseAnyClass =
600 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAnyRejectElementFunctionClass());
601 JSHandle<JSObject> promiseAnyFunc = factory->NewJSObjectWithInit(promiseAnyClass);
602 DUMP_FOR_HANDLE(promiseAnyFunc);
603 break;
604 }
605 case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION: {
606 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllSettledElementFunction::SIZE, 5U);
607 JSHandle<JSHClass> promiseAllSettledClass =
608 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseAllSettledElementFunctionClass());
609 JSHandle<JSObject> promiseAllSettledFunc = factory->NewJSObjectWithInit(promiseAllSettledClass);
610 DUMP_FOR_HANDLE(promiseAllSettledFunc);
611 break;
612 }
613 case JSType::JS_PROMISE_FINALLY_FUNCTION: {
614 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseFinallyFunction::SIZE, 2U);
615 JSHandle<JSHClass> promiseFinallyClass =
616 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseFinallyFunctionClass());
617 JSHandle<JSObject> promiseFinallyFunc = factory->NewJSObjectWithInit(promiseFinallyClass);
618 DUMP_FOR_HANDLE(promiseFinallyFunc);
619 break;
620 }
621 case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION: {
622 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseValueThunkOrThrowerFunction::SIZE, 1U);
623 JSHandle<JSHClass> promiseValueClass =
624 JSHandle<JSHClass>::Cast(globalEnv->GetPromiseValueThunkOrThrowerFunctionClass());
625 JSHandle<JSObject> promiseValueFunc = factory->NewJSObjectWithInit(promiseValueClass);
626 DUMP_FOR_HANDLE(promiseValueFunc);
627 break;
628 }
629 case JSType::JS_ASYNC_GENERATOR_FUNCTION: {
630 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorFunction::SIZE, 0U);
631 break;
632 }
633 case JSType::JS_GENERATOR_FUNCTION: {
634 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSGeneratorFunction::SIZE, 0U);
635 break;
636 }
637 case JSType::JS_ASYNC_FUNCTION:
638 case JSType::JS_SHARED_ASYNC_FUNCTION: {
639 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFunction::SIZE, 0U);
640 break;
641 }
642 case JSType::JS_INTL_BOUND_FUNCTION: {
643 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSIntlBoundFunction::SIZE, 3U);
644 JSHandle<JSIntlBoundFunction> intlBoundFunc = factory->NewJSIntlBoundFunction(
645 MethodIndex::BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER);
646 DUMP_FOR_HANDLE(intlBoundFunc);
647 break;
648 }
649 case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION: {
650 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncAwaitStatusFunction::SIZE, 1U);
651 JSHandle<JSAsyncAwaitStatusFunction> asyncAwaitFunc = factory->NewJSAsyncAwaitStatusFunction(
652 MethodIndex::BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED);
653 DUMP_FOR_HANDLE(asyncAwaitFunc);
654 break;
655 }
656 case JSType::JS_BOUND_FUNCTION: {
657 CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSBoundFunction::SIZE, 3U);
658 NEW_OBJECT_AND_DUMP(JSBoundFunction, JS_BOUND_FUNCTION);
659 break;
660 }
661 case JSType::JS_REG_EXP: {
662 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExp::SIZE, 5U);
663 NEW_OBJECT_AND_DUMP(JSRegExp, JS_REG_EXP);
664 break;
665 }
666 case JSType::JS_SET: {
667 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSet::SIZE, 1U);
668 JSHandle<JSSet> jsSet = NewJSSet(thread, factory, proto);
669 DUMP_FOR_HANDLE(jsSet);
670 break;
671 }
672 case JSType::JS_SHARED_SET: {
673 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSet::SIZE, 2U);
674 JSHandle<JSSharedSet> jsSet = NewJSSharedSet(thread, factory);
675 DUMP_FOR_HANDLE(jsSet);
676 break;
677 }
678 case JSType::JS_MAP: {
679 CHECK_DUMP_FIELDS(JSObject::SIZE, JSMap::SIZE, 1U);
680 JSHandle<JSMap> jsMap = NewJSMap(thread, factory, proto);
681 DUMP_FOR_HANDLE(jsMap);
682 break;
683 }
684 case JSType::JS_SHARED_MAP: {
685 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMap::SIZE, 2U);
686 JSHandle<JSSharedMap> jsMap = NewJSSharedMap(thread, factory);
687 DUMP_FOR_HANDLE(jsMap);
688 break;
689 }
690 case JSType::JS_WEAK_MAP: {
691 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakMap::SIZE, 1U);
692 JSHandle<JSHClass> weakMapClass = factory->NewEcmaHClass(JSWeakMap::SIZE, JSType::JS_WEAK_MAP, proto);
693 JSHandle<JSWeakMap> jsWeakMap = JSHandle<JSWeakMap>::Cast(factory->NewJSObjectWithInit(weakMapClass));
694 JSHandle<LinkedHashMap> weakLinkedMap(LinkedHashMap::Create(thread));
695 jsWeakMap->SetLinkedMap(thread, weakLinkedMap);
696 DUMP_FOR_HANDLE(jsWeakMap);
697 break;
698 }
699 case JSType::JS_WEAK_SET: {
700 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakSet::SIZE, 1U);
701 JSHandle<JSHClass> weakSetClass = factory->NewEcmaHClass(JSWeakSet::SIZE, JSType::JS_WEAK_SET, proto);
702 JSHandle<JSWeakSet> jsWeakSet = JSHandle<JSWeakSet>::Cast(factory->NewJSObjectWithInit(weakSetClass));
703 JSHandle<LinkedHashSet> weakLinkedSet(LinkedHashSet::Create(thread));
704 jsWeakSet->SetLinkedSet(thread, weakLinkedSet);
705 DUMP_FOR_HANDLE(jsWeakSet);
706 break;
707 }
708 case JSType::JS_WEAK_REF: {
709 CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakRef::SIZE, 1U);
710 JSHandle<JSHClass> weakRefClass = factory->NewEcmaHClass(JSWeakRef::SIZE, JSType::JS_WEAK_REF, proto);
711 JSHandle<JSWeakRef> jsWeakRef = JSHandle<JSWeakRef>::Cast(factory->NewJSObjectWithInit(weakRefClass));
712 jsWeakRef->SetWeakObject(thread, JSTaggedValue::Undefined());
713 DUMP_FOR_HANDLE(jsWeakRef);
714 break;
715 }
716 case JSType::JS_FINALIZATION_REGISTRY: {
717 CHECK_DUMP_FIELDS(JSObject::SIZE, JSFinalizationRegistry::SIZE, 5U);
718 JSHandle<JSHClass> finalizationRegistryClass =
719 factory->NewEcmaHClass(JSFinalizationRegistry::SIZE, JSType::JS_FINALIZATION_REGISTRY, proto);
720 JSHandle<JSFinalizationRegistry> jsFinalizationRegistry =
721 JSHandle<JSFinalizationRegistry>::Cast(factory->NewJSObjectWithInit(finalizationRegistryClass));
722 JSHandle<LinkedHashMap> weakLinkedMap(LinkedHashMap::Create(thread));
723 jsFinalizationRegistry->SetMaybeUnregister(thread, weakLinkedMap);
724 DUMP_FOR_HANDLE(jsFinalizationRegistry);
725 break;
726 }
727 case JSType::CELL_RECORD: {
728 CHECK_DUMP_FIELDS(Record::SIZE, CellRecord::SIZE, 2U);
729 JSHandle<CellRecord> cellRecord = factory->NewCellRecord();
730 DUMP_FOR_HANDLE(cellRecord);
731 break;
732 }
733 case JSType::JS_DATE: {
734 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDate::SIZE, 2U);
735 JSHandle<JSHClass> dateClass = factory->NewEcmaHClass(JSDate::SIZE, JSType::JS_DATE, proto);
736 JSHandle<JSDate> date = JSHandle<JSDate>::Cast(factory->NewJSObjectWithInit(dateClass));
737 date->SetTimeValue(thread, JSTaggedValue(0.0));
738 date->SetLocalOffset(thread, JSTaggedValue(0.0));
739 DUMP_FOR_HANDLE(date);
740 break;
741 }
742 case JSType::JS_FORIN_ITERATOR: {
743 CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 5U);
744 JSHandle<JSTaggedValue> array(thread, factory->NewJSArray().GetTaggedValue());
745 JSHandle<JSTaggedValue> keys(thread, factory->EmptyArray().GetTaggedValue());
746 JSHandle<JSTaggedValue> hclass(thread, JSTaggedValue::Undefined());
747 JSHandle<JSForInIterator> forInIter =
748 factory->NewJSForinIterator(array, keys, hclass, static_cast<uint32_t>(EnumCacheKind::NONE));
749 DUMP_FOR_HANDLE(forInIter);
750 break;
751 }
752 case JSType::JS_MAP_ITERATOR: {
753 CHECK_DUMP_FIELDS(JSObject::SIZE, JSMapIterator::SIZE, 2U);
754 JSHandle<JSMapIterator> jsMapIter =
755 factory->NewJSMapIterator(NewJSMap(thread, factory, proto), IterationKind::KEY);
756 DUMP_FOR_HANDLE(jsMapIter);
757 break;
758 }
759 case JSType::JS_SHARED_MAP_ITERATOR: {
760 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMapIterator::SIZE, 2U);
761 JSHandle<JSSharedMapIterator> jsMapIter =
762 factory->NewJSMapIterator(NewJSSharedMap(thread, factory), IterationKind::KEY);
763 DUMP_FOR_HANDLE(jsMapIter);
764 break;
765 }
766 case JSType::JS_SET_ITERATOR: {
767 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSetIterator::SIZE, 2U);
768 JSHandle<JSSetIterator> jsSetIter =
769 factory->NewJSSetIterator(NewJSSet(thread, factory, proto), IterationKind::KEY);
770 DUMP_FOR_HANDLE(jsSetIter);
771 break;
772 }
773 case JSType::JS_SHARED_SET_ITERATOR: {
774 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSetIterator::SIZE, 2U);
775 JSHandle<JSSharedSetIterator> jsSetIter =
776 factory->NewJSSetIterator(NewJSSharedSet(thread, factory), IterationKind::KEY);
777 DUMP_FOR_HANDLE(jsSetIter);
778 break;
779 }
780 case JSType::JS_REG_EXP_ITERATOR: {
781 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExpIterator::SIZE, 3U);
782 JSHandle<EcmaString> emptyString(thread->GlobalConstants()->GetHandledEmptyString());
783 JSHandle<JSTaggedValue> jsRegExp(NewJSRegExp(thread, factory, proto));
784 JSHandle<JSRegExpIterator> jsRegExpIter =
785 factory->NewJSRegExpIterator(jsRegExp, emptyString, false, false);
786 DUMP_FOR_HANDLE(jsRegExpIter);
787 break;
788 }
789 case JSType::JS_ARRAY_ITERATOR: {
790 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U);
791 JSHandle<JSArrayIterator> arrayIter =
792 factory->NewJSArrayIterator(JSHandle<JSObject>::Cast(factory->NewJSArray()), IterationKind::KEY);
793 DUMP_FOR_HANDLE(arrayIter);
794 break;
795 }
796 case JSType::JS_SHARED_ARRAY_ITERATOR: {
797 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U);
798 JSHandle<JSSharedArrayIterator> arrayIter = factory->NewJSSharedArrayIterator(
799 JSHandle<JSObject>::Cast(factory->NewJSSArray()), IterationKind::KEY);
800 DUMP_FOR_HANDLE(arrayIter);
801 break;
802 }
803 case JSType::JS_STRING_ITERATOR: {
804 CHECK_DUMP_FIELDS(JSObject::SIZE, JSStringIterator::SIZE, 2U);
805 JSHandle<JSTaggedValue> stringIter = globalEnv->GetStringIterator();
806 DUMP_FOR_HANDLE(stringIter);
807 break;
808 }
809 case JSType::JS_INTL: {
810 CHECK_DUMP_FIELDS(JSObject::SIZE, JSIntl::SIZE, 1U);
811 NEW_OBJECT_AND_DUMP(JSIntl, JS_INTL);
812 break;
813 }
814 case JSType::JS_LOCALE: {
815 CHECK_DUMP_FIELDS(JSObject::SIZE, JSLocale::SIZE, 1U);
816 NEW_OBJECT_AND_DUMP(JSLocale, JS_LOCALE);
817 break;
818 }
819 case JSType::JS_DATE_TIME_FORMAT: {
820 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDateTimeFormat::SIZE, 9U);
821 NEW_OBJECT_AND_DUMP(JSDateTimeFormat, JS_DATE_TIME_FORMAT);
822 break;
823 }
824 case JSType::JS_RELATIVE_TIME_FORMAT: {
825 CHECK_DUMP_FIELDS(JSObject::SIZE, JSRelativeTimeFormat::SIZE, 4U);
826 NEW_OBJECT_AND_DUMP(JSRelativeTimeFormat, JS_RELATIVE_TIME_FORMAT);
827 break;
828 }
829 case JSType::JS_NUMBER_FORMAT: {
830 CHECK_DUMP_FIELDS(JSObject::SIZE, JSNumberFormat::SIZE, 13U);
831 NEW_OBJECT_AND_DUMP(JSNumberFormat, JS_NUMBER_FORMAT);
832 break;
833 }
834 case JSType::JS_COLLATOR: {
835 CHECK_DUMP_FIELDS(JSObject::SIZE, JSCollator::SIZE, 5U);
836 NEW_OBJECT_AND_DUMP(JSCollator, JS_COLLATOR);
837 break;
838 }
839 case JSType::JS_PLURAL_RULES: {
840 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPluralRules::SIZE, 9U);
841 NEW_OBJECT_AND_DUMP(JSPluralRules, JS_PLURAL_RULES);
842 break;
843 }
844 case JSType::JS_DISPLAYNAMES: {
845 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDisplayNames::SIZE, 3U);
846 NEW_OBJECT_AND_DUMP(JSDisplayNames, JS_DISPLAYNAMES);
847 break;
848 }
849 case JSType::JS_SEGMENTER: {
850 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmenter::SIZE, 3U);
851 NEW_OBJECT_AND_DUMP(JSSegmenter, JS_SEGMENTER);
852 break;
853 }
854 case JSType::JS_SEGMENTS: {
855 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegments::SIZE, 4U);
856 NEW_OBJECT_AND_DUMP(JSSegments, JS_SEGMENTS);
857 break;
858 }
859 case JSType::JS_SEGMENT_ITERATOR: {
860 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmentIterator::SIZE, 4U);
861 NEW_OBJECT_AND_DUMP(JSSegmentIterator, JS_SEGMENTS);
862 break;
863 }
864 case JSType::JS_LIST_FORMAT: {
865 CHECK_DUMP_FIELDS(JSObject::SIZE, JSListFormat::SIZE, 3U);
866 NEW_OBJECT_AND_DUMP(JSListFormat, JS_LIST_FORMAT);
867 break;
868 }
869 case JSType::JS_SHARED_ARRAY_BUFFER:
870 case JSType::JS_ARRAY_BUFFER: {
871 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayBuffer::SIZE, 2U);
872 NEW_OBJECT_AND_DUMP(JSArrayBuffer, JS_ARRAY_BUFFER);
873 break;
874 }
875 case JSType::JS_SENDABLE_ARRAY_BUFFER: {
876 CHECK_DUMP_FIELDS(JSObject::SIZE, JSSendableArrayBuffer::SIZE, 2U);
877 NEW_OBJECT_AND_DUMP(JSSendableArrayBuffer, JS_SENDABLE_ARRAY_BUFFER);
878 break;
879 }
880 case JSType::JS_PROMISE: {
881 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPromise::SIZE, 4U);
882 NEW_OBJECT_AND_DUMP(JSPromise, JS_PROMISE);
883 break;
884 }
885 case JSType::JS_DATA_VIEW: {
886 CHECK_DUMP_FIELDS(JSObject::SIZE, JSDataView::SIZE, 3U);
887 NEW_OBJECT_AND_DUMP(JSDataView, JS_DATA_VIEW);
888 break;
889 }
890 case JSType::JS_GENERATOR_OBJECT: {
891 CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 4U);
892 NEW_OBJECT_AND_DUMP(JSGeneratorObject, JS_GENERATOR_OBJECT);
893 break;
894 }
895 case JSType::JS_ASYNC_GENERATOR_OBJECT: {
896 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncGeneratorObject::SIZE, 5U);
897 NEW_OBJECT_AND_DUMP(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT);
898 break;
899 }
900 case JSType::JS_ASYNC_FUNC_OBJECT: {
901 CHECK_DUMP_FIELDS(JSGeneratorObject::SIZE, JSAsyncFuncObject::SIZE, 1U);
902 JSHandle<JSAsyncFuncObject> asyncFuncObject = factory->NewJSAsyncFuncObject();
903 DUMP_FOR_HANDLE(asyncFuncObject);
904 break;
905 }
906 case JSType::JS_ARRAY: {
907 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U);
908 JSHandle<JSArray> jsArray = factory->NewJSArray();
909 DUMP_FOR_HANDLE(jsArray);
910 break;
911 }
912 case JSType::JS_SHARED_ARRAY: {
913 CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U);
914 JSHandle<JSSharedArray> jsArray = factory->NewJSSArray();
915 DUMP_FOR_HANDLE(jsArray);
916 break;
917 }
918 case JSType::JS_TYPED_ARRAY:
919 case JSType::JS_INT8_ARRAY:
920 case JSType::JS_UINT8_ARRAY:
921 case JSType::JS_UINT8_CLAMPED_ARRAY:
922 case JSType::JS_INT16_ARRAY:
923 case JSType::JS_UINT16_ARRAY:
924 case JSType::JS_INT32_ARRAY:
925 case JSType::JS_UINT32_ARRAY:
926 case JSType::JS_FLOAT32_ARRAY:
927 case JSType::JS_FLOAT64_ARRAY:
928 case JSType::JS_BIGINT64_ARRAY:
929 case JSType::JS_BIGUINT64_ARRAY: {
930 CHECK_DUMP_FIELDS(JSObject::SIZE, JSTypedArray::SIZE, 4U);
931 NEW_OBJECT_AND_DUMP(JSTypedArray, JS_TYPED_ARRAY);
932 break;
933 }
934 case JSType::JS_SHARED_TYPED_ARRAY:
935 case JSType::JS_SHARED_INT8_ARRAY:
936 case JSType::JS_SHARED_UINT8_ARRAY:
937 case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY:
938 case JSType::JS_SHARED_INT16_ARRAY:
939 case JSType::JS_SHARED_UINT16_ARRAY:
940 case JSType::JS_SHARED_INT32_ARRAY:
941 case JSType::JS_SHARED_UINT32_ARRAY:
942 case JSType::JS_SHARED_FLOAT32_ARRAY:
943 case JSType::JS_SHARED_FLOAT64_ARRAY:
944 case JSType::JS_SHARED_BIGINT64_ARRAY:
945 case JSType::JS_SHARED_BIGUINT64_ARRAY: {
946 // Fixme(Gymee) Add test later
947 break;
948 }
949 case JSType::JS_PRIMITIVE_REF: {
950 CHECK_DUMP_FIELDS(JSObject::SIZE, JSPrimitiveRef::SIZE, 1U);
951 NEW_OBJECT_AND_DUMP(JSPrimitiveRef, JS_PRIMITIVE_REF);
952 break;
953 }
954 case JSType::JS_GLOBAL_OBJECT: {
955 CHECK_DUMP_FIELDS(JSObject::SIZE, JSGlobalObject::SIZE, 0U);
956 JSHandle<JSTaggedValue> globalObject = globalEnv->GetJSGlobalObject();
957 DUMP_FOR_HANDLE(globalObject);
958 break;
959 }
960 case JSType::JS_PROXY: {
961 CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSProxy::SIZE, 5U);
962 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
963 JSHandle<JSProxy> proxy = factory->NewJSProxy(emptyObj, emptyObj);
964 DUMP_FOR_HANDLE(proxy);
965 break;
966 }
967 case JSType::HCLASS: {
968 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSHClass::SIZE, 10U);
969 JSHandle<JSHClass> hclass = factory->NewEcmaHClass(JSHClass::SIZE, JSType::HCLASS, proto);
970 DUMP_FOR_HANDLE(hclass);
971 break;
972 }
973 case JSType::LINE_STRING:
974 case JSType::TREE_STRING:
975 case JSType::SLICED_STRING: {
976 DUMP_FOR_HANDLE(globalEnv->GetObjectFunction());
977 break;
978 }
979 case JSType::BIGINT: {
980 DUMP_FOR_HANDLE(globalEnv->GetBigIntFunction());
981 break;
982 }
983 case JSType::PROFILE_TYPE_INFO_CELL_0:
984 case JSType::PROFILE_TYPE_INFO_CELL_1:
985 case JSType::PROFILE_TYPE_INFO_CELL_N: {
986 JSHandle<JSTaggedValue> handleUndefined(thread, JSTaggedValue::Undefined());
987 JSHandle<ProfileTypeInfoCell> profileTypeInfoCell = factory->NewProfileTypeInfoCell(handleUndefined);
988 DUMP_FOR_HANDLE(profileTypeInfoCell);
989 break;
990 }
991 case JSType::FUNCTION_TEMPLATE: {
992 auto method = JSFunction::Cast(globalEnv->GetTaggedObjectFunction())->GetMethod(thread);
993 JSHandle<Method> methodHandle(thread, method);
994 JSHandle<JSTaggedValue> handleUndefined(thread, JSTaggedValue::Undefined());
995 JSHandle<FunctionTemplate> funcTemp = factory->NewFunctionTemplate(methodHandle, handleUndefined, 0);
996 DUMP_FOR_HANDLE(funcTemp);
997 break;
998 }
999 case JSType::TAGGED_ARRAY:
1000 case JSType::VTABLE:
1001 case JSType::LEXICAL_ENV:
1002 case JSType::SFUNCTION_ENV:
1003 case JSType::SENDABLE_ENV:
1004 case JSType::AOT_LITERAL_INFO: {
1005 JSHandle<TaggedArray> taggedArray = factory->NewTaggedArray(4);
1006 DUMP_FOR_HANDLE(taggedArray);
1007 break;
1008 }
1009 case JSType::CONSTANT_POOL: {
1010 JSHandle<ConstantPool> constantPool = factory->NewConstantPool(4);
1011 DUMP_FOR_HANDLE(constantPool);
1012 break;
1013 }
1014 case JSType::PROFILE_TYPE_INFO: {
1015 JSHandle<ProfileTypeInfo> info = factory->NewProfileTypeInfo(4);
1016 DUMP_FOR_HANDLE(info);
1017 break;
1018 }
1019 case JSType::EXTRA_PROFILE_TYPE_INFO: {
1020 JSHandle<ExtraProfileTypeInfo> info = factory->NewExtraProfileTypeInfo();
1021 DUMP_FOR_HANDLE(info);
1022 break;
1023 }
1024 case JSType::TAGGED_DICTIONARY: {
1025 JSHandle<TaggedArray> dict = factory->NewDictionaryArray(4);
1026 DUMP_FOR_HANDLE(dict);
1027 break;
1028 }
1029 case JSType::BYTE_ARRAY: {
1030 JSHandle<ByteArray> byteArray = factory->NewByteArray(4, 8);
1031 DUMP_FOR_HANDLE(byteArray);
1032 break;
1033 }
1034 case JSType::COW_TAGGED_ARRAY: {
1035 JSHandle<COWTaggedArray> dict = factory->NewCOWTaggedArray(4);
1036 DUMP_FOR_HANDLE(dict);
1037 break;
1038 }
1039 case JSType::MUTANT_TAGGED_ARRAY: {
1040 JSHandle<MutantTaggedArray> array = factory->NewMutantTaggedArray(4);
1041 DUMP_FOR_HANDLE(array);
1042 break;
1043 }
1044 case JSType::COW_MUTANT_TAGGED_ARRAY: {
1045 JSHandle<COWMutantTaggedArray> array = factory->NewCOWMutantTaggedArray(4);
1046 DUMP_FOR_HANDLE(array);
1047 break;
1048 }
1049 case JSType::GLOBAL_ENV: {
1050 DUMP_FOR_HANDLE(globalEnv);
1051 break;
1052 }
1053 case JSType::ACCESSOR_DATA:
1054 case JSType::INTERNAL_ACCESSOR: {
1055 CHECK_DUMP_FIELDS(Record::SIZE, AccessorData::SIZE, 2U);
1056 JSHandle<AccessorData> accessor = factory->NewAccessorData();
1057 DUMP_FOR_HANDLE(accessor);
1058 break;
1059 }
1060 case JSType::SYMBOL: {
1061 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSSymbol::SIZE, 3U);
1062 JSHandle<JSSymbol> symbol = factory->NewJSSymbol();
1063 DUMP_FOR_HANDLE(symbol);
1064 break;
1065 }
1066 case JSType::JS_GENERATOR_CONTEXT: {
1067 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), GeneratorContext::SIZE, 7U);
1068 JSHandle<GeneratorContext> genContext = factory->NewGeneratorContext();
1069 DUMP_FOR_HANDLE(genContext);
1070 break;
1071 }
1072 case JSType::PROTOTYPE_HANDLER: {
1073 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PrototypeHandler::SIZE, 5U);
1074 JSHandle<PrototypeHandler> protoHandler = factory->NewPrototypeHandler();
1075 DUMP_FOR_HANDLE(protoHandler);
1076 break;
1077 }
1078 case JSType::TRANSITION_HANDLER: {
1079 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransitionHandler::SIZE, 2U);
1080 JSHandle<TransitionHandler> transitionHandler = factory->NewTransitionHandler();
1081 DUMP_FOR_HANDLE(transitionHandler);
1082 break;
1083 }
1084 case JSType::TRANS_WITH_PROTO_HANDLER: {
1085 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransWithProtoHandler::SIZE, 3U);
1086 JSHandle<TransWithProtoHandler> transWithProtoHandler = factory->NewTransWithProtoHandler();
1087 DUMP_FOR_HANDLE(transWithProtoHandler);
1088 break;
1089 }
1090 case JSType::STORE_TS_HANDLER: {
1091 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), StoreAOTHandler::SIZE, 3U);
1092 JSHandle<StoreAOTHandler> storeAOTHandler = factory->NewStoreAOTHandler();
1093 DUMP_FOR_HANDLE(storeAOTHandler);
1094 break;
1095 }
1096 case JSType::PROPERTY_BOX: {
1097 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PropertyBox::SIZE, 1U);
1098 JSHandle<PropertyBox> PropertyBox = factory->NewPropertyBox(globalConst->GetHandledEmptyArray());
1099 DUMP_FOR_HANDLE(PropertyBox);
1100 break;
1101 }
1102 case JSType::ENUM_CACHE: {
1103 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), EnumCache::SIZE, 4U);
1104 JSHandle<EnumCache> enumCache = factory->NewEnumCache();
1105 DUMP_FOR_HANDLE(enumCache);
1106 break;
1107 }
1108 case JSType::PROTO_CHANGE_MARKER: {
1109 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeMarker::SIZE, 1U);
1110 JSHandle<ProtoChangeMarker> protoMaker = factory->NewProtoChangeMarker();
1111 DUMP_FOR_HANDLE(protoMaker);
1112 break;
1113 }
1114 case JSType::MARKER_CELL: {
1115 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MarkerCell::SIZE, 1U);
1116 JSHandle<MarkerCell> markerCell = factory->NewMarkerCell();
1117 DUMP_FOR_HANDLE(markerCell);
1118 break;
1119 }
1120 case JSType::TRACK_INFO: {
1121 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TrackInfo::SIZE, 3U);
1122 break;
1123 }
1124 case JSType::PROTOTYPE_INFO: {
1125 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeDetails::SIZE, 2U);
1126 JSHandle<ProtoChangeDetails> protoDetails = factory->NewProtoChangeDetails();
1127 DUMP_FOR_HANDLE(protoDetails);
1128 break;
1129 }
1130 case JSType::TEMPLATE_MAP: {
1131 JSHandle<JSTaggedValue> templateMap = globalEnv->GetTemplateMap();
1132 DUMP_FOR_HANDLE(templateMap);
1133 break;
1134 }
1135 case JSType::PROGRAM: {
1136 CHECK_DUMP_FIELDS(ECMAObject::SIZE, Program::SIZE, 1U);
1137 JSHandle<Program> program = factory->NewProgram();
1138 DUMP_FOR_HANDLE(program);
1139 break;
1140 }
1141 case JSType::PROMISE_CAPABILITY: {
1142 CHECK_DUMP_FIELDS(Record::SIZE, PromiseCapability::SIZE, 3U);
1143 JSHandle<PromiseCapability> promiseCapa = factory->NewPromiseCapability();
1144 DUMP_FOR_HANDLE(promiseCapa);
1145 break;
1146 }
1147 case JSType::PROMISE_RECORD: {
1148 CHECK_DUMP_FIELDS(Record::SIZE, PromiseRecord::SIZE, 1U);
1149 JSHandle<PromiseRecord> promiseRecord = factory->NewPromiseRecord();
1150 DUMP_FOR_HANDLE(promiseRecord);
1151 break;
1152 }
1153 case JSType::RESOLVING_FUNCTIONS_RECORD: {
1154 CHECK_DUMP_FIELDS(Record::SIZE, ResolvingFunctionsRecord::SIZE, 2U);
1155 JSHandle<ResolvingFunctionsRecord> ResolvingFunc = factory->NewResolvingFunctionsRecord();
1156 DUMP_FOR_HANDLE(ResolvingFunc);
1157 break;
1158 }
1159 case JSType::ASYNC_GENERATOR_REQUEST: {
1160 CHECK_DUMP_FIELDS(Record::SIZE, AsyncGeneratorRequest::SIZE, 2U);
1161 JSHandle<AsyncGeneratorRequest> asyncGeneratorRequest = factory->NewAsyncGeneratorRequest();
1162 DUMP_FOR_HANDLE(asyncGeneratorRequest);
1163 break;
1164 }
1165 case JSType::ASYNC_ITERATOR_RECORD: {
1166 CHECK_DUMP_FIELDS(Record::SIZE, AsyncIteratorRecord::SIZE, 3U);
1167 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1168 JSHandle<JSTaggedValue> emptyMethod(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1169 JSHandle<AsyncIteratorRecord> asyncIteratorRecord =
1170 factory->NewAsyncIteratorRecord(emptyObj, emptyMethod, false);
1171 DUMP_FOR_HANDLE(asyncIteratorRecord);
1172 break;
1173 }
1174 case JSType::JS_ASYNC_FROM_SYNC_ITERATOR: {
1175 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncFromSyncIterator::SIZE, 1U);
1176 NEW_OBJECT_AND_DUMP(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR);
1177 break;
1178 }
1179 case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION: {
1180 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFromSyncIterUnwarpFunction::SIZE, 1U);
1181 break;
1182 }
1183 case JSType::PROMISE_REACTIONS: {
1184 CHECK_DUMP_FIELDS(Record::SIZE, PromiseReaction::SIZE, 3U);
1185 JSHandle<PromiseReaction> promiseReact = factory->NewPromiseReaction();
1186 DUMP_FOR_HANDLE(promiseReact);
1187 break;
1188 }
1189 case JSType::PROMISE_ITERATOR_RECORD: {
1190 CHECK_DUMP_FIELDS(Record::SIZE, PromiseIteratorRecord::SIZE, 2U);
1191 JSHandle<JSTaggedValue> emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue());
1192 JSHandle<PromiseIteratorRecord> promiseIter = factory->NewPromiseIteratorRecord(emptyObj, false);
1193 DUMP_FOR_HANDLE(promiseIter);
1194 break;
1195 }
1196 case JSType::MICRO_JOB_QUEUE: {
1197 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::MicroJobQueue::SIZE, 2U);
1198 JSHandle<ecmascript::job::MicroJobQueue> microJob = factory->NewMicroJobQueue();
1199 DUMP_FOR_HANDLE(microJob);
1200 break;
1201 }
1202 case JSType::PENDING_JOB: {
1203 #if defined(ENABLE_HITRACE)
1204 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 7U);
1205 #else
1206 CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 2U);
1207 #endif
1208 JSHandle<JSHClass> pendingClass(thread,
1209 JSHClass::Cast(globalConst->GetPendingJobClass().GetTaggedObject()));
1210 JSHandle<TaggedObject> pendingJob(thread, factory->NewObject(pendingClass));
1211 ecmascript::job::PendingJob::Cast(*pendingJob)->SetJob(thread, JSTaggedValue::Undefined());
1212 ecmascript::job::PendingJob::Cast(*pendingJob)->SetArguments(thread, JSTaggedValue::Undefined());
1213 DUMP_FOR_HANDLE(pendingJob);
1214 break;
1215 }
1216 case JSType::COMPLETION_RECORD: {
1217 CHECK_DUMP_FIELDS(Record::SIZE, CompletionRecord::SIZE, 2U);
1218 JSHandle<CompletionRecord> comRecord =
1219 factory->NewCompletionRecord(CompletionRecordType::NORMAL, globalConst->GetHandledEmptyArray());
1220 DUMP_FOR_HANDLE(comRecord);
1221 break;
1222 }
1223 case JSType::MACHINE_CODE_OBJECT: {
1224 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MachineCode::SIZE, machineCodeSize);
1225 GTEST_LOG_(INFO) << "MACHINE_CODE_OBJECT not support new in MachineCodeSpace";
1226 break;
1227 }
1228 case JSType::CLASS_INFO_EXTRACTOR: {
1229 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 8U);
1230 JSHandle<ClassInfoExtractor> classInfoExtractor = factory->NewClassInfoExtractor(
1231 JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
1232 DUMP_FOR_HANDLE(classInfoExtractor);
1233 break;
1234 }
1235 case JSType::JS_API_ARRAY_LIST: {
1236 // 1 : 1 dump fileds number
1237 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayList::SIZE, 1U);
1238 JSHandle<JSAPIArrayList> jsArrayList = NewJSAPIArrayList(thread, factory, proto);
1239 DUMP_FOR_HANDLE(jsArrayList);
1240 break;
1241 }
1242 case JSType::JS_API_ARRAYLIST_ITERATOR: {
1243 // 2 : 2 dump fileds number
1244 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayListIterator::SIZE, 2U);
1245 JSHandle<JSAPIArrayList> jsArrayList = NewJSAPIArrayList(thread, factory, proto);
1246 JSHandle<JSAPIArrayListIterator> jsArrayListIter = factory->NewJSAPIArrayListIterator(jsArrayList);
1247 DUMP_FOR_HANDLE(jsArrayListIter);
1248 break;
1249 }
1250 case JSType::JS_API_BITVECTOR: {
1251 break;
1252 }
1253 case JSType::JS_API_BITVECTOR_ITERATOR: {
1254 break;
1255 }
1256 case JSType::JS_API_FAST_BUFFER: {
1257 break;
1258 }
1259 case JSType::LINKED_NODE: {
1260 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), LinkedNode::SIZE, 4U);
1261 break;
1262 }
1263 case JSType::RB_TREENODE: {
1264 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), RBTreeNode::SIZE, 7U);
1265 break;
1266 }
1267 case JSType::JS_API_HASH_MAP: {
1268 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMap::SIZE, 2U);
1269 JSHandle<JSAPIHashMap> jsHashMap = NewJSAPIHashMap(thread, factory);
1270 DUMP_FOR_HANDLE(jsHashMap);
1271 break;
1272 }
1273 case JSType::JS_API_HASH_SET: {
1274 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSet::SIZE, 2U);
1275 JSHandle<JSAPIHashSet> jsHashSet = NewJSAPIHashSet(thread, factory);
1276 DUMP_FOR_HANDLE(jsHashSet);
1277 break;
1278 }
1279 case JSType::JS_API_HASHMAP_ITERATOR: {
1280 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMapIterator::SIZE, 4U);
1281 JSHandle<JSAPIHashMap> jsHashMap = NewJSAPIHashMap(thread, factory);
1282 JSHandle<JSAPIHashMapIterator> jsHashMapIter =
1283 factory->NewJSAPIHashMapIterator(jsHashMap, IterationKind::KEY);
1284 DUMP_FOR_HANDLE(jsHashMapIter);
1285 break;
1286 }
1287 case JSType::JS_API_HASHSET_ITERATOR: {
1288 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSetIterator::SIZE, 4U);
1289 JSHandle<JSAPIHashSet> jsHashSet = NewJSAPIHashSet(thread, factory);
1290 JSHandle<JSAPIHashSetIterator> jsHashSetIter =
1291 factory->NewJSAPIHashSetIterator(jsHashSet, IterationKind::KEY);
1292 DUMP_FOR_HANDLE(jsHashSetIter);
1293 break;
1294 }
1295 case JSType::JS_API_LIGHT_WEIGHT_MAP: {
1296 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMap::SIZE, 4U);
1297 JSHandle<JSAPILightWeightMap> jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory);
1298 DUMP_FOR_HANDLE(jSAPILightWeightMap);
1299 break;
1300 }
1301 case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR: {
1302 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMapIterator::SIZE, 2U);
1303 JSHandle<JSAPILightWeightMap> jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory);
1304 JSHandle<JSAPILightWeightMapIterator> jSAPILightWeightMapIterator =
1305 factory->NewJSAPILightWeightMapIterator(jSAPILightWeightMap, IterationKind::KEY);
1306 DUMP_FOR_HANDLE(jSAPILightWeightMapIterator);
1307 break;
1308 }
1309 case JSType::JS_API_LIGHT_WEIGHT_SET: {
1310 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSet::SIZE, 3U);
1311 JSHandle<JSAPILightWeightSet> jSAPILightWeightSet = NewJSAPILightWeightSet(thread, factory);
1312 DUMP_FOR_HANDLE(jSAPILightWeightSet);
1313 break;
1314 }
1315 case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR: {
1316 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSetIterator::SIZE, 2U);
1317 JSHandle<JSAPILightWeightSetIterator> jSAPILightWeightSetIter =
1318 factory->NewJSAPILightWeightSetIterator(NewJSAPILightWeightSet(thread, factory),
1319 IterationKind::KEY);
1320 DUMP_FOR_HANDLE(jSAPILightWeightSetIter);
1321 break;
1322 }
1323 case JSType::JS_API_QUEUE: {
1324 // 2 : 2 dump fileds number
1325 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueue::SIZE, 2U);
1326 JSHandle<JSAPIQueue> jsQueue = NewJSAPIQueue(thread, factory, proto);
1327 DUMP_FOR_HANDLE(jsQueue);
1328 break;
1329 }
1330 case JSType::JS_API_QUEUE_ITERATOR: {
1331 // 2 : 2 dump fileds number
1332 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueueIterator::SIZE, 2U);
1333 JSHandle<JSAPIQueue> jsQueue = NewJSAPIQueue(thread, factory, proto);
1334 JSHandle<JSAPIQueueIterator> jsQueueIter =
1335 factory->NewJSAPIQueueIterator(jsQueue);
1336 DUMP_FOR_HANDLE(jsQueueIter);
1337 break;
1338 }
1339 case JSType::JS_API_PLAIN_ARRAY: {
1340 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArray::SIZE, 3U);
1341 JSHandle<JSAPIPlainArray> jSAPIPlainArray = NewJSAPIPlainArray(thread, factory);
1342 DUMP_FOR_HANDLE(jSAPIPlainArray);
1343 break;
1344 }
1345 case JSType::JS_API_PLAIN_ARRAY_ITERATOR: {
1346 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArrayIterator::SIZE, 2U);
1347 JSHandle<JSAPIPlainArray> jSAPIPlainArray = NewJSAPIPlainArray(thread, factory);
1348 JSHandle<JSAPIPlainArrayIterator> jSAPIPlainArrayIter =
1349 factory->NewJSAPIPlainArrayIterator(jSAPIPlainArray, IterationKind::KEY);
1350 DUMP_FOR_HANDLE(jSAPIPlainArrayIter);
1351 break;
1352 }
1353 case JSType::JS_API_TREE_MAP: {
1354 // 1 : 1 dump fileds number
1355 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMap::SIZE, 1U);
1356 JSHandle<JSAPITreeMap> jsTreeMap = NewJSAPITreeMap(thread, factory);
1357 DUMP_FOR_HANDLE(jsTreeMap);
1358 break;
1359 }
1360 case JSType::JS_API_TREE_SET: {
1361 // 1 : 1 dump fileds number
1362 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSet::SIZE, 1U);
1363 JSHandle<JSAPITreeSet> jsTreeSet = NewJSAPITreeSet(thread, factory);
1364 DUMP_FOR_HANDLE(jsTreeSet);
1365 break;
1366 }
1367 case JSType::JS_API_TREEMAP_ITERATOR: {
1368 // 3 : 3 dump fileds number
1369 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMapIterator::SIZE, 3U);
1370 JSHandle<JSAPITreeMap> jsTreeMap = NewJSAPITreeMap(thread, factory);
1371 JSHandle<JSAPITreeMapIterator> jsTreeMapIter =
1372 factory->NewJSAPITreeMapIterator(jsTreeMap, IterationKind::KEY);
1373 DUMP_FOR_HANDLE(jsTreeMapIter);
1374 break;
1375 }
1376 case JSType::JS_API_TREESET_ITERATOR: {
1377 // 3 : 3 dump fileds number
1378 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSetIterator::SIZE, 3U);
1379 JSHandle<JSAPITreeSet> jsTreeSet = NewJSAPITreeSet(thread, factory);
1380 JSHandle<JSAPITreeSetIterator> jsTreeSetIter =
1381 factory->NewJSAPITreeSetIterator(jsTreeSet, IterationKind::KEY);
1382 DUMP_FOR_HANDLE(jsTreeSetIter);
1383 break;
1384 }
1385 case JSType::JS_API_DEQUE: {
1386 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDeque::SIZE, 1U);
1387 JSHandle<JSAPIDeque> jsDeque = NewJSAPIDeque(thread, factory, proto);
1388 DUMP_FOR_HANDLE(jsDeque);
1389 break;
1390 }
1391 case JSType::JS_API_DEQUE_ITERATOR: {
1392 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDequeIterator::SIZE, 2U);
1393 JSHandle<JSAPIDequeIterator> jsDequeIter =
1394 factory->NewJSAPIDequeIterator(NewJSAPIDeque(thread, factory, proto));
1395 DUMP_FOR_HANDLE(jsDequeIter);
1396 break;
1397 }
1398 case JSType::JS_API_STACK: {
1399 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStack::SIZE, 1U);
1400 JSHandle<JSAPIStack> jsStack = NewJSAPIStack(factory, proto);
1401 DUMP_FOR_HANDLE(jsStack);
1402 break;
1403 }
1404 case JSType::JS_API_STACK_ITERATOR: {
1405 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStackIterator::SIZE, 2U);
1406 JSHandle<JSAPIStackIterator> jsStackIter =
1407 factory->NewJSAPIStackIterator(NewJSAPIStack(factory, proto));
1408 DUMP_FOR_HANDLE(jsStackIter);
1409 break;
1410 }
1411 case JSType::JS_API_VECTOR: {
1412 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVector::SIZE, 1U);
1413 JSHandle<JSAPIVector> jsVector = NewJSAPIVector(factory, proto);
1414 DUMP_FOR_HANDLE(jsVector);
1415 break;
1416 }
1417 case JSType::JS_API_VECTOR_ITERATOR: {
1418 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVectorIterator::SIZE, 2U);
1419 JSHandle<JSAPIVectorIterator> jsVectorIter =
1420 factory->NewJSAPIVectorIterator(NewJSAPIVector(factory, proto));
1421 DUMP_FOR_HANDLE(jsVectorIter);
1422 break;
1423 }
1424 case JSType::JS_API_LIST: {
1425 // 1 : 1 dump fileds number
1426 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIList::SIZE, 2U);
1427 JSHandle<JSAPIList> jsAPIList = NewJSAPIList(thread, factory);
1428 DUMP_FOR_HANDLE(jsAPIList);
1429 break;
1430 }
1431 case JSType::JS_API_LINKED_LIST: {
1432 // 1 : 1 dump fileds number
1433 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedList::SIZE, 1U);
1434 JSHandle<JSAPILinkedList> jsAPILinkedList = NewJSAPILinkedList(thread, factory);
1435 DUMP_FOR_HANDLE(jsAPILinkedList);
1436 break;
1437 }
1438 case JSType::JS_API_LIST_ITERATOR: {
1439 // 2 : 2 dump fileds number
1440 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U);
1441 JSHandle<JSAPIList> jsAPIList = NewJSAPIList(thread, factory);
1442 JSHandle<JSAPIListIterator> jsAPIListIter = factory->NewJSAPIListIterator(jsAPIList);
1443 DUMP_FOR_HANDLE(jsAPIListIter);
1444 break;
1445 }
1446 case JSType::JS_API_LINKED_LIST_ITERATOR: {
1447 // 2 : 2 dump fileds number
1448 CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedListIterator::SIZE, 2U);
1449 JSHandle<JSAPILinkedList> jsAPILinkedList = NewJSAPILinkedList(thread, factory);
1450 JSHandle<JSAPILinkedListIterator> jsAPILinkedListIter =
1451 factory->NewJSAPILinkedListIterator(jsAPILinkedList);
1452 DUMP_FOR_HANDLE(jsAPILinkedListIter);
1453 break;
1454 }
1455 case JSType::MODULE_RECORD: {
1456 CHECK_DUMP_FIELDS(Record::SIZE, ModuleRecord::SIZE, 0U);
1457 break;
1458 }
1459 case JSType::SOURCE_TEXT_MODULE_RECORD: {
1460 CHECK_DUMP_FIELDS(ModuleRecord::SIZE, SourceTextModule::SIZE, 20U);
1461 JSHandle<SourceTextModule> moduleSourceRecord = factory->NewSourceTextModule();
1462 DUMP_FOR_HANDLE(moduleSourceRecord);
1463 break;
1464 }
1465 case JSType::IMPORTENTRY_RECORD: {
1466 CHECK_DUMP_FIELDS(Record::SIZE, ImportEntry::SIZE, 3U);
1467 JSHandle<ImportEntry> importEntry = factory->NewImportEntry();
1468 DUMP_FOR_HANDLE(importEntry);
1469 break;
1470 }
1471 case JSType::LOCAL_EXPORTENTRY_RECORD: {
1472 CHECK_DUMP_FIELDS(Record::SIZE, LocalExportEntry::SIZE, 3U);
1473 JSHandle<LocalExportEntry> localExportEntry = factory->NewLocalExportEntry();
1474 DUMP_FOR_HANDLE(localExportEntry);
1475 break;
1476 }
1477 case JSType::INDIRECT_EXPORTENTRY_RECORD: {
1478 CHECK_DUMP_FIELDS(Record::SIZE, IndirectExportEntry::SIZE, 3U);
1479 JSHandle<IndirectExportEntry> indirectExportEntry = factory->NewIndirectExportEntry();
1480 DUMP_FOR_HANDLE(indirectExportEntry);
1481 break;
1482 }
1483 case JSType::STAR_EXPORTENTRY_RECORD: {
1484 CHECK_DUMP_FIELDS(Record::SIZE, StarExportEntry::SIZE, 1U);
1485 break;
1486 }
1487 case JSType::RESOLVEDBINDING_RECORD: {
1488 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedBinding::SIZE, 2U);
1489 JSHandle<ResolvedBinding> resolvedBinding = factory->NewResolvedBindingRecord();
1490 DUMP_FOR_HANDLE(resolvedBinding);
1491 break;
1492 }
1493 case JSType::RESOLVEDINDEXBINDING_RECORD: {
1494 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedIndexBinding::SIZE, 2U);
1495 JSHandle<ResolvedIndexBinding> resolvedBinding = factory->NewResolvedIndexBindingRecord();
1496 DUMP_FOR_HANDLE(resolvedBinding);
1497 break;
1498 }
1499 case JSType::RESOLVEDRECORDINDEXBINDING_RECORD: {
1500 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordIndexBinding::SIZE, 3U);
1501 JSHandle<ResolvedRecordIndexBinding> recordBinding = factory->NewSResolvedRecordIndexBindingRecord();
1502 DUMP_FOR_HANDLE(recordBinding);
1503 break;
1504 }
1505 case JSType::RESOLVEDRECORDBINDING_RECORD: {
1506 CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordBinding::SIZE, 2U);
1507 JSHandle<ResolvedRecordBinding> recordBinding = factory->NewSResolvedRecordBindingRecord();
1508 DUMP_FOR_HANDLE(recordBinding);
1509 break;
1510 }
1511 case JSType::JS_MODULE_NAMESPACE: {
1512 CHECK_DUMP_FIELDS(JSObject::SIZE, ModuleNamespace::SIZE, 3U);
1513 JSHandle<ModuleNamespace> moduleNamespace = factory->NewModuleNamespace();
1514 DUMP_FOR_HANDLE(moduleNamespace);
1515 break;
1516 }
1517 case JSType::NATIVE_MODULE_FAILURE_INFO: {
1518 CHECK_DUMP_FIELDS(JSObject::SIZE, NativeModuleFailureInfo::SIZE, 1U);
1519 JSHandle<NativeModuleFailureInfo> nativeFailureInfo = factory->NewNativeModuleFailureInfo();
1520 DUMP_FOR_HANDLE(nativeFailureInfo);
1521 break;
1522 }
1523 case JSType::JS_CJS_EXPORTS: {
1524 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsExports::SIZE, 1U);
1525 JSHandle<CjsExports> cjsExports = factory->NewCjsExports();
1526 DUMP_FOR_HANDLE(cjsExports);
1527 break;
1528 }
1529 case JSType::JS_CJS_MODULE: {
1530 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsModule::SIZE, 5U);
1531 JSHandle<CjsModule> cjsModule = factory->NewCjsModule();
1532 DUMP_FOR_HANDLE(cjsModule);
1533 break;
1534 }
1535 case JSType::JS_CJS_REQUIRE: {
1536 CHECK_DUMP_FIELDS(JSObject::SIZE, CjsRequire::SIZE, 2U);
1537 JSHandle<CjsRequire> cjsRequire = factory->NewCjsRequire();
1538 DUMP_FOR_HANDLE(cjsRequire);
1539 break;
1540 }
1541 case JSType::JS_ITERATOR:
1542 case JSType::JS_ASYNCITERATOR:
1543 case JSType::FREE_OBJECT_WITH_ONE_FIELD:
1544 case JSType::FREE_OBJECT_WITH_NONE_FIELD:
1545 case JSType::FREE_OBJECT_WITH_TWO_FIELD:
1546 case JSType::JS_NATIVE_POINTER: {
1547 break;
1548 }
1549 case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN: {
1550 CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorResNextRetProRstFtn::SIZE, 1U);
1551 break;
1552 }
1553 case JSType::CLASS_LITERAL: {
1554 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassLiteral::SIZE, 2U);
1555 JSHandle<ClassLiteral> classLiteral = factory->NewClassLiteral();
1556 DUMP_FOR_HANDLE(classLiteral);
1557 break;
1558 }
1559 default:
1560 LOG_ECMA_MEM(FATAL) << "JSType " << static_cast<int>(type) << " cannot be dumped.";
1561 UNREACHABLE();
1562 break;
1563 }
1564 }
1565 #undef NEW_OBJECT_AND_DUMP
1566 #undef DUMP_FOR_HANDLE
1567 }
1568 } // namespace panda::test
1569