Commit ea41f385 authored by Mark Mentovai's avatar Mark Mentovai Committed by Commit Bot

mac arm64: use the correct page size for this platform in PartitionAlloc

Apple CPUs since A9 use a 16kB physical page size, which is a change for
macOS on arm64 relative to the 4kB pages used on x86_64. PartitionAlloc
operates on pages directly, and must be aware of the larger pages on
the new platform.

If this same change were effective for macOS on x86_64, it would allow
x86_64 Chrome to run under binary translation (Rosetta) on arm64. Doing
so has potential observable impacts, including memory footprint and
performance. Run-time page size detection could be used to overcome
this, and would also provide insulation against future page size
changes, but that’s a larger and more invasive change. It’s likely that
we will adopt one of these strategies soon, but for now, this
arm64-only change is sufficient to run Chrome on arm64 Macs.

Bug: 1098899
Change-Id: I50b48728350b87a319433188306daad747741e54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2292831
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Mark Mentovai <mark@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787452}
parent 54d234ac
......@@ -14,6 +14,8 @@ namespace base {
static constexpr size_t kPageAllocationGranularityShift = 16; // 64KB
#elif defined(_MIPS_ARCH_LOONGSON)
static constexpr size_t kPageAllocationGranularityShift = 14; // 16KB
#elif defined(OS_MACOSX) && defined(ARCH_CPU_ARM64)
static constexpr size_t kPageAllocationGranularityShift = 14; // 16KB
#else
static constexpr size_t kPageAllocationGranularityShift = 12; // 4KB
#endif
......@@ -32,6 +34,8 @@ static constexpr size_t kSystemPageSize = 16384;
// and binaries compiled for 64KB are likely to work on 4KB systems,
// 64KB is a good choice here.
static constexpr size_t kSystemPageSize = 65536;
#elif defined(OS_MACOSX) && defined(ARCH_CPU_ARM64)
static constexpr size_t kSystemPageSize = 16384;
#else
static constexpr size_t kSystemPageSize = 4096;
#endif
......
......@@ -34,6 +34,8 @@ namespace base {
static const size_t kPartitionPageShift = 16; // 64 KiB
#elif defined(ARCH_CPU_PPC64)
static const size_t kPartitionPageShift = 18; // 256 KiB
#elif defined (OS_MACOSX) && defined(ARCH_CPU_ARM64)
static const size_t kPartitionPageShift = 16; // 64 KiB
#else
static const size_t kPartitionPageShift = 14; // 16 KiB
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment