From a1faaf06a496cb85e4b26eefd20fd35265388923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Gro=C3=9F?= Date: Thu, 17 Feb 2022 11:40:49 +0100 Subject: [PATCH] Split V8_OS_MACOSX into V8_OS_DARWIN and V8_OS_MACOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, V8_OS_MACOSX was, somewhat confusingly, also used for iOS. With this CL, V8_OS_DARWIN will be set on both macOS and iOS, V8_OS_MACOS only on macOS, and V8_OS_IOS only on iOS. This CL also renames V8_TARGET_OS_MACOSX to V8_TARGET_OS_MACOS and renames platform-xnu.cc to platform-darwin.cc. Change-Id: I4bcafc7c337586662114144f6c7ccf47d978da1f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3468577 Reviewed-by: Jakob Gruber Reviewed-by: Igor Sheludko Reviewed-by: Toon Verwaest Commit-Queue: Samuel Groß Cr-Commit-Position: refs/heads/main@{#79167} --- BUILD.bazel | 4 +- BUILD.gn | 8 +-- include/v8-platform.h | 6 +-- include/v8config.h | 24 +++++---- src/api/api.cc | 4 +- src/base/atomicops.h | 2 +- src/base/build_config.h | 2 +- src/base/cpu.cc | 2 +- src/base/debug/stack_trace_posix.cc | 2 +- src/base/immediate-crash.h | 4 +- src/base/macros.h | 2 +- src/base/page-allocator.cc | 2 +- src/base/platform/condition-variable.cc | 6 +-- src/base/platform/mutex.cc | 6 +-- src/base/platform/mutex.h | 2 +- .../{platform-xnu.cc => platform-darwin.cc} | 0 src/base/platform/platform-macos.cc | 2 +- src/base/platform/platform-posix.cc | 50 +++++++++---------- src/base/platform/semaphore.cc | 6 +-- src/base/platform/semaphore.h | 4 +- src/base/platform/time.cc | 23 ++++----- src/base/sys-info.cc | 2 +- src/base/utils/random-number-generator.cc | 2 +- src/codegen/arm64/assembler-arm64.cc | 2 +- src/codegen/arm64/cpu-arm64.cc | 4 +- src/codegen/ia32/assembler-ia32.cc | 6 +-- src/codegen/turbo-assembler.h | 2 +- src/codegen/x64/assembler-x64.cc | 6 +-- src/codegen/x64/macro-assembler-x64.cc | 2 +- src/codegen/x64/macro-assembler-x64.h | 2 +- src/flags/flag-definitions.h | 6 +-- src/heap/heap.h | 4 +- src/inspector/value-mirror.cc | 2 +- src/libplatform/tracing/recorder.h | 6 +-- src/libsampler/sampler.cc | 4 +- .../platform-embedded-file-writer-base.cc | 2 +- src/trap-handler/handler-inside-posix.cc | 4 +- src/trap-handler/handler-inside-posix.h | 2 +- src/trap-handler/handler-outside-simulator.cc | 6 +-- src/trap-handler/trap-handler.h | 6 +-- test/cctest/test-icache.cc | 4 +- test/cctest/wasm/test-jump-table-assembler.cc | 6 +-- test/fuzzer/fuzzer-support.cc | 4 +- test/unittests/base/platform/time-unittest.cc | 5 +- test/unittests/heap/heap-unittest.cc | 4 +- test/unittests/utils/allocation-unittest.cc | 6 +-- .../wasm/trap-handler-x64-unittest.cc | 12 ++--- 47 files changed, 135 insertions(+), 137 deletions(-) rename src/base/platform/{platform-xnu.cc => platform-darwin.cc} (100%) diff --git a/BUILD.bazel b/BUILD.bazel index 594d9e7882..9db1e5ebbc 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -315,7 +315,7 @@ v8_config( ], "@v8//bazel/config:is_macos": [ "V8_HAVE_TARGET_OS", - "V8_TARGET_OS_MACOSX", + "V8_TARGET_OS_MACOS", ], "@v8//bazel/config:is_windows": [ "V8_HAVE_TARGET_OS", @@ -637,8 +637,8 @@ filegroup( ], "@v8//bazel/config:is_macos": [ "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-darwin.cc", "src/base/platform/platform-macos.cc", - "src/base/platform/platform-xnu.cc", ], "@v8//bazel/config:is_windows": [ "src/base/win32-headers.h", diff --git a/BUILD.gn b/BUILD.gn index 15afb93410..07382368a4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1213,7 +1213,7 @@ config("toolchain") { defines += [ "V8_TARGET_OS_LINUX" ] } else if (target_os == "mac") { defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_MACOSX" ] + defines += [ "V8_TARGET_OS_MACOS" ] } else if (target_os == "win") { defines += [ "V8_HAVE_TARGET_OS" ] defines += [ "V8_TARGET_OS_WIN" ] @@ -5186,8 +5186,8 @@ v8_component("v8_libbase") { if (host_os == "mac") { sources += [ "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-darwin.cc", "src/base/platform/platform-macos.cc", - "src/base/platform/platform-xnu.cc", ] } else { sources += [ @@ -5214,13 +5214,13 @@ v8_component("v8_libbase") { } else if (is_mac) { sources += [ "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-darwin.cc", "src/base/platform/platform-macos.cc", - "src/base/platform/platform-xnu.cc", ] } else if (is_ios) { sources += [ "src/base/debug/stack_trace_posix.cc", - "src/base/platform/platform-xnu.cc", + "src/base/platform/platform-darwin.cc", ] } else if (is_win) { # TODO(infra): Add support for cygwin. diff --git a/include/v8-platform.h b/include/v8-platform.h index 2decd2088b..607cec7a89 100644 --- a/include/v8-platform.h +++ b/include/v8-platform.h @@ -522,7 +522,7 @@ static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1; // to avoid pulling in large OS header files into this header file. Instead, // the users of these routines are expected to include the respecitve OS // headers in addition to this one. -#if defined(V8_OS_MACOSX) && !defined(V8_OS_IOS) +#if V8_OS_MACOS // Convert between a shared memory handle and a mach_port_t referencing a memory // entry object. inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry( @@ -533,7 +533,7 @@ inline unsigned int MachMemoryEntryFromSharedMemoryHandle( PlatformSharedMemoryHandle handle) { return static_cast(handle); } -#elif defined(V8_OS_FUCHSIA) +#elif V8_OS_FUCHSIA // Convert between a shared memory handle and a zx_handle_t to a VMO. inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) { return static_cast(handle); @@ -541,7 +541,7 @@ inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) { inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) { return static_cast(handle); } -#elif defined(V8_OS_WIN) +#elif V8_OS_WIN // Convert between a shared memory handle and a Windows HANDLE to a file mapping // object. inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileMapping( diff --git a/include/v8config.h b/include/v8config.h index b16ab3ff88..77fd65c6c5 100644 --- a/include/v8config.h +++ b/include/v8config.h @@ -65,13 +65,14 @@ path. Add it with -I to the command line // Operating system detection (host) // // V8_OS_ANDROID - Android -// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) +// V8_OS_BSD - BSDish (macOS, Net/Free/Open/DragonFlyBSD) // V8_OS_CYGWIN - Cygwin // V8_OS_DRAGONFLYBSD - DragonFlyBSD // V8_OS_FREEBSD - FreeBSD // V8_OS_FUCHSIA - Fuchsia -// V8_OS_LINUX - Linux -// V8_OS_MACOSX - Mac OS X +// V8_OS_LINUX - Linux (Android, ChromeOS, Linux, ...) +// V8_OS_DARWIN - Darwin (macOS, iOS) +// V8_OS_MACOS - macOS // V8_OS_IOS - iOS // V8_OS_NETBSD - NetBSD // V8_OS_OPENBSD - OpenBSD @@ -89,13 +90,14 @@ path. Add it with -I to the command line # define V8_OS_STRING "android" #elif defined(__APPLE__) -# define V8_OS_BSD 1 -# define V8_OS_MACOSX 1 # define V8_OS_POSIX 1 +# define V8_OS_BSD 1 +# define V8_OS_DARWIN 1 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE # define V8_OS_IOS 1 # define V8_OS_STRING "ios" # else +# define V8_OS_MACOS 1 # define V8_OS_STRING "macos" # endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE @@ -169,7 +171,7 @@ path. Add it with -I to the command line // V8_TARGET_OS_FUCHSIA // V8_TARGET_OS_IOS // V8_TARGET_OS_LINUX -// V8_TARGET_OS_MACOSX +// V8_TARGET_OS_MACOS // V8_TARGET_OS_WIN // // If not set explicitly, these fall back to corresponding V8_OS_ values. @@ -181,7 +183,7 @@ path. Add it with -I to the command line && !defined(V8_TARGET_OS_FUCHSIA) \ && !defined(V8_TARGET_OS_IOS) \ && !defined(V8_TARGET_OS_LINUX) \ - && !defined(V8_TARGET_OS_MACOSX) \ + && !defined(V8_TARGET_OS_MACOS) \ && !defined(V8_TARGET_OS_WIN) # error No known target OS defined. # endif @@ -192,7 +194,7 @@ path. Add it with -I to the command line || defined(V8_TARGET_OS_FUCHSIA) \ || defined(V8_TARGET_OS_IOS) \ || defined(V8_TARGET_OS_LINUX) \ - || defined(V8_TARGET_OS_MACOSX) \ + || defined(V8_TARGET_OS_MACOS) \ || defined(V8_TARGET_OS_WIN) # error A target OS is defined but V8_HAVE_TARGET_OS is unset. # endif @@ -214,8 +216,8 @@ path. Add it with -I to the command line # define V8_TARGET_OS_LINUX #endif -#ifdef V8_OS_MACOSX -# define V8_TARGET_OS_MACOSX +#ifdef V8_OS_MACOS +# define V8_TARGET_OS_MACOS #endif #ifdef V8_OS_WIN @@ -232,7 +234,7 @@ path. Add it with -I to the command line # define V8_TARGET_OS_STRING "ios" #elif defined(V8_TARGET_OS_LINUX) # define V8_TARGET_OS_STRING "linux" -#elif defined(V8_TARGET_OS_MACOSX) +#elif defined(V8_TARGET_OS_MACOS) # define V8_TARGET_OS_STRING "macos" #elif defined(V8_TARGET_OS_WINDOWS) # define V8_TARGET_OS_STRING "windows" diff --git a/src/api/api.cc b/src/api/api.cc index e6797c92a5..791bb76391 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -139,7 +139,7 @@ #include "src/wasm/wasm-serialization.h" #endif // V8_ENABLE_WEBASSEMBLY -#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD +#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD #include #include "include/v8-wasm-trap-handler-posix.h" #include "src/trap-handler/handler-inside-posix.h" @@ -6060,7 +6060,7 @@ bool v8::V8::Initialize(const int build_config) { return true; } -#if V8_OS_LINUX || V8_OS_MACOSX +#if V8_OS_LINUX || V8_OS_DARWIN bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info, void* context) { #if V8_ENABLE_WEBASSEMBLY && V8_TRAP_HANDLER_SUPPORTED diff --git a/src/base/atomicops.h b/src/base/atomicops.h index 56fd5f3094..fb7d30d672 100644 --- a/src/base/atomicops.h +++ b/src/base/atomicops.h @@ -441,7 +441,7 @@ inline int Relaxed_Memcmp(volatile const Atomic8* s1, // On some platforms we need additional declarations to make // AtomicWord compatible with our other Atomic* types. -#if defined(V8_OS_MACOSX) || defined(V8_OS_OPENBSD) || defined(V8_OS_AIX) +#if defined(V8_OS_DARWIN) || defined(V8_OS_OPENBSD) || defined(V8_OS_AIX) #include "src/base/atomicops_internals_atomicword_compat.h" #endif diff --git a/src/base/build_config.h b/src/base/build_config.h index 9349a7a50b..282097b2dd 100644 --- a/src/base/build_config.h +++ b/src/base/build_config.h @@ -222,7 +222,7 @@ #endif // pthread_jit_write_protect is only available on arm64 Mac. -#if defined(V8_OS_MACOSX) && !defined(V8_OS_IOS) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_MACOS) && defined(V8_HOST_ARCH_ARM64) #define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 1 #else #define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0 diff --git a/src/base/cpu.cc b/src/base/cpu.cc index 3d29fdd50f..dc61f4bf11 100644 --- a/src/base/cpu.cc +++ b/src/base/cpu.cc @@ -783,7 +783,7 @@ CPU::CPU() has_jscvt_ = HasListItem(features, "jscvt"); delete[] features; } -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN // ARM64 Macs always have JSCVT. has_jscvt_ = true; #endif // V8_OS_WIN diff --git a/src/base/debug/stack_trace_posix.cc b/src/base/debug/stack_trace_posix.cc index 270f1ca4e0..b76c098d88 100644 --- a/src/base/debug/stack_trace_posix.cc +++ b/src/base/debug/stack_trace_posix.cc @@ -33,7 +33,7 @@ #include #include #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #endif diff --git a/src/base/immediate-crash.h b/src/base/immediate-crash.h index 00ccb43012..770cb273f9 100644 --- a/src/base/immediate-crash.h +++ b/src/base/immediate-crash.h @@ -50,13 +50,13 @@ // to continue after SIGTRAP. #define TRAP_SEQUENCE1_() asm volatile("int3") -#if V8_OS_MACOSX +#if V8_OS_DARWIN // Intentionally empty: __builtin_unreachable() is always part of the sequence // (see IMMEDIATE_CRASH below) and already emits a ud2 on Mac. #define TRAP_SEQUENCE2_() asm volatile("") #else #define TRAP_SEQUENCE2_() asm volatile("ud2") -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN #elif V8_HOST_ARCH_ARM diff --git a/src/base/macros.h b/src/base/macros.h index 3a73afc1ce..fcb9f8756f 100644 --- a/src/base/macros.h +++ b/src/base/macros.h @@ -313,7 +313,7 @@ V8_INLINE A implicit_cast(A x) { #endif // Fix for Mac OS X defining uintptr_t as "unsigned long": -#if V8_OS_MACOSX +#if V8_OS_DARWIN #undef V8PRIxPTR #define V8PRIxPTR "lx" #undef V8PRIdPTR diff --git a/src/base/page-allocator.cc b/src/base/page-allocator.cc index 2956bf1475..2bb8aa8e95 100644 --- a/src/base/page-allocator.cc +++ b/src/base/page-allocator.cc @@ -7,7 +7,7 @@ #include "src/base/platform/platform.h" #include "src/base/platform/wrappers.h" -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include // For MAP_JIT. #endif diff --git a/src/base/platform/condition-variable.cc b/src/base/platform/condition-variable.cc index 5ab66d39a4..b7b21c9947 100644 --- a/src/base/platform/condition-variable.cc +++ b/src/base/platform/condition-variable.cc @@ -40,7 +40,7 @@ ConditionVariable::ConditionVariable() { ConditionVariable::~ConditionVariable() { -#if defined(V8_OS_MACOSX) +#if defined(V8_OS_DARWIN) // This hack is necessary to avoid a fatal pthreads subsystem bug in the // Darwin kernel. http://crbug.com/517681. { @@ -86,7 +86,7 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { struct timespec ts; int result; mutex->AssertHeldAndUnmark(); -#if V8_OS_MACOSX +#if V8_OS_DARWIN // Mac OS X provides pthread_cond_timedwait_relative_np(), which does // not depend on the real time clock, which is what you really WANT here! ts = rel_time.ToTimespec(); @@ -111,7 +111,7 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { ts = end_time.ToTimespec(); result = pthread_cond_timedwait( &native_handle_, &mutex->native_handle(), &ts); -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN mutex->AssertUnheldAndMark(); if (result == ETIMEDOUT) { return false; diff --git a/src/base/platform/mutex.cc b/src/base/platform/mutex.cc index 7bf60996ee..423ab0d98a 100644 --- a/src/base/platform/mutex.cc +++ b/src/base/platform/mutex.cc @@ -222,7 +222,7 @@ bool RecursiveMutex::TryLock() { return true; } -#if V8_OS_MACOSX +#if V8_OS_DARWIN SharedMutex::SharedMutex() { InitializeNativeHandle(&native_handle_); } @@ -251,7 +251,7 @@ bool SharedMutex::TryLockExclusive() { return true; } -#else // !V8_OS_MACOSX +#else // !V8_OS_DARWIN SharedMutex::SharedMutex() { pthread_rwlock_init(&native_handle_, nullptr); } @@ -301,7 +301,7 @@ bool SharedMutex::TryLockExclusive() { return result; } -#endif // !V8_OS_MACOSX +#endif // !V8_OS_DARWIN #elif V8_OS_WIN diff --git a/src/base/platform/mutex.h b/src/base/platform/mutex.h index 5fefa25ab6..ce13d8d763 100644 --- a/src/base/platform/mutex.h +++ b/src/base/platform/mutex.h @@ -265,7 +265,7 @@ class V8_BASE_EXPORT SharedMutex final { private: // The implementation-defined native handle type. -#if V8_OS_MACOSX +#if V8_OS_DARWIN // pthread_rwlock_t is broken on MacOS when signals are being sent to the // process (see https://crbug.com/v8/11399). Until Apple fixes that in the OS, // we have to fall back to a non-shared mutex. diff --git a/src/base/platform/platform-xnu.cc b/src/base/platform/platform-darwin.cc similarity index 100% rename from src/base/platform/platform-xnu.cc rename to src/base/platform/platform-darwin.cc diff --git a/src/base/platform/platform-macos.cc b/src/base/platform/platform-macos.cc index 4864beda7a..bba8d3c699 100644 --- a/src/base/platform/platform-macos.cc +++ b/src/base/platform/platform-macos.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. // Platform-specific code for MacOS goes here. Code shared between iOS and -// macOS is in platform-xnu.cc, while the POSIX-compatible are in in +// macOS is in platform-darwin.cc, while the POSIX-compatible are in in // platform-posix.cc. #include diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc index 5cdc0a328d..18fee5a196 100644 --- a/src/base/platform/platform-posix.cc +++ b/src/base/platform/platform-posix.cc @@ -46,7 +46,7 @@ #include #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #include #endif @@ -65,7 +65,7 @@ #include #endif -#if V8_OS_FREEBSD || V8_OS_MACOSX || V8_OS_OPENBSD || V8_OS_SOLARIS +#if V8_OS_FREEBSD || V8_OS_DARWIN || V8_OS_OPENBSD || V8_OS_SOLARIS #define MAP_ANONYMOUS MAP_ANON #endif @@ -102,16 +102,16 @@ DEFINE_LAZY_LEAKY_OBJECT_GETTER(RandomNumberGenerator, static LazyMutex rng_mutex = LAZY_MUTEX_INITIALIZER; #if !V8_OS_FUCHSIA -#if V8_OS_MACOSX +#if V8_OS_DARWIN // kMmapFd is used to pass vm_alloc flags to tag the region with the user // defined tag 255 This helps identify V8-allocated regions in memory analysis // tools like vmmap(1). const int kMmapFd = VM_MAKE_TAG(255); -#else // !V8_OS_MACOSX +#else // !V8_OS_DARWIN const int kMmapFd = -1; -#endif // !V8_OS_MACOSX +#endif // !V8_OS_DARWIN -#if defined(V8_TARGET_OS_MACOSX) && V8_HOST_ARCH_ARM64 +#if defined(V8_TARGET_OS_MACOS) && V8_HOST_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. @@ -153,7 +153,7 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access, flags |= MAP_LAZY; #endif // V8_OS_QNX } -#if V8_OS_MACOSX +#if V8_OS_DARWIN // MAP_JIT is required to obtain writable and executable pages when the // hardened runtime/memory protection is enabled, which is optional (via code // signing) on Intel-based Macs but mandatory on Apple silicon ones. See also @@ -161,7 +161,7 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access, if (access == OS::MemoryPermission::kNoAccessWillJitLater) { flags |= MAP_JIT; } -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN return flags; } @@ -269,7 +269,7 @@ int OS::ActivationFrameAlignment() { // static size_t OS::AllocatePageSize() { -#if defined(V8_TARGET_OS_MACOSX) && V8_HOST_ARCH_ARM64 +#if defined(V8_TARGET_OS_MACOS) && V8_HOST_ARCH_ARM64 return kAppleArmPageSize; #else static size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); @@ -299,7 +299,7 @@ void* OS::GetRandomMmapAddr() { GetPlatformRandomNumberGenerator()->NextBytes(&raw_addr, sizeof(raw_addr)); } #if V8_HOST_ARCH_ARM64 -#if defined(V8_TARGET_OS_MACOSX) +#if defined(V8_TARGET_OS_MACOS) DCHECK_EQ(1 << 14, AllocatePageSize()); #endif // Keep the address page-aligned, AArch64 supports 4K, 16K and 64K @@ -435,7 +435,7 @@ bool OS::Free(void* address, size_t size) { } // macOS specific implementation in platform-macos.cc. -#if !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#if !defined(V8_OS_MACOS) // static void* OS::AllocateShared(void* hint, size_t size, MemoryPermission access, PlatformSharedMemoryHandle handle, uint64_t offset) { @@ -446,7 +446,7 @@ void* OS::AllocateShared(void* hint, size_t size, MemoryPermission access, if (result == MAP_FAILED) return nullptr; return result; } -#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#endif // !defined(V8_OS_MACOS) // static bool OS::FreeShared(void* address, size_t size) { @@ -471,7 +471,7 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { // MacOS 11.2 on Apple Silicon refuses to switch permissions from // rwx to none. Just use madvise instead. -#if defined(V8_OS_MACOSX) +#if defined(V8_OS_DARWIN) if (ret != 0 && access == OS::MemoryPermission::kNoAccess) { ret = madvise(address, size, MADV_FREE_REUSABLE); return ret == 0; @@ -489,7 +489,7 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { // The cost is a syscall that effectively no-ops. // TODO(erikchen): Fix this to only call MADV_FREE_REUSE when necessary. // https://crbug.com/823915 -#if defined(V8_OS_MACOSX) +#if defined(V8_OS_DARWIN) if (access != OS::MemoryPermission::kNoAccess) madvise(address, size, MADV_FREE_REUSE); #endif @@ -503,7 +503,7 @@ bool OS::DiscardSystemPages(void* address, size_t size) { // (base/allocator/partition_allocator/page_allocator_internals_posix.h) DCHECK_EQ(0, reinterpret_cast(address) % CommitPageSize()); DCHECK_EQ(0, size % CommitPageSize()); -#if defined(V8_OS_MACOSX) +#if defined(V8_OS_DARWIN) // On OSX, MADV_FREE_REUSABLE has comparable behavior to MADV_FREE, but also // marks the pages with the reusable bit, which allows both Activity Monitor // and memory-infra to correctly track the pages. @@ -573,7 +573,7 @@ bool OS::FreeAddressSpaceReservation(AddressSpaceReservation reservation) { } // macOS specific implementation in platform-macos.cc. -#if !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#if !defined(V8_OS_MACOS) // static PlatformSharedMemoryHandle OS::CreateSharedMemoryHandleForTesting(size_t size) { #if V8_OS_LINUX && !V8_OS_ANDROID @@ -593,11 +593,11 @@ void OS::DestroySharedMemoryHandle(PlatformSharedMemoryHandle handle) { int fd = FileDescriptorFromSharedMemoryHandle(handle); CHECK_EQ(0, close(fd)); } -#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#endif // !defined(V8_OS_MACOS) // static bool OS::HasLazyCommits() { -#if V8_OS_AIX || V8_OS_LINUX || V8_OS_MACOSX +#if V8_OS_AIX || V8_OS_LINUX || V8_OS_DARWIN return true; #else // TODO(bbudge) Return true for all POSIX platforms. @@ -730,7 +730,7 @@ int OS::GetCurrentProcessId() { int OS::GetCurrentThreadId() { -#if V8_OS_MACOSX || (V8_OS_ANDROID && defined(__APPLE__)) +#if V8_OS_DARWIN || (V8_OS_ANDROID && defined(__APPLE__)) return static_cast(pthread_mach_thread_np(pthread_self())); #elif V8_OS_LINUX return static_cast(syscall(__NR_gettid)); @@ -950,7 +950,7 @@ bool AddressSpaceReservation::Free(void* address, size_t size) { } // macOS specific implementation in platform-macos.cc. -#if !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#if !defined(V8_OS_MACOS) bool AddressSpaceReservation::AllocateShared(void* address, size_t size, OS::MemoryPermission access, PlatformSharedMemoryHandle handle, @@ -961,7 +961,7 @@ bool AddressSpaceReservation::AllocateShared(void* address, size_t size, return mmap(address, size, prot, MAP_SHARED | MAP_FIXED, fd, offset) != MAP_FAILED; } -#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS) +#endif // !defined(V8_OS_MACOS) bool AddressSpaceReservation::FreeShared(void* address, size_t size) { DCHECK(Contains(address, size)); @@ -1020,7 +1020,7 @@ static void SetThreadName(const char* name) { #elif V8_OS_NETBSD STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP); pthread_setname_np(pthread_self(), "%s", name); -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN // pthread_setname_np is only available in 10.6 or later, so test // for it at runtime. int (*dynamic_pthread_setname_np)(const char*); @@ -1066,7 +1066,7 @@ bool Thread::Start() { if (result != 0) return false; size_t stack_size = stack_size_; if (stack_size == 0) { -#if V8_OS_MACOSX +#if V8_OS_DARWIN // Default on Mac OS X is 512kB -- bump up to 1MB stack_size = 1 * 1024 * 1024; #elif V8_OS_AIX @@ -1215,7 +1215,7 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) { // pthread_getattr_np used below is non portable (hence the _np suffix). We // keep this version in POSIX as most Linux-compatible derivatives will // support it. MacOS and FreeBSD are different here. -#if !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && !defined(_AIX) && \ +#if !defined(V8_OS_FREEBSD) && !defined(V8_OS_DARWIN) && !defined(_AIX) && \ !defined(V8_OS_SOLARIS) // static @@ -1242,7 +1242,7 @@ Stack::StackSlot Stack::GetStackStart() { #endif // !defined(V8_LIBC_GLIBC) } -#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && +#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_DARWIN) && // !defined(_AIX) && !defined(V8_OS_SOLARIS) // static diff --git a/src/base/platform/semaphore.cc b/src/base/platform/semaphore.cc index 2fc748da87..3e9f6334d9 100644 --- a/src/base/platform/semaphore.cc +++ b/src/base/platform/semaphore.cc @@ -4,7 +4,7 @@ #include "src/base/platform/semaphore.h" -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #elif V8_OS_WIN #include @@ -19,7 +19,7 @@ namespace v8 { namespace base { -#if V8_OS_MACOSX +#if V8_OS_DARWIN Semaphore::Semaphore(int count) { native_handle_ = dispatch_semaphore_create(count); @@ -174,7 +174,7 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) { return native_handle_.TakeWait(microseconds); } -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN } // namespace base } // namespace v8 diff --git a/src/base/platform/semaphore.h b/src/base/platform/semaphore.h index ec107bd290..2d5b50bca9 100644 --- a/src/base/platform/semaphore.h +++ b/src/base/platform/semaphore.h @@ -11,7 +11,7 @@ #include "src/base/win32-headers.h" #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #elif V8_OS_POSIX #include @@ -55,7 +55,7 @@ class V8_BASE_EXPORT Semaphore final { // the semaphore counter is decremented and true is returned. bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT; -#if V8_OS_MACOSX +#if V8_OS_DARWIN using NativeHandle = dispatch_semaphore_t; #elif V8_OS_POSIX using NativeHandle = sem_t; diff --git a/src/base/platform/time.cc b/src/base/platform/time.cc index cdd091d858..5efa998795 100644 --- a/src/base/platform/time.cc +++ b/src/base/platform/time.cc @@ -9,7 +9,7 @@ #include #include #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #include #include @@ -39,7 +39,7 @@ namespace { -#if V8_OS_MACOSX +#if V8_OS_DARWIN int64_t ComputeThreadTicks() { mach_msg_type_number_t thread_info_count = THREAD_BASIC_INFO_COUNT; thread_basic_info_data_t thread_info_data; @@ -156,8 +156,7 @@ V8_INLINE uint64_t QPCNowRaw() { USE(result); return perf_counter_now.QuadPart; } -#endif // V8_OS_MACOSX - +#endif // V8_OS_DARWIN } // namespace @@ -245,8 +244,7 @@ int64_t TimeDelta::InNanoseconds() const { return delta_ * Time::kNanosecondsPerMicrosecond; } - -#if V8_OS_MACOSX +#if V8_OS_DARWIN TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) { DCHECK_GE(ts.tv_nsec, 0); @@ -266,8 +264,7 @@ struct mach_timespec TimeDelta::ToMachTimespec() const { return ts; } -#endif // V8_OS_MACOSX - +#endif // V8_OS_DARWIN #if V8_OS_POSIX @@ -713,7 +710,7 @@ bool TimeTicks::IsHighResolution() { TimeTicks TimeTicks::Now() { int64_t ticks; -#if V8_OS_MACOSX +#if V8_OS_DARWIN static struct mach_timebase_info info; if (info.denom == 0) { kern_return_t result = mach_timebase_info(&info); @@ -730,14 +727,14 @@ TimeTicks TimeTicks::Now() { ticks = SbTimeGetMonotonicNow(); #else #error platform does not implement TimeTicks::Now. -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN // Make sure we never return 0 here. return TimeTicks(ticks + 1); } // static bool TimeTicks::IsHighResolution() { -#if V8_OS_MACOSX +#if V8_OS_DARWIN return true; #elif V8_OS_POSIX static const bool is_high_resolution = IsHighResolutionTimer(CLOCK_MONOTONIC); @@ -763,7 +760,7 @@ bool ThreadTicks::IsSupported() { // Thread CPU time accounting is unavailable in PASE return false; #elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ - defined(V8_OS_MACOSX) || defined(V8_OS_ANDROID) || defined(V8_OS_SOLARIS) + defined(V8_OS_DARWIN) || defined(V8_OS_ANDROID) || defined(V8_OS_SOLARIS) return true; #elif defined(V8_OS_WIN) return IsSupportedWin(); @@ -784,7 +781,7 @@ ThreadTicks ThreadTicks::Now() { #else UNREACHABLE(); #endif -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN return ThreadTicks(ComputeThreadTicks()); #elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ defined(V8_OS_ANDROID) diff --git a/src/base/sys-info.cc b/src/base/sys-info.cc index 6f69e2aa9c..143aa4ae89 100644 --- a/src/base/sys-info.cc +++ b/src/base/sys-info.cc @@ -63,7 +63,7 @@ int SysInfo::NumberOfProcessors() { // static int64_t SysInfo::AmountOfPhysicalMemory() { -#if V8_OS_MACOSX +#if V8_OS_DARWIN int mib[2] = {CTL_HW, HW_MEMSIZE}; int64_t memsize = 0; size_t len = sizeof(memsize); diff --git a/src/base/utils/random-number-generator.cc b/src/base/utils/random-number-generator.cc index ac941cf2b7..f6dc62893c 100644 --- a/src/base/utils/random-number-generator.cc +++ b/src/base/utils/random-number-generator.cc @@ -56,7 +56,7 @@ RandomNumberGenerator::RandomNumberGenerator() { DCHECK_EQ(0, result); USE(result); SetSeed((static_cast(first_half) << 32) + second_half); -#elif V8_OS_MACOSX || V8_OS_FREEBSD || V8_OS_OPENBSD +#elif V8_OS_DARWIN || V8_OS_FREEBSD || V8_OS_OPENBSD // Despite its prefix suggests it is not RC4 algorithm anymore. // It always succeeds while having decent performance and // no file descriptor involved. diff --git a/src/codegen/arm64/assembler-arm64.cc b/src/codegen/arm64/assembler-arm64.cc index ac7a46a895..72a57ef8b5 100644 --- a/src/codegen/arm64/assembler-arm64.cc +++ b/src/codegen/arm64/assembler-arm64.cc @@ -73,7 +73,7 @@ constexpr unsigned CpuFeaturesFromCompiler() { constexpr unsigned CpuFeaturesFromTargetOS() { unsigned features = 0; -#if defined(V8_TARGET_OS_MACOSX) +#if defined(V8_TARGET_OS_MACOS) features |= 1u << JSCVT; #endif return features; diff --git a/src/codegen/arm64/cpu-arm64.cc b/src/codegen/arm64/cpu-arm64.cc index 4c61e1fd82..96bb73f0d4 100644 --- a/src/codegen/arm64/cpu-arm64.cc +++ b/src/codegen/arm64/cpu-arm64.cc @@ -9,7 +9,7 @@ #include "src/codegen/arm64/utils-arm64.h" #include "src/codegen/cpu-features.h" -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #endif @@ -49,7 +49,7 @@ void CpuFeatures::FlushICache(void* address, size_t length) { #if defined(V8_HOST_ARCH_ARM64) #if defined(V8_OS_WIN) ::FlushInstructionCache(GetCurrentProcess(), address, length); -#elif defined(V8_OS_MACOSX) +#elif defined(V8_OS_DARWIN) sys_icache_invalidate(address, length); #else // The code below assumes user space cache operations are allowed. The goal diff --git a/src/codegen/ia32/assembler-ia32.cc b/src/codegen/ia32/assembler-ia32.cc index 389640e89a..49a92fe8c5 100644 --- a/src/codegen/ia32/assembler-ia32.cc +++ b/src/codegen/ia32/assembler-ia32.cc @@ -43,7 +43,7 @@ #if V8_LIBC_MSVCRT #include // _xgetbv() #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #endif @@ -96,7 +96,7 @@ V8_INLINE uint64_t xgetbv(unsigned int xcr) { } bool OSHasAVXSupport() { -#if V8_OS_MACOSX +#if V8_OS_DARWIN // Mac OS X up to 10.9 has a bug where AVX transitions were indeed being // caused by ISRs, so we detect that here and disable AVX in that case. char buffer[128]; @@ -112,7 +112,7 @@ bool OSHasAVXSupport() { *period_pos = '\0'; long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT if (kernel_version_major <= 13) return false; -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN // Check whether OS claims to support AVX. uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK return (feature_mask & 0x6) == 0x6; diff --git a/src/codegen/turbo-assembler.h b/src/codegen/turbo-assembler.h index 2f2deadaac..ad255ff1ac 100644 --- a/src/codegen/turbo-assembler.h +++ b/src/codegen/turbo-assembler.h @@ -95,7 +95,7 @@ class V8_EXPORT_PRIVATE TurboAssemblerBase : public Assembler { static bool IsAddressableThroughRootRegister( Isolate* isolate, const ExternalReference& reference); -#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX) +#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOS) // Minimum page size. We must touch memory once per page when expanding the // stack, to avoid access violations. static constexpr int kStackPageSize = 4 * KB; diff --git a/src/codegen/x64/assembler-x64.cc b/src/codegen/x64/assembler-x64.cc index 37fe52595e..761aa93861 100644 --- a/src/codegen/x64/assembler-x64.cc +++ b/src/codegen/x64/assembler-x64.cc @@ -11,7 +11,7 @@ #if V8_LIBC_MSVCRT #include // _xgetbv() #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #endif @@ -49,7 +49,7 @@ V8_INLINE uint64_t xgetbv(unsigned int xcr) { } bool OSHasAVXSupport() { -#if V8_OS_MACOSX +#if V8_OS_DARWIN // Mac OS X up to 10.9 has a bug where AVX transitions were indeed being // caused by ISRs, so we detect that here and disable AVX in that case. char buffer[128]; @@ -65,7 +65,7 @@ bool OSHasAVXSupport() { *period_pos = '\0'; long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT if (kernel_version_major <= 13) return false; -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN // Check whether OS claims to support AVX. uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK return (feature_mask & 0x6) == 0x6; diff --git a/src/codegen/x64/macro-assembler-x64.cc b/src/codegen/x64/macro-assembler-x64.cc index 68fc024dd3..4e0c94cc32 100644 --- a/src/codegen/x64/macro-assembler-x64.cc +++ b/src/codegen/x64/macro-assembler-x64.cc @@ -2763,7 +2763,7 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) { popq(rbp); } -#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX) +#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOS) void TurboAssembler::AllocateStackSpace(Register bytes_scratch) { ASM_CODE_COMMENT(this); // On Windows and on macOS, we cannot increment the stack size by more than diff --git a/src/codegen/x64/macro-assembler-x64.h b/src/codegen/x64/macro-assembler-x64.h index d1f584116d..f1aba1355c 100644 --- a/src/codegen/x64/macro-assembler-x64.h +++ b/src/codegen/x64/macro-assembler-x64.h @@ -474,7 +474,7 @@ class V8_EXPORT_PRIVATE TurboAssembler // stack check, do it before calling this function because this function may // write into the newly allocated space. It may also overwrite the given // register's value, in the version that takes a register. -#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX) +#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOS) void AllocateStackSpace(Register bytes_scratch); void AllocateStackSpace(int bytes); #else diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h index aaf2b14893..59b7c2417f 100644 --- a/src/flags/flag-definitions.h +++ b/src/flags/flag-definitions.h @@ -211,7 +211,7 @@ struct MaybeBoolFlag { #define ENABLE_SPARKPLUG_BY_DEFAULT false #endif -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // Must be enabled on M1. #define MUST_WRITE_PROTECT_CODE_MEMORY true #else @@ -684,7 +684,7 @@ DEFINE_BOOL(always_sparkplug, false, "directly tier up to Sparkplug code") #if ENABLE_SPARKPLUG DEFINE_IMPLICATION(always_sparkplug, sparkplug) DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code") -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // M1 requires W^X. DEFINE_BOOL_READONLY(concurrent_sparkplug, false, "compile Sparkplug code in a background thread") @@ -722,7 +722,7 @@ DEFINE_BOOL(trace_baseline_concurrent_compilation, false, DEFINE_BOOL(shared_string_table, false, "internalize strings into shared table") DEFINE_IMPLICATION(harmony_struct, shared_string_table) -#if !defined(V8_OS_MACOSX) || !defined(V8_HOST_ARCH_ARM64) +#if !defined(V8_OS_DARWIN) || !defined(V8_HOST_ARCH_ARM64) DEFINE_BOOL(write_code_using_rwx, true, "flip permissions to rwx to write page instead of rw") DEFINE_NEG_IMPLICATION(jitless, write_code_using_rwx) diff --git a/src/heap/heap.h b/src/heap/heap.h index c08913d106..7741c6d367 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -1601,7 +1601,7 @@ class Heap { void* GetRandomMmapAddr() { void* result = v8::internal::GetRandomMmapAddr(); #if V8_TARGET_ARCH_X64 -#if V8_OS_MACOSX +#if V8_OS_DARWIN // The Darwin kernel [as of macOS 10.12.5] does not clean up page // directory entries [PDE] created from mmap or mach_vm_allocate, even // after the region is destroyed. Using a virtual address space that is @@ -1611,7 +1611,7 @@ class Heap { // space. See crbug.com/700928. uintptr_t offset = reinterpret_cast(result) & kMmapRegionMask; result = reinterpret_cast(mmap_region_base_ + offset); -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN #endif // V8_TARGET_ARCH_X64 return result; } diff --git a/src/inspector/value-mirror.cc b/src/inspector/value-mirror.cc index 3001a56356..1c320ac404 100644 --- a/src/inspector/value-mirror.cc +++ b/src/inspector/value-mirror.cc @@ -152,7 +152,7 @@ Response toProtocolValue(v8::Local context, v8::Local value, std::unique_ptr* result) { if (value->IsUndefined()) return Response::Success(); -#if defined(V8_USE_ADDRESS_SANITIZER) && V8_OS_MACOSX +#if defined(V8_USE_ADDRESS_SANITIZER) && V8_OS_DARWIN // For whatever reason, ASan on MacOS has bigger stack frames. static const int kMaxDepth = 900; #else diff --git a/src/libplatform/tracing/recorder.h b/src/libplatform/tracing/recorder.h index 8b8eb0e0e9..309697f128 100644 --- a/src/libplatform/tracing/recorder.h +++ b/src/libplatform/tracing/recorder.h @@ -13,7 +13,7 @@ #error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION" #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability" @@ -47,7 +47,7 @@ class V8_PLATFORM_EXPORT Recorder { void AddEvent(TraceObject* trace_event); private: -#if V8_OS_MACOSX +#if V8_OS_DARWIN os_log_t v8Provider; #endif }; @@ -56,7 +56,7 @@ class V8_PLATFORM_EXPORT Recorder { } // namespace platform } // namespace v8 -#if V8_OS_MACOSX +#if V8_OS_DARWIN #pragma clang diagnostic pop #endif diff --git a/src/libsampler/sampler.cc b/src/libsampler/sampler.cc index 111ae5e864..9e5569455f 100644 --- a/src/libsampler/sampler.cc +++ b/src/libsampler/sampler.cc @@ -19,7 +19,7 @@ #include #endif -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include // OpenBSD doesn't have . ucontext_t lives in // and is a typedef for struct sigcontext. There is no uc_mcontext. @@ -467,7 +467,7 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) { #error Unexpected iOS target architecture. #endif // V8_TARGET_ARCH_ARM64 -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN #if V8_HOST_ARCH_X64 state->pc = reinterpret_cast(mcontext->__ss.__rip); state->sp = reinterpret_cast(mcontext->__ss.__rsp); diff --git a/src/snapshot/embedded/platform-embedded-file-writer-base.cc b/src/snapshot/embedded/platform-embedded-file-writer-base.cc index 447d2e9bac..7e0ec70ac4 100644 --- a/src/snapshot/embedded/platform-embedded-file-writer-base.cc +++ b/src/snapshot/embedded/platform-embedded-file-writer-base.cc @@ -116,7 +116,7 @@ EmbeddedTargetArch ToEmbeddedTargetArch(const char* s) { EmbeddedTargetOs DefaultEmbeddedTargetOs() { #if defined(V8_OS_AIX) return EmbeddedTargetOs::kAIX; -#elif defined(V8_OS_MACOSX) +#elif defined(V8_OS_DARWIN) return EmbeddedTargetOs::kMac; #elif defined(V8_OS_WIN) return EmbeddedTargetOs::kWin; diff --git a/src/trap-handler/handler-inside-posix.cc b/src/trap-handler/handler-inside-posix.cc index 86e2fb8b8e..e4454c378f 100644 --- a/src/trap-handler/handler-inside-posix.cc +++ b/src/trap-handler/handler-inside-posix.cc @@ -29,7 +29,7 @@ #if defined(V8_OS_LINUX) || defined(V8_OS_FREEBSD) #include -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN #include #endif @@ -49,7 +49,7 @@ namespace trap_handler { #if V8_OS_LINUX #define CONTEXT_REG(reg, REG) &uc->uc_mcontext.gregs[REG_##REG] -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN #define CONTEXT_REG(reg, REG) &uc->uc_mcontext->__ss.__##reg #elif V8_OS_FREEBSD #define CONTEXT_REG(reg, REG) &uc->uc_mcontext.mc_##reg diff --git a/src/trap-handler/handler-inside-posix.h b/src/trap-handler/handler-inside-posix.h index 27e46773bb..745e92d501 100644 --- a/src/trap-handler/handler-inside-posix.h +++ b/src/trap-handler/handler-inside-posix.h @@ -15,7 +15,7 @@ namespace trap_handler { #if V8_OS_LINUX || V8_OS_FREEBSD constexpr int kOobSignal = SIGSEGV; -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN constexpr int kOobSignal = SIGBUS; #else #error Posix trap handlers are only supported on Linux, MacOSX and FreeBSD. diff --git a/src/trap-handler/handler-outside-simulator.cc b/src/trap-handler/handler-outside-simulator.cc index d59debe625..179eab0659 100644 --- a/src/trap-handler/handler-outside-simulator.cc +++ b/src/trap-handler/handler-outside-simulator.cc @@ -5,11 +5,11 @@ #include "include/v8config.h" #include "src/trap-handler/trap-handler-simulator.h" -#if V8_OS_MACOSX +#if V8_OS_DARWIN #define SYMBOL(name) "_" #name -#else // !V8_OS_MACOSX +#else // !V8_OS_DARWIN #define SYMBOL(name) #name -#endif // !V8_OS_MACOSX +#endif // !V8_OS_DARWIN // Define the ProbeMemory function declared in trap-handler-simulators.h. asm( diff --git a/src/trap-handler/trap-handler.h b/src/trap-handler/trap-handler.h index 79ddf56653..84ffdbd056 100644 --- a/src/trap-handler/trap-handler.h +++ b/src/trap-handler/trap-handler.h @@ -19,15 +19,15 @@ namespace trap_handler { // X64 on Linux, Windows, MacOS, FreeBSD. #if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \ - ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_MACOSX || \ + ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_DARWIN || \ V8_OS_FREEBSD) #define V8_TRAP_HANDLER_SUPPORTED true // Arm64 (non-simulator) on Mac. -#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_MACOSX +#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_DARWIN #define V8_TRAP_HANDLER_SUPPORTED true // Arm64 simulator on x64 on Linux, Mac, or Windows. #elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && \ - (V8_OS_LINUX || V8_OS_MACOSX || V8_OS_WIN) + (V8_OS_LINUX || V8_OS_DARWIN || V8_OS_WIN) #define V8_TRAP_HANDLER_VIA_SIMULATOR #define V8_TRAP_HANDLER_SUPPORTED true // Everything else is unsupported. diff --git a/test/cctest/test-icache.cc b/test/cctest/test-icache.cc index be7f846d86..93e083d73b 100644 --- a/test/cctest/test-icache.cc +++ b/test/cctest/test-icache.cc @@ -194,7 +194,7 @@ TEST(TestFlushICacheOfWritableAndExecutable) { CHECK(SetPermissions(GetPlatformPageAllocator(), buffer->start(), buffer->size(), v8::PageAllocator::kReadWriteExecute)); { -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // Make sure to switch memory to writable on M1 hardware. wasm::CodeSpaceWriteScope code_space_write_scope(nullptr); #endif @@ -203,7 +203,7 @@ TEST(TestFlushICacheOfWritableAndExecutable) { } CHECK_EQ(23 + kNumInstr, f.Call(23)); // Call into generated code. { -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // Make sure to switch memory to writable on M1 hardware. wasm::CodeSpaceWriteScope code_space_write_scope(nullptr); #endif diff --git a/test/cctest/wasm/test-jump-table-assembler.cc b/test/cctest/wasm/test-jump-table-assembler.cc index 5ff1a422f6..39c89936f8 100644 --- a/test/cctest/wasm/test-jump-table-assembler.cc +++ b/test/cctest/wasm/test-jump-table-assembler.cc @@ -162,7 +162,7 @@ void CompileJumpTableThunk(Address thunk, Address jump_target) { __ Ret(); FlushInstructionCache(thunk, kThunkBufferSize); -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // MacOS on arm64 refuses {mprotect} calls to toggle permissions of RWX // memory. Simply do nothing here, as the space will by default be executable // and non-writable for the JumpTableRunner. @@ -203,7 +203,7 @@ class JumpTablePatcher : public v8::base::Thread { void Run() override { TRACE("Patcher %p is starting ...\n", this); -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // Make sure to switch memory to writable on M1 hardware. CodeSpaceWriteScope code_space_write_scope(nullptr); #endif @@ -267,7 +267,7 @@ TEST(JumpTablePatchingStress) { std::vector> thunk_buffers; std::vector
patcher_thunks; { -#if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64) +#if defined(V8_OS_DARWIN) && defined(V8_HOST_ARCH_ARM64) // Make sure to switch memory to writable on M1 hardware. CodeSpaceWriteScope code_space_write_scope(nullptr); #endif diff --git a/test/fuzzer/fuzzer-support.cc b/test/fuzzer/fuzzer-support.cc index 51e905490d..b266f58ab3 100644 --- a/test/fuzzer/fuzzer-support.cc +++ b/test/fuzzer/fuzzer-support.cc @@ -106,9 +106,9 @@ bool FuzzerSupport::PumpMessageLoop( // Explicitly specify some attributes to avoid issues with the linker dead- // stripping the following function on macOS, as it is not called directly // by fuzz target. LibFuzzer runtime uses dlsym() to resolve that function. -#if V8_OS_MACOSX +#if V8_OS_DARWIN __attribute__((used)) __attribute__((visibility("default"))) -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { v8_fuzzer::FuzzerSupport::InitializeFuzzerSupport(argc, argv); diff --git a/test/unittests/base/platform/time-unittest.cc b/test/unittests/base/platform/time-unittest.cc index 16b6a39457..4858e08544 100644 --- a/test/unittests/base/platform/time-unittest.cc +++ b/test/unittests/base/platform/time-unittest.cc @@ -4,7 +4,7 @@ #include "src/base/platform/time.h" -#if V8_OS_MACOSX +#if V8_OS_DARWIN #include #endif #if V8_OS_POSIX @@ -201,8 +201,7 @@ TEST(TimeDelta, FromAndIn) { TimeDelta::FromMicroseconds(13).InMicroseconds()); } - -#if V8_OS_MACOSX +#if V8_OS_DARWIN TEST(TimeDelta, MachTimespec) { TimeDelta null = TimeDelta(); EXPECT_EQ(null, TimeDelta::FromMachTimespec(null.ToMachTimespec())); diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc index 18192c3b53..82b5eee57d 100644 --- a/test/unittests/heap/heap-unittest.cc +++ b/test/unittests/heap/heap-unittest.cc @@ -93,7 +93,7 @@ TEST(Heap, HeapSizeFromPhysicalMemory) { TEST_F(HeapTest, ASLR) { #if V8_TARGET_ARCH_X64 -#if V8_OS_MACOSX +#if V8_OS_DARWIN Heap* heap = i_isolate()->heap(); std::set hints; for (int i = 0; i < 1000; i++) { @@ -114,7 +114,7 @@ TEST_F(HeapTest, ASLR) { EXPECT_LE(diff, kRegionMask); } } -#endif // V8_OS_MACOSX +#endif // V8_OS_DARWIN #endif // V8_TARGET_ARCH_X64 } diff --git a/test/unittests/utils/allocation-unittest.cc b/test/unittests/utils/allocation-unittest.cc index ac72ab38f1..2c486fba19 100644 --- a/test/unittests/utils/allocation-unittest.cc +++ b/test/unittests/utils/allocation-unittest.cc @@ -35,7 +35,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test { } struct sigaction old_action_; // On Mac, sometimes we get SIGBUS instead of SIGSEGV. -#if V8_OS_MACOSX +#if V8_OS_DARWIN struct sigaction old_bus_action_; #endif @@ -46,7 +46,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test { sigemptyset(&action.sa_mask); action.sa_flags = SA_SIGINFO; sigaction(SIGSEGV, &action, &old_action_); -#if V8_OS_MACOSX +#if V8_OS_DARWIN sigaction(SIGBUS, &action, &old_bus_action_); #endif } @@ -54,7 +54,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test { void TearDown() override { // Be a good citizen and restore the old signal handler. sigaction(SIGSEGV, &old_action_, nullptr); -#if V8_OS_MACOSX +#if V8_OS_DARWIN sigaction(SIGBUS, &old_bus_action_, nullptr); #endif } diff --git a/test/unittests/wasm/trap-handler-x64-unittest.cc b/test/unittests/wasm/trap-handler-x64-unittest.cc index 0356782c17..37f22072b5 100644 --- a/test/unittests/wasm/trap-handler-x64-unittest.cc +++ b/test/unittests/wasm/trap-handler-x64-unittest.cc @@ -7,7 +7,7 @@ #if V8_OS_LINUX || V8_OS_FREEBSD #include #include -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN #include #include #elif V8_OS_WIN @@ -40,7 +40,7 @@ namespace wasm { namespace { constexpr Register scratch = r10; bool g_test_handler_executed = false; -#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD +#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD struct sigaction g_old_segv_action; struct sigaction g_old_fpe_action; struct sigaction g_old_bus_action; // We get SIGBUS on Mac sometimes. @@ -96,7 +96,7 @@ class TrapHandlerTest : public TestWithIsolate, } void InstallFallbackHandler() { -#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD +#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD // Set up a signal handler to recover from the expected crash. struct sigaction action; action.sa_sigaction = SignalHandler; @@ -124,7 +124,7 @@ class TrapHandlerTest : public TestWithIsolate, // Clean up the trap handler trap_handler::RemoveTrapHandler(); if (!g_test_handler_executed) { -#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD +#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD // The test handler cleans up the signal handler setup in the test. If the // test handler was not called, we have to do the cleanup ourselves. EXPECT_EQ(0, sigaction(SIGSEGV, &g_old_segv_action, nullptr)); @@ -155,7 +155,7 @@ class TrapHandlerTest : public TestWithIsolate, reinterpret_cast
(desc.buffer + recovery_offset); } -#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD +#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD static void SignalHandler(int signal, siginfo_t* info, void* context) { if (g_use_as_first_chance_handler) { if (v8::TryHandleWebAssemblyTrapPosix(signal, info, context)) { @@ -174,7 +174,7 @@ class TrapHandlerTest : public TestWithIsolate, ucontext_t* uc = reinterpret_cast(context); #if V8_OS_LINUX uc->uc_mcontext.gregs[REG_RIP] = g_recovery_address; -#elif V8_OS_MACOSX +#elif V8_OS_DARWIN uc->uc_mcontext->__ss.__rip = g_recovery_address; #elif V8_OS_FREEBSD uc->uc_mcontext.mc_rip = g_recovery_address;