2013-08-23 07:32:25 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
#ifndef V8CONFIG_H_
|
|
|
|
#define V8CONFIG_H_
|
|
|
|
|
2021-01-18 15:45:12 +00:00
|
|
|
#ifdef V8_GN_HEADER
|
|
|
|
#if __cplusplus >= 201703L && !__has_include("v8-gn.h")
|
|
|
|
#error Missing v8-gn.h. The configuration for v8 is missing from the include \
|
|
|
|
path. Add it with -I<path> to the command line
|
|
|
|
#endif
|
|
|
|
#include "v8-gn.h" // NOLINT(build/include_directory)
|
|
|
|
#endif
|
|
|
|
|
2015-06-29 11:47:50 +00:00
|
|
|
// clang-format off
|
|
|
|
|
2013-08-30 12:09:50 +00:00
|
|
|
// Platform headers for feature detection below.
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
# include <sys/cdefs.h>
|
|
|
|
#elif defined(__APPLE__)
|
2013-08-30 12:30:09 +00:00
|
|
|
# include <TargetConditionals.h>
|
2013-08-30 12:09:50 +00:00
|
|
|
#elif defined(__linux__)
|
|
|
|
# include <features.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro allows to test for the version of the GNU C library (or
|
|
|
|
// a compatible C library that masquerades as glibc). It evaluates to
|
|
|
|
// 0 if libc is not GNU libc or compatible.
|
|
|
|
// Use like:
|
|
|
|
// #if V8_GLIBC_PREREQ(2, 3)
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
|
|
|
# define V8_GLIBC_PREREQ(major, minor) \
|
|
|
|
((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
|
|
|
|
#else
|
|
|
|
# define V8_GLIBC_PREREQ(major, minor) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// This macro allows to test for the version of the GNU C++ compiler.
|
|
|
|
// Note that this also applies to compilers that masquerade as GCC,
|
|
|
|
// for example clang and the Intel C++ compiler for Linux.
|
|
|
|
// Use like:
|
|
|
|
// #if V8_GNUC_PREREQ(4, 3, 1)
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
|
|
|
|
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \
|
|
|
|
((major) * 10000 + (minor) * 100 + (patchlevel)))
|
|
|
|
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
|
2015-03-25 14:22:27 +00:00
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) \
|
|
|
|
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \
|
2013-08-30 12:09:50 +00:00
|
|
|
((major) * 10000 + (minor) * 100 + (patchlevel)))
|
|
|
|
#else
|
|
|
|
# define V8_GNUC_PREREQ(major, minor, patchlevel) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2019-09-19 11:26:15 +00:00
|
|
|
// Operating system detection (host)
|
2013-08-23 07:32:25 +00:00
|
|
|
//
|
|
|
|
// V8_OS_ANDROID - Android
|
|
|
|
// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD)
|
|
|
|
// V8_OS_CYGWIN - Cygwin
|
|
|
|
// V8_OS_DRAGONFLYBSD - DragonFlyBSD
|
|
|
|
// V8_OS_FREEBSD - FreeBSD
|
2017-06-11 06:31:33 +00:00
|
|
|
// V8_OS_FUCHSIA - Fuchsia
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_LINUX - Linux
|
|
|
|
// V8_OS_MACOSX - Mac OS X
|
2019-04-16 13:48:14 +00:00
|
|
|
// V8_OS_IOS - iOS
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_NETBSD - NetBSD
|
|
|
|
// V8_OS_OPENBSD - OpenBSD
|
|
|
|
// V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
|
2014-01-02 07:04:05 +00:00
|
|
|
// V8_OS_QNX - QNX Neutrino
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_SOLARIS - Sun Solaris and OpenSolaris
|
2020-08-22 02:27:50 +00:00
|
|
|
// V8_OS_STARBOARD - Starboard (platform abstraction for Cobalt)
|
2015-01-30 08:01:53 +00:00
|
|
|
// V8_OS_AIX - AIX
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_OS_WIN - Microsoft Windows
|
|
|
|
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
# define V8_OS_ANDROID 1
|
|
|
|
# define V8_OS_LINUX 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "android"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_MACOSX 1
|
|
|
|
# define V8_OS_POSIX 1
|
2019-04-16 13:48:14 +00:00
|
|
|
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
|
|
|
# define V8_OS_IOS 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "ios"
|
|
|
|
# else
|
|
|
|
# define V8_OS_STRING "macos"
|
2019-04-16 13:48:14 +00:00
|
|
|
# endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
2021-08-02 13:39:11 +00:00
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__CYGWIN__)
|
|
|
|
# define V8_OS_CYGWIN 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "cygwin"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__linux__)
|
|
|
|
# define V8_OS_LINUX 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "linux"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__sun)
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
# define V8_OS_SOLARIS 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "sun"
|
|
|
|
|
2020-08-22 02:27:50 +00:00
|
|
|
#elif defined(STARBOARD)
|
|
|
|
# define V8_OS_STARBOARD 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "starboard"
|
|
|
|
|
2015-01-30 08:01:53 +00:00
|
|
|
#elif defined(_AIX)
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
# define V8_OS_AIX 1
|
|
|
|
# define V8_OS_STRING "aix"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_FREEBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "freebsd"
|
|
|
|
|
2017-06-11 06:31:33 +00:00
|
|
|
#elif defined(__Fuchsia__)
|
|
|
|
# define V8_OS_FUCHSIA 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "fuchsia"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__DragonFly__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_DRAGONFLYBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "dragonflybsd"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_NETBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "netbsd"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
# define V8_OS_BSD 1
|
|
|
|
# define V8_OS_OPENBSD 1
|
|
|
|
# define V8_OS_POSIX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "openbsd"
|
|
|
|
|
2014-01-02 07:04:05 +00:00
|
|
|
#elif defined(__QNXNTO__)
|
|
|
|
# define V8_OS_POSIX 1
|
|
|
|
# define V8_OS_QNX 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "qnx"
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
# define V8_OS_WIN 1
|
2021-08-02 13:39:11 +00:00
|
|
|
# define V8_OS_STRING "windows"
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-19 11:26:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Operating system detection (target)
|
|
|
|
//
|
|
|
|
// V8_TARGET_OS_ANDROID
|
|
|
|
// V8_TARGET_OS_FUCHSIA
|
|
|
|
// V8_TARGET_OS_IOS
|
|
|
|
// V8_TARGET_OS_LINUX
|
|
|
|
// V8_TARGET_OS_MACOSX
|
|
|
|
// V8_TARGET_OS_WIN
|
|
|
|
//
|
|
|
|
// If not set explicitly, these fall back to corresponding V8_OS_ values.
|
|
|
|
|
|
|
|
#ifdef V8_HAVE_TARGET_OS
|
|
|
|
|
|
|
|
// The target OS is provided, just check that at least one known value is set.
|
|
|
|
# if !defined(V8_TARGET_OS_ANDROID) \
|
|
|
|
&& !defined(V8_TARGET_OS_FUCHSIA) \
|
|
|
|
&& !defined(V8_TARGET_OS_IOS) \
|
|
|
|
&& !defined(V8_TARGET_OS_LINUX) \
|
|
|
|
&& !defined(V8_TARGET_OS_MACOSX) \
|
|
|
|
&& !defined(V8_TARGET_OS_WIN)
|
|
|
|
# error No known target OS defined.
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#else // V8_HAVE_TARGET_OS
|
|
|
|
|
|
|
|
# if defined(V8_TARGET_OS_ANDROID) \
|
|
|
|
|| defined(V8_TARGET_OS_FUCHSIA) \
|
|
|
|
|| defined(V8_TARGET_OS_IOS) \
|
|
|
|
|| defined(V8_TARGET_OS_LINUX) \
|
|
|
|
|| defined(V8_TARGET_OS_MACOSX) \
|
|
|
|
|| defined(V8_TARGET_OS_WIN)
|
|
|
|
# error A target OS is defined but V8_HAVE_TARGET_OS is unset.
|
|
|
|
# endif
|
|
|
|
|
|
|
|
// Fall back to the detected host OS.
|
|
|
|
#ifdef V8_OS_ANDROID
|
|
|
|
# define V8_TARGET_OS_ANDROID
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef V8_OS_FUCHSIA
|
|
|
|
# define V8_TARGET_OS_FUCHSIA
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef V8_OS_IOS
|
|
|
|
# define V8_TARGET_OS_IOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef V8_OS_LINUX
|
|
|
|
# define V8_TARGET_OS_LINUX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef V8_OS_MACOSX
|
|
|
|
# define V8_TARGET_OS_MACOSX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef V8_OS_WIN
|
|
|
|
# define V8_TARGET_OS_WIN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // V8_HAVE_TARGET_OS
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2021-08-02 13:39:11 +00:00
|
|
|
#if defined(V8_TARGET_OS_ANDROID)
|
|
|
|
# define V8_TARGET_OS_STRING "android"
|
|
|
|
#elif defined(V8_TARGET_OS_FUCHSIA)
|
|
|
|
# define V8_TARGET_OS_STRING "fuchsia"
|
|
|
|
#elif defined(V8_TARGET_OS_IOS)
|
|
|
|
# define V8_TARGET_OS_STRING "ios"
|
|
|
|
#elif defined(V8_TARGET_OS_LINUX)
|
|
|
|
# define V8_TARGET_OS_STRING "linux"
|
|
|
|
#elif defined(V8_TARGET_OS_MACOSX)
|
|
|
|
# define V8_TARGET_OS_STRING "macos"
|
|
|
|
#elif defined(V8_TARGET_OS_WINDOWS)
|
|
|
|
# define V8_TARGET_OS_STRING "windows"
|
|
|
|
#else
|
|
|
|
# define V8_TARGET_OS_STRING "unknown"
|
|
|
|
#endif
|
|
|
|
|
2013-08-30 12:09:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// C library detection
|
|
|
|
//
|
2014-01-28 19:11:13 +00:00
|
|
|
// V8_LIBC_MSVCRT - MSVC libc
|
2013-08-30 12:09:50 +00:00
|
|
|
// V8_LIBC_BIONIC - Bionic libc
|
|
|
|
// V8_LIBC_BSD - BSD libc derivate
|
|
|
|
// V8_LIBC_GLIBC - GNU C library
|
2015-04-14 07:54:30 +00:00
|
|
|
// V8_LIBC_UCLIBC - uClibc
|
2013-08-30 12:09:50 +00:00
|
|
|
//
|
|
|
|
// Note that testing for libc must be done using #if not #ifdef. For example,
|
|
|
|
// to test for the GNU C library, use:
|
|
|
|
// #if V8_LIBC_GLIBC
|
|
|
|
// ...
|
|
|
|
// #endif
|
|
|
|
|
2014-01-28 19:11:13 +00:00
|
|
|
#if defined (_MSC_VER)
|
|
|
|
# define V8_LIBC_MSVCRT 1
|
|
|
|
#elif defined(__BIONIC__)
|
2013-08-30 12:09:50 +00:00
|
|
|
# define V8_LIBC_BIONIC 1
|
|
|
|
# define V8_LIBC_BSD 1
|
2015-04-14 07:54:30 +00:00
|
|
|
#elif defined(__UCLIBC__)
|
|
|
|
// Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC.
|
|
|
|
# define V8_LIBC_UCLIBC 1
|
2013-08-30 12:09:50 +00:00
|
|
|
#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
|
|
|
|
# define V8_LIBC_GLIBC 1
|
|
|
|
#else
|
|
|
|
# define V8_LIBC_BSD V8_OS_BSD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Compiler detection
|
|
|
|
//
|
2014-12-02 05:23:09 +00:00
|
|
|
// V8_CC_GNU - GCC, or clang in gcc mode
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_CC_INTEL - Intel C++
|
2013-08-23 07:32:25 +00:00
|
|
|
// V8_CC_MINGW - Minimalist GNU for Windows
|
2013-08-27 14:16:34 +00:00
|
|
|
// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
|
|
|
|
// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
|
2014-12-02 05:23:09 +00:00
|
|
|
// V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode
|
2013-08-23 07:32:25 +00:00
|
|
|
//
|
|
|
|
// C++11 feature detection
|
|
|
|
//
|
|
|
|
// Compiler-specific feature detection
|
|
|
|
//
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline))
|
|
|
|
// supported
|
2019-09-17 11:59:59 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_NONNULL - __attribute__((nonnull)) supported
|
2013-08-27 09:21:16 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported
|
2013-11-12 12:09:38 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported
|
|
|
|
// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
|
|
|
|
// supported
|
2020-11-25 10:50:49 +00:00
|
|
|
// V8_HAS_CPP_ATTRIBUTE_NODISCARD - [[nodiscard]] supported
|
2021-11-04 13:01:05 +00:00
|
|
|
// V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS
|
|
|
|
// - [[no_unique_address]] supported
|
2018-04-25 06:28:35 +00:00
|
|
|
// V8_HAS_BUILTIN_BSWAP16 - __builtin_bswap16() supported
|
|
|
|
// V8_HAS_BUILTIN_BSWAP32 - __builtin_bswap32() supported
|
|
|
|
// V8_HAS_BUILTIN_BSWAP64 - __builtin_bswap64() supported
|
2014-08-20 12:10:41 +00:00
|
|
|
// V8_HAS_BUILTIN_CLZ - __builtin_clz() supported
|
|
|
|
// V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported
|
2014-10-20 12:04:22 +00:00
|
|
|
// V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported
|
2014-08-20 12:10:41 +00:00
|
|
|
// V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported
|
2014-09-09 14:18:17 +00:00
|
|
|
// V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported
|
|
|
|
// V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported
|
2015-06-12 12:03:03 +00:00
|
|
|
// V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported
|
2019-08-06 12:53:11 +00:00
|
|
|
// V8_HAS_COMPUTED_GOTO - computed goto/labels as values
|
|
|
|
// supported
|
2013-08-27 09:21:16 +00:00
|
|
|
// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
|
2015-01-30 09:29:25 +00:00
|
|
|
// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported
|
2013-08-27 08:27:42 +00:00
|
|
|
// V8_HAS___FORCEINLINE - __forceinline supported
|
|
|
|
//
|
|
|
|
// Note that testing for compilers and/or features must be done using #if
|
|
|
|
// not #ifdef. For example, to test for Intel C++ Compiler, use:
|
|
|
|
// #if V8_CC_INTEL
|
|
|
|
// ...
|
|
|
|
// #endif
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2020-11-25 10:50:49 +00:00
|
|
|
#if defined(__has_cpp_attribute)
|
|
|
|
#define V8_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
|
|
|
|
#else
|
|
|
|
#define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0
|
|
|
|
#endif
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
|
2014-12-02 05:23:09 +00:00
|
|
|
#if defined(__GNUC__) // Clang in gcc mode.
|
|
|
|
# define V8_CC_GNU 1
|
|
|
|
#endif
|
2013-08-26 08:06:15 +00:00
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
|
2019-09-17 11:59:59 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull))
|
2013-08-27 09:21:16 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
|
2013-11-12 12:09:38 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
|
2013-08-27 08:27:42 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
|
|
|
|
(__has_attribute(warn_unused_result))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2020-11-25 10:50:49 +00:00
|
|
|
# define V8_HAS_CPP_ATTRIBUTE_NODISCARD (V8_HAS_CPP_ATTRIBUTE(nodiscard))
|
2021-11-04 13:01:05 +00:00
|
|
|
# define V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS \
|
|
|
|
(V8_HAS_CPP_ATTRIBUTE(no_unique_address))
|
2020-11-25 10:50:49 +00:00
|
|
|
|
2019-08-29 11:14:02 +00:00
|
|
|
# define V8_HAS_BUILTIN_ASSUME_ALIGNED (__has_builtin(__builtin_assume_aligned))
|
2018-04-25 06:28:35 +00:00
|
|
|
# define V8_HAS_BUILTIN_BSWAP16 (__has_builtin(__builtin_bswap16))
|
|
|
|
# define V8_HAS_BUILTIN_BSWAP32 (__has_builtin(__builtin_bswap32))
|
|
|
|
# define V8_HAS_BUILTIN_BSWAP64 (__has_builtin(__builtin_bswap64))
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz))
|
|
|
|
# define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz))
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
|
2014-10-20 12:04:22 +00:00
|
|
|
# define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address))
|
2014-08-20 12:10:41 +00:00
|
|
|
# define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount))
|
2014-09-09 14:18:17 +00:00
|
|
|
# define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow))
|
|
|
|
# define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow))
|
2015-06-12 12:03:03 +00:00
|
|
|
# define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow))
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2019-08-06 12:53:11 +00:00
|
|
|
// Clang has no __has_feature for computed gotos.
|
|
|
|
// GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
|
|
|
|
# define V8_HAS_COMPUTED_GOTO 1
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif defined(__GNUC__)
|
|
|
|
|
|
|
|
# define V8_CC_GNU 1
|
2015-06-29 11:47:50 +00:00
|
|
|
# if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0
|
|
|
|
# define V8_CC_INTEL 1
|
|
|
|
# endif
|
|
|
|
# if defined(__MINGW32__)
|
|
|
|
# define V8_CC_MINGW32 1
|
|
|
|
# endif
|
|
|
|
# if defined(__MINGW64__)
|
|
|
|
# define V8_CC_MINGW64 1
|
|
|
|
# endif
|
2013-08-27 14:16:34 +00:00
|
|
|
# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2013-08-24 16:58:32 +00:00
|
|
|
// always_inline is available in gcc 4.0 but not very reliable until 4.4.
|
|
|
|
// Works around "sorry, unimplemented: inlining failed" build errors with
|
|
|
|
// older compilers.
|
2019-10-15 13:45:06 +00:00
|
|
|
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE 1
|
|
|
|
# define V8_HAS_ATTRIBUTE_NOINLINE 1
|
|
|
|
# define V8_HAS_ATTRIBUTE_UNUSED 1
|
|
|
|
# define V8_HAS_ATTRIBUTE_VISIBILITY 1
|
|
|
|
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT (!V8_CC_INTEL)
|
2021-04-27 18:18:23 +00:00
|
|
|
|
|
|
|
// [[nodiscard]] does not work together with with
|
|
|
|
// __attribute__((visibility(""))) on GCC 7.4 which is why there is no define
|
|
|
|
// for V8_HAS_CPP_ATTRIBUTE_NODISCARD. See https://crbug.com/v8/11707.
|
2019-10-15 13:45:06 +00:00
|
|
|
|
|
|
|
# define V8_HAS_BUILTIN_ASSUME_ALIGNED 1
|
|
|
|
# define V8_HAS_BUILTIN_CLZ 1
|
|
|
|
# define V8_HAS_BUILTIN_CTZ 1
|
|
|
|
# define V8_HAS_BUILTIN_EXPECT 1
|
|
|
|
# define V8_HAS_BUILTIN_FRAME_ADDRESS 1
|
|
|
|
# define V8_HAS_BUILTIN_POPCOUNT 1
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2019-08-06 12:53:11 +00:00
|
|
|
// GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
|
2019-10-15 13:45:06 +00:00
|
|
|
#define V8_HAS_COMPUTED_GOTO 1
|
2019-08-06 12:53:11 +00:00
|
|
|
|
2015-05-21 16:21:24 +00:00
|
|
|
#endif
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2015-05-21 16:21:24 +00:00
|
|
|
#if defined(_MSC_VER)
|
2013-08-23 07:32:25 +00:00
|
|
|
# define V8_CC_MSVC 1
|
2013-08-26 11:18:28 +00:00
|
|
|
|
2013-08-27 09:21:16 +00:00
|
|
|
# define V8_HAS_DECLSPEC_NOINLINE 1
|
2015-01-30 09:29:25 +00:00
|
|
|
# define V8_HAS_DECLSPEC_SELECTANY 1
|
2013-08-23 07:32:25 +00:00
|
|
|
|
|
|
|
# define V8_HAS___FORCEINLINE 1
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Helper macros
|
|
|
|
|
|
|
|
// A macro used to make better inlining. Don't bother for debug builds.
|
2013-09-12 08:57:10 +00:00
|
|
|
// Use like:
|
|
|
|
// V8_INLINE int GetZero() { return 0; }
|
2013-08-23 07:32:25 +00:00
|
|
|
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE inline __attribute__((always_inline))
|
2013-08-23 07:32:25 +00:00
|
|
|
#elif !defined(DEBUG) && V8_HAS___FORCEINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE __forceinline
|
2013-08-23 07:32:25 +00:00
|
|
|
#else
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_INLINE inline
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-29 11:14:02 +00:00
|
|
|
#if V8_HAS_BUILTIN_ASSUME_ALIGNED
|
|
|
|
# define V8_ASSUME_ALIGNED(ptr, alignment) \
|
|
|
|
__builtin_assume_aligned((ptr), (alignment))
|
|
|
|
#else
|
2019-10-09 11:51:33 +00:00
|
|
|
# define V8_ASSUME_ALIGNED(ptr, alignment) (ptr)
|
2019-08-29 11:14:02 +00:00
|
|
|
#endif
|
2013-08-23 07:32:25 +00:00
|
|
|
|
2019-09-17 11:59:59 +00:00
|
|
|
|
|
|
|
// A macro to mark specific arguments as non-null.
|
|
|
|
// Use like:
|
|
|
|
// int add(int* x, int y, int* z) V8_NONNULL(1, 3) { return *x + y + *z; }
|
|
|
|
#if V8_HAS_ATTRIBUTE_NONNULL
|
|
|
|
# define V8_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
|
|
|
|
#else
|
|
|
|
# define V8_NONNULL(...) /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-27 09:21:16 +00:00
|
|
|
// A macro used to tell the compiler to never inline a particular function.
|
2013-09-12 08:57:10 +00:00
|
|
|
// Use like:
|
|
|
|
// V8_NOINLINE int GetMinusOne() { return -1; }
|
2020-01-14 11:26:48 +00:00
|
|
|
#if V8_HAS_ATTRIBUTE_NOINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE __attribute__((noinline))
|
2020-01-14 11:26:48 +00:00
|
|
|
#elif V8_HAS_DECLSPEC_NOINLINE
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE __declspec(noinline)
|
2013-08-27 09:21:16 +00:00
|
|
|
#else
|
2013-09-12 08:57:10 +00:00
|
|
|
# define V8_NOINLINE /* NOT SUPPORTED */
|
2013-08-27 09:21:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-05-21 10:34:42 +00:00
|
|
|
// A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
|
2019-10-08 16:30:08 +00:00
|
|
|
#if defined(V8_DEPRECATION_WARNINGS)
|
|
|
|
# define V8_DEPRECATED(message) [[deprecated(message)]]
|
2013-08-23 07:32:25 +00:00
|
|
|
#else
|
2019-10-08 16:30:08 +00:00
|
|
|
# define V8_DEPRECATED(message)
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-05-21 10:34:42 +00:00
|
|
|
// A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated.
|
2019-10-08 16:30:08 +00:00
|
|
|
#if defined(V8_IMMINENT_DEPRECATION_WARNINGS)
|
|
|
|
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
|
2015-05-21 10:34:42 +00:00
|
|
|
#else
|
2019-10-08 16:30:08 +00:00
|
|
|
# define V8_DEPRECATE_SOON(message)
|
2015-05-21 10:34:42 +00:00
|
|
|
#endif
|
2015-03-09 09:49:09 +00:00
|
|
|
|
|
|
|
|
2020-05-12 11:09:49 +00:00
|
|
|
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 6)
|
|
|
|
# define V8_ENUM_DEPRECATED(message)
|
|
|
|
# define V8_ENUM_DEPRECATE_SOON(message)
|
|
|
|
#else
|
|
|
|
# define V8_ENUM_DEPRECATED(message) V8_DEPRECATED(message)
|
|
|
|
# define V8_ENUM_DEPRECATE_SOON(message) V8_DEPRECATE_SOON(message)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
// A macro to provide the compiler with branch prediction information.
|
|
|
|
#if V8_HAS_BUILTIN_EXPECT
|
|
|
|
# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
|
|
|
|
# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1))
|
|
|
|
#else
|
|
|
|
# define V8_UNLIKELY(condition) (condition)
|
|
|
|
# define V8_LIKELY(condition) (condition)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-02-27 10:39:25 +00:00
|
|
|
// Annotate a function indicating the caller must examine the return value.
|
|
|
|
// Use like:
|
2018-04-06 09:37:52 +00:00
|
|
|
// int foo() V8_WARN_UNUSED_RESULT;
|
2015-02-27 10:39:25 +00:00
|
|
|
#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
|
|
|
|
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
|
|
|
#else
|
|
|
|
#define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
2020-11-25 10:50:49 +00:00
|
|
|
|
|
|
|
// Annotate a class or constructor indicating the caller must assign the
|
|
|
|
// constructed instances.
|
|
|
|
// Apply to the whole class like:
|
|
|
|
// class V8_NODISCARD Foo() { ... };
|
|
|
|
// or apply to just one constructor like:
|
|
|
|
// V8_NODISCARD Foo() { ... };
|
|
|
|
// [[nodiscard]] comes in C++17 but supported in clang with -std >= c++11.
|
|
|
|
#if V8_HAS_CPP_ATTRIBUTE_NODISCARD
|
|
|
|
#define V8_NODISCARD [[nodiscard]]
|
|
|
|
#else
|
|
|
|
#define V8_NODISCARD /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
2021-11-04 13:01:05 +00:00
|
|
|
// The no_unique_address attribute allows tail padding in a non-static data
|
|
|
|
// member to overlap other members of the enclosing class (and in the special
|
|
|
|
// case when the type is empty, permits it to fully overlap other members). The
|
|
|
|
// field is laid out as if a base class were encountered at the corresponding
|
|
|
|
// point within the class (except that it does not share a vptr with the
|
|
|
|
// enclosing object).
|
|
|
|
//
|
|
|
|
// Apply to a data member like:
|
|
|
|
//
|
|
|
|
// class Foo {
|
|
|
|
// V8_NO_UNIQUE_ADDRESS Bar bar_;
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// [[no_unique_address]] comes in C++20 but supported in clang with
|
|
|
|
// -std >= c++11.
|
|
|
|
#if V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS
|
|
|
|
#define V8_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
|
|
|
#else
|
|
|
|
#define V8_NO_UNIQUE_ADDRESS /* NOT SUPPORTED */
|
|
|
|
#endif
|
|
|
|
|
2020-06-18 07:19:50 +00:00
|
|
|
// Helper macro to define no_sanitize attributes only with clang.
|
|
|
|
#if defined(__clang__) && defined(__has_attribute)
|
|
|
|
#if __has_attribute(no_sanitize)
|
|
|
|
#define V8_CLANG_NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if !defined(V8_CLANG_NO_SANITIZE)
|
|
|
|
#define V8_CLANG_NO_SANITIZE(what)
|
|
|
|
#endif
|
|
|
|
|
2019-05-24 07:36:05 +00:00
|
|
|
#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
|
|
|
|
#error Inconsistent build configuration: To build the V8 shared library \
|
|
|
|
set BUILDING_V8_SHARED, to include its headers for linking against the \
|
|
|
|
V8 shared library set USING_V8_SHARED.
|
|
|
|
#endif
|
|
|
|
|
2018-09-07 09:03:35 +00:00
|
|
|
#ifdef V8_OS_WIN
|
|
|
|
|
|
|
|
// Setup for Windows DLL export/import. When building the V8 DLL the
|
|
|
|
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
|
|
|
|
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
|
|
|
|
// static library or building a program which uses the V8 static library neither
|
|
|
|
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
|
|
|
|
#ifdef BUILDING_V8_SHARED
|
|
|
|
# define V8_EXPORT __declspec(dllexport)
|
|
|
|
#elif USING_V8_SHARED
|
|
|
|
# define V8_EXPORT __declspec(dllimport)
|
|
|
|
#else
|
|
|
|
# define V8_EXPORT
|
|
|
|
#endif // BUILDING_V8_SHARED
|
|
|
|
|
|
|
|
#else // V8_OS_WIN
|
|
|
|
|
|
|
|
// Setup for Linux shared library export.
|
|
|
|
#if V8_HAS_ATTRIBUTE_VISIBILITY
|
|
|
|
# ifdef BUILDING_V8_SHARED
|
|
|
|
# define V8_EXPORT __attribute__ ((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define V8_EXPORT
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define V8_EXPORT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // V8_OS_WIN
|
|
|
|
|
V8 Sandbox rebranding
This CL renames a number of things related to the V8 sandbox.
Mainly, what used to be under V8_HEAP_SANDBOX is now under
V8_SANDBOXED_EXTERNAL_POINTERS, while the previous V8 VirtualMemoryCage
is now simply the V8 Sandbox:
V8_VIRTUAL_MEMORY_CAGE => V8_SANDBOX
V8_HEAP_SANDBOX => V8_SANDBOXED_EXTERNAL_POINTERS
V8_CAGED_POINTERS => V8_SANDBOXED_POINTERS
V8VirtualMemoryCage => Sandbox
CagedPointer => SandboxedPointer
fake cage => partially reserved sandbox
src/security => src/sandbox
This naming scheme should simplify things: the sandbox is now the large
region of virtual address space inside which V8 mainly operates and
which should be considered untrusted. Mechanisms like sandboxed pointers
are then used to attempt to prevent escapes from the sandbox (i.e.
corruption of memory outside of it). Furthermore, the new naming scheme
avoids the confusion with the various other "cages" in V8, in
particular, the VirtualMemoryCage class, by dropping that name entirely.
Future sandbox features are developed under their own V8_SANDBOX_X flag,
and will, once final, be merged into V8_SANDBOX. Current future features
are sandboxed external pointers (using the external pointer table), and
sandboxed pointers (pointers guaranteed to point into the sandbox, e.g.
because they are encoded as offsets). This CL then also introduces a new
build flag, v8_enable_sandbox_future, which enables all future features.
Bug: v8:10391
Change-Id: I5174ea8f5ab40fb96a04af10853da735ad775c96
Cq-Include-Trybots: luci.v8.try:v8_linux64_heap_sandbox_dbg_ng,v8_linux_arm64_sim_heap_sandbox_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3322981
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78384}
2021-12-15 13:39:15 +00:00
|
|
|
// The sandbox is available (i.e. defined) when pointer compression
|
|
|
|
// is enabled, but it is only used when V8_SANDBOX is enabled as
|
|
|
|
// well. This allows better test coverage of the sandbox.
|
2021-10-13 09:35:15 +00:00
|
|
|
#if defined(V8_COMPRESS_POINTERS)
|
V8 Sandbox rebranding
This CL renames a number of things related to the V8 sandbox.
Mainly, what used to be under V8_HEAP_SANDBOX is now under
V8_SANDBOXED_EXTERNAL_POINTERS, while the previous V8 VirtualMemoryCage
is now simply the V8 Sandbox:
V8_VIRTUAL_MEMORY_CAGE => V8_SANDBOX
V8_HEAP_SANDBOX => V8_SANDBOXED_EXTERNAL_POINTERS
V8_CAGED_POINTERS => V8_SANDBOXED_POINTERS
V8VirtualMemoryCage => Sandbox
CagedPointer => SandboxedPointer
fake cage => partially reserved sandbox
src/security => src/sandbox
This naming scheme should simplify things: the sandbox is now the large
region of virtual address space inside which V8 mainly operates and
which should be considered untrusted. Mechanisms like sandboxed pointers
are then used to attempt to prevent escapes from the sandbox (i.e.
corruption of memory outside of it). Furthermore, the new naming scheme
avoids the confusion with the various other "cages" in V8, in
particular, the VirtualMemoryCage class, by dropping that name entirely.
Future sandbox features are developed under their own V8_SANDBOX_X flag,
and will, once final, be merged into V8_SANDBOX. Current future features
are sandboxed external pointers (using the external pointer table), and
sandboxed pointers (pointers guaranteed to point into the sandbox, e.g.
because they are encoded as offsets). This CL then also introduces a new
build flag, v8_enable_sandbox_future, which enables all future features.
Bug: v8:10391
Change-Id: I5174ea8f5ab40fb96a04af10853da735ad775c96
Cq-Include-Trybots: luci.v8.try:v8_linux64_heap_sandbox_dbg_ng,v8_linux_arm64_sim_heap_sandbox_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3322981
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78384}
2021-12-15 13:39:15 +00:00
|
|
|
#define V8_SANDBOX_IS_AVAILABLE
|
2021-10-29 12:51:58 +00:00
|
|
|
#endif
|
|
|
|
|
2021-11-30 12:09:00 +00:00
|
|
|
// From C++17 onwards, static constexpr member variables are defined to be
|
|
|
|
// "inline", and adding a separate definition for them can trigger deprecation
|
|
|
|
// warnings. For C++14 and below, however, these definitions are required.
|
2021-11-30 22:19:53 +00:00
|
|
|
#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
|
2021-11-30 12:09:00 +00:00
|
|
|
#define V8_STATIC_CONSTEXPR_VARIABLES_NEED_DEFINITIONS
|
|
|
|
#endif
|
|
|
|
|
2015-06-29 11:47:50 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2020-11-25 10:50:49 +00:00
|
|
|
#undef V8_HAS_CPP_ATTRIBUTE
|
|
|
|
|
2013-08-23 07:32:25 +00:00
|
|
|
#endif // V8CONFIG_H_
|