1 //===-- allocator_config.h --------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef SCUDO_ALLOCATOR_CONFIG_H_ 10 #define SCUDO_ALLOCATOR_CONFIG_H_ 11 12 #include "combined.h" 13 #include "common.h" 14 #include "flags.h" 15 #include "primary32.h" 16 #include "primary64.h" 17 #include "size_class_map.h" 18 #include "tsd_exclusive.h" 19 #include "tsd_shared.h" 20 21 namespace scudo { 22 23 // Default configurations for various platforms. 24 25 struct DefaultConfig { 26 using SizeClassMap = DefaultSizeClassMap; 27 #if SCUDO_CAN_USE_PRIMARY64 28 // 1GB Regions 29 typedef SizeClassAllocator64<SizeClassMap, 30U> Primary; 30 #else 31 // 512KB regions 32 typedef SizeClassAllocator32<SizeClassMap, 19U> Primary; 33 #endif 34 template <class A> using TSDRegistryT = TSDRegistryExT<A>; // Exclusive 35 }; 36 37 struct AndroidConfig { 38 using SizeClassMap = AndroidSizeClassMap; 39 #if SCUDO_CAN_USE_PRIMARY64 40 // 1GB regions 41 typedef SizeClassAllocator64<SizeClassMap, 30U> Primary; 42 #else 43 // 512KB regions 44 typedef SizeClassAllocator32<SizeClassMap, 19U> Primary; 45 #endif 46 template <class A> 47 using TSDRegistryT = TSDRegistrySharedT<A, 2U>; // Shared, max 2 TSDs. 48 }; 49 50 struct AndroidSvelteConfig { 51 using SizeClassMap = SvelteSizeClassMap; 52 #if SCUDO_CAN_USE_PRIMARY64 53 // 512MB regions 54 typedef SizeClassAllocator64<SizeClassMap, 29U> Primary; 55 #else 56 // 64KB regions 57 typedef SizeClassAllocator32<SizeClassMap, 16U> Primary; 58 #endif 59 template <class A> 60 using TSDRegistryT = TSDRegistrySharedT<A, 1U>; // Shared, only 1 TSD. 61 }; 62 63 struct FuchsiaConfig { 64 // 1GB Regions 65 typedef SizeClassAllocator64<DefaultSizeClassMap, 30U> Primary; 66 template <class A> 67 using TSDRegistryT = TSDRegistrySharedT<A, 8U>; // Shared, max 8 TSDs. 68 }; 69 70 #if SCUDO_ANDROID 71 typedef AndroidConfig Config; 72 #elif SCUDO_FUCHSIA 73 typedef FuchsiaConfig Config; 74 #else 75 typedef DefaultConfig Config; 76 #endif 77 78 } // namespace scudo 79 80 #endif // SCUDO_ALLOCATOR_CONFIG_H_ 81