|
| 1 | +//===-- allocator_config.def ------------------------------------*- 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 | +// This file defines all the flags and types supported in Scudo. For optional |
| 10 | +// flags and types, only explicitly define them when interested (i.e., unused |
| 11 | +// optional flags or types can be skipped). |
| 12 | + |
| 13 | +#ifndef BASE_REQUIRED_TEMPLATE_TYPE |
| 14 | +#define BASE_REQUIRED_TEMPLATE_TYPE(...) |
| 15 | +#endif |
| 16 | +#ifndef BASE_OPTIONAL |
| 17 | +#define BASE_OPTIONAL(...) |
| 18 | +#endif |
| 19 | +#ifndef PRIMARY_REQUIRED_TYPE |
| 20 | +#define PRIMARY_REQUIRED_TYPE(...) |
| 21 | +#endif |
| 22 | +#ifndef PRIMARY_REQUIRED |
| 23 | +#define PRIMARY_REQUIRED(...) |
| 24 | +#endif |
| 25 | +#ifndef PRIMARY_OPTIONAL |
| 26 | +#define PRIMARY_OPTIONAL(...) |
| 27 | +#endif |
| 28 | +#ifndef PRIMARY_OPTIONAL_TYPE |
| 29 | +#define PRIMARY_OPTIONAL_TYPE(...) |
| 30 | +#endif |
| 31 | +#ifndef SECONDARY_REQUIRED_TEMPLATE_TYPE |
| 32 | +#define SECONDARY_REQUIRED_TEMPLATE_TYPE(...) |
| 33 | +#endif |
| 34 | +#ifndef SECONDARY_CACHE_OPTIONAL |
| 35 | +#define SECONDARY_CACHE_OPTIONAL(...) |
| 36 | +#endif |
| 37 | + |
| 38 | +// BASE_REQUIRED_TEMPLATE_TYPE(NAME) |
| 39 | +// |
| 40 | +// Thread-Specific Data Registry used, shared or exclusive. |
| 41 | +BASE_REQUIRED_TEMPLATE_TYPE(TSDRegistryT) |
| 42 | + |
| 43 | +// Defines the type of Primary allocator to use. |
| 44 | +BASE_REQUIRED_TEMPLATE_TYPE(PrimaryT) |
| 45 | + |
| 46 | +// Defines the type of Secondary allocator to use. |
| 47 | +BASE_REQUIRED_TEMPLATE_TYPE(SecondaryT) |
| 48 | + |
| 49 | +// BASE_OPTIONAL(TYPE, NAME, DEFAULT) |
| 50 | +// |
| 51 | +// Indicates possible support for Memory Tagging. |
| 52 | +BASE_OPTIONAL(const bool, MaySupportMemoryTagging, false) |
| 53 | + |
| 54 | +// PRIMARY_REQUIRED_TYPE(NAME) |
| 55 | +// |
| 56 | +// SizeClassMap to use with the Primary. |
| 57 | +PRIMARY_REQUIRED_TYPE(SizeClassMap) |
| 58 | + |
| 59 | +// Defines the type and scale of a compact pointer. A compact pointer can |
| 60 | +// be understood as the offset of a pointer within the region it belongs |
| 61 | +// to, in increments of a power-of-2 scale. See `CompactPtrScale` also. |
| 62 | +PRIMARY_REQUIRED_TYPE(CompactPtrT) |
| 63 | + |
| 64 | +// PRIMARY_REQUIRED(TYPE, NAME) |
| 65 | +// |
| 66 | +// The scale of a compact pointer. E.g., Ptr = Base + (CompactPtr << Scale). |
| 67 | +PRIMARY_REQUIRED(const uptr, CompactPtrScale) |
| 68 | + |
| 69 | +// Log2 of the size of a size class region, as used by the Primary. |
| 70 | +PRIMARY_REQUIRED(const uptr, RegionSizeLog) |
| 71 | + |
| 72 | +// Conceptually, a region will be divided into groups based on the address |
| 73 | +// range. Each allocation consumes blocks in the same group until exhaustion |
| 74 | +// then it pops out blocks in a new group. Therefore, `GroupSizeLog` is always |
| 75 | +// smaller or equal to `RegionSizeLog`. Note that `GroupSizeLog` needs to be |
| 76 | +// equal to `RegionSizeLog` for SizeClassAllocator32 because of certain |
| 77 | +// constraints. |
| 78 | +PRIMARY_REQUIRED(const uptr, GroupSizeLog) |
| 79 | + |
| 80 | +// Call map for user memory with at least this size. Only used with primary64. |
| 81 | +PRIMARY_REQUIRED(const uptr, MapSizeIncrement) |
| 82 | + |
| 83 | +// Defines the minimal & maximal release interval that can be set. |
| 84 | +PRIMARY_REQUIRED(const s32, MinReleaseToOsIntervalMs) |
| 85 | +PRIMARY_REQUIRED(const s32, MaxReleaseToOsIntervalMs) |
| 86 | + |
| 87 | +// PRIMARY_OPTIONAL(TYPE, NAME, DEFAULT) |
| 88 | +// |
| 89 | +// Indicates support for offsetting the start of a region by a random number of |
| 90 | +// pages. Only used with primary64. |
| 91 | +PRIMARY_OPTIONAL(const bool, EnableRandomOffset, false) |
| 92 | + |
| 93 | +// PRIMARY_OPTIONAL_TYPE(NAME, DEFAULT) |
| 94 | +// |
| 95 | +// Use condition variable to shorten the waiting time of refillment of |
| 96 | +// freelist. Note that this depends on the implementation of condition |
| 97 | +// variable on each platform and the performance may vary so that it does not |
| 98 | +// guarantee a performance benefit. |
| 99 | +PRIMARY_OPTIONAL_TYPE(ConditionVariableT, ConditionVariableDummy) |
| 100 | + |
| 101 | +// SECONDARY_REQUIRED_TEMPLATE_TYPE(NAME) |
| 102 | +// |
| 103 | +// Defines the type of Secondary Cache to use. |
| 104 | +SECONDARY_REQUIRED_TEMPLATE_TYPE(CacheT) |
| 105 | + |
| 106 | +// SECONDARY_CACHE_OPTIONAL(TYPE, NAME, DEFAULT) |
| 107 | +// |
| 108 | +// Defines the type of cache used by the Secondary. Some additional |
| 109 | +// configuration entries can be necessary depending on the Cache. |
| 110 | +SECONDARY_CACHE_OPTIONAL(const u32, EntriesArraySize, 0) |
| 111 | +SECONDARY_CACHE_OPTIONAL(const u32, QuarantineSize, 0) |
| 112 | +SECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntriesCount, 0) |
| 113 | +SECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntrySize, 0) |
| 114 | +SECONDARY_CACHE_OPTIONAL(const s32, MinReleaseToOsIntervalMs, INT32_MIN) |
| 115 | +SECONDARY_CACHE_OPTIONAL(const s32, MaxReleaseToOsIntervalMs, INT32_MAX) |
| 116 | + |
| 117 | +#undef SECONDARY_CACHE_OPTIONAL |
| 118 | +#undef SECONDARY_REQUIRED_TEMPLATE_TYPE |
| 119 | +#undef PRIMARY_OPTIONAL_TYPE |
| 120 | +#undef PRIMARY_OPTIONAL |
| 121 | +#undef PRIMARY_REQUIRED |
| 122 | +#undef PRIMARY_REQUIRED_TYPE |
| 123 | +#undef BASE_OPTIONAL |
| 124 | +#undef BASE_REQUIRED_TEMPLATE_TYPE |
0 commit comments