Update v8 to run on iPhone

iOS uses 16kb memory pages. This change modifies OS::GetRandomMmapAddr()
to return a 16kb-aligned address on apple ARM64.

The mrs instruction is invalid on iOS. This change modifies
CacheLineSizes::CacheLineSizes() so that mrs is not executed.

Change-Id: I13fcc8498e715c03432c7a652ee723660f746069
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1701127
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62730}
This commit is contained in:
Shawn Presser 2019-07-15 02:08:28 -05:00 committed by Commit Bot
parent 4babedaeeb
commit 23d485508b
3 changed files with 8 additions and 1 deletions

View File

@ -172,6 +172,7 @@ Sandro Santilli <strk@keybit.net>
Sanjoy Das <sanjoy@playingwithpointers.com>
Seo Sanghyeon <sanxiyn@gmail.com>
Shawn Anastasio <shawnanastasio@gmail.com>
Shawn Presser <shawnpresser@gmail.com>
Stefan Penner <stefan.penner@gmail.com>
Sylvestre Ledru <sledru@mozilla.com>
Taketoshi Aono <brn@b6n.ch>

View File

@ -199,6 +199,12 @@ void* OS::GetRandomMmapAddr() {
MutexGuard guard(rng_mutex.Pointer());
GetPlatformRandomNumberGenerator()->NextBytes(&raw_addr, sizeof(raw_addr));
}
#if defined(__APPLE__)
#if 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

View File

@ -15,7 +15,7 @@ namespace internal {
class CacheLineSizes {
public:
CacheLineSizes() {
#if !defined(V8_HOST_ARCH_ARM64) || defined(V8_OS_WIN)
#if !defined(V8_HOST_ARCH_ARM64) || defined(V8_OS_WIN) || defined(__APPLE__)
cache_type_register_ = 0;
#else
// Copy the content of the cache type register to a core register.