14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#include "ecmascript/global_env_constants.h"
174514f5e3Sopenharmony_ci
184514f5e3Sopenharmony_ci#include "ecmascript/ecma_string-inl.h"
194514f5e3Sopenharmony_ci#include "ecmascript/free_object.h"
204514f5e3Sopenharmony_ci#include "ecmascript/ic/ic_handler.h"
214514f5e3Sopenharmony_ci#include "ecmascript/ic/proto_change_details.h"
224514f5e3Sopenharmony_ci#include "ecmascript/jobs/pending_job.h"
234514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_arraylist_iterator.h"
244514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_bitvector_iterator.h"
254514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_deque_iterator.h"
264514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_lightweightmap_iterator.h"
274514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_lightweightset_iterator.h"
284514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_linked_list_iterator.h"
294514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_list_iterator.h"
304514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_plain_array_iterator.h"
314514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_queue_iterator.h"
324514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_stack_iterator.h"
334514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_hashmap_iterator.h"
344514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_hashset_iterator.h"
354514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_tree_map_iterator.h"
364514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_tree_set_iterator.h"
374514f5e3Sopenharmony_ci#include "ecmascript/js_api/js_api_vector_iterator.h"
384514f5e3Sopenharmony_ci#include "ecmascript/js_async_generator_object.h"
394514f5e3Sopenharmony_ci#include "ecmascript/jspandafile/program_object.h"
404514f5e3Sopenharmony_ci#include "ecmascript/js_array_iterator.h"
414514f5e3Sopenharmony_ci#include "ecmascript/js_finalization_registry.h"
424514f5e3Sopenharmony_ci#include "ecmascript/js_map_iterator.h"
434514f5e3Sopenharmony_ci#include "ecmascript/js_promise.h"
444514f5e3Sopenharmony_ci#include "ecmascript/js_realm.h"
454514f5e3Sopenharmony_ci#include "ecmascript/js_regexp_iterator.h"
464514f5e3Sopenharmony_ci#include "ecmascript/js_set_iterator.h"
474514f5e3Sopenharmony_ci#include "ecmascript/marker_cell.h"
484514f5e3Sopenharmony_ci#include "ecmascript/runtime.h"
494514f5e3Sopenharmony_ci#include "ecmascript/shared_objects/js_shared_array.h"
504514f5e3Sopenharmony_ci#include "ecmascript/shared_objects/js_shared_array_iterator.h"
514514f5e3Sopenharmony_ci#include "ecmascript/shared_objects/js_shared_map_iterator.h"
524514f5e3Sopenharmony_ci#include "ecmascript/shared_objects/js_shared_set_iterator.h"
534514f5e3Sopenharmony_ci#include "ecmascript/vtable.h"
544514f5e3Sopenharmony_ci
554514f5e3Sopenharmony_cinamespace panda::ecmascript {
564514f5e3Sopenharmony_civoid GlobalEnvConstants::Init(JSThread *thread)
574514f5e3Sopenharmony_ci{
584514f5e3Sopenharmony_ci    ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
594514f5e3Sopenharmony_ci    if (Runtime::GetInstance()->SharedConstInited()) {
604514f5e3Sopenharmony_ci        auto *globalConst = Runtime::GetInstance()->GetGlobalEnvConstants();
614514f5e3Sopenharmony_ci        // 1. Copy shareds.
624514f5e3Sopenharmony_ci        for (size_t i = static_cast<size_t>(ConstantIndex::SHARED_BEGIN);
634514f5e3Sopenharmony_ci            i <= static_cast<size_t>(ConstantIndex::SHARED_END); i++) {
644514f5e3Sopenharmony_ci            constants_[i] = globalConst->constants_[i];
654514f5e3Sopenharmony_ci        }
664514f5e3Sopenharmony_ci    } else {
674514f5e3Sopenharmony_ci        InitSharedRootsClasses(factory);
684514f5e3Sopenharmony_ci        InitSharedMiscellanious(thread, factory);
694514f5e3Sopenharmony_ci        InitSharedStrings(factory);
704514f5e3Sopenharmony_ci    }
714514f5e3Sopenharmony_ci    // 2. Init non-shareds.
724514f5e3Sopenharmony_ci    InitMiscellanious(thread, factory);
734514f5e3Sopenharmony_ci    InitRootsClasses(factory);
744514f5e3Sopenharmony_ci}
754514f5e3Sopenharmony_ci
764514f5e3Sopenharmony_civoid GlobalEnvConstants::CopySharedConstantsFrom(const GlobalEnvConstants *src)
774514f5e3Sopenharmony_ci{
784514f5e3Sopenharmony_ci    for (size_t i = 0; i < static_cast<size_t>(ConstantIndex::SHARED_BEGIN); i++) {
794514f5e3Sopenharmony_ci        constants_[i] = JSTaggedValue::Hole();
804514f5e3Sopenharmony_ci    }
814514f5e3Sopenharmony_ci    for (size_t i = static_cast<size_t>(ConstantIndex::SHARED_BEGIN);
824514f5e3Sopenharmony_ci        i <= static_cast<size_t>(ConstantIndex::SHARED_END); i++) {
834514f5e3Sopenharmony_ci        constants_[i] = src->constants_[i];
844514f5e3Sopenharmony_ci    }
854514f5e3Sopenharmony_ci    for (size_t i = static_cast<size_t>(ConstantIndex::SHARED_END) + 1;
864514f5e3Sopenharmony_ci        i < static_cast<size_t>(ConstantIndex::CONSTANT_COUNT); i++) {
874514f5e3Sopenharmony_ci        constants_[i] = JSTaggedValue::Hole();
884514f5e3Sopenharmony_ci    }
894514f5e3Sopenharmony_ci}
904514f5e3Sopenharmony_ci
914514f5e3Sopenharmony_civoid GlobalEnvConstants::InitSharedStrings(ObjectFactory *factory)
924514f5e3Sopenharmony_ci{
934514f5e3Sopenharmony_ci    #define INIT_GLOBAL_ENV_CONSTANT_STRING(Name, Index, Token) \
944514f5e3Sopenharmony_ci        SetConstant(ConstantIndex::Index, factory->NewFromASCIIReadOnly(Token));
954514f5e3Sopenharmony_ci        SHARED_GLOBAL_ENV_CONSTANT_STRING(INIT_GLOBAL_ENV_CONSTANT_STRING)
964514f5e3Sopenharmony_ci    #undef INIT_GLOBAL_ENV_CONSTANT_STRING
974514f5e3Sopenharmony_ci}
984514f5e3Sopenharmony_ci
994514f5e3Sopenharmony_civoid GlobalEnvConstants::InitSharedRootsClasses(ObjectFactory *factory)
1004514f5e3Sopenharmony_ci{
1014514f5e3Sopenharmony_ci    // Global constants are readonly.
1024514f5e3Sopenharmony_ci    JSHClass *hClass = *factory->InitSClassClass();
1034514f5e3Sopenharmony_ci
1044514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::HCLASS_CLASS_INDEX, JSTaggedValue(hClass));
1054514f5e3Sopenharmony_ci    // To reverse the order, the hclass of string needs to load default supers
1064514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ARRAY_CLASS_INDEX,
1074514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::TAGGED_ARRAY));
1084514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FREE_OBJECT_WITH_NONE_FIELD_CLASS_INDEX,
1094514f5e3Sopenharmony_ci                factory->NewSEcmaReadOnlyHClass(hClass, FreeObject::NEXT_OFFSET, JSType::FREE_OBJECT_WITH_NONE_FIELD));
1104514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FREE_OBJECT_WITH_ONE_FIELD_CLASS_INDEX,
1114514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, FreeObject::SIZE_OFFSET, JSType::FREE_OBJECT_WITH_ONE_FIELD));
1124514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FREE_OBJECT_WITH_TWO_FIELD_CLASS_INDEX,
1134514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, FreeObject::SIZE, JSType::FREE_OBJECT_WITH_TWO_FIELD));
1144514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::LINE_STRING_CLASS_INDEX,
1154514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::LINE_STRING));
1164514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SLICED_STRING_CLASS_INDEX,
1174514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::SLICED_STRING));
1184514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CONSTANT_STRING_CLASS_INDEX,
1194514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::CONSTANT_STRING));
1204514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::TREE_STRING_CLASS_INDEX,
1214514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::TREE_STRING));
1224514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::BYTE_ARRAY_CLASS_INDEX,
1234514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::BYTE_ARRAY));
1244514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CONSTANT_POOL_CLASS_INDEX,
1254514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::CONSTANT_POOL));
1264514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROFILE_TYPE_INFO_CLASS_INDEX,
1274514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::PROFILE_TYPE_INFO));
1284514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::AOT_LITERAL_INFO_CLASS_INDEX,
1294514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::AOT_LITERAL_INFO));
1304514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EXTRA_PROFILE_TYPE_INFO_CLASS_INDEX,
1314514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ExtraProfileTypeInfo::SIZE, JSType::EXTRA_PROFILE_TYPE_INFO));
1324514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROFILE_TYPE_INFO_CELL_0_CLASS_INDEX,
1334514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ProfileTypeInfoCell::SIZE, JSType::PROFILE_TYPE_INFO_CELL_0));
1344514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROFILE_TYPE_INFO_CELL_1_CLASS_INDEX,
1354514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ProfileTypeInfoCell::SIZE, JSType::PROFILE_TYPE_INFO_CELL_1));
1364514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROFILE_TYPE_INFO_CELL_N_CLASS_INDEX,
1374514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ProfileTypeInfoCell::SIZE, JSType::PROFILE_TYPE_INFO_CELL_N));
1384514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FUNCTION_TEMPLATE_CLASS_INDEX,
1394514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, FunctionTemplate::SIZE, JSType::FUNCTION_TEMPLATE));
1404514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::VTABLE_CLASS_INDEX,
1414514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::VTABLE));
1424514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::COW_MUTANT_TAGGED_ARRAY_CLASS_INDEX,
1434514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::COW_MUTANT_TAGGED_ARRAY));
1444514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::MUTANT_TAGGED_ARRAY_CLASS_INDEX,
1454514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::MUTANT_TAGGED_ARRAY));
1464514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::DICTIONARY_CLASS_INDEX,
1474514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::TAGGED_DICTIONARY));
1484514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::COW_ARRAY_CLASS_INDEX,
1494514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::COW_TAGGED_ARRAY));
1504514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::BIGINT_CLASS_INDEX,
1514514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, BigInt::SIZE, JSType::BIGINT));
1524514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SENDABLE_JS_NATIVE_POINTER_CLASS_INDEX,
1534514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, JSNativePointer::SIZE, JSType::JS_NATIVE_POINTER));
1544514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ENV_CLASS_INDEX,
1554514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::LEXICAL_ENV));
1564514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SYMBOL_CLASS_INDEX,
1574514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, JSSymbol::SIZE, JSType::SYMBOL));
1584514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ACCESSOR_DATA_CLASS_INDEX,
1594514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, AccessorData::SIZE, JSType::ACCESSOR_DATA));
1604514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::INTERNAL_ACCESSOR_CLASS_INDEX,
1614514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, AccessorData::SIZE, JSType::INTERNAL_ACCESSOR));
1624514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::COMPLETION_RECORD_CLASS_INDEX,
1634514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, CompletionRecord::SIZE, JSType::COMPLETION_RECORD));
1644514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::GENERATOR_CONTEST_INDEX,
1654514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, GeneratorContext::SIZE, JSType::JS_GENERATOR_CONTEXT));
1664514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ASYNC_GENERATOR_REQUEST_CLASS_INDEX,
1674514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, AsyncGeneratorRequest::SIZE,
1684514f5e3Sopenharmony_ci                                        JSType::ASYNC_GENERATOR_REQUEST));
1694514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ASYNC_ITERATOR_RECORD_CLASS_INDEX,
1704514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, AsyncIteratorRecord::SIZE, JSType::ASYNC_ITERATOR_RECORD));
1714514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CAPABILITY_RECORD_CLASS_INDEX,
1724514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PromiseCapability::SIZE, JSType::PROMISE_CAPABILITY));
1734514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::REACTIONS_RECORD_CLASS_INDEX,
1744514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PromiseReaction::SIZE, JSType::PROMISE_REACTIONS));
1754514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROMISE_ITERATOR_RECORD_CLASS_INDEX,
1764514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PromiseIteratorRecord::SIZE,
1774514f5e3Sopenharmony_ci                                        JSType::PROMISE_ITERATOR_RECORD));
1784514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROMISE_RECORD_CLASS_INDEX,
1794514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PromiseRecord::SIZE, JSType::PROMISE_RECORD));
1804514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROMISE_RESOLVING_FUNCTIONS_CLASS_INDEX,
1814514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ResolvingFunctionsRecord::SIZE,
1824514f5e3Sopenharmony_ci                                        JSType::RESOLVING_FUNCTIONS_RECORD));
1834514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::MICRO_JOB_QUEUE_CLASS_INDEX,
1844514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, job::MicroJobQueue::SIZE, JSType::MICRO_JOB_QUEUE));
1854514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PENDING_JOB_CLASS_INDEX,
1864514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, job::PendingJob::SIZE, JSType::PENDING_JOB));
1874514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROTO_CHANGE_MARKER_CLASS_INDEX,
1884514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ProtoChangeMarker::SIZE, JSType::PROTO_CHANGE_MARKER));
1894514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROTO_CHANGE_DETAILS_CLASS_INDEX,
1904514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ProtoChangeDetails::SIZE, JSType::PROTOTYPE_INFO));
1914514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::MARKER_CELL_CLASS_INDEX,
1924514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, MarkerCell::SIZE, JSType::MARKER_CELL));
1934514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::TRACK_INFO_CLASS_INDEX,
1944514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, TrackInfo::SIZE, JSType::TRACK_INFO));
1954514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROTOTYPE_HANDLER_CLASS_INDEX,
1964514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PrototypeHandler::SIZE, JSType::PROTOTYPE_HANDLER));
1974514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::TRANSITION_HANDLER_CLASS_INDEX,
1984514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, TransitionHandler::SIZE, JSType::TRANSITION_HANDLER));
1994514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::TRANS_WITH_PROTO_HANDLER_CLASS_INDEX,
2004514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, TransWithProtoHandler::SIZE, JSType::TRANS_WITH_PROTO_HANDLER));
2014514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::STORE_TS_HANDLER_CLASS_INDEX,
2024514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, StoreTSHandler::SIZE, JSType::STORE_TS_HANDLER));
2034514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROPERTY_BOX_CLASS_INDEX,
2044514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, PropertyBox::SIZE, JSType::PROPERTY_BOX));
2054514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::PROGRAM_CLASS_INDEX,
2064514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, Program::SIZE, JSType::PROGRAM));
2074514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::IMPORT_ENTRY_CLASS_INDEX,
2084514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ImportEntry::SIZE, JSType::IMPORTENTRY_RECORD));
2094514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::LOCAL_EXPORT_ENTRY_CLASS_INDEX,
2104514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, LocalExportEntry::SIZE, JSType::LOCAL_EXPORTENTRY_RECORD));
2114514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::INDIRECT_EXPORT_ENTRY_CLASS_INDEX,
2124514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, IndirectExportEntry::SIZE,
2134514f5e3Sopenharmony_ci                                        JSType::INDIRECT_EXPORTENTRY_RECORD));
2144514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::STAR_EXPORT_ENTRY_CLASS_INDEX,
2154514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, StarExportEntry::SIZE, JSType::STAR_EXPORTENTRY_RECORD));
2164514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SOURCE_TEXT_MODULE_CLASS_INDEX,
2174514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, SourceTextModule::SIZE, JSType::SOURCE_TEXT_MODULE_RECORD));
2184514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::RESOLVED_BINDING_CLASS_INDEX,
2194514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ResolvedBinding::SIZE, JSType::RESOLVEDBINDING_RECORD));
2204514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::RESOLVED_INDEX_BINDING_CLASS_INDEX,
2214514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ResolvedIndexBinding::SIZE, JSType::RESOLVEDINDEXBINDING_RECORD));
2224514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::MACHINE_CODE_CLASS_INDEX,
2234514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::MACHINE_CODE_OBJECT));
2244514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CLASS_INFO_EXTRACTOR_HCLASS_INDEX,
2254514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ClassInfoExtractor::SIZE,
2264514f5e3Sopenharmony_ci                                        JSType::CLASS_INFO_EXTRACTOR));
2274514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CELL_RECORD_CLASS_INDEX,
2284514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, CellRecord::SIZE, JSType::CELL_RECORD));
2294514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::METHOD_CLASS_INDEX,
2304514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, Method::SIZE, JSType::METHOD));
2314514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::LINKED_NODE_CLASS_INDEX,
2324514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, LinkedNode::SIZE, JSType::LINKED_NODE));
2334514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::RB_TREENODE_CLASS_INDEX,
2344514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, RBTreeNode::SIZE, JSType::RB_TREENODE));
2354514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CLASS_LITERAL_HCLASS_INDEX,
2364514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ClassLiteral::SIZE, JSType::CLASS_LITERAL));
2374514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::RESOLVED_RECORD_INEDX_BINDING_CLASS_INDEX,
2384514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ResolvedRecordIndexBinding::SIZE,
2394514f5e3Sopenharmony_ci        JSType::RESOLVEDRECORDINDEXBINDING_RECORD));
2404514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::RESOLVED_RECORD_BINDING_CLASS_INDEX,
2414514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, ResolvedRecordBinding::SIZE, JSType::RESOLVEDRECORDBINDING_RECORD));
2424514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SENDABLE_ENV_CLASS_INDEX,
2434514f5e3Sopenharmony_ci        factory->NewSEcmaReadOnlyHClass(hClass, 0, JSType::SENDABLE_ENV));
2444514f5e3Sopenharmony_ci}
2454514f5e3Sopenharmony_ci
2464514f5e3Sopenharmony_civoid GlobalEnvConstants::InitSharedMiscellanious(JSThread *thread, ObjectFactory *factory)
2474514f5e3Sopenharmony_ci{
2484514f5e3Sopenharmony_ci    // Accessors
2494514f5e3Sopenharmony_ci    auto accessor = factory->NewSInternalAccessor(reinterpret_cast<void *>(JSFunction::PrototypeSetter),
2504514f5e3Sopenharmony_ci                                                  reinterpret_cast<void *>(JSFunction::PrototypeGetter));
2514514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FUNCTION_PROTOTYPE_ACCESSOR, accessor);
2524514f5e3Sopenharmony_ci    accessor = factory->NewSInternalAccessor(nullptr, reinterpret_cast<void *>(JSFunction::NameGetter));
2534514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FUNCTION_NAME_ACCESSOR, accessor);
2544514f5e3Sopenharmony_ci    accessor = factory->NewSInternalAccessor(nullptr, reinterpret_cast<void *>(JSFunction::LengthGetter));
2554514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FUNCTION_LENGTH_ACCESSOR, accessor);
2564514f5e3Sopenharmony_ci    accessor = factory->NewSInternalAccessor(reinterpret_cast<void *>(JSArray::LengthSetter),
2574514f5e3Sopenharmony_ci                                             reinterpret_cast<void *>(JSArray::LengthGetter));
2584514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::ARRAY_LENGTH_ACCESSOR, accessor);
2594514f5e3Sopenharmony_ci    accessor = factory->NewSInternalAccessor(reinterpret_cast<void *>(JSSharedArray::DummyLengthSetter),
2604514f5e3Sopenharmony_ci                                             reinterpret_cast<void *>(JSSharedArray::LengthGetter));
2614514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SHARED_ARRAY_LENGTH_ACCESSOR, accessor);
2624514f5e3Sopenharmony_ci    // Specials
2634514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::UNDEFINED_INDEX, JSTaggedValue::Undefined());
2644514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::NULL_INDEX, JSTaggedValue::Null());
2654514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::HOLE_INDEX, JSTaggedValue::Hole());
2664514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::TRUE_INDEX, JSTaggedValue::True());
2674514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::FALSE_INDEX, JSTaggedValue::False());
2684514f5e3Sopenharmony_ci    // Emptys
2694514f5e3Sopenharmony_ci    auto vm = thread->GetEcmaVM();
2704514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_STRING_OBJECT_INDEX, JSTaggedValue(EcmaStringAccessor::CreateEmptyString(vm)));
2714514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::SINGLE_CHAR_TABLE_INDEX, SingleCharTable::CreateSingleCharTable(thread));
2724514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_ARRAY_OBJECT_INDEX, factory->NewSEmptyArray());
2734514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_MUTANT_ARRAY_OBJECT_INDEX, factory->NewSEmptyMutantArray());
2744514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_SLAYOUT_INFO_OBJECT_INDEX, factory->NewSEmptyLayoutInfo());
2754514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::UINT64_MAX_BIGINT_INDEX, BigInt::CreateUint64MaxBigInt(thread));
2764514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::INT64_MAX_BIGINT_INDEX, BigInt::CreateInt64MaxBigInt(thread));
2774514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_PROFILE_TYPE_INFO_CELL_INDEX, factory->NewSEmptyProfileTypeInfoCell());
2784514f5e3Sopenharmony_ci}
2794514f5e3Sopenharmony_ci
2804514f5e3Sopenharmony_civoid GlobalEnvConstants::InitRootsClassesPartOne(JSHClass *hClass, ObjectFactory *factory)
2814514f5e3Sopenharmony_ci{
2824514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_LINKED_LIST_ITERATOR_CLASS_INDEX,
2834514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPILinkedListIterator::SIZE, JSType::JS_API_LINKED_LIST_ITERATOR));
2844514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_LIST_ITERATOR_CLASS_INDEX,
2854514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIListIterator::SIZE, JSType::JS_API_LIST_ITERATOR));
2864514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_PLAIN_ARRAY_ITERATOR_CLASS_INDEX,
2874514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIPlainArrayIterator::SIZE, JSType::JS_API_PLAIN_ARRAY_ITERATOR));
2884514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_QUEUE_ITERATOR_CLASS_INDEX,
2894514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIQueueIterator::SIZE, JSType::JS_API_QUEUE_ITERATOR));
2904514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_STACK_ITERATOR_CLASS_INDEX,
2914514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIStackIterator::SIZE, JSType::JS_API_STACK_ITERATOR));
2924514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_VECTOR_ITERATOR_CLASS_INDEX,
2934514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIVectorIterator::SIZE, JSType::JS_API_VECTOR_ITERATOR));
2944514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_HASH_MAP_ITERATOR_CLASS_INDEX,
2954514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIHashMapIterator::SIZE, JSType::JS_API_HASHMAP_ITERATOR));
2964514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_HASH_SET_ITERATOR_CLASS_INDEX,
2974514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIHashSetIterator::SIZE, JSType::JS_API_HASHSET_ITERATOR));
2984514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_TREE_MAP_ITERATOR_CLASS_INDEX,
2994514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPITreeMapIterator::SIZE, JSType::JS_API_TREEMAP_ITERATOR));
3004514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_TREE_SET_ITERATOR_CLASS_INDEX,
3014514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPITreeSetIterator::SIZE, JSType::JS_API_TREESET_ITERATOR));
3024514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::OBJECT_HCLASS_INDEX, factory->NewEcmaHClass(JSObject::SIZE, JSType::JS_OBJECT));
3034514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CLASS_PROTOTYPE_HCLASS_INDEX,
3044514f5e3Sopenharmony_ci                factory->CreateDefaultClassPrototypeHClass(hClass));
3054514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CLASS_CONSTRUCTOR_HCLASS_INDEX,
3064514f5e3Sopenharmony_ci                factory->CreateDefaultClassConstructorHClass(hClass));
3074514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_PROXY_ORDINARY_CLASS_INDEX,
3084514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSProxy::SIZE, JSType::JS_PROXY));
3094514f5e3Sopenharmony_ci    // napi_wrap need set NativePointer to object, so only mark the shared bit in shared JSNativePointer hclass.
3104514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_NATIVE_POINTER_CLASS_INDEX,
3114514f5e3Sopenharmony_ci        factory->NewEcmaReadOnlyHClass(hClass, JSNativePointer::SIZE, JSType::JS_NATIVE_POINTER));
3124514f5e3Sopenharmony_ci}
3134514f5e3Sopenharmony_ci
3144514f5e3Sopenharmony_civoid GlobalEnvConstants::InitRootsClassesPartTwo(JSHClass *hClass, ObjectFactory *factory)
3154514f5e3Sopenharmony_ci{
3164514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_REALM_CLASS_INDEX,
3174514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSRealm::SIZE, JSType::JS_REALM));
3184514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_REGEXP_ITERATOR_CLASS_INDEX,
3194514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSRegExpIterator::SIZE, JSType::JS_REG_EXP_ITERATOR));
3204514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_SET_ITERATOR_CLASS_INDEX,
3214514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSSetIterator::SIZE, JSType::JS_SET_ITERATOR, 0)); // 0: no inlined props
3224514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_SHARED_SET_ITERATOR_CLASS_INDEX,
3234514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSSharedSetIterator::SIZE,
3244514f5e3Sopenharmony_ci                JSType::JS_SHARED_SET_ITERATOR, 0)); // 0: no inlined props
3254514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_MAP_ITERATOR_CLASS_INDEX,
3264514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSMapIterator::SIZE, JSType::JS_MAP_ITERATOR, 0)); // 0: no inlined props
3274514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_SHARED_MAP_ITERATOR_CLASS_INDEX,
3284514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSSharedMapIterator::SIZE,
3294514f5e3Sopenharmony_ci                JSType::JS_SHARED_MAP_ITERATOR, 0)); // 0: no inlined props
3304514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_ARRAY_ITERATOR_CLASS_INDEX,
3314514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSArrayIterator::SIZE, JSType::JS_ARRAY_ITERATOR, 0));
3324514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_SHARED_ARRAY_ITERATOR_CLASS_INDEX,
3334514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSSharedArrayIterator::SIZE, JSType::JS_SHARED_ARRAY_ITERATOR, 0));
3344514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_ARRAYLIST_ITERATOR_CLASS_INDEX,
3354514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIArrayListIterator::SIZE, JSType::JS_API_ARRAYLIST_ITERATOR));
3364514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_DEQUE_ITERATOR_CLASS_INDEX,
3374514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIDequeIterator::SIZE, JSType::JS_API_DEQUE_ITERATOR));
3384514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_LIGHTWEIGHTMAP_ITERATOR_CLASS_INDEX,
3394514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPILightWeightMapIterator::SIZE,
3404514f5e3Sopenharmony_ci                JSType::JS_API_LIGHT_WEIGHT_MAP_ITERATOR));
3414514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_LIGHTWEIGHTSET_ITERATOR_CLASS_INDEX,
3424514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPILightWeightSetIterator::SIZE,
3434514f5e3Sopenharmony_ci                JSType::JS_API_LIGHT_WEIGHT_SET_ITERATOR));
3444514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_API_BITVECTOR_ITERATOR_CLASS_INDEX,
3454514f5e3Sopenharmony_ci                factory->NewEcmaHClass(hClass, JSAPIBitVectorIterator::SIZE, JSType::JS_API_BITVECTOR_ITERATOR));
3464514f5e3Sopenharmony_ci}
3474514f5e3Sopenharmony_ci
3484514f5e3Sopenharmony_civoid GlobalEnvConstants::InitRootsClasses(ObjectFactory *factory)
3494514f5e3Sopenharmony_ci{
3504514f5e3Sopenharmony_ci    JSHClass *hClass = JSHClass::Cast(GetHClassClass().GetTaggedObject());
3514514f5e3Sopenharmony_ci
3524514f5e3Sopenharmony_ci    InitRootsClassesPartOne(hClass, factory);
3534514f5e3Sopenharmony_ci    InitRootsClassesPartTwo(hClass, factory);
3544514f5e3Sopenharmony_ci    // JS_PROXY_CALLABLE_CLASS_INDEX
3554514f5e3Sopenharmony_ci    JSHClass *jsProxyCallableClass = *factory->NewEcmaHClass(hClass, JSProxy::SIZE, JSType::JS_PROXY);
3564514f5e3Sopenharmony_ci    jsProxyCallableClass->SetCallable(true);
3574514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_PROXY_CALLABLE_CLASS_INDEX, JSTaggedValue(jsProxyCallableClass));
3584514f5e3Sopenharmony_ci    // JS_PROXY_CONSTRUCT_CLASS_INDEX
3594514f5e3Sopenharmony_ci    JSHClass *jsProxyConstructClass = *factory->NewEcmaHClass(hClass, JSProxy::SIZE, JSType::JS_PROXY);
3604514f5e3Sopenharmony_ci    jsProxyConstructClass->SetCallable(true);
3614514f5e3Sopenharmony_ci    jsProxyConstructClass->SetConstructor(true);
3624514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::JS_PROXY_CONSTRUCT_CLASS_INDEX, JSTaggedValue(jsProxyConstructClass));
3634514f5e3Sopenharmony_ci}
3644514f5e3Sopenharmony_ci
3654514f5e3Sopenharmony_civoid GlobalEnvConstants::InitMiscellanious(JSThread *thread, ObjectFactory *factory)
3664514f5e3Sopenharmony_ci{
3674514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_LAYOUT_INFO_OBJECT_INDEX, factory->CreateLayoutInfo(0));
3684514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::EMPTY_TAGGED_QUEUE_OBJECT_INDEX, factory->NewTaggedQueue(0));
3694514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::DEFAULT_SUPERS_INDEX,
3704514f5e3Sopenharmony_ci                WeakVector::Create(thread, VTable::DEFAULT_SUPERS_CAPACITY, MemSpaceType::NON_MOVABLE));
3714514f5e3Sopenharmony_ci
3724514f5e3Sopenharmony_ci    // non ECMA standard jsapi containers iterators, init to Undefined first
3734514f5e3Sopenharmony_ci    InitJSAPIContainers();
3744514f5e3Sopenharmony_ci
3754514f5e3Sopenharmony_ci    InitGlobalCaches();
3764514f5e3Sopenharmony_ci}
3774514f5e3Sopenharmony_ci
3784514f5e3Sopenharmony_civoid GlobalEnvConstants::InitGlobalCaches()
3794514f5e3Sopenharmony_ci{
3804514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::CACHED_JSCOLLATOR_LOCALES_INDEX, JSTaggedValue::Undefined());
3814514f5e3Sopenharmony_ci}
3824514f5e3Sopenharmony_ci
3834514f5e3Sopenharmony_civoid GlobalEnvConstants::SetCachedLocales(JSTaggedValue value)
3844514f5e3Sopenharmony_ci{
3854514f5e3Sopenharmony_ci    JSTaggedValue cached = GetCachedJSCollatorLocales();
3864514f5e3Sopenharmony_ci    if (cached.IsUndefined()) {
3874514f5e3Sopenharmony_ci        SetConstant(ConstantIndex::CACHED_JSCOLLATOR_LOCALES_INDEX, value);
3884514f5e3Sopenharmony_ci    }
3894514f5e3Sopenharmony_ci}
3904514f5e3Sopenharmony_ci
3914514f5e3Sopenharmony_civoid GlobalEnvConstants::InitJSAPIContainers()
3924514f5e3Sopenharmony_ci{
3934514f5e3Sopenharmony_ci    for (size_t i = GetJSAPIContainersBegin(); i <= GetJSAPIContainersEnd(); i++) {
3944514f5e3Sopenharmony_ci        SetConstant(static_cast<ConstantIndex>(i), JSTaggedValue::Undefined());
3954514f5e3Sopenharmony_ci    }
3964514f5e3Sopenharmony_ci}
3974514f5e3Sopenharmony_ci
3984514f5e3Sopenharmony_civoid GlobalEnvConstants::InitSpecialForSnapshot()
3994514f5e3Sopenharmony_ci{
4004514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::UNDEFINED_INDEX, JSTaggedValue::Undefined());
4014514f5e3Sopenharmony_ci    SetConstant(ConstantIndex::NULL_INDEX, JSTaggedValue::Null());
4024514f5e3Sopenharmony_ci    InitJSAPIContainers();
4034514f5e3Sopenharmony_ci}
4044514f5e3Sopenharmony_ci
4054514f5e3Sopenharmony_civoid GlobalEnvConstants::InitElementKindHClass(const JSThread *thread, JSHandle<JSHClass> originHClass)
4064514f5e3Sopenharmony_ci{
4074514f5e3Sopenharmony_ci    auto map = thread->GetArrayHClassIndexMap();
4084514f5e3Sopenharmony_ci    for (auto iter : map) {
4094514f5e3Sopenharmony_ci        JSHandle<JSHClass> hclassWithProto = JSHClass::CloneWithElementsKind(thread, originHClass, iter.first, true);
4104514f5e3Sopenharmony_ci        if (iter.first != ElementsKind::GENERIC) {
4114514f5e3Sopenharmony_ci            JSHandle<JSHClass> hclass = JSHClass::CloneWithElementsKind(thread, originHClass, iter.first, false);
4124514f5e3Sopenharmony_ci            SetConstant(iter.second.first, hclass);
4134514f5e3Sopenharmony_ci        } else {
4144514f5e3Sopenharmony_ci            SetConstant(iter.second.first, originHClass);
4154514f5e3Sopenharmony_ci        }
4164514f5e3Sopenharmony_ci        SetConstant(iter.second.second, hclassWithProto);
4174514f5e3Sopenharmony_ci    }
4184514f5e3Sopenharmony_ci}
4194514f5e3Sopenharmony_ci}  // namespace panda::ecmascript
420