/* * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ecmascript/accessor_data.h" #include "ecmascript/builtins/builtins_array.h" #include "ecmascript/dfx/hprof/heap_profiler.h" #include "ecmascript/dfx/hprof/heap_profiler_interface.h" #include "ecmascript/dfx/hprof/heap_snapshot.h" #include "ecmascript/dfx/hprof/heap_snapshot_json_serializer.h" #include "ecmascript/dfx/hprof/string_hashmap.h" #include "ecmascript/dfx/native_module_failure_info.h" #include "ecmascript/ecma_vm.h" #include "ecmascript/global_dictionary-inl.h" #include "ecmascript/global_env.h" #include "ecmascript/ic/ic_handler.h" #include "ecmascript/ic/property_box.h" #include "ecmascript/ic/proto_change_details.h" #include "ecmascript/jobs/micro_job_queue.h" #include "ecmascript/jobs/pending_job.h" #include "ecmascript/jspandafile/class_info_extractor.h" #include "ecmascript/jspandafile/class_literal.h" #include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_api/js_api_arraylist.h" #include "ecmascript/js_api/js_api_arraylist_iterator.h" #include "ecmascript/js_api/js_api_deque.h" #include "ecmascript/js_api/js_api_deque_iterator.h" #include "ecmascript/js_api/js_api_lightweightmap.h" #include "ecmascript/js_api/js_api_lightweightmap_iterator.h" #include "ecmascript/js_api/js_api_lightweightset.h" #include "ecmascript/js_api/js_api_lightweightset_iterator.h" #include "ecmascript/js_api/js_api_linked_list.h" #include "ecmascript/js_api/js_api_linked_list_iterator.h" #include "ecmascript/js_api/js_api_list.h" #include "ecmascript/js_api/js_api_list_iterator.h" #include "ecmascript/js_api/js_api_plain_array.h" #include "ecmascript/js_api/js_api_plain_array_iterator.h" #include "ecmascript/js_api/js_api_queue.h" #include "ecmascript/js_api/js_api_queue_iterator.h" #include "ecmascript/js_api/js_api_stack.h" #include "ecmascript/js_api/js_api_stack_iterator.h" #include "ecmascript/js_api/js_api_tree_map.h" #include "ecmascript/js_api/js_api_tree_map_iterator.h" #include "ecmascript/js_api/js_api_tree_set.h" #include "ecmascript/js_api/js_api_tree_set_iterator.h" #include "ecmascript/js_api/js_api_vector.h" #include "ecmascript/js_api/js_api_vector_iterator.h" #include "ecmascript/js_arguments.h" #include "ecmascript/js_array.h" #include "ecmascript/js_array_iterator.h" #include "ecmascript/js_arraybuffer.h" #include "ecmascript/js_async_from_sync_iterator.h" #include "ecmascript/js_async_function.h" #include "ecmascript/js_async_generator_object.h" #include "ecmascript/js_bigint.h" #include "ecmascript/js_collator.h" #include "ecmascript/js_dataview.h" #include "ecmascript/js_date.h" #include "ecmascript/js_date_time_format.h" #include "ecmascript/js_finalization_registry.h" #include "ecmascript/js_for_in_iterator.h" #include "ecmascript/js_function.h" #include "ecmascript/js_generator_object.h" #include "ecmascript/js_global_object.h" #include "ecmascript/js_handle.h" #include "ecmascript/js_api/js_api_hashmap.h" #include "ecmascript/js_api/js_api_hashmap_iterator.h" #include "ecmascript/js_api/js_api_hashset.h" #include "ecmascript/js_api/js_api_hashset_iterator.h" #include "ecmascript/js_intl.h" #include "ecmascript/js_locale.h" #include "ecmascript/js_map.h" #include "ecmascript/js_map_iterator.h" #include "ecmascript/js_number_format.h" #include "ecmascript/js_object-inl.h" #include "ecmascript/js_plural_rules.h" #include "ecmascript/js_displaynames.h" #include "ecmascript/js_list_format.h" #include "ecmascript/js_primitive_ref.h" #include "ecmascript/js_promise.h" #include "ecmascript/js_realm.h" #include "ecmascript/js_regexp.h" #include "ecmascript/js_regexp_iterator.h" #include "ecmascript/js_relative_time_format.h" #include "ecmascript/js_segmenter.h" #include "ecmascript/js_segments.h" #include "ecmascript/js_segment_iterator.h" #include "ecmascript/js_set.h" #include "ecmascript/js_set_iterator.h" #include "ecmascript/js_string_iterator.h" #include "ecmascript/js_tagged_number.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/js_thread.h" #include "ecmascript/js_typed_array.h" #include "ecmascript/js_weak_container.h" #include "ecmascript/js_weak_ref.h" #include "ecmascript/layout_info-inl.h" #include "ecmascript/lexical_env.h" #include "ecmascript/linked_hash_table.h" #include "ecmascript/marker_cell.h" #include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/machine_code.h" #include "ecmascript/module/js_module_source_text.h" #include "ecmascript/object_factory.h" #include "ecmascript/shared_objects/js_shared_array.h" #include "ecmascript/shared_objects/js_sendable_arraybuffer.h" #include "ecmascript/shared_objects/js_shared_array_iterator.h" #include "ecmascript/shared_objects/js_shared_map.h" #include "ecmascript/shared_objects/js_shared_map_iterator.h" #include "ecmascript/shared_objects/js_shared_set.h" #include "ecmascript/shared_objects/js_shared_set_iterator.h" #include "ecmascript/shared_objects/js_shared_typed_array.h" #include "ecmascript/stubs/runtime_stubs.h" #include "ecmascript/tagged_array.h" #include "ecmascript/tagged_dictionary.h" #include "ecmascript/tagged_hash_array.h" #include "ecmascript/tagged_list.h" #include "ecmascript/tagged_node.h" #include "ecmascript/tagged_tree.h" #include "ecmascript/template_map.h" #include "ecmascript/tests/test_helper.h" #include "ecmascript/transitions_dictionary.h" #include "ecmascript/require/js_cjs_module.h" #include "ecmascript/require/js_cjs_require.h" #include "ecmascript/require/js_cjs_exports.h" #include using namespace panda::ecmascript; using namespace panda::ecmascript::base; using Array = panda::ecmascript::builtins::BuiltinsArray; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define CHECK_DUMP_FIELDS(begin, end, num); \ LOG_ECMA_IF((num) != ((end) - (begin)) / JSTaggedValue::TaggedTypeSize() && sizeof(uintptr_t) == 8, FATAL) \ << "Fields in obj are not in dump list. " namespace panda::test { class EcmaDumpTest : public BaseTestWithScope { }; #ifndef NDEBUG HWTEST_F_L0(EcmaDumpTest, Dump) { std::ostringstream os; JSTaggedValue value1(100); value1.Dump(thread, os); JSTaggedValue value2(100.0); JSTaggedValue(value2.GetRawData()).Dump(thread, os); JSTaggedValue::Undefined().Dump(thread, os); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); env.GetTaggedValue().Dump(thread, os); JSHandle objFunc(env->GetObjectFunction()); objFunc.GetTaggedValue().Dump(thread, os); } #endif // #ifndef NDEBUG HWTEST_F_L0(EcmaDumpTest, DumpTaggedValueType) { std::vector> loopVal {}; std::vector loopRes {}; // [Int] int32_t a = 1; JSTaggedValue intVal = JSTaggedValue(a); loopVal.push_back(JSHandle(thread, intVal)); loopRes.push_back("[Int]"); // [Double] double b = 3.14; JSTaggedValue doubleVal = JSTaggedValue(b); loopVal.push_back(JSHandle(thread, doubleVal)); loopRes.push_back("[Double]"); // [Undefine] JSTaggedValue undefineVal = JSTaggedValue::Undefined(); loopVal.push_back(JSHandle(thread, undefineVal)); loopRes.push_back("[Special Value] : Undefined"); // [Null] JSTaggedValue nullVal = JSTaggedValue::Null(); loopVal.push_back(JSHandle(thread, nullVal)); loopRes.push_back("[Special Value] : Null"); // JSArray JSHandle array(thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction()); JSHandle globalObject(thread, thread->GetEcmaVM()->GetGlobalEnv()->GetGlobalObject()); auto ecmaRuntimeCallInfo1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); ecmaRuntimeCallInfo1->SetFunction(array.GetTaggedValue()); ecmaRuntimeCallInfo1->SetThis(globalObject.GetTaggedValue()); [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo1); JSTaggedValue arrVal = Array::ArrayConstructor(ecmaRuntimeCallInfo1); TestHelper::TearDownFrame(thread, prev); loopVal.push_back(JSHandle(thread, arrVal)); loopRes.push_back("[Array]"); // Object JSHandle globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle objFun = globalEnv->GetObjectFunction(); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle obj(factory->NewJSObjectByConstructor(JSHandle(objFun), objFun)); loopVal.push_back(obj); loopRes.push_back("[Object]"); for (int i = 0; i < loopVal.size(); i++) { std::stringstream oss; loopVal[i].GetTaggedValue().DumpTaggedValueType(oss); ASSERT_EQ(oss.str(), loopRes[i]); } } static JSHandle NewJSMap(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle mapClass = factory->NewEcmaHClass(JSMap::SIZE, JSType::JS_MAP, proto); JSHandle jsMap = JSHandle::Cast(factory->NewJSObjectWithInit(mapClass)); JSHandle linkedMap(LinkedHashMap::Create(thread)); jsMap->SetLinkedMap(thread, linkedMap); return jsMap; } static JSHandle NewJSSharedMap(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetSFunctionPrototype(); auto emptySLayout = thread->GlobalConstants()->GetHandledEmptySLayoutInfo(); JSHandle mapClass = factory->NewSEcmaHClass(JSSharedMap::SIZE, 0, JSType::JS_SHARED_MAP, proto, emptySLayout); JSHandle jsMap = JSHandle::Cast(factory->NewSharedOldSpaceJSObjectWithInit(mapClass)); JSHandle linkedMap( LinkedHashMap::Create(thread, LinkedHashMap::MIN_CAPACITY, MemSpaceKind::SHARED)); jsMap->SetLinkedMap(thread, linkedMap); jsMap->SetModRecord(0); return jsMap; } static JSHandle NewJSSet(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle setClass = factory->NewEcmaHClass(JSSet::SIZE, JSType::JS_SET, proto); JSHandle jsSet = JSHandle::Cast(factory->NewJSObjectWithInit(setClass)); JSHandle linkedSet(LinkedHashSet::Create(thread)); jsSet->SetLinkedSet(thread, linkedSet); return jsSet; } static JSHandle NewJSSharedSet(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetSFunctionPrototype(); auto emptySLayout = thread->GlobalConstants()->GetHandledEmptySLayoutInfo(); JSHandle setClass = factory->NewSEcmaHClass(JSSharedSet::SIZE, 0, JSType::JS_SHARED_SET, proto, emptySLayout); JSHandle jsSet = JSHandle::Cast(factory->NewSharedOldSpaceJSObjectWithInit(setClass)); JSHandle linkedSet( LinkedHashSet::Create(thread, LinkedHashSet::MIN_CAPACITY, MemSpaceKind::SHARED)); jsSet->SetLinkedSet(thread, linkedSet); jsSet->SetModRecord(0); return jsSet; } static JSHandle NewJSAPIHashMap(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle mapClass = factory->NewEcmaHClass(JSAPIHashMap::SIZE, JSType::JS_API_HASH_MAP, proto); JSHandle jsHashMap = JSHandle::Cast(factory->NewJSObjectWithInit(mapClass)); jsHashMap->SetTable(thread, TaggedHashArray::Create(thread)); jsHashMap->SetSize(0); return jsHashMap; } static JSHandle NewJSAPIHashSet(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle setClass = factory->NewEcmaHClass(JSAPIHashSet::SIZE, JSType::JS_API_HASH_SET, proto); JSHandle jsHashSet = JSHandle::Cast(factory->NewJSObjectWithInit(setClass)); jsHashSet->SetTable(thread, TaggedHashArray::Create(thread)); jsHashSet->SetSize(0); return jsHashSet; } static JSHandle NewJSAPITreeMap(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle mapClass = factory->NewEcmaHClass(JSAPITreeMap::SIZE, JSType::JS_API_TREE_MAP, proto); JSHandle jsTreeMap = JSHandle::Cast(factory->NewJSObjectWithInit(mapClass)); JSHandle treeMap(thread, TaggedTreeMap::Create(thread)); jsTreeMap->SetTreeMap(thread, treeMap); return jsTreeMap; } static JSHandle NewJSAPITreeSet(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle setClass = factory->NewEcmaHClass(JSAPITreeSet::SIZE, JSType::JS_API_TREE_SET, proto); JSHandle jsTreeSet = JSHandle::Cast(factory->NewJSObjectWithInit(setClass)); JSHandle treeSet(thread, TaggedTreeSet::Create(thread)); jsTreeSet->SetTreeSet(thread, treeSet); return jsTreeSet; } static JSHandle NewJSAPIPlainArray(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle mapClass = factory->NewEcmaHClass(JSAPIPlainArray::SIZE, JSType::JS_API_PLAIN_ARRAY, proto); JSHandle jSAPIPlainArray = JSHandle::Cast(factory->NewJSObjectWithInit(mapClass)); JSHandle keys = JSAPIPlainArray::CreateSlot(thread, JSAPIPlainArray::DEFAULT_CAPACITY_LENGTH); JSHandle values = JSAPIPlainArray::CreateSlot(thread, JSAPIPlainArray::DEFAULT_CAPACITY_LENGTH); jSAPIPlainArray->SetKeys(thread, keys); jSAPIPlainArray->SetValues(thread, values); jSAPIPlainArray->SetLength(0); return jSAPIPlainArray; } static JSHandle NewJSAPIList(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle listClass = factory->NewEcmaHClass(JSAPIList::SIZE, JSType::JS_API_LIST, proto); JSHandle jsAPIList = JSHandle::Cast(factory->NewJSObjectWithInit(listClass)); JSHandle taggedSingleList(thread, TaggedSingleList::Create(thread)); jsAPIList->SetSingleList(thread, taggedSingleList); return jsAPIList; } static JSHandle NewJSAPILinkedList(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle mapClass = factory->NewEcmaHClass(JSAPILinkedList::SIZE, JSType::JS_API_LINKED_LIST, proto); JSHandle jsAPILinkedList = JSHandle::Cast(factory->NewJSObjectWithInit(mapClass)); JSHandle linkedlist(thread, TaggedDoubleList::Create(thread)); jsAPILinkedList->SetDoubleList(thread, linkedlist); return jsAPILinkedList; } static JSHandle NewJSObject(JSThread *thread, ObjectFactory *factory, JSHandle globalEnv) { JSFunction *jsFunc = globalEnv->GetObjectFunction().GetObject(); JSHandle jsFunc1(thread, jsFunc); JSHandle jsObj = factory->NewJSObjectByConstructor(JSHandle(jsFunc1), jsFunc1); return jsObj; } static JSHandle NewJSAPIArrayList(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle arrayListClass = factory->NewEcmaHClass(JSAPIArrayList::SIZE, JSType::JS_API_ARRAY_LIST, proto); JSHandle jsArrayList = JSHandle::Cast(factory->NewJSObjectWithInit(arrayListClass)); jsArrayList->SetLength(thread, JSTaggedValue(0)); return jsArrayList; } static JSHandle NewJSAPIStack(ObjectFactory *factory, JSHandle proto) { JSHandle stackClass = factory->NewEcmaHClass(JSAPIStack::SIZE, JSType::JS_API_STACK, proto); JSHandle jsStack = JSHandle::Cast(factory->NewJSObjectWithInit(stackClass)); jsStack->SetTop(0); return jsStack; } static JSHandle NewJSRegExp(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle jSRegExpClass = factory->NewEcmaHClass(JSRegExp::SIZE, JSType::JS_REG_EXP, proto); JSHandle jSRegExp = JSHandle::Cast(factory->NewJSObject(jSRegExpClass)); jSRegExp->SetByteCodeBuffer(thread, JSTaggedValue::Undefined()); jSRegExp->SetOriginalSource(thread, JSTaggedValue::Undefined()); jSRegExp->SetGroupName(thread, JSTaggedValue::Undefined()); jSRegExp->SetOriginalFlags(thread, JSTaggedValue(0)); jSRegExp->SetLength(0); return jSRegExp; } static JSHandle NewJSAPILightWeightMap(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle lwmapClass = factory->NewEcmaHClass(JSAPILightWeightMap::SIZE, JSType::JS_API_LIGHT_WEIGHT_MAP, proto); JSHandle jSAPILightWeightMap = JSHandle::Cast(factory->NewJSObjectWithInit(lwmapClass)); JSHandle hashArray = JSHandle(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH)); JSHandle keyArray = JSHandle(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH)); JSHandle valueArray = JSHandle(factory->NewTaggedArray(JSAPILightWeightMap::DEFAULT_CAPACITY_LENGTH)); jSAPILightWeightMap->SetHashes(thread, hashArray); jSAPILightWeightMap->SetKeys(thread, keyArray); jSAPILightWeightMap->SetValues(thread, valueArray); jSAPILightWeightMap->SetLength(0); return jSAPILightWeightMap; } static JSHandle NewJSAPILightWeightSet(JSThread *thread, ObjectFactory *factory) { auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle proto = globalEnv->GetObjectFunctionPrototype(); JSHandle setClass = factory->NewEcmaHClass(JSAPILightWeightSet::SIZE, JSType::JS_API_LIGHT_WEIGHT_SET, proto); JSHandle jSAPILightWeightSet = JSHandle::Cast(factory->NewJSObjectWithInit(setClass)); JSHandle hashes = JSAPILightWeightSet::CreateSlot(thread, JSAPILightWeightSet::DEFAULT_CAPACITY_LENGTH); JSHandle values = JSAPILightWeightSet::CreateSlot(thread, JSAPILightWeightSet::DEFAULT_CAPACITY_LENGTH); jSAPILightWeightSet->SetHashes(thread, hashes); jSAPILightWeightSet->SetValues(thread, values); jSAPILightWeightSet->SetLength(0); return jSAPILightWeightSet; } static JSHandle NewJSAPIQueue(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle queueClass = factory->NewEcmaHClass(JSAPIQueue::SIZE, JSType::JS_API_QUEUE, proto); JSHandle jsQueue = JSHandle::Cast(factory->NewJSObjectWithInit(queueClass)); JSHandle newElements = factory->NewTaggedArray(JSAPIQueue::DEFAULT_CAPACITY_LENGTH); jsQueue->SetLength(thread, JSTaggedValue(0)); jsQueue->SetFront(0); jsQueue->SetTail(0); jsQueue->SetElements(thread, newElements); return jsQueue; } static JSHandle NewJSAPIDeque(JSThread *thread, ObjectFactory *factory, JSHandle proto) { JSHandle dequeClass = factory->NewEcmaHClass(JSAPIDeque::SIZE, JSType::JS_API_DEQUE, proto); JSHandle jsDeque = JSHandle::Cast(factory->NewJSObjectWithInit(dequeClass)); JSHandle newElements = factory->NewTaggedArray(JSAPIDeque::DEFAULT_CAPACITY_LENGTH); jsDeque->SetFirst(0); jsDeque->SetLast(0); jsDeque->SetElements(thread, newElements); return jsDeque; } static JSHandle NewJSAPIVector(ObjectFactory *factory, JSHandle proto) { JSHandle vectorClass = factory->NewEcmaHClass(JSAPIVector::SIZE, JSType::JS_API_VECTOR, proto); JSHandle jsVector = JSHandle::Cast(factory->NewJSObjectWithInit(vectorClass)); jsVector->SetLength(0); return jsVector; } HWTEST_F_L0(EcmaDumpTest, HeapProfileDump) { [[maybe_unused]] ecmascript::EcmaHandleScope scope(thread); auto factory = thread->GetEcmaVM()->GetFactory(); auto globalEnv = thread->GetEcmaVM()->GetGlobalEnv(); auto globalConst = const_cast(thread->GlobalConstants()); JSHandle proto = globalEnv->GetFunctionPrototype(); std::vector snapshotVector; std::ostringstream os; #define DUMP_FOR_HANDLE(dumpHandle) \ do { \ JSTaggedValue dumpValue = (dumpHandle).GetTaggedValue(); \ dumpValue.Dump(thread, os); \ dumpValue.DumpForSnapshot(thread, snapshotVector); \ /* Testing runtime stubs: */ \ JSTaggedType dumpRawData = dumpValue.GetRawData(); \ uintptr_t hintStr = reinterpret_cast("Testing with: " #dumpHandle); \ RuntimeStubs::Dump(dumpRawData); \ RuntimeStubs::DebugDump(dumpRawData); \ RuntimeStubs::DumpWithHint(hintStr, dumpRawData); \ RuntimeStubs::DebugDumpWithHint(hintStr, dumpRawData); \ } while (false) #if defined(PANDA_TARGET_AMD64) || defined(PANDA_TARGET_ARM64) static const unsigned int machineCodeSize = 42; #else static const unsigned int machineCodeSize = 26; #endif #define NEW_OBJECT_AND_DUMP(ClassName, TypeName) \ do { \ JSHandle class##ClassName = \ factory->NewEcmaHClass(ClassName::SIZE, JSType::TypeName, proto); \ JSHandle object##ClassName = factory->NewJSObjectWithInit(class##ClassName); \ DUMP_FOR_HANDLE(object##ClassName); \ } while (false) for (JSType type = JSType::JS_OBJECT; type <= JSType::TYPE_LAST; type = JSType(static_cast(type) + 1)) { switch (type) { case JSType::JS_ERROR: case JSType::JS_EVAL_ERROR: case JSType::JS_RANGE_ERROR: case JSType::JS_TYPE_ERROR: case JSType::JS_AGGREGATE_ERROR: case JSType::JS_REFERENCE_ERROR: case JSType::JS_URI_ERROR: case JSType::JS_ARGUMENTS: case JSType::JS_SYNTAX_ERROR: case JSType::JS_OOM_ERROR: case JSType::JS_TERMINATION_ERROR: case JSType::JS_OBJECT: case JSType::JS_SHARED_OBJECT: { CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U); JSHandle jsObj = NewJSObject(thread, factory, globalEnv); DUMP_FOR_HANDLE(jsObj); break; } case JSType::JS_XREF_OBJECT: { CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U); JSHandle jsXRefObject(factory->NewJSXRefObject()); DUMP_FOR_HANDLE(jsXRefObject); break; } case JSType::JS_REALM: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSRealm::SIZE, 2U); JSHandle jsRealm = factory->NewJSRealm(); DUMP_FOR_HANDLE(jsRealm); break; } case JSType::METHOD: { #ifdef PANDA_TARGET_64 CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U); #else CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U); #endif break; } case JSType::JS_FUNCTION_BASE: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSFunctionBase::SIZE, 3U); break; } case JSType::JS_FUNCTION: case JSType::JS_SHARED_FUNCTION: { CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 8U); JSHandle jsFunc = globalEnv->GetFunctionFunction(); DUMP_FOR_HANDLE(jsFunc); break; } case JSType::JS_PROXY_REVOC_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSProxyRevocFunction::SIZE, 1U); JSHandle proxyRevocClass = JSHandle::Cast(globalEnv->GetProxyRevocFunctionClass()); JSHandle proxyRevocFunc = factory->NewJSObjectWithInit(proxyRevocClass); DUMP_FOR_HANDLE(proxyRevocFunc); break; } case JSType::JS_PROMISE_REACTIONS_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseReactionsFunction::SIZE, 2U); JSHandle promiseReactClass = JSHandle::Cast(globalEnv->GetPromiseReactionFunctionClass()); JSHandle promiseReactFunc = factory->NewJSObjectWithInit(promiseReactClass); DUMP_FOR_HANDLE(promiseReactFunc); break; } case JSType::JS_PROMISE_EXECUTOR_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseExecutorFunction::SIZE, 1U); JSHandle promiseExeClass = JSHandle::Cast(globalEnv->GetPromiseExecutorFunctionClass()); JSHandle promiseExeFunc = factory->NewJSObjectWithInit(promiseExeClass); DUMP_FOR_HANDLE(promiseExeFunc); break; } case JSType::JS_ASYNC_MODULE_FULFILLED_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleFulfilledFunction::SIZE, 0U); JSHandle moduleFulfilledClass = JSHandle::Cast(globalEnv->GetAsyncModuleFulfilledFunctionClass()); JSHandle moduleFulfilledFunc = factory->NewJSObjectWithInit(moduleFulfilledClass); DUMP_FOR_HANDLE(moduleFulfilledFunc); break; } case JSType::JS_ASYNC_MODULE_REJECTED_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncModuleRejectedFunction::SIZE, 0U); JSHandle moduleRejectedClass = JSHandle::Cast(globalEnv->GetAsyncModuleRejectedFunctionClass()); JSHandle moduleRejectedFunc = factory->NewJSObjectWithInit(moduleRejectedClass); DUMP_FOR_HANDLE(moduleRejectedFunc); break; } case JSType::JS_PROMISE_ALL_RESOLVE_ELEMENT_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllResolveElementFunction::SIZE, 5U); JSHandle promiseAllClass = JSHandle::Cast(globalEnv->GetPromiseAllResolveElementFunctionClass()); JSHandle promiseAllFunc = factory->NewJSObjectWithInit(promiseAllClass); DUMP_FOR_HANDLE(promiseAllFunc); break; } case JSType::JS_PROMISE_ANY_REJECT_ELEMENT_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAnyRejectElementFunction::SIZE, 5U); JSHandle promiseAnyClass = JSHandle::Cast(globalEnv->GetPromiseAnyRejectElementFunctionClass()); JSHandle promiseAnyFunc = factory->NewJSObjectWithInit(promiseAnyClass); DUMP_FOR_HANDLE(promiseAnyFunc); break; } case JSType::JS_PROMISE_ALL_SETTLED_ELEMENT_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseAllSettledElementFunction::SIZE, 5U); JSHandle promiseAllSettledClass = JSHandle::Cast(globalEnv->GetPromiseAllSettledElementFunctionClass()); JSHandle promiseAllSettledFunc = factory->NewJSObjectWithInit(promiseAllSettledClass); DUMP_FOR_HANDLE(promiseAllSettledFunc); break; } case JSType::JS_PROMISE_FINALLY_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseFinallyFunction::SIZE, 2U); JSHandle promiseFinallyClass = JSHandle::Cast(globalEnv->GetPromiseFinallyFunctionClass()); JSHandle promiseFinallyFunc = factory->NewJSObjectWithInit(promiseFinallyClass); DUMP_FOR_HANDLE(promiseFinallyFunc); break; } case JSType::JS_PROMISE_VALUE_THUNK_OR_THROWER_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSPromiseValueThunkOrThrowerFunction::SIZE, 1U); JSHandle promiseValueClass = JSHandle::Cast(globalEnv->GetPromiseValueThunkOrThrowerFunctionClass()); JSHandle promiseValueFunc = factory->NewJSObjectWithInit(promiseValueClass); DUMP_FOR_HANDLE(promiseValueFunc); break; } case JSType::JS_ASYNC_GENERATOR_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorFunction::SIZE, 0U); break; } case JSType::JS_GENERATOR_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSGeneratorFunction::SIZE, 0U); break; } case JSType::JS_ASYNC_FUNCTION: case JSType::JS_SHARED_ASYNC_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFunction::SIZE, 0U); break; } case JSType::JS_INTL_BOUND_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSIntlBoundFunction::SIZE, 3U); JSHandle intlBoundFunc = factory->NewJSIntlBoundFunction( MethodIndex::BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER); DUMP_FOR_HANDLE(intlBoundFunc); break; } case JSType::JS_ASYNC_AWAIT_STATUS_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncAwaitStatusFunction::SIZE, 1U); JSHandle asyncAwaitFunc = factory->NewJSAsyncAwaitStatusFunction( MethodIndex::BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED); DUMP_FOR_HANDLE(asyncAwaitFunc); break; } case JSType::JS_BOUND_FUNCTION: { CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSBoundFunction::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSBoundFunction, JS_BOUND_FUNCTION); break; } case JSType::JS_REG_EXP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExp::SIZE, 5U); NEW_OBJECT_AND_DUMP(JSRegExp, JS_REG_EXP); break; } case JSType::JS_SET: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSet::SIZE, 1U); JSHandle jsSet = NewJSSet(thread, factory, proto); DUMP_FOR_HANDLE(jsSet); break; } case JSType::JS_SHARED_SET: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSet::SIZE, 2U); JSHandle jsSet = NewJSSharedSet(thread, factory); DUMP_FOR_HANDLE(jsSet); break; } case JSType::JS_MAP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSMap::SIZE, 1U); JSHandle jsMap = NewJSMap(thread, factory, proto); DUMP_FOR_HANDLE(jsMap); break; } case JSType::JS_SHARED_MAP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMap::SIZE, 2U); JSHandle jsMap = NewJSSharedMap(thread, factory); DUMP_FOR_HANDLE(jsMap); break; } case JSType::JS_WEAK_MAP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakMap::SIZE, 1U); JSHandle weakMapClass = factory->NewEcmaHClass(JSWeakMap::SIZE, JSType::JS_WEAK_MAP, proto); JSHandle jsWeakMap = JSHandle::Cast(factory->NewJSObjectWithInit(weakMapClass)); JSHandle weakLinkedMap(LinkedHashMap::Create(thread)); jsWeakMap->SetLinkedMap(thread, weakLinkedMap); DUMP_FOR_HANDLE(jsWeakMap); break; } case JSType::JS_WEAK_SET: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakSet::SIZE, 1U); JSHandle weakSetClass = factory->NewEcmaHClass(JSWeakSet::SIZE, JSType::JS_WEAK_SET, proto); JSHandle jsWeakSet = JSHandle::Cast(factory->NewJSObjectWithInit(weakSetClass)); JSHandle weakLinkedSet(LinkedHashSet::Create(thread)); jsWeakSet->SetLinkedSet(thread, weakLinkedSet); DUMP_FOR_HANDLE(jsWeakSet); break; } case JSType::JS_WEAK_REF: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSWeakRef::SIZE, 1U); JSHandle weakRefClass = factory->NewEcmaHClass(JSWeakRef::SIZE, JSType::JS_WEAK_REF, proto); JSHandle jsWeakRef = JSHandle::Cast(factory->NewJSObjectWithInit(weakRefClass)); jsWeakRef->SetWeakObject(thread, JSTaggedValue::Undefined()); DUMP_FOR_HANDLE(jsWeakRef); break; } case JSType::JS_FINALIZATION_REGISTRY: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSFinalizationRegistry::SIZE, 5U); JSHandle finalizationRegistryClass = factory->NewEcmaHClass(JSFinalizationRegistry::SIZE, JSType::JS_FINALIZATION_REGISTRY, proto); JSHandle jsFinalizationRegistry = JSHandle::Cast(factory->NewJSObjectWithInit(finalizationRegistryClass)); JSHandle weakLinkedMap(LinkedHashMap::Create(thread)); jsFinalizationRegistry->SetMaybeUnregister(thread, weakLinkedMap); DUMP_FOR_HANDLE(jsFinalizationRegistry); break; } case JSType::CELL_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, CellRecord::SIZE, 2U); JSHandle cellRecord = factory->NewCellRecord(); DUMP_FOR_HANDLE(cellRecord); break; } case JSType::JS_DATE: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSDate::SIZE, 2U); JSHandle dateClass = factory->NewEcmaHClass(JSDate::SIZE, JSType::JS_DATE, proto); JSHandle date = JSHandle::Cast(factory->NewJSObjectWithInit(dateClass)); date->SetTimeValue(thread, JSTaggedValue(0.0)); date->SetLocalOffset(thread, JSTaggedValue(0.0)); DUMP_FOR_HANDLE(date); break; } case JSType::JS_FORIN_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 5U); JSHandle array(thread, factory->NewJSArray().GetTaggedValue()); JSHandle keys(thread, factory->EmptyArray().GetTaggedValue()); JSHandle hclass(thread, JSTaggedValue::Undefined()); JSHandle forInIter = factory->NewJSForinIterator(array, keys, hclass, static_cast(EnumCacheKind::NONE)); DUMP_FOR_HANDLE(forInIter); break; } case JSType::JS_MAP_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSMapIterator::SIZE, 2U); JSHandle jsMapIter = factory->NewJSMapIterator(NewJSMap(thread, factory, proto), IterationKind::KEY); DUMP_FOR_HANDLE(jsMapIter); break; } case JSType::JS_SHARED_MAP_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedMapIterator::SIZE, 2U); JSHandle jsMapIter = factory->NewJSMapIterator(NewJSSharedMap(thread, factory), IterationKind::KEY); DUMP_FOR_HANDLE(jsMapIter); break; } case JSType::JS_SET_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSetIterator::SIZE, 2U); JSHandle jsSetIter = factory->NewJSSetIterator(NewJSSet(thread, factory, proto), IterationKind::KEY); DUMP_FOR_HANDLE(jsSetIter); break; } case JSType::JS_SHARED_SET_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSharedSetIterator::SIZE, 2U); JSHandle jsSetIter = factory->NewJSSetIterator(NewJSSharedSet(thread, factory), IterationKind::KEY); DUMP_FOR_HANDLE(jsSetIter); break; } case JSType::JS_REG_EXP_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSRegExpIterator::SIZE, 3U); JSHandle emptyString(thread->GlobalConstants()->GetHandledEmptyString()); JSHandle jsRegExp(NewJSRegExp(thread, factory, proto)); JSHandle jsRegExpIter = factory->NewJSRegExpIterator(jsRegExp, emptyString, false, false); DUMP_FOR_HANDLE(jsRegExpIter); break; } case JSType::JS_ARRAY_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U); JSHandle arrayIter = factory->NewJSArrayIterator(JSHandle::Cast(factory->NewJSArray()), IterationKind::KEY); DUMP_FOR_HANDLE(arrayIter); break; } case JSType::JS_SHARED_ARRAY_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayIterator::SIZE, 2U); JSHandle arrayIter = factory->NewJSSharedArrayIterator( JSHandle::Cast(factory->NewJSSArray()), IterationKind::KEY); DUMP_FOR_HANDLE(arrayIter); break; } case JSType::JS_STRING_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSStringIterator::SIZE, 2U); JSHandle stringIter = globalEnv->GetStringIterator(); DUMP_FOR_HANDLE(stringIter); break; } case JSType::JS_INTL: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSIntl::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSIntl, JS_INTL); break; } case JSType::JS_LOCALE: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSLocale::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSLocale, JS_LOCALE); break; } case JSType::JS_DATE_TIME_FORMAT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSDateTimeFormat::SIZE, 9U); NEW_OBJECT_AND_DUMP(JSDateTimeFormat, JS_DATE_TIME_FORMAT); break; } case JSType::JS_RELATIVE_TIME_FORMAT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSRelativeTimeFormat::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSRelativeTimeFormat, JS_RELATIVE_TIME_FORMAT); break; } case JSType::JS_NUMBER_FORMAT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSNumberFormat::SIZE, 13U); NEW_OBJECT_AND_DUMP(JSNumberFormat, JS_NUMBER_FORMAT); break; } case JSType::JS_COLLATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSCollator::SIZE, 5U); NEW_OBJECT_AND_DUMP(JSCollator, JS_COLLATOR); break; } case JSType::JS_PLURAL_RULES: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSPluralRules::SIZE, 9U); NEW_OBJECT_AND_DUMP(JSPluralRules, JS_PLURAL_RULES); break; } case JSType::JS_DISPLAYNAMES: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSDisplayNames::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSDisplayNames, JS_DISPLAYNAMES); break; } case JSType::JS_SEGMENTER: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmenter::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSSegmenter, JS_SEGMENTER); break; } case JSType::JS_SEGMENTS: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegments::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSSegments, JS_SEGMENTS); break; } case JSType::JS_SEGMENT_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSegmentIterator::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSSegmentIterator, JS_SEGMENTS); break; } case JSType::JS_LIST_FORMAT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSListFormat::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSListFormat, JS_LIST_FORMAT); break; } case JSType::JS_SHARED_ARRAY_BUFFER: case JSType::JS_ARRAY_BUFFER: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSArrayBuffer::SIZE, 2U); NEW_OBJECT_AND_DUMP(JSArrayBuffer, JS_ARRAY_BUFFER); break; } case JSType::JS_SENDABLE_ARRAY_BUFFER: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSSendableArrayBuffer::SIZE, 2U); NEW_OBJECT_AND_DUMP(JSSendableArrayBuffer, JS_SENDABLE_ARRAY_BUFFER); break; } case JSType::JS_PROMISE: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSPromise::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSPromise, JS_PROMISE); break; } case JSType::JS_DATA_VIEW: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSDataView::SIZE, 3U); NEW_OBJECT_AND_DUMP(JSDataView, JS_DATA_VIEW); break; } case JSType::JS_GENERATOR_OBJECT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSGeneratorObject, JS_GENERATOR_OBJECT); break; } case JSType::JS_ASYNC_GENERATOR_OBJECT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncGeneratorObject::SIZE, 5U); NEW_OBJECT_AND_DUMP(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT); break; } case JSType::JS_ASYNC_FUNC_OBJECT: { CHECK_DUMP_FIELDS(JSGeneratorObject::SIZE, JSAsyncFuncObject::SIZE, 1U); JSHandle asyncFuncObject = factory->NewJSAsyncFuncObject(); DUMP_FOR_HANDLE(asyncFuncObject); break; } case JSType::JS_ARRAY: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U); JSHandle jsArray = factory->NewJSArray(); DUMP_FOR_HANDLE(jsArray); break; } case JSType::JS_SHARED_ARRAY: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSArray::SIZE, 2U); JSHandle jsArray = factory->NewJSSArray(); DUMP_FOR_HANDLE(jsArray); break; } case JSType::JS_TYPED_ARRAY: case JSType::JS_INT8_ARRAY: case JSType::JS_UINT8_ARRAY: case JSType::JS_UINT8_CLAMPED_ARRAY: case JSType::JS_INT16_ARRAY: case JSType::JS_UINT16_ARRAY: case JSType::JS_INT32_ARRAY: case JSType::JS_UINT32_ARRAY: case JSType::JS_FLOAT32_ARRAY: case JSType::JS_FLOAT64_ARRAY: case JSType::JS_BIGINT64_ARRAY: case JSType::JS_BIGUINT64_ARRAY: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSTypedArray::SIZE, 4U); NEW_OBJECT_AND_DUMP(JSTypedArray, JS_TYPED_ARRAY); break; } case JSType::JS_SHARED_TYPED_ARRAY: case JSType::JS_SHARED_INT8_ARRAY: case JSType::JS_SHARED_UINT8_ARRAY: case JSType::JS_SHARED_UINT8_CLAMPED_ARRAY: case JSType::JS_SHARED_INT16_ARRAY: case JSType::JS_SHARED_UINT16_ARRAY: case JSType::JS_SHARED_INT32_ARRAY: case JSType::JS_SHARED_UINT32_ARRAY: case JSType::JS_SHARED_FLOAT32_ARRAY: case JSType::JS_SHARED_FLOAT64_ARRAY: case JSType::JS_SHARED_BIGINT64_ARRAY: case JSType::JS_SHARED_BIGUINT64_ARRAY: { // Fixme(Gymee) Add test later break; } case JSType::JS_PRIMITIVE_REF: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSPrimitiveRef::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSPrimitiveRef, JS_PRIMITIVE_REF); break; } case JSType::JS_GLOBAL_OBJECT: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSGlobalObject::SIZE, 0U); JSHandle globalObject = globalEnv->GetJSGlobalObject(); DUMP_FOR_HANDLE(globalObject); break; } case JSType::JS_PROXY: { CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSProxy::SIZE, 5U); JSHandle emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle proxy = factory->NewJSProxy(emptyObj, emptyObj); DUMP_FOR_HANDLE(proxy); break; } case JSType::HCLASS: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSHClass::SIZE, 10U); JSHandle hclass = factory->NewEcmaHClass(JSHClass::SIZE, JSType::HCLASS, proto); DUMP_FOR_HANDLE(hclass); break; } case JSType::LINE_STRING: case JSType::TREE_STRING: case JSType::SLICED_STRING: { DUMP_FOR_HANDLE(globalEnv->GetObjectFunction()); break; } case JSType::BIGINT: { DUMP_FOR_HANDLE(globalEnv->GetBigIntFunction()); break; } case JSType::PROFILE_TYPE_INFO_CELL_0: case JSType::PROFILE_TYPE_INFO_CELL_1: case JSType::PROFILE_TYPE_INFO_CELL_N: { JSHandle handleUndefined(thread, JSTaggedValue::Undefined()); JSHandle profileTypeInfoCell = factory->NewProfileTypeInfoCell(handleUndefined); DUMP_FOR_HANDLE(profileTypeInfoCell); break; } case JSType::FUNCTION_TEMPLATE: { auto method = JSFunction::Cast(globalEnv->GetTaggedObjectFunction())->GetMethod(thread); JSHandle methodHandle(thread, method); JSHandle handleUndefined(thread, JSTaggedValue::Undefined()); JSHandle funcTemp = factory->NewFunctionTemplate(methodHandle, handleUndefined, 0); DUMP_FOR_HANDLE(funcTemp); break; } case JSType::TAGGED_ARRAY: case JSType::VTABLE: case JSType::LEXICAL_ENV: case JSType::SFUNCTION_ENV: case JSType::SENDABLE_ENV: case JSType::AOT_LITERAL_INFO: { JSHandle taggedArray = factory->NewTaggedArray(4); DUMP_FOR_HANDLE(taggedArray); break; } case JSType::CONSTANT_POOL: { JSHandle constantPool = factory->NewConstantPool(4); DUMP_FOR_HANDLE(constantPool); break; } case JSType::PROFILE_TYPE_INFO: { JSHandle info = factory->NewProfileTypeInfo(4); DUMP_FOR_HANDLE(info); break; } case JSType::EXTRA_PROFILE_TYPE_INFO: { JSHandle info = factory->NewExtraProfileTypeInfo(); DUMP_FOR_HANDLE(info); break; } case JSType::TAGGED_DICTIONARY: { JSHandle dict = factory->NewDictionaryArray(4); DUMP_FOR_HANDLE(dict); break; } case JSType::BYTE_ARRAY: { JSHandle byteArray = factory->NewByteArray(4, 8); DUMP_FOR_HANDLE(byteArray); break; } case JSType::COW_TAGGED_ARRAY: { JSHandle dict = factory->NewCOWTaggedArray(4); DUMP_FOR_HANDLE(dict); break; } case JSType::MUTANT_TAGGED_ARRAY: { JSHandle array = factory->NewMutantTaggedArray(4); DUMP_FOR_HANDLE(array); break; } case JSType::COW_MUTANT_TAGGED_ARRAY: { JSHandle array = factory->NewCOWMutantTaggedArray(4); DUMP_FOR_HANDLE(array); break; } case JSType::GLOBAL_ENV: { DUMP_FOR_HANDLE(globalEnv); break; } case JSType::ACCESSOR_DATA: case JSType::INTERNAL_ACCESSOR: { CHECK_DUMP_FIELDS(Record::SIZE, AccessorData::SIZE, 2U); JSHandle accessor = factory->NewAccessorData(); DUMP_FOR_HANDLE(accessor); break; } case JSType::SYMBOL: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), JSSymbol::SIZE, 3U); JSHandle symbol = factory->NewJSSymbol(); DUMP_FOR_HANDLE(symbol); break; } case JSType::JS_GENERATOR_CONTEXT: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), GeneratorContext::SIZE, 7U); JSHandle genContext = factory->NewGeneratorContext(); DUMP_FOR_HANDLE(genContext); break; } case JSType::PROTOTYPE_HANDLER: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PrototypeHandler::SIZE, 5U); JSHandle protoHandler = factory->NewPrototypeHandler(); DUMP_FOR_HANDLE(protoHandler); break; } case JSType::TRANSITION_HANDLER: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransitionHandler::SIZE, 2U); JSHandle transitionHandler = factory->NewTransitionHandler(); DUMP_FOR_HANDLE(transitionHandler); break; } case JSType::TRANS_WITH_PROTO_HANDLER: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TransWithProtoHandler::SIZE, 3U); JSHandle transWithProtoHandler = factory->NewTransWithProtoHandler(); DUMP_FOR_HANDLE(transWithProtoHandler); break; } case JSType::STORE_TS_HANDLER: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), StoreAOTHandler::SIZE, 3U); JSHandle storeAOTHandler = factory->NewStoreAOTHandler(); DUMP_FOR_HANDLE(storeAOTHandler); break; } case JSType::PROPERTY_BOX: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), PropertyBox::SIZE, 1U); JSHandle PropertyBox = factory->NewPropertyBox(globalConst->GetHandledEmptyArray()); DUMP_FOR_HANDLE(PropertyBox); break; } case JSType::ENUM_CACHE: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), EnumCache::SIZE, 4U); JSHandle enumCache = factory->NewEnumCache(); DUMP_FOR_HANDLE(enumCache); break; } case JSType::PROTO_CHANGE_MARKER: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeMarker::SIZE, 1U); JSHandle protoMaker = factory->NewProtoChangeMarker(); DUMP_FOR_HANDLE(protoMaker); break; } case JSType::MARKER_CELL: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MarkerCell::SIZE, 1U); JSHandle markerCell = factory->NewMarkerCell(); DUMP_FOR_HANDLE(markerCell); break; } case JSType::TRACK_INFO: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), TrackInfo::SIZE, 3U); break; } case JSType::PROTOTYPE_INFO: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ProtoChangeDetails::SIZE, 2U); JSHandle protoDetails = factory->NewProtoChangeDetails(); DUMP_FOR_HANDLE(protoDetails); break; } case JSType::TEMPLATE_MAP: { JSHandle templateMap = globalEnv->GetTemplateMap(); DUMP_FOR_HANDLE(templateMap); break; } case JSType::PROGRAM: { CHECK_DUMP_FIELDS(ECMAObject::SIZE, Program::SIZE, 1U); JSHandle program = factory->NewProgram(); DUMP_FOR_HANDLE(program); break; } case JSType::PROMISE_CAPABILITY: { CHECK_DUMP_FIELDS(Record::SIZE, PromiseCapability::SIZE, 3U); JSHandle promiseCapa = factory->NewPromiseCapability(); DUMP_FOR_HANDLE(promiseCapa); break; } case JSType::PROMISE_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, PromiseRecord::SIZE, 1U); JSHandle promiseRecord = factory->NewPromiseRecord(); DUMP_FOR_HANDLE(promiseRecord); break; } case JSType::RESOLVING_FUNCTIONS_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ResolvingFunctionsRecord::SIZE, 2U); JSHandle ResolvingFunc = factory->NewResolvingFunctionsRecord(); DUMP_FOR_HANDLE(ResolvingFunc); break; } case JSType::ASYNC_GENERATOR_REQUEST: { CHECK_DUMP_FIELDS(Record::SIZE, AsyncGeneratorRequest::SIZE, 2U); JSHandle asyncGeneratorRequest = factory->NewAsyncGeneratorRequest(); DUMP_FOR_HANDLE(asyncGeneratorRequest); break; } case JSType::ASYNC_ITERATOR_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, AsyncIteratorRecord::SIZE, 3U); JSHandle emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle emptyMethod(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle asyncIteratorRecord = factory->NewAsyncIteratorRecord(emptyObj, emptyMethod, false); DUMP_FOR_HANDLE(asyncIteratorRecord); break; } case JSType::JS_ASYNC_FROM_SYNC_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAsyncFromSyncIterator::SIZE, 1U); NEW_OBJECT_AND_DUMP(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR); break; } case JSType::JS_ASYNC_FROM_SYNC_ITER_UNWARP_FUNCTION: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncFromSyncIterUnwarpFunction::SIZE, 1U); break; } case JSType::PROMISE_REACTIONS: { CHECK_DUMP_FIELDS(Record::SIZE, PromiseReaction::SIZE, 3U); JSHandle promiseReact = factory->NewPromiseReaction(); DUMP_FOR_HANDLE(promiseReact); break; } case JSType::PROMISE_ITERATOR_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, PromiseIteratorRecord::SIZE, 2U); JSHandle emptyObj(thread, NewJSObject(thread, factory, globalEnv).GetTaggedValue()); JSHandle promiseIter = factory->NewPromiseIteratorRecord(emptyObj, false); DUMP_FOR_HANDLE(promiseIter); break; } case JSType::MICRO_JOB_QUEUE: { CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::MicroJobQueue::SIZE, 2U); JSHandle microJob = factory->NewMicroJobQueue(); DUMP_FOR_HANDLE(microJob); break; } case JSType::PENDING_JOB: { #if defined(ENABLE_HITRACE) CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 7U); #else CHECK_DUMP_FIELDS(Record::SIZE, ecmascript::job::PendingJob::SIZE, 2U); #endif JSHandle pendingClass(thread, JSHClass::Cast(globalConst->GetPendingJobClass().GetTaggedObject())); JSHandle pendingJob(thread, factory->NewObject(pendingClass)); ecmascript::job::PendingJob::Cast(*pendingJob)->SetJob(thread, JSTaggedValue::Undefined()); ecmascript::job::PendingJob::Cast(*pendingJob)->SetArguments(thread, JSTaggedValue::Undefined()); DUMP_FOR_HANDLE(pendingJob); break; } case JSType::COMPLETION_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, CompletionRecord::SIZE, 2U); JSHandle comRecord = factory->NewCompletionRecord(CompletionRecordType::NORMAL, globalConst->GetHandledEmptyArray()); DUMP_FOR_HANDLE(comRecord); break; } case JSType::MACHINE_CODE_OBJECT: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), MachineCode::SIZE, machineCodeSize); GTEST_LOG_(INFO) << "MACHINE_CODE_OBJECT not support new in MachineCodeSpace"; break; } case JSType::CLASS_INFO_EXTRACTOR: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassInfoExtractor::SIZE, 8U); JSHandle classInfoExtractor = factory->NewClassInfoExtractor( JSHandle(thread, JSTaggedValue::Undefined())); DUMP_FOR_HANDLE(classInfoExtractor); break; } case JSType::JS_API_ARRAY_LIST: { // 1 : 1 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayList::SIZE, 1U); JSHandle jsArrayList = NewJSAPIArrayList(thread, factory, proto); DUMP_FOR_HANDLE(jsArrayList); break; } case JSType::JS_API_ARRAYLIST_ITERATOR: { // 2 : 2 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIArrayListIterator::SIZE, 2U); JSHandle jsArrayList = NewJSAPIArrayList(thread, factory, proto); JSHandle jsArrayListIter = factory->NewJSAPIArrayListIterator(jsArrayList); DUMP_FOR_HANDLE(jsArrayListIter); break; } case JSType::JS_API_BITVECTOR: { break; } case JSType::JS_API_BITVECTOR_ITERATOR: { break; } case JSType::JS_API_FAST_BUFFER: { break; } case JSType::LINKED_NODE: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), LinkedNode::SIZE, 4U); break; } case JSType::RB_TREENODE: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), RBTreeNode::SIZE, 7U); break; } case JSType::JS_API_HASH_MAP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMap::SIZE, 2U); JSHandle jsHashMap = NewJSAPIHashMap(thread, factory); DUMP_FOR_HANDLE(jsHashMap); break; } case JSType::JS_API_HASH_SET: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSet::SIZE, 2U); JSHandle jsHashSet = NewJSAPIHashSet(thread, factory); DUMP_FOR_HANDLE(jsHashSet); break; } case JSType::JS_API_HASHMAP_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashMapIterator::SIZE, 4U); JSHandle jsHashMap = NewJSAPIHashMap(thread, factory); JSHandle jsHashMapIter = factory->NewJSAPIHashMapIterator(jsHashMap, IterationKind::KEY); DUMP_FOR_HANDLE(jsHashMapIter); break; } case JSType::JS_API_HASHSET_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIHashSetIterator::SIZE, 4U); JSHandle jsHashSet = NewJSAPIHashSet(thread, factory); JSHandle jsHashSetIter = factory->NewJSAPIHashSetIterator(jsHashSet, IterationKind::KEY); DUMP_FOR_HANDLE(jsHashSetIter); break; } case JSType::JS_API_LIGHT_WEIGHT_MAP: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMap::SIZE, 4U); JSHandle jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory); DUMP_FOR_HANDLE(jSAPILightWeightMap); break; } case JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightMapIterator::SIZE, 2U); JSHandle jSAPILightWeightMap = NewJSAPILightWeightMap(thread, factory); JSHandle jSAPILightWeightMapIterator = factory->NewJSAPILightWeightMapIterator(jSAPILightWeightMap, IterationKind::KEY); DUMP_FOR_HANDLE(jSAPILightWeightMapIterator); break; } case JSType::JS_API_LIGHT_WEIGHT_SET: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSet::SIZE, 3U); JSHandle jSAPILightWeightSet = NewJSAPILightWeightSet(thread, factory); DUMP_FOR_HANDLE(jSAPILightWeightSet); break; } case JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILightWeightSetIterator::SIZE, 2U); JSHandle jSAPILightWeightSetIter = factory->NewJSAPILightWeightSetIterator(NewJSAPILightWeightSet(thread, factory), IterationKind::KEY); DUMP_FOR_HANDLE(jSAPILightWeightSetIter); break; } case JSType::JS_API_QUEUE: { // 2 : 2 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueue::SIZE, 2U); JSHandle jsQueue = NewJSAPIQueue(thread, factory, proto); DUMP_FOR_HANDLE(jsQueue); break; } case JSType::JS_API_QUEUE_ITERATOR: { // 2 : 2 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIQueueIterator::SIZE, 2U); JSHandle jsQueue = NewJSAPIQueue(thread, factory, proto); JSHandle jsQueueIter = factory->NewJSAPIQueueIterator(jsQueue); DUMP_FOR_HANDLE(jsQueueIter); break; } case JSType::JS_API_PLAIN_ARRAY: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArray::SIZE, 3U); JSHandle jSAPIPlainArray = NewJSAPIPlainArray(thread, factory); DUMP_FOR_HANDLE(jSAPIPlainArray); break; } case JSType::JS_API_PLAIN_ARRAY_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIPlainArrayIterator::SIZE, 2U); JSHandle jSAPIPlainArray = NewJSAPIPlainArray(thread, factory); JSHandle jSAPIPlainArrayIter = factory->NewJSAPIPlainArrayIterator(jSAPIPlainArray, IterationKind::KEY); DUMP_FOR_HANDLE(jSAPIPlainArrayIter); break; } case JSType::JS_API_TREE_MAP: { // 1 : 1 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMap::SIZE, 1U); JSHandle jsTreeMap = NewJSAPITreeMap(thread, factory); DUMP_FOR_HANDLE(jsTreeMap); break; } case JSType::JS_API_TREE_SET: { // 1 : 1 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSet::SIZE, 1U); JSHandle jsTreeSet = NewJSAPITreeSet(thread, factory); DUMP_FOR_HANDLE(jsTreeSet); break; } case JSType::JS_API_TREEMAP_ITERATOR: { // 3 : 3 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeMapIterator::SIZE, 3U); JSHandle jsTreeMap = NewJSAPITreeMap(thread, factory); JSHandle jsTreeMapIter = factory->NewJSAPITreeMapIterator(jsTreeMap, IterationKind::KEY); DUMP_FOR_HANDLE(jsTreeMapIter); break; } case JSType::JS_API_TREESET_ITERATOR: { // 3 : 3 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPITreeSetIterator::SIZE, 3U); JSHandle jsTreeSet = NewJSAPITreeSet(thread, factory); JSHandle jsTreeSetIter = factory->NewJSAPITreeSetIterator(jsTreeSet, IterationKind::KEY); DUMP_FOR_HANDLE(jsTreeSetIter); break; } case JSType::JS_API_DEQUE: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDeque::SIZE, 1U); JSHandle jsDeque = NewJSAPIDeque(thread, factory, proto); DUMP_FOR_HANDLE(jsDeque); break; } case JSType::JS_API_DEQUE_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIDequeIterator::SIZE, 2U); JSHandle jsDequeIter = factory->NewJSAPIDequeIterator(NewJSAPIDeque(thread, factory, proto)); DUMP_FOR_HANDLE(jsDequeIter); break; } case JSType::JS_API_STACK: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStack::SIZE, 1U); JSHandle jsStack = NewJSAPIStack(factory, proto); DUMP_FOR_HANDLE(jsStack); break; } case JSType::JS_API_STACK_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIStackIterator::SIZE, 2U); JSHandle jsStackIter = factory->NewJSAPIStackIterator(NewJSAPIStack(factory, proto)); DUMP_FOR_HANDLE(jsStackIter); break; } case JSType::JS_API_VECTOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVector::SIZE, 1U); JSHandle jsVector = NewJSAPIVector(factory, proto); DUMP_FOR_HANDLE(jsVector); break; } case JSType::JS_API_VECTOR_ITERATOR: { CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIVectorIterator::SIZE, 2U); JSHandle jsVectorIter = factory->NewJSAPIVectorIterator(NewJSAPIVector(factory, proto)); DUMP_FOR_HANDLE(jsVectorIter); break; } case JSType::JS_API_LIST: { // 1 : 1 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIList::SIZE, 2U); JSHandle jsAPIList = NewJSAPIList(thread, factory); DUMP_FOR_HANDLE(jsAPIList); break; } case JSType::JS_API_LINKED_LIST: { // 1 : 1 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedList::SIZE, 1U); JSHandle jsAPILinkedList = NewJSAPILinkedList(thread, factory); DUMP_FOR_HANDLE(jsAPILinkedList); break; } case JSType::JS_API_LIST_ITERATOR: { // 2 : 2 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPIListIterator::SIZE, 2U); JSHandle jsAPIList = NewJSAPIList(thread, factory); JSHandle jsAPIListIter = factory->NewJSAPIListIterator(jsAPIList); DUMP_FOR_HANDLE(jsAPIListIter); break; } case JSType::JS_API_LINKED_LIST_ITERATOR: { // 2 : 2 dump fileds number CHECK_DUMP_FIELDS(JSObject::SIZE, JSAPILinkedListIterator::SIZE, 2U); JSHandle jsAPILinkedList = NewJSAPILinkedList(thread, factory); JSHandle jsAPILinkedListIter = factory->NewJSAPILinkedListIterator(jsAPILinkedList); DUMP_FOR_HANDLE(jsAPILinkedListIter); break; } case JSType::MODULE_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ModuleRecord::SIZE, 0U); break; } case JSType::SOURCE_TEXT_MODULE_RECORD: { CHECK_DUMP_FIELDS(ModuleRecord::SIZE, SourceTextModule::SIZE, 20U); JSHandle moduleSourceRecord = factory->NewSourceTextModule(); DUMP_FOR_HANDLE(moduleSourceRecord); break; } case JSType::IMPORTENTRY_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ImportEntry::SIZE, 3U); JSHandle importEntry = factory->NewImportEntry(); DUMP_FOR_HANDLE(importEntry); break; } case JSType::LOCAL_EXPORTENTRY_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, LocalExportEntry::SIZE, 3U); JSHandle localExportEntry = factory->NewLocalExportEntry(); DUMP_FOR_HANDLE(localExportEntry); break; } case JSType::INDIRECT_EXPORTENTRY_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, IndirectExportEntry::SIZE, 3U); JSHandle indirectExportEntry = factory->NewIndirectExportEntry(); DUMP_FOR_HANDLE(indirectExportEntry); break; } case JSType::STAR_EXPORTENTRY_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, StarExportEntry::SIZE, 1U); break; } case JSType::RESOLVEDBINDING_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ResolvedBinding::SIZE, 2U); JSHandle resolvedBinding = factory->NewResolvedBindingRecord(); DUMP_FOR_HANDLE(resolvedBinding); break; } case JSType::RESOLVEDINDEXBINDING_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ResolvedIndexBinding::SIZE, 2U); JSHandle resolvedBinding = factory->NewResolvedIndexBindingRecord(); DUMP_FOR_HANDLE(resolvedBinding); break; } case JSType::RESOLVEDRECORDINDEXBINDING_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordIndexBinding::SIZE, 3U); JSHandle recordBinding = factory->NewSResolvedRecordIndexBindingRecord(); DUMP_FOR_HANDLE(recordBinding); break; } case JSType::RESOLVEDRECORDBINDING_RECORD: { CHECK_DUMP_FIELDS(Record::SIZE, ResolvedRecordBinding::SIZE, 2U); JSHandle recordBinding = factory->NewSResolvedRecordBindingRecord(); DUMP_FOR_HANDLE(recordBinding); break; } case JSType::JS_MODULE_NAMESPACE: { CHECK_DUMP_FIELDS(JSObject::SIZE, ModuleNamespace::SIZE, 3U); JSHandle moduleNamespace = factory->NewModuleNamespace(); DUMP_FOR_HANDLE(moduleNamespace); break; } case JSType::NATIVE_MODULE_FAILURE_INFO: { CHECK_DUMP_FIELDS(JSObject::SIZE, NativeModuleFailureInfo::SIZE, 1U); JSHandle nativeFailureInfo = factory->NewNativeModuleFailureInfo(); DUMP_FOR_HANDLE(nativeFailureInfo); break; } case JSType::JS_CJS_EXPORTS: { CHECK_DUMP_FIELDS(JSObject::SIZE, CjsExports::SIZE, 1U); JSHandle cjsExports = factory->NewCjsExports(); DUMP_FOR_HANDLE(cjsExports); break; } case JSType::JS_CJS_MODULE: { CHECK_DUMP_FIELDS(JSObject::SIZE, CjsModule::SIZE, 5U); JSHandle cjsModule = factory->NewCjsModule(); DUMP_FOR_HANDLE(cjsModule); break; } case JSType::JS_CJS_REQUIRE: { CHECK_DUMP_FIELDS(JSObject::SIZE, CjsRequire::SIZE, 2U); JSHandle cjsRequire = factory->NewCjsRequire(); DUMP_FOR_HANDLE(cjsRequire); break; } case JSType::JS_ITERATOR: case JSType::JS_ASYNCITERATOR: case JSType::FREE_OBJECT_WITH_ONE_FIELD: case JSType::FREE_OBJECT_WITH_NONE_FIELD: case JSType::FREE_OBJECT_WITH_TWO_FIELD: case JSType::JS_NATIVE_POINTER: { break; } case JSType::JS_ASYNC_GENERATOR_RESUME_NEXT_RETURN_PROCESSOR_RST_FTN: { CHECK_DUMP_FIELDS(JSFunction::SIZE, JSAsyncGeneratorResNextRetProRstFtn::SIZE, 1U); break; } case JSType::CLASS_LITERAL: { CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), ClassLiteral::SIZE, 2U); JSHandle classLiteral = factory->NewClassLiteral(); DUMP_FOR_HANDLE(classLiteral); break; } default: LOG_ECMA_MEM(FATAL) << "JSType " << static_cast(type) << " cannot be dumped."; UNREACHABLE(); break; } } #undef NEW_OBJECT_AND_DUMP #undef DUMP_FOR_HANDLE } } // namespace panda::test