1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_GLOBAL_INDEX_MAP_H 17 #define ECMASCRIPT_GLOBAL_INDEX_MAP_H 18 19 #include "utils/bit_field.h" 20 #include "ecmascript/global_index.h" 21 #include "ecmascript/tagged_dictionary.h" 22 23 namespace panda::ecmascript { 24 // HeapObject's Pointer To IndexHashmap 25 class GlobalIndexMap { 26 public: 27 static void Initialize(const JSThread *thread, 28 JSMutableHandle<PointerToIndexDictionary> globalIndexMap); 29 static void InitGlobalIndexMap(const JSThread *thread, 30 JSMutableHandle<PointerToIndexDictionary> globalIndexMap); 31 static void InitGlobalConst(const JSThread *thread, 32 JSMutableHandle<PointerToIndexDictionary> globalIndexMap); 33 static void InitGlobalEnv(const JSThread *thread, 34 JSMutableHandle<PointerToIndexDictionary> globalIndexMap); 35 static void InitBuiltinEntries(const JSThread *thread, 36 JSMutableHandle<PointerToIndexDictionary> globalIndexMap); 37 static void FindGlobalIndex(JSHandle<PointerToIndexDictionary> globalIndexMap, 38 JSTaggedValue obj, GlobalIndex *globalIndex); GetGlobalIndexMap(EcmaContext *context)39 static inline JSHandle<PointerToIndexDictionary> GetGlobalIndexMap(EcmaContext *context) 40 { 41 return JSHandle<PointerToIndexDictionary>(reinterpret_cast<uintptr_t>(&context->pointerToIndexDictionary_)); 42 } 43 }; 44 } // namespace panda::ecmascript 45 46 #endif // ECMASCRIPT_GLOBAL_INDEX_MAP_H