Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/base/allocator/partition_allocator/address_space_randomization.h b/base/allocator/partition_allocator/address_space_randomization.h
- index 43033d728050a..4287cd5644823 100644
- --- a/base/allocator/partition_allocator/address_space_randomization.h
- +++ b/base/allocator/partition_allocator/address_space_randomization.h
- @@ -125,10 +125,10 @@ AslrMask(uintptr_t bits) {
- // ARM64 on Linux has 39-bit user space. Use 38 bits since ASLROffset()
- // could cause a carry.
- - constexpr ALWAYS_INLINE uintptr_t ASLRMask() {
- + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t ASLRMask() {
- return AslrMask(38);
- }
- - constexpr ALWAYS_INLINE uintptr_t ASLROffset() {
- + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t ASLROffset() {
- return AslrAddress(0x1000000000ULL);
- }
- diff --git a/base/allocator/partition_allocator/page_allocator.cc b/base/allocator/partition_allocator/page_allocator.cc
- index 524e107418501..d2cbf866212e7 100644
- --- a/base/allocator/partition_allocator/page_allocator.cc
- +++ b/base/allocator/partition_allocator/page_allocator.cc
- @@ -28,6 +28,22 @@
- #error Platform not supported.
- #endif
- +#if BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- +
- +#include <unistd.h>
- +
- +#pragma GCC diagnostic push
- +#pragma GCC diagnostic ignored "-Wglobal-constructors"
- +
- +const PageCharacteristics kPage = []() {
- + int size = getpagesize();
- + return PageCharacteristics{size, __builtin_ctz(size)};
- +}();
- +
- +#pragma GCC diagnostic pop
- +
- +#endif
- +
- namespace partition_alloc {
- namespace {
- diff --git a/base/allocator/partition_allocator/page_allocator_constants.h b/base/allocator/partition_allocator/page_allocator_constants.h
- index 12515b9a02865..bec35d191e738 100644
- --- a/base/allocator/partition_allocator/page_allocator_constants.h
- +++ b/base/allocator/partition_allocator/page_allocator_constants.h
- @@ -24,6 +24,18 @@
- // elimination.
- #define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
- +#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- +
- +// Linux ARM64 can have different page sizes depending on the kernel.
- +#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
- +
- +struct PageCharacteristics {
- + int size;
- + int shift;
- +};
- +
- +extern const PageCharacteristics kPage;
- +
- #else
- // When defined, page size constants are fixed at compile time. When not
- @@ -50,6 +62,8 @@ PageAllocationGranularityShift() {
- return 14; // 16kB
- #elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
- return vm_page_shift;
- +#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- + return kPage.shift;
- #else
- return 12; // 4kB
- #endif
- diff --git a/base/allocator/partition_allocator/partition_alloc_constants.h b/base/allocator/partition_allocator/partition_alloc_constants.h
- index e0c871d6f60fe..e0d5702ac71ea 100644
- --- a/base/allocator/partition_allocator/partition_alloc_constants.h
- +++ b/base/allocator/partition_allocator/partition_alloc_constants.h
- @@ -84,6 +84,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
- PartitionPageShift() {
- return vm_page_shift + 2;
- }
- +#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- +PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
- +PartitionPageShift() {
- + return kPage.shift + 2;
- +}
- #else
- PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
- PartitionPageShift() {
- diff --git a/base/allocator/partition_allocator/partition_page.h b/base/allocator/partition_allocator/partition_page.h
- index 9419fa4c44f2d..de5907d6a324c 100644
- --- a/base/allocator/partition_allocator/partition_page.h
- +++ b/base/allocator/partition_allocator/partition_page.h
- @@ -134,6 +134,9 @@ struct __attribute__((packed)) SlotSpanMetadata {
- // PartitionPageSize() is 4 times the OS page size.
- static constexpr size_t kMaxSlotsPerSlotSpan =
- 4 * (1 << 14) / kSmallestBucket;
- +#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
- + static constexpr size_t kMaxSlotsPerSlotSpan =
- + 4 * (1 << 14) / kSmallestBucket;
- #else
- // A slot span can "span" multiple PartitionPages, but then its slot size is
- // larger, so it doesn't have as many slots.
- diff --git a/base/allocator/partition_allocator/partition_root.cc b/base/allocator/partition_allocator/partition_root.cc
- index 70d7d63ff4c65..c31356e0f0421 100644
- --- a/base/allocator/partition_allocator/partition_root.cc
- +++ b/base/allocator/partition_allocator/partition_root.cc
- @@ -309,7 +309,7 @@ static size_t PartitionPurgeSlotSpan(
- constexpr size_t kMaxSlotCount =
- (PartitionPageSize() * kMaxPartitionPagesPerRegularSlotSpan) /
- SystemPageSize();
- -#elif BUILDFLAG(IS_APPLE)
- +#elif BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
- // It's better for slot_usage to be stack-allocated and fixed-size, which
- // demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is
- // always SystemPageSize() << 2, so regardless of what the run time page size
Add Comment
Please, Sign In to add comment