Commit a6f31733 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac/arm64: When cross-building the snapshot, use page size of the target ISA instead of the host.

Bug: chromium:1107945
Change-Id: I0f721ccaf06c7ddaf0213448c29f48f5c57ccc6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2310575
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69000}
parent b8e51d93
......@@ -111,6 +111,13 @@ const int kMmapFd = VM_MAKE_TAG(255);
const int kMmapFd = -1;
#endif // !V8_OS_MACOSX
#if defined(__APPLE__) && V8_TARGET_ARCH_ARM64
// During snapshot generation in cross builds, sysconf() runs on the Intel
// host and returns host page size, while the snapshot needs to use the
// target page size.
constexpr int kAppleArmPageSize = 1 << 14;
#endif
const int kMmapFdOffset = 0;
// TODO(v8:10026): Add the right permission flag to make executable pages
......@@ -226,12 +233,20 @@ int OS::ActivationFrameAlignment() {
// static
size_t OS::AllocatePageSize() {
#if defined(__APPLE__) && V8_TARGET_ARCH_ARM64
return kAppleArmPageSize;
#else
return static_cast<size_t>(sysconf(_SC_PAGESIZE));
#endif
}
// static
size_t OS::CommitPageSize() {
#if defined(__APPLE__) && V8_TARGET_ARCH_ARM64
static size_t page_size = kAppleArmPageSize;
#else
static size_t page_size = getpagesize();
#endif
return page_size;
}
......@@ -250,12 +265,10 @@ void* OS::GetRandomMmapAddr() {
MutexGuard guard(rng_mutex.Pointer());
GetPlatformRandomNumberGenerator()->NextBytes(&raw_addr, sizeof(raw_addr));
}
#if defined(__APPLE__)
#if V8_TARGET_ARCH_ARM64
#if defined(__APPLE__) && V8_TARGET_ARCH_ARM64
DCHECK_EQ(1 << 14, AllocatePageSize());
raw_addr = RoundDown(raw_addr, 1 << 14);
#endif
#endif
#if defined(V8_USE_ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER)
// If random hint addresses interfere with address ranges hard coded in
......@@ -265,7 +278,7 @@ void* OS::GetRandomMmapAddr() {
raw_addr &= 0x007fffff0000ULL;
raw_addr += 0x7e8000000000ULL;
#else
#if V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64
// Currently available CPUs have 48 bits of virtual addressing. Truncate
// the hint address to 46 bits to give the kernel a fighting chance of
// fulfilling our placement request.
......
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