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:
parent
6d62edeaca
commit
a1faaf06a4
@ -315,7 +315,7 @@ v8_config(
|
|||||||
],
|
],
|
||||||
"@v8//bazel/config:is_macos": [
|
"@v8//bazel/config:is_macos": [
|
||||||
"V8_HAVE_TARGET_OS",
|
"V8_HAVE_TARGET_OS",
|
||||||
"V8_TARGET_OS_MACOSX",
|
"V8_TARGET_OS_MACOS",
|
||||||
],
|
],
|
||||||
"@v8//bazel/config:is_windows": [
|
"@v8//bazel/config:is_windows": [
|
||||||
"V8_HAVE_TARGET_OS",
|
"V8_HAVE_TARGET_OS",
|
||||||
@ -637,8 +637,8 @@ filegroup(
|
|||||||
],
|
],
|
||||||
"@v8//bazel/config:is_macos": [
|
"@v8//bazel/config:is_macos": [
|
||||||
"src/base/debug/stack_trace_posix.cc",
|
"src/base/debug/stack_trace_posix.cc",
|
||||||
|
"src/base/platform/platform-darwin.cc",
|
||||||
"src/base/platform/platform-macos.cc",
|
"src/base/platform/platform-macos.cc",
|
||||||
"src/base/platform/platform-xnu.cc",
|
|
||||||
],
|
],
|
||||||
"@v8//bazel/config:is_windows": [
|
"@v8//bazel/config:is_windows": [
|
||||||
"src/base/win32-headers.h",
|
"src/base/win32-headers.h",
|
||||||
|
8
BUILD.gn
8
BUILD.gn
@ -1213,7 +1213,7 @@ config("toolchain") {
|
|||||||
defines += [ "V8_TARGET_OS_LINUX" ]
|
defines += [ "V8_TARGET_OS_LINUX" ]
|
||||||
} else if (target_os == "mac") {
|
} else if (target_os == "mac") {
|
||||||
defines += [ "V8_HAVE_TARGET_OS" ]
|
defines += [ "V8_HAVE_TARGET_OS" ]
|
||||||
defines += [ "V8_TARGET_OS_MACOSX" ]
|
defines += [ "V8_TARGET_OS_MACOS" ]
|
||||||
} else if (target_os == "win") {
|
} else if (target_os == "win") {
|
||||||
defines += [ "V8_HAVE_TARGET_OS" ]
|
defines += [ "V8_HAVE_TARGET_OS" ]
|
||||||
defines += [ "V8_TARGET_OS_WIN" ]
|
defines += [ "V8_TARGET_OS_WIN" ]
|
||||||
@ -5186,8 +5186,8 @@ v8_component("v8_libbase") {
|
|||||||
if (host_os == "mac") {
|
if (host_os == "mac") {
|
||||||
sources += [
|
sources += [
|
||||||
"src/base/debug/stack_trace_posix.cc",
|
"src/base/debug/stack_trace_posix.cc",
|
||||||
|
"src/base/platform/platform-darwin.cc",
|
||||||
"src/base/platform/platform-macos.cc",
|
"src/base/platform/platform-macos.cc",
|
||||||
"src/base/platform/platform-xnu.cc",
|
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
sources += [
|
sources += [
|
||||||
@ -5214,13 +5214,13 @@ v8_component("v8_libbase") {
|
|||||||
} else if (is_mac) {
|
} else if (is_mac) {
|
||||||
sources += [
|
sources += [
|
||||||
"src/base/debug/stack_trace_posix.cc",
|
"src/base/debug/stack_trace_posix.cc",
|
||||||
|
"src/base/platform/platform-darwin.cc",
|
||||||
"src/base/platform/platform-macos.cc",
|
"src/base/platform/platform-macos.cc",
|
||||||
"src/base/platform/platform-xnu.cc",
|
|
||||||
]
|
]
|
||||||
} else if (is_ios) {
|
} else if (is_ios) {
|
||||||
sources += [
|
sources += [
|
||||||
"src/base/debug/stack_trace_posix.cc",
|
"src/base/debug/stack_trace_posix.cc",
|
||||||
"src/base/platform/platform-xnu.cc",
|
"src/base/platform/platform-darwin.cc",
|
||||||
]
|
]
|
||||||
} else if (is_win) {
|
} else if (is_win) {
|
||||||
# TODO(infra): Add support for cygwin.
|
# TODO(infra): Add support for cygwin.
|
||||||
|
@ -522,7 +522,7 @@ static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1;
|
|||||||
// to avoid pulling in large OS header files into this header file. Instead,
|
// 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
|
// the users of these routines are expected to include the respecitve OS
|
||||||
// headers in addition to this one.
|
// 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
|
// Convert between a shared memory handle and a mach_port_t referencing a memory
|
||||||
// entry object.
|
// entry object.
|
||||||
inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry(
|
inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry(
|
||||||
@ -533,7 +533,7 @@ inline unsigned int MachMemoryEntryFromSharedMemoryHandle(
|
|||||||
PlatformSharedMemoryHandle handle) {
|
PlatformSharedMemoryHandle handle) {
|
||||||
return static_cast<unsigned int>(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.
|
// Convert between a shared memory handle and a zx_handle_t to a VMO.
|
||||||
inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
|
inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
|
||||||
return static_cast<PlatformSharedMemoryHandle>(handle);
|
return static_cast<PlatformSharedMemoryHandle>(handle);
|
||||||
@ -541,7 +541,7 @@ inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
|
|||||||
inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) {
|
inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) {
|
||||||
return static_cast<uint32_t>(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
|
// Convert between a shared memory handle and a Windows HANDLE to a file mapping
|
||||||
// object.
|
// object.
|
||||||
inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileMapping(
|
inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileMapping(
|
||||||
|
@ -65,13 +65,14 @@ path. Add it with -I<path> to the command line
|
|||||||
// Operating system detection (host)
|
// Operating system detection (host)
|
||||||
//
|
//
|
||||||
// V8_OS_ANDROID - Android
|
// 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_CYGWIN - Cygwin
|
||||||
// V8_OS_DRAGONFLYBSD - DragonFlyBSD
|
// V8_OS_DRAGONFLYBSD - DragonFlyBSD
|
||||||
// V8_OS_FREEBSD - FreeBSD
|
// V8_OS_FREEBSD - FreeBSD
|
||||||
// V8_OS_FUCHSIA - Fuchsia
|
// V8_OS_FUCHSIA - Fuchsia
|
||||||
// V8_OS_LINUX - Linux
|
// V8_OS_LINUX - Linux (Android, ChromeOS, Linux, ...)
|
||||||
// V8_OS_MACOSX - Mac OS X
|
// V8_OS_DARWIN - Darwin (macOS, iOS)
|
||||||
|
// V8_OS_MACOS - macOS
|
||||||
// V8_OS_IOS - iOS
|
// V8_OS_IOS - iOS
|
||||||
// V8_OS_NETBSD - NetBSD
|
// V8_OS_NETBSD - NetBSD
|
||||||
// V8_OS_OPENBSD - OpenBSD
|
// V8_OS_OPENBSD - OpenBSD
|
||||||
@ -89,13 +90,14 @@ path. Add it with -I<path> to the command line
|
|||||||
# define V8_OS_STRING "android"
|
# define V8_OS_STRING "android"
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
# define V8_OS_BSD 1
|
|
||||||
# define V8_OS_MACOSX 1
|
|
||||||
# define V8_OS_POSIX 1
|
# define V8_OS_POSIX 1
|
||||||
|
# define V8_OS_BSD 1
|
||||||
|
# define V8_OS_DARWIN 1
|
||||||
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||||
# define V8_OS_IOS 1
|
# define V8_OS_IOS 1
|
||||||
# define V8_OS_STRING "ios"
|
# define V8_OS_STRING "ios"
|
||||||
# else
|
# else
|
||||||
|
# define V8_OS_MACOS 1
|
||||||
# define V8_OS_STRING "macos"
|
# define V8_OS_STRING "macos"
|
||||||
# endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
# 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_FUCHSIA
|
||||||
// V8_TARGET_OS_IOS
|
// V8_TARGET_OS_IOS
|
||||||
// V8_TARGET_OS_LINUX
|
// V8_TARGET_OS_LINUX
|
||||||
// V8_TARGET_OS_MACOSX
|
// V8_TARGET_OS_MACOS
|
||||||
// V8_TARGET_OS_WIN
|
// V8_TARGET_OS_WIN
|
||||||
//
|
//
|
||||||
// If not set explicitly, these fall back to corresponding V8_OS_ values.
|
// 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_FUCHSIA) \
|
||||||
&& !defined(V8_TARGET_OS_IOS) \
|
&& !defined(V8_TARGET_OS_IOS) \
|
||||||
&& !defined(V8_TARGET_OS_LINUX) \
|
&& !defined(V8_TARGET_OS_LINUX) \
|
||||||
&& !defined(V8_TARGET_OS_MACOSX) \
|
&& !defined(V8_TARGET_OS_MACOS) \
|
||||||
&& !defined(V8_TARGET_OS_WIN)
|
&& !defined(V8_TARGET_OS_WIN)
|
||||||
# error No known target OS defined.
|
# error No known target OS defined.
|
||||||
# endif
|
# endif
|
||||||
@ -192,7 +194,7 @@ path. Add it with -I<path> to the command line
|
|||||||
|| defined(V8_TARGET_OS_FUCHSIA) \
|
|| defined(V8_TARGET_OS_FUCHSIA) \
|
||||||
|| defined(V8_TARGET_OS_IOS) \
|
|| defined(V8_TARGET_OS_IOS) \
|
||||||
|| defined(V8_TARGET_OS_LINUX) \
|
|| defined(V8_TARGET_OS_LINUX) \
|
||||||
|| defined(V8_TARGET_OS_MACOSX) \
|
|| defined(V8_TARGET_OS_MACOS) \
|
||||||
|| defined(V8_TARGET_OS_WIN)
|
|| defined(V8_TARGET_OS_WIN)
|
||||||
# error A target OS is defined but V8_HAVE_TARGET_OS is unset.
|
# error A target OS is defined but V8_HAVE_TARGET_OS is unset.
|
||||||
# endif
|
# endif
|
||||||
@ -214,8 +216,8 @@ path. Add it with -I<path> to the command line
|
|||||||
# define V8_TARGET_OS_LINUX
|
# define V8_TARGET_OS_LINUX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef V8_OS_MACOSX
|
#ifdef V8_OS_MACOS
|
||||||
# define V8_TARGET_OS_MACOSX
|
# define V8_TARGET_OS_MACOS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef V8_OS_WIN
|
#ifdef V8_OS_WIN
|
||||||
@ -232,7 +234,7 @@ path. Add it with -I<path> to the command line
|
|||||||
# define V8_TARGET_OS_STRING "ios"
|
# define V8_TARGET_OS_STRING "ios"
|
||||||
#elif defined(V8_TARGET_OS_LINUX)
|
#elif defined(V8_TARGET_OS_LINUX)
|
||||||
# define V8_TARGET_OS_STRING "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"
|
# define V8_TARGET_OS_STRING "macos"
|
||||||
#elif defined(V8_TARGET_OS_WINDOWS)
|
#elif defined(V8_TARGET_OS_WINDOWS)
|
||||||
# define V8_TARGET_OS_STRING "windows"
|
# define V8_TARGET_OS_STRING "windows"
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
#include "src/wasm/wasm-serialization.h"
|
#include "src/wasm/wasm-serialization.h"
|
||||||
#endif // V8_ENABLE_WEBASSEMBLY
|
#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 <signal.h>
|
||||||
#include "include/v8-wasm-trap-handler-posix.h"
|
#include "include/v8-wasm-trap-handler-posix.h"
|
||||||
#include "src/trap-handler/handler-inside-posix.h"
|
#include "src/trap-handler/handler-inside-posix.h"
|
||||||
@ -6060,7 +6060,7 @@ bool v8::V8::Initialize(const int build_config) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if V8_OS_LINUX || V8_OS_MACOSX
|
#if V8_OS_LINUX || V8_OS_DARWIN
|
||||||
bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
|
bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
|
||||||
void* context) {
|
void* context) {
|
||||||
#if V8_ENABLE_WEBASSEMBLY && V8_TRAP_HANDLER_SUPPORTED
|
#if V8_ENABLE_WEBASSEMBLY && V8_TRAP_HANDLER_SUPPORTED
|
||||||
|
@ -441,7 +441,7 @@ inline int Relaxed_Memcmp(volatile const Atomic8* s1,
|
|||||||
|
|
||||||
// On some platforms we need additional declarations to make
|
// On some platforms we need additional declarations to make
|
||||||
// AtomicWord compatible with our other Atomic* types.
|
// 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"
|
#include "src/base/atomicops_internals_atomicword_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pthread_jit_write_protect is only available on arm64 Mac.
|
// 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
|
#define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 1
|
||||||
#else
|
#else
|
||||||
#define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0
|
#define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0
|
||||||
|
@ -783,7 +783,7 @@ CPU::CPU()
|
|||||||
has_jscvt_ = HasListItem(features, "jscvt");
|
has_jscvt_ = HasListItem(features, "jscvt");
|
||||||
delete[] features;
|
delete[] features;
|
||||||
}
|
}
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
// ARM64 Macs always have JSCVT.
|
// ARM64 Macs always have JSCVT.
|
||||||
has_jscvt_ = true;
|
has_jscvt_ = true;
|
||||||
#endif // V8_OS_WIN
|
#endif // V8_OS_WIN
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <AvailabilityMacros.h>
|
#include <AvailabilityMacros.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@
|
|||||||
// to continue after SIGTRAP.
|
// to continue after SIGTRAP.
|
||||||
#define TRAP_SEQUENCE1_() asm volatile("int3")
|
#define TRAP_SEQUENCE1_() asm volatile("int3")
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
// Intentionally empty: __builtin_unreachable() is always part of the sequence
|
// Intentionally empty: __builtin_unreachable() is always part of the sequence
|
||||||
// (see IMMEDIATE_CRASH below) and already emits a ud2 on Mac.
|
// (see IMMEDIATE_CRASH below) and already emits a ud2 on Mac.
|
||||||
#define TRAP_SEQUENCE2_() asm volatile("")
|
#define TRAP_SEQUENCE2_() asm volatile("")
|
||||||
#else
|
#else
|
||||||
#define TRAP_SEQUENCE2_() asm volatile("ud2")
|
#define TRAP_SEQUENCE2_() asm volatile("ud2")
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
|
|
||||||
#elif V8_HOST_ARCH_ARM
|
#elif V8_HOST_ARCH_ARM
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ V8_INLINE A implicit_cast(A x) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fix for Mac OS X defining uintptr_t as "unsigned long":
|
// Fix for Mac OS X defining uintptr_t as "unsigned long":
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#undef V8PRIxPTR
|
#undef V8PRIxPTR
|
||||||
#define V8PRIxPTR "lx"
|
#define V8PRIxPTR "lx"
|
||||||
#undef V8PRIdPTR
|
#undef V8PRIdPTR
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "src/base/platform/platform.h"
|
#include "src/base/platform/platform.h"
|
||||||
#include "src/base/platform/wrappers.h"
|
#include "src/base/platform/wrappers.h"
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <sys/mman.h> // For MAP_JIT.
|
#include <sys/mman.h> // For MAP_JIT.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ ConditionVariable::ConditionVariable() {
|
|||||||
|
|
||||||
|
|
||||||
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
|
// This hack is necessary to avoid a fatal pthreads subsystem bug in the
|
||||||
// Darwin kernel. http://crbug.com/517681.
|
// Darwin kernel. http://crbug.com/517681.
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) {
|
|||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int result;
|
int result;
|
||||||
mutex->AssertHeldAndUnmark();
|
mutex->AssertHeldAndUnmark();
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
// Mac OS X provides pthread_cond_timedwait_relative_np(), which does
|
// 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!
|
// not depend on the real time clock, which is what you really WANT here!
|
||||||
ts = rel_time.ToTimespec();
|
ts = rel_time.ToTimespec();
|
||||||
@ -111,7 +111,7 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) {
|
|||||||
ts = end_time.ToTimespec();
|
ts = end_time.ToTimespec();
|
||||||
result = pthread_cond_timedwait(
|
result = pthread_cond_timedwait(
|
||||||
&native_handle_, &mutex->native_handle(), &ts);
|
&native_handle_, &mutex->native_handle(), &ts);
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
mutex->AssertUnheldAndMark();
|
mutex->AssertUnheldAndMark();
|
||||||
if (result == ETIMEDOUT) {
|
if (result == ETIMEDOUT) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -222,7 +222,7 @@ bool RecursiveMutex::TryLock() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
|
|
||||||
SharedMutex::SharedMutex() { InitializeNativeHandle(&native_handle_); }
|
SharedMutex::SharedMutex() { InitializeNativeHandle(&native_handle_); }
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ bool SharedMutex::TryLockExclusive() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !V8_OS_MACOSX
|
#else // !V8_OS_DARWIN
|
||||||
|
|
||||||
SharedMutex::SharedMutex() { pthread_rwlock_init(&native_handle_, nullptr); }
|
SharedMutex::SharedMutex() { pthread_rwlock_init(&native_handle_, nullptr); }
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ bool SharedMutex::TryLockExclusive() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !V8_OS_MACOSX
|
#endif // !V8_OS_DARWIN
|
||||||
|
|
||||||
#elif V8_OS_WIN
|
#elif V8_OS_WIN
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ class V8_BASE_EXPORT SharedMutex final {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// The implementation-defined native handle type.
|
// 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
|
// 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,
|
// process (see https://crbug.com/v8/11399). Until Apple fixes that in the OS,
|
||||||
// we have to fall back to a non-shared mutex.
|
// we have to fall back to a non-shared mutex.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// Platform-specific code for MacOS goes here. Code shared between iOS and
|
// 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.
|
// platform-posix.cc.
|
||||||
|
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#endif
|
#endif
|
||||||
@ -65,7 +65,7 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#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
|
#define MAP_ANONYMOUS MAP_ANON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -102,16 +102,16 @@ DEFINE_LAZY_LEAKY_OBJECT_GETTER(RandomNumberGenerator,
|
|||||||
static LazyMutex rng_mutex = LAZY_MUTEX_INITIALIZER;
|
static LazyMutex rng_mutex = LAZY_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
#if !V8_OS_FUCHSIA
|
#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
|
// 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
|
// defined tag 255 This helps identify V8-allocated regions in memory analysis
|
||||||
// tools like vmmap(1).
|
// tools like vmmap(1).
|
||||||
const int kMmapFd = VM_MAKE_TAG(255);
|
const int kMmapFd = VM_MAKE_TAG(255);
|
||||||
#else // !V8_OS_MACOSX
|
#else // !V8_OS_DARWIN
|
||||||
const int kMmapFd = -1;
|
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
|
// During snapshot generation in cross builds, sysconf() runs on the Intel
|
||||||
// host and returns host page size, while the snapshot needs to use the
|
// host and returns host page size, while the snapshot needs to use the
|
||||||
// target page size.
|
// target page size.
|
||||||
@ -153,7 +153,7 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access,
|
|||||||
flags |= MAP_LAZY;
|
flags |= MAP_LAZY;
|
||||||
#endif // V8_OS_QNX
|
#endif // V8_OS_QNX
|
||||||
}
|
}
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
// MAP_JIT is required to obtain writable and executable pages when the
|
// MAP_JIT is required to obtain writable and executable pages when the
|
||||||
// hardened runtime/memory protection is enabled, which is optional (via code
|
// hardened runtime/memory protection is enabled, which is optional (via code
|
||||||
// signing) on Intel-based Macs but mandatory on Apple silicon ones. See also
|
// 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) {
|
if (access == OS::MemoryPermission::kNoAccessWillJitLater) {
|
||||||
flags |= MAP_JIT;
|
flags |= MAP_JIT;
|
||||||
}
|
}
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ int OS::ActivationFrameAlignment() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
size_t OS::AllocatePageSize() {
|
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;
|
return kAppleArmPageSize;
|
||||||
#else
|
#else
|
||||||
static size_t page_size = static_cast<size_t>(sysconf(_SC_PAGESIZE));
|
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));
|
GetPlatformRandomNumberGenerator()->NextBytes(&raw_addr, sizeof(raw_addr));
|
||||||
}
|
}
|
||||||
#if V8_HOST_ARCH_ARM64
|
#if V8_HOST_ARCH_ARM64
|
||||||
#if defined(V8_TARGET_OS_MACOSX)
|
#if defined(V8_TARGET_OS_MACOS)
|
||||||
DCHECK_EQ(1 << 14, AllocatePageSize());
|
DCHECK_EQ(1 << 14, AllocatePageSize());
|
||||||
#endif
|
#endif
|
||||||
// Keep the address page-aligned, AArch64 supports 4K, 16K and 64K
|
// 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.
|
// macOS specific implementation in platform-macos.cc.
|
||||||
#if !defined(V8_OS_MACOSX) || defined(V8_OS_IOS)
|
#if !defined(V8_OS_MACOS)
|
||||||
// static
|
// static
|
||||||
void* OS::AllocateShared(void* hint, size_t size, MemoryPermission access,
|
void* OS::AllocateShared(void* hint, size_t size, MemoryPermission access,
|
||||||
PlatformSharedMemoryHandle handle, uint64_t offset) {
|
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;
|
if (result == MAP_FAILED) return nullptr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS)
|
#endif // !defined(V8_OS_MACOS)
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool OS::FreeShared(void* address, size_t size) {
|
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
|
// MacOS 11.2 on Apple Silicon refuses to switch permissions from
|
||||||
// rwx to none. Just use madvise instead.
|
// rwx to none. Just use madvise instead.
|
||||||
#if defined(V8_OS_MACOSX)
|
#if defined(V8_OS_DARWIN)
|
||||||
if (ret != 0 && access == OS::MemoryPermission::kNoAccess) {
|
if (ret != 0 && access == OS::MemoryPermission::kNoAccess) {
|
||||||
ret = madvise(address, size, MADV_FREE_REUSABLE);
|
ret = madvise(address, size, MADV_FREE_REUSABLE);
|
||||||
return ret == 0;
|
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.
|
// The cost is a syscall that effectively no-ops.
|
||||||
// TODO(erikchen): Fix this to only call MADV_FREE_REUSE when necessary.
|
// TODO(erikchen): Fix this to only call MADV_FREE_REUSE when necessary.
|
||||||
// https://crbug.com/823915
|
// https://crbug.com/823915
|
||||||
#if defined(V8_OS_MACOSX)
|
#if defined(V8_OS_DARWIN)
|
||||||
if (access != OS::MemoryPermission::kNoAccess)
|
if (access != OS::MemoryPermission::kNoAccess)
|
||||||
madvise(address, size, MADV_FREE_REUSE);
|
madvise(address, size, MADV_FREE_REUSE);
|
||||||
#endif
|
#endif
|
||||||
@ -503,7 +503,7 @@ bool OS::DiscardSystemPages(void* address, size_t size) {
|
|||||||
// (base/allocator/partition_allocator/page_allocator_internals_posix.h)
|
// (base/allocator/partition_allocator/page_allocator_internals_posix.h)
|
||||||
DCHECK_EQ(0, reinterpret_cast<uintptr_t>(address) % CommitPageSize());
|
DCHECK_EQ(0, reinterpret_cast<uintptr_t>(address) % CommitPageSize());
|
||||||
DCHECK_EQ(0, size % 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
|
// 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
|
// marks the pages with the reusable bit, which allows both Activity Monitor
|
||||||
// and memory-infra to correctly track the pages.
|
// and memory-infra to correctly track the pages.
|
||||||
@ -573,7 +573,7 @@ bool OS::FreeAddressSpaceReservation(AddressSpaceReservation reservation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// macOS specific implementation in platform-macos.cc.
|
// macOS specific implementation in platform-macos.cc.
|
||||||
#if !defined(V8_OS_MACOSX) || defined(V8_OS_IOS)
|
#if !defined(V8_OS_MACOS)
|
||||||
// static
|
// static
|
||||||
PlatformSharedMemoryHandle OS::CreateSharedMemoryHandleForTesting(size_t size) {
|
PlatformSharedMemoryHandle OS::CreateSharedMemoryHandleForTesting(size_t size) {
|
||||||
#if V8_OS_LINUX && !V8_OS_ANDROID
|
#if V8_OS_LINUX && !V8_OS_ANDROID
|
||||||
@ -593,11 +593,11 @@ void OS::DestroySharedMemoryHandle(PlatformSharedMemoryHandle handle) {
|
|||||||
int fd = FileDescriptorFromSharedMemoryHandle(handle);
|
int fd = FileDescriptorFromSharedMemoryHandle(handle);
|
||||||
CHECK_EQ(0, close(fd));
|
CHECK_EQ(0, close(fd));
|
||||||
}
|
}
|
||||||
#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS)
|
#endif // !defined(V8_OS_MACOS)
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool OS::HasLazyCommits() {
|
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;
|
return true;
|
||||||
#else
|
#else
|
||||||
// TODO(bbudge) Return true for all POSIX platforms.
|
// TODO(bbudge) Return true for all POSIX platforms.
|
||||||
@ -730,7 +730,7 @@ int OS::GetCurrentProcessId() {
|
|||||||
|
|
||||||
|
|
||||||
int OS::GetCurrentThreadId() {
|
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()));
|
return static_cast<int>(pthread_mach_thread_np(pthread_self()));
|
||||||
#elif V8_OS_LINUX
|
#elif V8_OS_LINUX
|
||||||
return static_cast<int>(syscall(__NR_gettid));
|
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.
|
// 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,
|
bool AddressSpaceReservation::AllocateShared(void* address, size_t size,
|
||||||
OS::MemoryPermission access,
|
OS::MemoryPermission access,
|
||||||
PlatformSharedMemoryHandle handle,
|
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) !=
|
return mmap(address, size, prot, MAP_SHARED | MAP_FIXED, fd, offset) !=
|
||||||
MAP_FAILED;
|
MAP_FAILED;
|
||||||
}
|
}
|
||||||
#endif // !defined(V8_OS_MACOSX) || defined(V8_OS_IOS)
|
#endif // !defined(V8_OS_MACOS)
|
||||||
|
|
||||||
bool AddressSpaceReservation::FreeShared(void* address, size_t size) {
|
bool AddressSpaceReservation::FreeShared(void* address, size_t size) {
|
||||||
DCHECK(Contains(address, size));
|
DCHECK(Contains(address, size));
|
||||||
@ -1020,7 +1020,7 @@ static void SetThreadName(const char* name) {
|
|||||||
#elif V8_OS_NETBSD
|
#elif V8_OS_NETBSD
|
||||||
STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP);
|
STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP);
|
||||||
pthread_setname_np(pthread_self(), "%s", name);
|
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
|
// pthread_setname_np is only available in 10.6 or later, so test
|
||||||
// for it at runtime.
|
// for it at runtime.
|
||||||
int (*dynamic_pthread_setname_np)(const char*);
|
int (*dynamic_pthread_setname_np)(const char*);
|
||||||
@ -1066,7 +1066,7 @@ bool Thread::Start() {
|
|||||||
if (result != 0) return false;
|
if (result != 0) return false;
|
||||||
size_t stack_size = stack_size_;
|
size_t stack_size = stack_size_;
|
||||||
if (stack_size == 0) {
|
if (stack_size == 0) {
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
// Default on Mac OS X is 512kB -- bump up to 1MB
|
// Default on Mac OS X is 512kB -- bump up to 1MB
|
||||||
stack_size = 1 * 1024 * 1024;
|
stack_size = 1 * 1024 * 1024;
|
||||||
#elif V8_OS_AIX
|
#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
|
// pthread_getattr_np used below is non portable (hence the _np suffix). We
|
||||||
// keep this version in POSIX as most Linux-compatible derivatives will
|
// keep this version in POSIX as most Linux-compatible derivatives will
|
||||||
// support it. MacOS and FreeBSD are different here.
|
// 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)
|
!defined(V8_OS_SOLARIS)
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -1242,7 +1242,7 @@ Stack::StackSlot Stack::GetStackStart() {
|
|||||||
#endif // !defined(V8_LIBC_GLIBC)
|
#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)
|
// !defined(_AIX) && !defined(V8_OS_SOLARIS)
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "src/base/platform/semaphore.h"
|
#include "src/base/platform/semaphore.h"
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
#elif V8_OS_WIN
|
#elif V8_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
namespace v8 {
|
namespace v8 {
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
|
|
||||||
Semaphore::Semaphore(int count) {
|
Semaphore::Semaphore(int count) {
|
||||||
native_handle_ = dispatch_semaphore_create(count);
|
native_handle_ = dispatch_semaphore_create(count);
|
||||||
@ -174,7 +174,7 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
|
|||||||
return native_handle_.TakeWait(microseconds);
|
return native_handle_.TakeWait(microseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "src/base/win32-headers.h"
|
#include "src/base/win32-headers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
#elif V8_OS_POSIX
|
#elif V8_OS_POSIX
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
@ -55,7 +55,7 @@ class V8_BASE_EXPORT Semaphore final {
|
|||||||
// the semaphore counter is decremented and true is returned.
|
// the semaphore counter is decremented and true is returned.
|
||||||
bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
|
bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
using NativeHandle = dispatch_semaphore_t;
|
using NativeHandle = dispatch_semaphore_t;
|
||||||
#elif V8_OS_POSIX
|
#elif V8_OS_POSIX
|
||||||
using NativeHandle = sem_t;
|
using NativeHandle = sem_t;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
int64_t ComputeThreadTicks() {
|
int64_t ComputeThreadTicks() {
|
||||||
mach_msg_type_number_t thread_info_count = THREAD_BASIC_INFO_COUNT;
|
mach_msg_type_number_t thread_info_count = THREAD_BASIC_INFO_COUNT;
|
||||||
thread_basic_info_data_t thread_info_data;
|
thread_basic_info_data_t thread_info_data;
|
||||||
@ -156,8 +156,7 @@ V8_INLINE uint64_t QPCNowRaw() {
|
|||||||
USE(result);
|
USE(result);
|
||||||
return perf_counter_now.QuadPart;
|
return perf_counter_now.QuadPart;
|
||||||
}
|
}
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -245,8 +244,7 @@ int64_t TimeDelta::InNanoseconds() const {
|
|||||||
return delta_ * Time::kNanosecondsPerMicrosecond;
|
return delta_ * Time::kNanosecondsPerMicrosecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if V8_OS_DARWIN
|
||||||
#if V8_OS_MACOSX
|
|
||||||
|
|
||||||
TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) {
|
TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) {
|
||||||
DCHECK_GE(ts.tv_nsec, 0);
|
DCHECK_GE(ts.tv_nsec, 0);
|
||||||
@ -266,8 +264,7 @@ struct mach_timespec TimeDelta::ToMachTimespec() const {
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
|
|
||||||
|
|
||||||
#if V8_OS_POSIX
|
#if V8_OS_POSIX
|
||||||
|
|
||||||
@ -713,7 +710,7 @@ bool TimeTicks::IsHighResolution() {
|
|||||||
|
|
||||||
TimeTicks TimeTicks::Now() {
|
TimeTicks TimeTicks::Now() {
|
||||||
int64_t ticks;
|
int64_t ticks;
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
static struct mach_timebase_info info;
|
static struct mach_timebase_info info;
|
||||||
if (info.denom == 0) {
|
if (info.denom == 0) {
|
||||||
kern_return_t result = mach_timebase_info(&info);
|
kern_return_t result = mach_timebase_info(&info);
|
||||||
@ -730,14 +727,14 @@ TimeTicks TimeTicks::Now() {
|
|||||||
ticks = SbTimeGetMonotonicNow();
|
ticks = SbTimeGetMonotonicNow();
|
||||||
#else
|
#else
|
||||||
#error platform does not implement TimeTicks::Now.
|
#error platform does not implement TimeTicks::Now.
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
// Make sure we never return 0 here.
|
// Make sure we never return 0 here.
|
||||||
return TimeTicks(ticks + 1);
|
return TimeTicks(ticks + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool TimeTicks::IsHighResolution() {
|
bool TimeTicks::IsHighResolution() {
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
return true;
|
return true;
|
||||||
#elif V8_OS_POSIX
|
#elif V8_OS_POSIX
|
||||||
static const bool is_high_resolution = IsHighResolutionTimer(CLOCK_MONOTONIC);
|
static const bool is_high_resolution = IsHighResolutionTimer(CLOCK_MONOTONIC);
|
||||||
@ -763,7 +760,7 @@ bool ThreadTicks::IsSupported() {
|
|||||||
// Thread CPU time accounting is unavailable in PASE
|
// Thread CPU time accounting is unavailable in PASE
|
||||||
return false;
|
return false;
|
||||||
#elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
|
#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;
|
return true;
|
||||||
#elif defined(V8_OS_WIN)
|
#elif defined(V8_OS_WIN)
|
||||||
return IsSupportedWin();
|
return IsSupportedWin();
|
||||||
@ -784,7 +781,7 @@ ThreadTicks ThreadTicks::Now() {
|
|||||||
#else
|
#else
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
#endif
|
#endif
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
return ThreadTicks(ComputeThreadTicks());
|
return ThreadTicks(ComputeThreadTicks());
|
||||||
#elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
|
#elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
|
||||||
defined(V8_OS_ANDROID)
|
defined(V8_OS_ANDROID)
|
||||||
|
@ -63,7 +63,7 @@ int SysInfo::NumberOfProcessors() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
int64_t SysInfo::AmountOfPhysicalMemory() {
|
int64_t SysInfo::AmountOfPhysicalMemory() {
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
int mib[2] = {CTL_HW, HW_MEMSIZE};
|
int mib[2] = {CTL_HW, HW_MEMSIZE};
|
||||||
int64_t memsize = 0;
|
int64_t memsize = 0;
|
||||||
size_t len = sizeof(memsize);
|
size_t len = sizeof(memsize);
|
||||||
|
@ -56,7 +56,7 @@ RandomNumberGenerator::RandomNumberGenerator() {
|
|||||||
DCHECK_EQ(0, result);
|
DCHECK_EQ(0, result);
|
||||||
USE(result);
|
USE(result);
|
||||||
SetSeed((static_cast<int64_t>(first_half) << 32) + second_half);
|
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.
|
// Despite its prefix suggests it is not RC4 algorithm anymore.
|
||||||
// It always succeeds while having decent performance and
|
// It always succeeds while having decent performance and
|
||||||
// no file descriptor involved.
|
// no file descriptor involved.
|
||||||
|
@ -73,7 +73,7 @@ constexpr unsigned CpuFeaturesFromCompiler() {
|
|||||||
|
|
||||||
constexpr unsigned CpuFeaturesFromTargetOS() {
|
constexpr unsigned CpuFeaturesFromTargetOS() {
|
||||||
unsigned features = 0;
|
unsigned features = 0;
|
||||||
#if defined(V8_TARGET_OS_MACOSX)
|
#if defined(V8_TARGET_OS_MACOS)
|
||||||
features |= 1u << JSCVT;
|
features |= 1u << JSCVT;
|
||||||
#endif
|
#endif
|
||||||
return features;
|
return features;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "src/codegen/arm64/utils-arm64.h"
|
#include "src/codegen/arm64/utils-arm64.h"
|
||||||
#include "src/codegen/cpu-features.h"
|
#include "src/codegen/cpu-features.h"
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <libkern/OSCacheControl.h>
|
#include <libkern/OSCacheControl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void CpuFeatures::FlushICache(void* address, size_t length) {
|
|||||||
#if defined(V8_HOST_ARCH_ARM64)
|
#if defined(V8_HOST_ARCH_ARM64)
|
||||||
#if defined(V8_OS_WIN)
|
#if defined(V8_OS_WIN)
|
||||||
::FlushInstructionCache(GetCurrentProcess(), address, length);
|
::FlushInstructionCache(GetCurrentProcess(), address, length);
|
||||||
#elif defined(V8_OS_MACOSX)
|
#elif defined(V8_OS_DARWIN)
|
||||||
sys_icache_invalidate(address, length);
|
sys_icache_invalidate(address, length);
|
||||||
#else
|
#else
|
||||||
// The code below assumes user space cache operations are allowed. The goal
|
// The code below assumes user space cache operations are allowed. The goal
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#if V8_LIBC_MSVCRT
|
#if V8_LIBC_MSVCRT
|
||||||
#include <intrin.h> // _xgetbv()
|
#include <intrin.h> // _xgetbv()
|
||||||
#endif
|
#endif
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ V8_INLINE uint64_t xgetbv(unsigned int xcr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OSHasAVXSupport() {
|
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
|
// 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.
|
// caused by ISRs, so we detect that here and disable AVX in that case.
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
@ -112,7 +112,7 @@ bool OSHasAVXSupport() {
|
|||||||
*period_pos = '\0';
|
*period_pos = '\0';
|
||||||
long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT
|
long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT
|
||||||
if (kernel_version_major <= 13) return false;
|
if (kernel_version_major <= 13) return false;
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
// Check whether OS claims to support AVX.
|
// Check whether OS claims to support AVX.
|
||||||
uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK
|
uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK
|
||||||
return (feature_mask & 0x6) == 0x6;
|
return (feature_mask & 0x6) == 0x6;
|
||||||
|
@ -95,7 +95,7 @@ class V8_EXPORT_PRIVATE TurboAssemblerBase : public Assembler {
|
|||||||
static bool IsAddressableThroughRootRegister(
|
static bool IsAddressableThroughRootRegister(
|
||||||
Isolate* isolate, const ExternalReference& reference);
|
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
|
// Minimum page size. We must touch memory once per page when expanding the
|
||||||
// stack, to avoid access violations.
|
// stack, to avoid access violations.
|
||||||
static constexpr int kStackPageSize = 4 * KB;
|
static constexpr int kStackPageSize = 4 * KB;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#if V8_LIBC_MSVCRT
|
#if V8_LIBC_MSVCRT
|
||||||
#include <intrin.h> // _xgetbv()
|
#include <intrin.h> // _xgetbv()
|
||||||
#endif
|
#endif
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ V8_INLINE uint64_t xgetbv(unsigned int xcr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OSHasAVXSupport() {
|
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
|
// 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.
|
// caused by ISRs, so we detect that here and disable AVX in that case.
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
@ -65,7 +65,7 @@ bool OSHasAVXSupport() {
|
|||||||
*period_pos = '\0';
|
*period_pos = '\0';
|
||||||
long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT
|
long kernel_version_major = strtol(buffer, nullptr, 10); // NOLINT
|
||||||
if (kernel_version_major <= 13) return false;
|
if (kernel_version_major <= 13) return false;
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
// Check whether OS claims to support AVX.
|
// Check whether OS claims to support AVX.
|
||||||
uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK
|
uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK
|
||||||
return (feature_mask & 0x6) == 0x6;
|
return (feature_mask & 0x6) == 0x6;
|
||||||
|
@ -2763,7 +2763,7 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) {
|
|||||||
popq(rbp);
|
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) {
|
void TurboAssembler::AllocateStackSpace(Register bytes_scratch) {
|
||||||
ASM_CODE_COMMENT(this);
|
ASM_CODE_COMMENT(this);
|
||||||
// On Windows and on macOS, we cannot increment the stack size by more than
|
// On Windows and on macOS, we cannot increment the stack size by more than
|
||||||
|
@ -474,7 +474,7 @@ class V8_EXPORT_PRIVATE TurboAssembler
|
|||||||
// stack check, do it before calling this function because this function may
|
// stack check, do it before calling this function because this function may
|
||||||
// write into the newly allocated space. It may also overwrite the given
|
// write into the newly allocated space. It may also overwrite the given
|
||||||
// register's value, in the version that takes a register.
|
// 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(Register bytes_scratch);
|
||||||
void AllocateStackSpace(int bytes);
|
void AllocateStackSpace(int bytes);
|
||||||
#else
|
#else
|
||||||
|
@ -211,7 +211,7 @@ struct MaybeBoolFlag {
|
|||||||
#define ENABLE_SPARKPLUG_BY_DEFAULT false
|
#define ENABLE_SPARKPLUG_BY_DEFAULT false
|
||||||
#endif
|
#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.
|
// Must be enabled on M1.
|
||||||
#define MUST_WRITE_PROTECT_CODE_MEMORY true
|
#define MUST_WRITE_PROTECT_CODE_MEMORY true
|
||||||
#else
|
#else
|
||||||
@ -684,7 +684,7 @@ DEFINE_BOOL(always_sparkplug, false, "directly tier up to Sparkplug code")
|
|||||||
#if ENABLE_SPARKPLUG
|
#if ENABLE_SPARKPLUG
|
||||||
DEFINE_IMPLICATION(always_sparkplug, sparkplug)
|
DEFINE_IMPLICATION(always_sparkplug, sparkplug)
|
||||||
DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code")
|
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.
|
// M1 requires W^X.
|
||||||
DEFINE_BOOL_READONLY(concurrent_sparkplug, false,
|
DEFINE_BOOL_READONLY(concurrent_sparkplug, false,
|
||||||
"compile Sparkplug code in a background thread")
|
"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_BOOL(shared_string_table, false, "internalize strings into shared table")
|
||||||
DEFINE_IMPLICATION(harmony_struct, shared_string_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,
|
DEFINE_BOOL(write_code_using_rwx, true,
|
||||||
"flip permissions to rwx to write page instead of rw")
|
"flip permissions to rwx to write page instead of rw")
|
||||||
DEFINE_NEG_IMPLICATION(jitless, write_code_using_rwx)
|
DEFINE_NEG_IMPLICATION(jitless, write_code_using_rwx)
|
||||||
|
@ -1601,7 +1601,7 @@ class Heap {
|
|||||||
void* GetRandomMmapAddr() {
|
void* GetRandomMmapAddr() {
|
||||||
void* result = v8::internal::GetRandomMmapAddr();
|
void* result = v8::internal::GetRandomMmapAddr();
|
||||||
#if V8_TARGET_ARCH_X64
|
#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
|
// 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
|
// directory entries [PDE] created from mmap or mach_vm_allocate, even
|
||||||
// after the region is destroyed. Using a virtual address space that is
|
// after the region is destroyed. Using a virtual address space that is
|
||||||
@ -1611,7 +1611,7 @@ class Heap {
|
|||||||
// space. See crbug.com/700928.
|
// space. See crbug.com/700928.
|
||||||
uintptr_t offset = reinterpret_cast<uintptr_t>(result) & kMmapRegionMask;
|
uintptr_t offset = reinterpret_cast<uintptr_t>(result) & kMmapRegionMask;
|
||||||
result = reinterpret_cast<void*>(mmap_region_base_ + offset);
|
result = reinterpret_cast<void*>(mmap_region_base_ + offset);
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
#endif // V8_TARGET_ARCH_X64
|
#endif // V8_TARGET_ARCH_X64
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ Response toProtocolValue(v8::Local<v8::Context> context,
|
|||||||
v8::Local<v8::Value> value,
|
v8::Local<v8::Value> value,
|
||||||
std::unique_ptr<protocol::Value>* result) {
|
std::unique_ptr<protocol::Value>* result) {
|
||||||
if (value->IsUndefined()) return Response::Success();
|
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.
|
// For whatever reason, ASan on MacOS has bigger stack frames.
|
||||||
static const int kMaxDepth = 900;
|
static const int kMaxDepth = 900;
|
||||||
#else
|
#else
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION"
|
#error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <os/signpost.h>
|
#include <os/signpost.h>
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||||
@ -47,7 +47,7 @@ class V8_PLATFORM_EXPORT Recorder {
|
|||||||
void AddEvent(TraceObject* trace_event);
|
void AddEvent(TraceObject* trace_event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
os_log_t v8Provider;
|
os_log_t v8Provider;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -56,7 +56,7 @@ class V8_PLATFORM_EXPORT Recorder {
|
|||||||
} // namespace platform
|
} // namespace platform
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
// OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.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.
|
// 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.
|
#error Unexpected iOS target architecture.
|
||||||
#endif // V8_TARGET_ARCH_ARM64
|
#endif // V8_TARGET_ARCH_ARM64
|
||||||
|
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
#if V8_HOST_ARCH_X64
|
#if V8_HOST_ARCH_X64
|
||||||
state->pc = reinterpret_cast<void*>(mcontext->__ss.__rip);
|
state->pc = reinterpret_cast<void*>(mcontext->__ss.__rip);
|
||||||
state->sp = reinterpret_cast<void*>(mcontext->__ss.__rsp);
|
state->sp = reinterpret_cast<void*>(mcontext->__ss.__rsp);
|
||||||
|
@ -116,7 +116,7 @@ EmbeddedTargetArch ToEmbeddedTargetArch(const char* s) {
|
|||||||
EmbeddedTargetOs DefaultEmbeddedTargetOs() {
|
EmbeddedTargetOs DefaultEmbeddedTargetOs() {
|
||||||
#if defined(V8_OS_AIX)
|
#if defined(V8_OS_AIX)
|
||||||
return EmbeddedTargetOs::kAIX;
|
return EmbeddedTargetOs::kAIX;
|
||||||
#elif defined(V8_OS_MACOSX)
|
#elif defined(V8_OS_DARWIN)
|
||||||
return EmbeddedTargetOs::kMac;
|
return EmbeddedTargetOs::kMac;
|
||||||
#elif defined(V8_OS_WIN)
|
#elif defined(V8_OS_WIN)
|
||||||
return EmbeddedTargetOs::kWin;
|
return EmbeddedTargetOs::kWin;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#if defined(V8_OS_LINUX) || defined(V8_OS_FREEBSD)
|
#if defined(V8_OS_LINUX) || defined(V8_OS_FREEBSD)
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ namespace trap_handler {
|
|||||||
|
|
||||||
#if V8_OS_LINUX
|
#if V8_OS_LINUX
|
||||||
#define CONTEXT_REG(reg, REG) &uc->uc_mcontext.gregs[REG_##REG]
|
#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
|
#define CONTEXT_REG(reg, REG) &uc->uc_mcontext->__ss.__##reg
|
||||||
#elif V8_OS_FREEBSD
|
#elif V8_OS_FREEBSD
|
||||||
#define CONTEXT_REG(reg, REG) &uc->uc_mcontext.mc_##reg
|
#define CONTEXT_REG(reg, REG) &uc->uc_mcontext.mc_##reg
|
||||||
|
@ -15,7 +15,7 @@ namespace trap_handler {
|
|||||||
|
|
||||||
#if V8_OS_LINUX || V8_OS_FREEBSD
|
#if V8_OS_LINUX || V8_OS_FREEBSD
|
||||||
constexpr int kOobSignal = SIGSEGV;
|
constexpr int kOobSignal = SIGSEGV;
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
constexpr int kOobSignal = SIGBUS;
|
constexpr int kOobSignal = SIGBUS;
|
||||||
#else
|
#else
|
||||||
#error Posix trap handlers are only supported on Linux, MacOSX and FreeBSD.
|
#error Posix trap handlers are only supported on Linux, MacOSX and FreeBSD.
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
#include "include/v8config.h"
|
#include "include/v8config.h"
|
||||||
#include "src/trap-handler/trap-handler-simulator.h"
|
#include "src/trap-handler/trap-handler-simulator.h"
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#define SYMBOL(name) "_" #name
|
#define SYMBOL(name) "_" #name
|
||||||
#else // !V8_OS_MACOSX
|
#else // !V8_OS_DARWIN
|
||||||
#define SYMBOL(name) #name
|
#define SYMBOL(name) #name
|
||||||
#endif // !V8_OS_MACOSX
|
#endif // !V8_OS_DARWIN
|
||||||
|
|
||||||
// Define the ProbeMemory function declared in trap-handler-simulators.h.
|
// Define the ProbeMemory function declared in trap-handler-simulators.h.
|
||||||
asm(
|
asm(
|
||||||
|
@ -19,15 +19,15 @@ namespace trap_handler {
|
|||||||
|
|
||||||
// X64 on Linux, Windows, MacOS, FreeBSD.
|
// X64 on Linux, Windows, MacOS, FreeBSD.
|
||||||
#if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \
|
#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)
|
V8_OS_FREEBSD)
|
||||||
#define V8_TRAP_HANDLER_SUPPORTED true
|
#define V8_TRAP_HANDLER_SUPPORTED true
|
||||||
// Arm64 (non-simulator) on Mac.
|
// 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
|
#define V8_TRAP_HANDLER_SUPPORTED true
|
||||||
// Arm64 simulator on x64 on Linux, Mac, or Windows.
|
// Arm64 simulator on x64 on Linux, Mac, or Windows.
|
||||||
#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && \
|
#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_VIA_SIMULATOR
|
||||||
#define V8_TRAP_HANDLER_SUPPORTED true
|
#define V8_TRAP_HANDLER_SUPPORTED true
|
||||||
// Everything else is unsupported.
|
// Everything else is unsupported.
|
||||||
|
@ -194,7 +194,7 @@ TEST(TestFlushICacheOfWritableAndExecutable) {
|
|||||||
CHECK(SetPermissions(GetPlatformPageAllocator(), buffer->start(),
|
CHECK(SetPermissions(GetPlatformPageAllocator(), buffer->start(),
|
||||||
buffer->size(), v8::PageAllocator::kReadWriteExecute));
|
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.
|
// Make sure to switch memory to writable on M1 hardware.
|
||||||
wasm::CodeSpaceWriteScope code_space_write_scope(nullptr);
|
wasm::CodeSpaceWriteScope code_space_write_scope(nullptr);
|
||||||
#endif
|
#endif
|
||||||
@ -203,7 +203,7 @@ TEST(TestFlushICacheOfWritableAndExecutable) {
|
|||||||
}
|
}
|
||||||
CHECK_EQ(23 + kNumInstr, f.Call(23)); // Call into generated code.
|
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.
|
// Make sure to switch memory to writable on M1 hardware.
|
||||||
wasm::CodeSpaceWriteScope code_space_write_scope(nullptr);
|
wasm::CodeSpaceWriteScope code_space_write_scope(nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -162,7 +162,7 @@ void CompileJumpTableThunk(Address thunk, Address jump_target) {
|
|||||||
__ Ret();
|
__ Ret();
|
||||||
|
|
||||||
FlushInstructionCache(thunk, kThunkBufferSize);
|
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
|
// MacOS on arm64 refuses {mprotect} calls to toggle permissions of RWX
|
||||||
// memory. Simply do nothing here, as the space will by default be executable
|
// memory. Simply do nothing here, as the space will by default be executable
|
||||||
// and non-writable for the JumpTableRunner.
|
// and non-writable for the JumpTableRunner.
|
||||||
@ -203,7 +203,7 @@ class JumpTablePatcher : public v8::base::Thread {
|
|||||||
|
|
||||||
void Run() override {
|
void Run() override {
|
||||||
TRACE("Patcher %p is starting ...\n", this);
|
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.
|
// Make sure to switch memory to writable on M1 hardware.
|
||||||
CodeSpaceWriteScope code_space_write_scope(nullptr);
|
CodeSpaceWriteScope code_space_write_scope(nullptr);
|
||||||
#endif
|
#endif
|
||||||
@ -267,7 +267,7 @@ TEST(JumpTablePatchingStress) {
|
|||||||
std::vector<std::unique_ptr<TestingAssemblerBuffer>> thunk_buffers;
|
std::vector<std::unique_ptr<TestingAssemblerBuffer>> thunk_buffers;
|
||||||
std::vector<Address> patcher_thunks;
|
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.
|
// Make sure to switch memory to writable on M1 hardware.
|
||||||
CodeSpaceWriteScope code_space_write_scope(nullptr);
|
CodeSpaceWriteScope code_space_write_scope(nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -106,9 +106,9 @@ bool FuzzerSupport::PumpMessageLoop(
|
|||||||
// Explicitly specify some attributes to avoid issues with the linker dead-
|
// Explicitly specify some attributes to avoid issues with the linker dead-
|
||||||
// stripping the following function on macOS, as it is not called directly
|
// stripping the following function on macOS, as it is not called directly
|
||||||
// by fuzz target. LibFuzzer runtime uses dlsym() to resolve that function.
|
// by fuzz target. LibFuzzer runtime uses dlsym() to resolve that function.
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
__attribute__((used)) __attribute__((visibility("default")))
|
__attribute__((used)) __attribute__((visibility("default")))
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
extern "C" int
|
extern "C" int
|
||||||
LLVMFuzzerInitialize(int* argc, char*** argv) {
|
LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||||
v8_fuzzer::FuzzerSupport::InitializeFuzzerSupport(argc, argv);
|
v8_fuzzer::FuzzerSupport::InitializeFuzzerSupport(argc, argv);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "src/base/platform/time.h"
|
#include "src/base/platform/time.h"
|
||||||
|
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
#endif
|
#endif
|
||||||
#if V8_OS_POSIX
|
#if V8_OS_POSIX
|
||||||
@ -201,8 +201,7 @@ TEST(TimeDelta, FromAndIn) {
|
|||||||
TimeDelta::FromMicroseconds(13).InMicroseconds());
|
TimeDelta::FromMicroseconds(13).InMicroseconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if V8_OS_DARWIN
|
||||||
#if V8_OS_MACOSX
|
|
||||||
TEST(TimeDelta, MachTimespec) {
|
TEST(TimeDelta, MachTimespec) {
|
||||||
TimeDelta null = TimeDelta();
|
TimeDelta null = TimeDelta();
|
||||||
EXPECT_EQ(null, TimeDelta::FromMachTimespec(null.ToMachTimespec()));
|
EXPECT_EQ(null, TimeDelta::FromMachTimespec(null.ToMachTimespec()));
|
||||||
|
@ -93,7 +93,7 @@ TEST(Heap, HeapSizeFromPhysicalMemory) {
|
|||||||
|
|
||||||
TEST_F(HeapTest, ASLR) {
|
TEST_F(HeapTest, ASLR) {
|
||||||
#if V8_TARGET_ARCH_X64
|
#if V8_TARGET_ARCH_X64
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
Heap* heap = i_isolate()->heap();
|
Heap* heap = i_isolate()->heap();
|
||||||
std::set<void*> hints;
|
std::set<void*> hints;
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
@ -114,7 +114,7 @@ TEST_F(HeapTest, ASLR) {
|
|||||||
EXPECT_LE(diff, kRegionMask);
|
EXPECT_LE(diff, kRegionMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // V8_OS_MACOSX
|
#endif // V8_OS_DARWIN
|
||||||
#endif // V8_TARGET_ARCH_X64
|
#endif // V8_TARGET_ARCH_X64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
struct sigaction old_action_;
|
struct sigaction old_action_;
|
||||||
// On Mac, sometimes we get SIGBUS instead of SIGSEGV.
|
// On Mac, sometimes we get SIGBUS instead of SIGSEGV.
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
struct sigaction old_bus_action_;
|
struct sigaction old_bus_action_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test {
|
|||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
action.sa_flags = SA_SIGINFO;
|
action.sa_flags = SA_SIGINFO;
|
||||||
sigaction(SIGSEGV, &action, &old_action_);
|
sigaction(SIGSEGV, &action, &old_action_);
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
sigaction(SIGBUS, &action, &old_bus_action_);
|
sigaction(SIGBUS, &action, &old_bus_action_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ class MemoryAllocationPermissionsTest : public ::testing::Test {
|
|||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
// Be a good citizen and restore the old signal handler.
|
// Be a good citizen and restore the old signal handler.
|
||||||
sigaction(SIGSEGV, &old_action_, nullptr);
|
sigaction(SIGSEGV, &old_action_, nullptr);
|
||||||
#if V8_OS_MACOSX
|
#if V8_OS_DARWIN
|
||||||
sigaction(SIGBUS, &old_bus_action_, nullptr);
|
sigaction(SIGBUS, &old_bus_action_, nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#if V8_OS_LINUX || V8_OS_FREEBSD
|
#if V8_OS_LINUX || V8_OS_FREEBSD
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
#elif V8_OS_MACOSX
|
#elif V8_OS_DARWIN
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#elif V8_OS_WIN
|
#elif V8_OS_WIN
|
||||||
@ -40,7 +40,7 @@ namespace wasm {
|
|||||||
namespace {
|
namespace {
|
||||||
constexpr Register scratch = r10;
|
constexpr Register scratch = r10;
|
||||||
bool g_test_handler_executed = false;
|
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_segv_action;
|
||||||
struct sigaction g_old_fpe_action;
|
struct sigaction g_old_fpe_action;
|
||||||
struct sigaction g_old_bus_action; // We get SIGBUS on Mac sometimes.
|
struct sigaction g_old_bus_action; // We get SIGBUS on Mac sometimes.
|
||||||
@ -96,7 +96,7 @@ class TrapHandlerTest : public TestWithIsolate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InstallFallbackHandler() {
|
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.
|
// Set up a signal handler to recover from the expected crash.
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_sigaction = SignalHandler;
|
action.sa_sigaction = SignalHandler;
|
||||||
@ -124,7 +124,7 @@ class TrapHandlerTest : public TestWithIsolate,
|
|||||||
// Clean up the trap handler
|
// Clean up the trap handler
|
||||||
trap_handler::RemoveTrapHandler();
|
trap_handler::RemoveTrapHandler();
|
||||||
if (!g_test_handler_executed) {
|
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
|
// 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.
|
// test handler was not called, we have to do the cleanup ourselves.
|
||||||
EXPECT_EQ(0, sigaction(SIGSEGV, &g_old_segv_action, nullptr));
|
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);
|
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) {
|
static void SignalHandler(int signal, siginfo_t* info, void* context) {
|
||||||
if (g_use_as_first_chance_handler) {
|
if (g_use_as_first_chance_handler) {
|
||||||
if (v8::TryHandleWebAssemblyTrapPosix(signal, info, context)) {
|
if (v8::TryHandleWebAssemblyTrapPosix(signal, info, context)) {
|
||||||
@ -174,7 +174,7 @@ class TrapHandlerTest : public TestWithIsolate,
|
|||||||
ucontext_t* uc = reinterpret_cast<ucontext_t*>(context);
|
ucontext_t* uc = reinterpret_cast<ucontext_t*>(context);
|
||||||
#if V8_OS_LINUX
|
#if V8_OS_LINUX
|
||||||
uc->uc_mcontext.gregs[REG_RIP] = g_recovery_address;
|
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;
|
uc->uc_mcontext->__ss.__rip = g_recovery_address;
|
||||||
#elif V8_OS_FREEBSD
|
#elif V8_OS_FREEBSD
|
||||||
uc->uc_mcontext.mc_rip = g_recovery_address;
|
uc->uc_mcontext.mc_rip = g_recovery_address;
|
||||||
|
Loading…
Reference in New Issue
Block a user