1 /** 2 * Copyright (c) 2021-2022 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 #ifndef PANDA_RUNTIME_OBJECT_HEADER_CONFIG_H_ 16 #define PANDA_RUNTIME_OBJECT_HEADER_CONFIG_H_ 17 18 #include <cstdint> 19 #include <cstdlib> 20 21 #include "libpandabase/mem/mem.h" 22 23 namespace panda { 24 25 using array_size_t = uint32_t; 26 using array_ssize_t = int32_t; 27 28 class MarkWord; 29 template <size_t PSIZE> 30 class LowEndConfig; 31 template <size_t PSIZE> 32 class HighEndConfig; 33 34 // For now this value is hardcoded: 35 #define HIGHENDSYSTEM 36 37 // We have possible 2 variants of configuration - for High-end devices and for Low-end devices 38 #ifdef HIGHENDSYSTEM 39 using MemoryModelConfig = HighEndConfig<OBJECT_POINTER_SIZE>; 40 #else 41 using MemoryModelConfig = LowEndConfig<OBJECT_POINTER_SIZE>; 42 #endif 43 44 // Config for High-end devices with hash stored inside object header and 32 bits pointer 45 template <> 46 class HighEndConfig<sizeof(uint32_t)> { 47 public: 48 using Size = uint32_t; 49 static constexpr Size BITS = 32U; 50 static constexpr Size LOCK_THREADID_SIZE = 13U; 51 static constexpr bool IS_HASH_IN_OBJ_HEADER = true; 52 }; 53 54 // Config for High-end devices with hash stored inside object header and 64 bits pointer 55 template <> 56 class HighEndConfig<sizeof(uint64_t)> { 57 public: 58 using Size = uint64_t; 59 static constexpr Size BITS = 64UL; 60 static constexpr Size LOCK_THREADID_SIZE = 29UL; 61 static constexpr bool IS_HASH_IN_OBJ_HEADER = true; 62 }; 63 64 // Config for Low-end devices with hash stored inside object header and 32 bits pointer 65 template <> 66 class LowEndConfig<sizeof(uint32_t)> { 67 public: 68 using Size = uint16_t; 69 static constexpr Size BITS = 16U; 70 static constexpr Size LOCK_THREADID_SIZE = 7U; 71 static constexpr bool IS_HASH_IN_OBJ_HEADER = true; 72 }; 73 74 } // namespace panda 75 76 #endif // PANDA_RUNTIME_OBJECT_HEADER_CONFIG_H_ 77