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