Split V8_OS_MACOSX into V8_OS_DARWIN and V8_OS_MACOS

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 <jgruber@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79167}
This commit is contained in:
Samuel Groß 2022-02-17 11:40:49 +01:00 committed by V8 LUCI CQ
parent 6d62edeaca
commit a1faaf06a4
47 changed files with 135 additions and 137 deletions

View File

@ -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",

View File

@ -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.

View File

@ -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<unsigned int>(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<PlatformSharedMemoryHandle>(handle);
@ -541,7 +541,7 @@ inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) {
return static_cast<uint32_t>(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(

View File

@ -65,13 +65,14 @@ path. Add it with -I<path> 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<path> 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<path> 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<path> 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<path> 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<path> 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<path> 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"

View File

@ -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 <signal.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -33,7 +33,7 @@
#include <cxxabi.h>
#include <execinfo.h>
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <AvailabilityMacros.h>
#endif

View File

@ -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

View File

@ -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

View File

@ -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 <sys/mman.h> // For MAP_JIT.
#endif

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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 <mach/mach.h>

View File

@ -46,7 +46,7 @@
#include <atomic>
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <dlfcn.h>
#include <mach/mach.h>
#endif
@ -65,7 +65,7 @@
#include <sys/syscall.h>
#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<size_t>(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<uintptr_t>(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<int>(pthread_mach_thread_np(pthread_self()));
#elif V8_OS_LINUX
return static_cast<int>(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

View File

@ -4,7 +4,7 @@
#include "src/base/platform/semaphore.h"
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <dispatch/dispatch.h>
#elif V8_OS_WIN
#include <windows.h>
@ -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

View File

@ -11,7 +11,7 @@
#include "src/base/win32-headers.h"
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <dispatch/dispatch.h>
#elif V8_OS_POSIX
#include <semaphore.h>
@ -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;

View File

@ -9,7 +9,7 @@
#include <sys/time.h>
#include <unistd.h>
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <pthread.h>
@ -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)

View File

@ -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);

View File

@ -56,7 +56,7 @@ RandomNumberGenerator::RandomNumberGenerator() {
DCHECK_EQ(0, result);
USE(result);
SetSeed((static_cast<int64_t>(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.

View File

@ -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;

View File

@ -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 <libkern/OSCacheControl.h>
#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

View File

@ -43,7 +43,7 @@
#if V8_LIBC_MSVCRT
#include <intrin.h> // _xgetbv()
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <sys/sysctl.h>
#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;

View File

@ -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;

View File

@ -11,7 +11,7 @@
#if V8_LIBC_MSVCRT
#include <intrin.h> // _xgetbv()
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <sys/sysctl.h>
#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;

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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<uintptr_t>(result) & kMmapRegionMask;
result = reinterpret_cast<void*>(mmap_region_base_ + offset);
#endif // V8_OS_MACOSX
#endif // V8_OS_DARWIN
#endif // V8_TARGET_ARCH_X64
return result;
}

View File

@ -152,7 +152,7 @@ Response toProtocolValue(v8::Local<v8::Context> context,
v8::Local<v8::Value> value,
std::unique_ptr<protocol::Value>* 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

View File

@ -13,7 +13,7 @@
#error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION"
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <os/signpost.h>
#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

View File

@ -19,7 +19,7 @@
#include <sys/syscall.h>
#endif
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <mach/mach.h>
// OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
// 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<void*>(mcontext->__ss.__rip);
state->sp = reinterpret_cast<void*>(mcontext->__ss.__rsp);

View File

@ -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;

View File

@ -29,7 +29,7 @@
#if defined(V8_OS_LINUX) || defined(V8_OS_FREEBSD)
#include <ucontext.h>
#elif V8_OS_MACOSX
#elif V8_OS_DARWIN
#include <sys/ucontext.h>
#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

View File

@ -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.

View File

@ -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(

View File

@ -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.

View File

@ -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

View File

@ -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<std::unique_ptr<TestingAssemblerBuffer>> thunk_buffers;
std::vector<Address> 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

View File

@ -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);

View File

@ -4,7 +4,7 @@
#include "src/base/platform/time.h"
#if V8_OS_MACOSX
#if V8_OS_DARWIN
#include <mach/mach_time.h>
#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()));

View File

@ -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<void*> 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
}

View File

@ -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
}

View File

@ -7,7 +7,7 @@
#if V8_OS_LINUX || V8_OS_FREEBSD
#include <signal.h>
#include <ucontext.h>
#elif V8_OS_MACOSX
#elif V8_OS_DARWIN
#include <signal.h>
#include <sys/ucontext.h>
#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<Address>(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<ucontext_t*>(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;