1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PARTITION_ALLOC_PARTITION_PAGE_CONSTANTS_H_ 6 #define PARTITION_ALLOC_PARTITION_PAGE_CONSTANTS_H_ 7 8 #include "build/build_config.h" 9 #include "partition_alloc/partition_alloc_base/compiler_specific.h" 10 #include "partition_alloc/partition_alloc_constants.h" 11 12 namespace partition_alloc::internal { 13 14 #if BUILDFLAG(HAS_64_BIT_POINTERS) && BUILDFLAG(IS_APPLE) 15 // System page size is not a constant on Apple OSes, but is either 4 or 16kiB 16 // (1 << 12 or 1 << 14), as checked in PartitionRoot::Init(). And 17 // PartitionPageSize() is 4 times the OS page size. 18 static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 14) / kSmallestBucket; 19 #elif defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) 20 // System page size can be 4, 16, or 64 kiB on Linux on arm64. 64 kiB is 21 // currently (kMaxSlotsPerSlotSpanBits == 13) not supported by the code, 22 // so we use the 16 kiB maximum (64 kiB will crash). 23 static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 14) / kSmallestBucket; 24 #else 25 // A slot span can "span" multiple PartitionPages, but then its slot size is 26 // larger, so it doesn't have as many slots. 27 static constexpr size_t kMaxSlotsPerSlotSpan = 28 PartitionPageSize() / kSmallestBucket; 29 #endif // BUILDFLAG(HAS_64_BIT_POINTERS) && BUILDFLAG(IS_APPLE) 30 31 } // namespace partition_alloc::internal 32 33 #endif // PARTITION_ALLOC_PARTITION_PAGE_CONSTANTS_H_ 34