Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-06 08:45:11

0001 // Copyright 2013 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef V8CONFIG_H_
0006 #define V8CONFIG_H_
0007 
0008 // gcc 10 defines __cplusplus to "an unspecified value strictly larger than
0009 // 201703L" for its experimental -std=gnu++2a config.
0010 // TODO(leszeks): Change to `__cplusplus <= 202002L` once we only support
0011 // compilers with full C++20 support.
0012 #if __cplusplus <= 201703L
0013 #error "C++20 or later required."
0014 #endif
0015 
0016 #ifdef V8_GN_HEADER
0017 #if !__has_include("v8-gn.h")
0018 #error Missing v8-gn.h. The configuration for v8 is missing from the include \
0019 path. Add it with -I<path> to the command line
0020 #endif
0021 #include "v8-gn.h"  // NOLINT(build/include_directory)
0022 #endif
0023 
0024 #include <memory>
0025 // clang-format off
0026 
0027 // Platform headers for feature detection below.
0028 #if defined(__ANDROID__)
0029 # include <sys/cdefs.h>
0030 #elif defined(__APPLE__)
0031 # include <TargetConditionals.h>
0032 #elif defined(__linux__)
0033 # include <features.h>
0034 #elif defined(__MVS__)
0035 # include "zos-base.h"
0036 #endif
0037 
0038 
0039 // This macro allows to test for the version of the GNU C library (or
0040 // a compatible C library that masquerades as glibc). It evaluates to
0041 // 0 if libc is not GNU libc or compatible.
0042 // Use like:
0043 //  #if V8_GLIBC_PREREQ(2, 3)
0044 //   ...
0045 //  #endif
0046 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
0047 # define V8_GLIBC_PREREQ(major, minor)                                    \
0048     ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor)))
0049 #else
0050 # define V8_GLIBC_PREREQ(major, minor) 0
0051 #endif
0052 
0053 
0054 // This macro allows to test for the version of the GNU C++ compiler.
0055 // Note that this also applies to compilers that masquerade as GCC,
0056 // for example clang and the Intel C++ compiler for Linux.
0057 // Use like:
0058 //  #if V8_GNUC_PREREQ(4, 3, 1)
0059 //   ...
0060 //  #endif
0061 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
0062 # define V8_GNUC_PREREQ(major, minor, patchlevel)                         \
0063     ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >=   \
0064      ((major) * 10000 + (minor) * 100 + (patchlevel)))
0065 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
0066 # define V8_GNUC_PREREQ(major, minor, patchlevel)      \
0067     ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >=      \
0068      ((major) * 10000 + (minor) * 100 + (patchlevel)))
0069 #else
0070 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
0071 #endif
0072 
0073 
0074 
0075 // -----------------------------------------------------------------------------
0076 // Operating system detection (host)
0077 //
0078 //  V8_OS_ANDROID       - Android
0079 //  V8_OS_BSD           - BSDish (macOS, Net/Free/Open/DragonFlyBSD)
0080 //  V8_OS_CYGWIN        - Cygwin
0081 //  V8_OS_DRAGONFLYBSD  - DragonFlyBSD
0082 //  V8_OS_FREEBSD       - FreeBSD
0083 //  V8_OS_FUCHSIA       - Fuchsia
0084 //  V8_OS_LINUX         - Linux (Android, ChromeOS, Linux, ...)
0085 //  V8_OS_DARWIN        - Darwin (macOS, iOS)
0086 //  V8_OS_MACOS         - macOS
0087 //  V8_OS_IOS           - iOS
0088 //  V8_OS_NETBSD        - NetBSD
0089 //  V8_OS_OPENBSD       - OpenBSD
0090 //  V8_OS_POSIX         - POSIX compatible (mostly everything except Windows)
0091 //  V8_OS_QNX           - QNX Neutrino
0092 //  V8_OS_SOLARIS       - Sun Solaris and OpenSolaris
0093 //  V8_OS_STARBOARD     - Starboard (platform abstraction for Cobalt)
0094 //  V8_OS_AIX           - AIX
0095 //  V8_OS_WIN           - Microsoft Windows
0096 //  V8_OS_ZOS           - z/OS
0097 
0098 #if defined(__ANDROID__)
0099 # define V8_OS_ANDROID 1
0100 # define V8_OS_LINUX 1
0101 # define V8_OS_POSIX 1
0102 # define V8_OS_STRING "android"
0103 
0104 #elif defined(__APPLE__)
0105 # define V8_OS_POSIX 1
0106 # define V8_OS_BSD 1
0107 # define V8_OS_DARWIN 1
0108 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0109 #  define V8_OS_IOS 1
0110 #  define V8_OS_STRING "ios"
0111 # else
0112 #  define V8_OS_MACOS 1
0113 #  define V8_OS_STRING "macos"
0114 # endif  // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0115 
0116 #elif defined(__CYGWIN__)
0117 # define V8_OS_CYGWIN 1
0118 # define V8_OS_POSIX 1
0119 # define V8_OS_STRING "cygwin"
0120 
0121 #elif defined(__linux__)
0122 # define V8_OS_LINUX 1
0123 # define V8_OS_POSIX 1
0124 # define V8_OS_STRING "linux"
0125 
0126 #elif defined(__sun)
0127 # define V8_OS_POSIX 1
0128 # define V8_OS_SOLARIS 1
0129 # define V8_OS_STRING "sun"
0130 
0131 #elif defined(STARBOARD)
0132 # define V8_OS_STARBOARD 1
0133 # define V8_OS_STRING "starboard"
0134 
0135 #elif defined(_AIX)
0136 # define V8_OS_POSIX 1
0137 # define V8_OS_AIX 1
0138 # define V8_OS_STRING "aix"
0139 
0140 #elif defined(__FreeBSD__)
0141 # define V8_OS_BSD 1
0142 # define V8_OS_FREEBSD 1
0143 # define V8_OS_POSIX 1
0144 # define V8_OS_STRING "freebsd"
0145 
0146 #elif defined(__Fuchsia__)
0147 # define V8_OS_FUCHSIA 1
0148 # define V8_OS_POSIX 1
0149 # define V8_OS_STRING "fuchsia"
0150 
0151 #elif defined(__DragonFly__)
0152 # define V8_OS_BSD 1
0153 # define V8_OS_DRAGONFLYBSD 1
0154 # define V8_OS_POSIX 1
0155 # define V8_OS_STRING "dragonflybsd"
0156 
0157 #elif defined(__NetBSD__)
0158 # define V8_OS_BSD 1
0159 # define V8_OS_NETBSD 1
0160 # define V8_OS_POSIX 1
0161 # define V8_OS_STRING "netbsd"
0162 
0163 #elif defined(__OpenBSD__)
0164 # define V8_OS_BSD 1
0165 # define V8_OS_OPENBSD 1
0166 # define V8_OS_POSIX 1
0167 # define V8_OS_STRING "openbsd"
0168 
0169 #elif defined(__QNXNTO__)
0170 # define V8_OS_POSIX 1
0171 # define V8_OS_QNX 1
0172 # define V8_OS_STRING "qnx"
0173 
0174 #elif defined(_WIN32)
0175 # define V8_OS_WIN 1
0176 # define V8_OS_STRING "windows"
0177 
0178 #elif defined(__MVS__)
0179 # define V8_OS_POSIX 1
0180 # define V8_OS_ZOS 1
0181 # define V8_OS_STRING "zos"
0182 #endif
0183 
0184 // -----------------------------------------------------------------------------
0185 // Operating system detection (target)
0186 //
0187 //  V8_TARGET_OS_ANDROID
0188 //  V8_TARGET_OS_FUCHSIA
0189 //  V8_TARGET_OS_IOS
0190 //  V8_TARGET_OS_LINUX
0191 //  V8_TARGET_OS_MACOS
0192 //  V8_TARGET_OS_WIN
0193 //  V8_TARGET_OS_CHROMEOS
0194 //
0195 // If not set explicitly, these fall back to corresponding V8_OS_ values.
0196 
0197 #ifdef V8_HAVE_TARGET_OS
0198 
0199 // The target OS is provided, just check that at least one known value is set.
0200 # if !defined(V8_TARGET_OS_ANDROID) \
0201   && !defined(V8_TARGET_OS_FUCHSIA) \
0202   && !defined(V8_TARGET_OS_IOS) \
0203   && !defined(V8_TARGET_OS_LINUX) \
0204   && !defined(V8_TARGET_OS_MACOS) \
0205   && !defined(V8_TARGET_OS_WIN) \
0206   && !defined(V8_TARGET_OS_CHROMEOS)
0207 #  error No known target OS defined.
0208 # endif
0209 
0210 #else  // V8_HAVE_TARGET_OS
0211 
0212 # if defined(V8_TARGET_OS_ANDROID) \
0213   || defined(V8_TARGET_OS_FUCHSIA) \
0214   || defined(V8_TARGET_OS_IOS) \
0215   || defined(V8_TARGET_OS_LINUX) \
0216   || defined(V8_TARGET_OS_MACOS) \
0217   || defined(V8_TARGET_OS_WIN) \
0218   || defined(V8_TARGET_OS_CHROMEOS)
0219 #  error A target OS is defined but V8_HAVE_TARGET_OS is unset.
0220 # endif
0221 
0222 // Fall back to the detected host OS.
0223 #ifdef V8_OS_ANDROID
0224 # define V8_TARGET_OS_ANDROID
0225 #endif
0226 
0227 #ifdef V8_OS_FUCHSIA
0228 # define V8_TARGET_OS_FUCHSIA
0229 #endif
0230 
0231 #ifdef V8_OS_IOS
0232 # define V8_TARGET_OS_IOS
0233 #endif
0234 
0235 #ifdef V8_OS_LINUX
0236 # define V8_TARGET_OS_LINUX
0237 #endif
0238 
0239 #ifdef V8_OS_MACOS
0240 # define V8_TARGET_OS_MACOS
0241 #endif
0242 
0243 #ifdef V8_OS_WIN
0244 # define V8_TARGET_OS_WIN
0245 #endif
0246 
0247 #endif  // V8_HAVE_TARGET_OS
0248 
0249 #if defined(V8_TARGET_OS_ANDROID)
0250 # define V8_TARGET_OS_STRING "android"
0251 #elif defined(V8_TARGET_OS_FUCHSIA)
0252 # define V8_TARGET_OS_STRING "fuchsia"
0253 #elif defined(V8_TARGET_OS_IOS)
0254 # define V8_TARGET_OS_STRING "ios"
0255 #elif defined(V8_TARGET_OS_LINUX)
0256 # define V8_TARGET_OS_STRING "linux"
0257 #elif defined(V8_TARGET_OS_MACOS)
0258 # define V8_TARGET_OS_STRING "macos"
0259 #elif defined(V8_TARGET_OS_WINDOWS)
0260 # define V8_TARGET_OS_STRING "windows"
0261 #else
0262 # define V8_TARGET_OS_STRING "unknown"
0263 #endif
0264 
0265 // -----------------------------------------------------------------------------
0266 // C library detection
0267 //
0268 //  V8_LIBC_MSVCRT  - MSVC libc
0269 //  V8_LIBC_BIONIC  - Bionic libc
0270 //  V8_LIBC_BSD     - BSD libc derivate
0271 //  V8_LIBC_GLIBC   - GNU C library
0272 //  V8_LIBC_UCLIBC  - uClibc
0273 //
0274 // Note that testing for libc must be done using #if not #ifdef. For example,
0275 // to test for the GNU C library, use:
0276 //  #if V8_LIBC_GLIBC
0277 //   ...
0278 //  #endif
0279 
0280 #if defined (_MSC_VER)
0281 # define V8_LIBC_MSVCRT 1
0282 #elif defined(__BIONIC__)
0283 # define V8_LIBC_BIONIC 1
0284 # define V8_LIBC_BSD 1
0285 #elif defined(__UCLIBC__)
0286 // Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC.
0287 # define V8_LIBC_UCLIBC 1
0288 #elif defined(__GLIBC__) || defined(__GNU_LIBRARY__)
0289 # define V8_LIBC_GLIBC 1
0290 #else
0291 # define V8_LIBC_BSD V8_OS_BSD
0292 #endif
0293 
0294 
0295 // -----------------------------------------------------------------------------
0296 // Compiler detection
0297 //
0298 //  V8_CC_GNU     - GCC, or clang in gcc mode
0299 //  V8_CC_INTEL   - Intel C++
0300 //  V8_CC_MINGW   - Minimalist GNU for Windows
0301 //  V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
0302 //  V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
0303 //  V8_CC_MSVC    - Microsoft Visual C/C++, or clang in cl.exe mode
0304 //
0305 // C++11 feature detection
0306 //
0307 // Compiler-specific feature detection
0308 //
0309 //  V8_HAS_ATTRIBUTE_ALWAYS_INLINE      - __attribute__((always_inline))
0310 //                                        supported
0311 //  V8_HAS_ATTRIBUTE_CONSTINIT          - __attribute__((require_constant_
0312 //                                                       initialization))
0313 //                                        supported
0314 //  V8_HAS_ATTRIBUTE_NONNULL            - __attribute__((nonnull)) supported
0315 //  V8_HAS_ATTRIBUTE_NOINLINE           - __attribute__((noinline)) supported
0316 //  V8_HAS_ATTRIBUTE_UNUSED             - __attribute__((unused)) supported
0317 //  V8_HAS_ATTRIBUTE_USED               - __attribute__((used)) supported
0318 //  V8_HAS_ATTRIBUTE_RETAIN             - __attribute__((retain)) supported
0319 //  V8_HAS_ATTRIBUTE_VISIBILITY         - __attribute__((visibility)) supported
0320 //  V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
0321 //                                        supported
0322 //  V8_HAS_CPP_ATTRIBUTE_NODISCARD      - [[nodiscard]] supported
0323 //  V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS
0324 //                                      - [[no_unique_address]] supported
0325 //  V8_HAS_BUILTIN_ADD_OVERFLOW         - __builtin_add_overflow() supported
0326 //  V8_HAS_BUILTIN_BIT_CAST             - __builtin_bit_cast() supported
0327 //  V8_HAS_BUILTIN_BSWAP16              - __builtin_bswap16() supported
0328 //  V8_HAS_BUILTIN_BSWAP32              - __builtin_bswap32() supported
0329 //  V8_HAS_BUILTIN_BSWAP64              - __builtin_bswap64() supported
0330 //  V8_HAS_BUILTIN_CLZ                  - __builtin_clz() supported
0331 //  V8_HAS_BUILTIN_CTZ                  - __builtin_ctz() supported
0332 //  V8_HAS_BUILTIN_EXPECT               - __builtin_expect() supported
0333 //  V8_HAS_BUILTIN_FRAME_ADDRESS        - __builtin_frame_address() supported
0334 //  V8_HAS_BUILTIN_MUL_OVERFLOW         - __builtin_mul_overflow() supported
0335 //  V8_HAS_BUILTIN_POPCOUNT             - __builtin_popcount() supported
0336 //  V8_HAS_BUILTIN_SADD_OVERFLOW        - __builtin_sadd_overflow() supported
0337 //  V8_HAS_BUILTIN_SMUL_OVERFLOW        - __builtin_smul_overflow() supported
0338 //  V8_HAS_BUILTIN_SSUB_OVERFLOW        - __builtin_ssub_overflow() supported
0339 //  V8_HAS_BUILTIN_SUB_OVERFLOW         - __builtin_sub_overflow() supported
0340 //  V8_HAS_BUILTIN_UADD_OVERFLOW        - __builtin_uadd_overflow() supported
0341 //  V8_HAS_COMPUTED_GOTO                - computed goto/labels as values
0342 //                                        supported
0343 //  V8_HAS_DECLSPEC_NOINLINE            - __declspec(noinline) supported
0344 //  V8_HAS_DECLSPEC_SELECTANY           - __declspec(selectany) supported
0345 //  V8_HAS___FORCEINLINE                - __forceinline supported
0346 //
0347 // Note that testing for compilers and/or features must be done using #if
0348 // not #ifdef. For example, to test for Intel C++ Compiler, use:
0349 //  #if V8_CC_INTEL
0350 //   ...
0351 //  #endif
0352 
0353 #if defined(__has_cpp_attribute)
0354 #define V8_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
0355 #else
0356 #define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0
0357 #endif
0358 
0359 #if defined(__clang__)
0360 
0361 #if defined(__GNUC__)  // Clang in gcc mode.
0362 # define V8_CC_GNU 1
0363 #endif
0364 
0365 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
0366 # define V8_HAS_ATTRIBUTE_CONSTINIT \
0367     (__has_attribute(require_constant_initialization))
0368 # define V8_HAS_ATTRIBUTE_CONST (__has_attribute(const))
0369 # define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull))
0370 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
0371 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
0372 # define V8_HAS_ATTRIBUTE_USED (__has_attribute(used))
0373 # define V8_HAS_ATTRIBUTE_RETAIN (__has_attribute(retain))
0374 # define V8_HAS_ATTRIBUTE_OPTNONE (__has_attribute(optnone))
0375 // Support for the "preserve_most" attribute is limited:
0376 // - 32-bit platforms do not implement it,
0377 // - component builds fail because _dl_runtime_resolve clobbers registers,
0378 // - we see crashes on arm64 on Windows (https://crbug.com/1409934), which can
0379 //   hopefully be fixed in the future.
0380 // Additionally, the initial implementation in clang <= 16 overwrote the return
0381 // register(s) in the epilogue of a preserve_most function, so we only use
0382 // preserve_most in clang >= 17 (see https://reviews.llvm.org/D143425).
0383 #if (defined(_M_X64) || defined(__x86_64__)            /* x64 (everywhere) */  \
0384      || ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */    \
0385          && !defined(_WIN32)))                         /* not on windows */    \
0386      && !defined(COMPONENT_BUILD)                      /* no component build */\
0387      && __clang_major__ >= 17                          /* clang >= 17 */
0388 # define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
0389 #endif
0390 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
0391 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
0392     (__has_attribute(warn_unused_result))
0393 # define V8_HAS_ATTRIBUTE_WEAK (__has_attribute(weak))
0394 
0395 # define V8_HAS_CPP_ATTRIBUTE_NODISCARD (V8_HAS_CPP_ATTRIBUTE(nodiscard))
0396 #if defined(V8_CC_MSVC)
0397 # define V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS       \
0398     (V8_HAS_CPP_ATTRIBUTE(msvc::no_unique_address) || \
0399      V8_HAS_CPP_ATTRIBUTE(no_unique_address))
0400 #else
0401 # define V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS \
0402     (V8_HAS_CPP_ATTRIBUTE(no_unique_address))
0403 #endif
0404 
0405 # define V8_HAS_BUILTIN_ADD_OVERFLOW (__has_builtin(__builtin_add_overflow))
0406 # define V8_HAS_BUILTIN_ASSUME (__has_builtin(__builtin_assume))
0407 # define V8_HAS_BUILTIN_ASSUME_ALIGNED (__has_builtin(__builtin_assume_aligned))
0408 # define V8_HAS_BUILTIN_BIT_CAST (__has_builtin(__builtin_bit_cast))
0409 # define V8_HAS_BUILTIN_BSWAP16 (__has_builtin(__builtin_bswap16))
0410 # define V8_HAS_BUILTIN_BSWAP32 (__has_builtin(__builtin_bswap32))
0411 # define V8_HAS_BUILTIN_BSWAP64 (__has_builtin(__builtin_bswap64))
0412 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz))
0413 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz))
0414 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
0415 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address))
0416 # define V8_HAS_BUILTIN_MUL_OVERFLOW (__has_builtin(__builtin_mul_overflow))
0417 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount))
0418 # define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow))
0419 # define V8_HAS_BUILTIN_SMUL_OVERFLOW (__has_builtin(__builtin_smul_overflow))
0420 # define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow))
0421 # define V8_HAS_BUILTIN_SUB_OVERFLOW (__has_builtin(__builtin_sub_overflow))
0422 # define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow))
0423 # define V8_HAS_BUILTIN_UNREACHABLE (__has_builtin(__builtin_unreachable))
0424 
0425 // Clang has no __has_feature for computed gotos.
0426 // GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
0427 # define V8_HAS_COMPUTED_GOTO 1
0428 
0429 #elif defined(__GNUC__)
0430 
0431 # define V8_CC_GNU 1
0432 # if defined(__INTEL_COMPILER)  // Intel C++ also masquerades as GCC 3.2.0
0433 #  define V8_CC_INTEL 1
0434 # endif
0435 # if defined(__MINGW32__)
0436 #  define V8_CC_MINGW32 1
0437 # endif
0438 # if defined(__MINGW64__)
0439 #  define V8_CC_MINGW64 1
0440 # endif
0441 # define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64)
0442 
0443 // FYI: __has_builtin is only available with GCC 10 and later, so explicitly
0444 // check GCC version numbers to enable features. TODO(leszeks): Merge feature
0445 // enabling for GCC 10 and later into the Clang section above, and leave this
0446 // section for GCC 9 and earlier.
0447 
0448 // always_inline is available in gcc 4.0 but not very reliable until 4.4.
0449 // Works around "sorry, unimplemented: inlining failed" build errors with
0450 // older compilers.
0451 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE 1
0452 # define V8_HAS_ATTRIBUTE_NOINLINE 1
0453 # define V8_HAS_ATTRIBUTE_UNUSED 1
0454 # define V8_HAS_ATTRIBUTE_VISIBILITY 1
0455 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT (!V8_CC_INTEL)
0456 # define V8_HAS_ATTRIBUTE_WEAK 1
0457 
0458 // [[nodiscard]] does not work together with with
0459 // __attribute__((visibility(""))) on GCC 7.4 which is why there is no define
0460 // for V8_HAS_CPP_ATTRIBUTE_NODISCARD. See https://crbug.com/v8/11707.
0461 
0462 # define V8_HAS_BUILTIN_ASSUME_ALIGNED 1
0463 # if __GNUC__ >= 11
0464 #  define V8_HAS_BUILTIN_BIT_CAST 1
0465 # endif
0466 # define V8_HAS_BUILTIN_CLZ 1
0467 # define V8_HAS_BUILTIN_CTZ 1
0468 # define V8_HAS_BUILTIN_EXPECT 1
0469 # define V8_HAS_BUILTIN_FRAME_ADDRESS 1
0470 # define V8_HAS_BUILTIN_POPCOUNT 1
0471 # define V8_HAS_BUILTIN_UNREACHABLE 1
0472 
0473 // GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
0474 #define V8_HAS_COMPUTED_GOTO 1
0475 
0476 #endif
0477 
0478 #if defined(_MSC_VER)
0479 # define V8_CC_MSVC 1
0480 
0481 # define V8_HAS_DECLSPEC_NOINLINE 1
0482 # define V8_HAS_DECLSPEC_SELECTANY 1
0483 
0484 # define V8_HAS___FORCEINLINE 1
0485 
0486 #endif
0487 
0488 
0489 // -----------------------------------------------------------------------------
0490 // Helper macros
0491 
0492 // A macro used to make better inlining. Don't bother for debug builds.
0493 // Use like:
0494 //   V8_INLINE int GetZero() { return 0; }
0495 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
0496 # define V8_INLINE inline __attribute__((always_inline))
0497 #elif !defined(DEBUG) && V8_HAS___FORCEINLINE
0498 # define V8_INLINE __forceinline
0499 #else
0500 # define V8_INLINE inline
0501 #endif
0502 
0503 // A macro to force better inlining of calls in a statement. Don't bother for
0504 // debug builds.
0505 // Use like:
0506 //   V8_INLINE_STATEMENT foo = bar(); // Will force inlining the bar() call.
0507 #if !defined(DEBUG) && defined(__clang__) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
0508 # define V8_INLINE_STATEMENT [[clang::always_inline]]
0509 #else
0510 # define V8_INLINE_STATEMENT
0511 #endif
0512 
0513 #if V8_HAS_BUILTIN_ASSUME
0514 #ifdef DEBUG
0515 // In debug mode, check assumptions in addition to adding annotations.
0516 // This helps GCC (and maybe other compilers) figure out that certain
0517 // situations are unreachable.
0518 # define V8_ASSUME(condition)    \
0519   do {                           \
0520     DCHECK(condition);           \
0521     __builtin_assume(condition); \
0522   } while (false)
0523 #else  // DEBUG
0524 # define V8_ASSUME __builtin_assume
0525 #endif  // DEBUG
0526 #elif V8_HAS_BUILTIN_UNREACHABLE
0527 # define V8_ASSUME(condition)                  \
0528   do {                                         \
0529     DCHECK(condition);                         \
0530     if (!(condition)) __builtin_unreachable(); \
0531   } while (false)
0532 #else
0533 # define V8_ASSUME USE
0534 #endif
0535 
0536 // Prefer c++20 std::assume_aligned. Don't use it on MSVC though, because it's
0537 // not happy with our large 4GB alignment values.
0538 #if __cplusplus >= 202002L && defined(__cpp_lib_assume_aligned) && !V8_CC_MSVC
0539 # define V8_ASSUME_ALIGNED(ptr, alignment) \
0540   std::assume_aligned<(alignment)>(ptr)
0541 #elif V8_HAS_BUILTIN_ASSUME_ALIGNED
0542 # define V8_ASSUME_ALIGNED(ptr, alignment) \
0543   __builtin_assume_aligned((ptr), (alignment))
0544 #else
0545 # define V8_ASSUME_ALIGNED(ptr, alignment) (ptr)
0546 #endif
0547 
0548 // A macro to mark functions whose values don't change (e.g. across calls)
0549 // and thereby compiler is free to hoist and fold multiple calls together.
0550 // Use like:
0551 //   V8_CONST int foo() { ... }
0552 #if V8_HAS_ATTRIBUTE_CONST
0553 # define V8_CONST __attribute__((const))
0554 #else
0555 # define V8_CONST
0556 #endif
0557 
0558 // A macro to mark a declaration as requiring constant initialization.
0559 // Use like:
0560 //   int* foo V8_CONSTINIT;
0561 #if V8_HAS_ATTRIBUTE_CONSTINIT
0562 # define V8_CONSTINIT __attribute__((require_constant_initialization))
0563 #else
0564 # define V8_CONSTINIT
0565 #endif
0566 
0567 
0568 // A macro to mark specific arguments as non-null.
0569 // Use like:
0570 //   int add(int* x, int y, int* z) V8_NONNULL(1, 3) { return *x + y + *z; }
0571 #if V8_HAS_ATTRIBUTE_NONNULL
0572 # define V8_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
0573 #else
0574 # define V8_NONNULL(...) /* NOT SUPPORTED */
0575 #endif
0576 
0577 
0578 // A macro used to tell the compiler to never inline a particular function.
0579 // Use like:
0580 //   V8_NOINLINE int GetMinusOne() { return -1; }
0581 #if V8_HAS_ATTRIBUTE_NOINLINE
0582 # define V8_NOINLINE __attribute__((noinline))
0583 #elif V8_HAS_DECLSPEC_NOINLINE
0584 # define V8_NOINLINE __declspec(noinline)
0585 #else
0586 # define V8_NOINLINE /* NOT SUPPORTED */
0587 #endif
0588 
0589 
0590 // A macro used to change the calling conventions to preserve all registers (no
0591 // caller-saved registers). Use this for cold functions called from hot
0592 // functions.
0593 // Use like:
0594 //   V8_NOINLINE V8_PRESERVE_MOST void UnlikelyMethod();
0595 #if V8_OS_WIN
0596 # define V8_PRESERVE_MOST
0597 #else
0598 #if V8_HAS_ATTRIBUTE_PRESERVE_MOST
0599 # define V8_PRESERVE_MOST __attribute__((preserve_most))
0600 #else
0601 # define V8_PRESERVE_MOST /* NOT SUPPORTED */
0602 #endif
0603 #endif
0604 
0605 
0606 // A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
0607 #if defined(V8_DEPRECATION_WARNINGS)
0608 # define V8_DEPRECATED(message) [[deprecated(message)]]
0609 #else
0610 # define V8_DEPRECATED(message)
0611 #endif
0612 
0613 
0614 // A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated.
0615 #if defined(V8_IMMINENT_DEPRECATION_WARNINGS)
0616 # define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
0617 #else
0618 # define V8_DEPRECATE_SOON(message)
0619 #endif
0620 
0621 
0622 #if defined(V8_IMMINENT_DEPRECATION_WARNINGS) || \
0623     defined(V8_DEPRECATION_WARNINGS)
0624 #if defined(V8_CC_MSVC)
0625 # define START_ALLOW_USE_DEPRECATED() \
0626     __pragma(warning(push))           \
0627     __pragma(warning(disable : 4996))
0628 # define END_ALLOW_USE_DEPRECATED() __pragma(warning(pop))
0629 #else  // !defined(V8_CC_MSVC)
0630 # define START_ALLOW_USE_DEPRECATED()                               \
0631     _Pragma("GCC diagnostic push")                                  \
0632     _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
0633 #define END_ALLOW_USE_DEPRECATED() _Pragma("GCC diagnostic pop")
0634 #endif  // !defined(V8_CC_MSVC)
0635 #else  // !(defined(V8_IMMINENT_DEPRECATION_WARNINGS) ||
0636        // defined(V8_DEPRECATION_WARNINGS))
0637 #define START_ALLOW_USE_DEPRECATED()
0638 #define END_ALLOW_USE_DEPRECATED()
0639 #endif  // !(defined(V8_IMMINENT_DEPRECATION_WARNINGS) ||
0640         // defined(V8_DEPRECATION_WARNINGS))
0641 #define ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(ClassName) \
0642   START_ALLOW_USE_DEPRECATED()                                \
0643   ClassName(const ClassName&) = default;                      \
0644   ClassName(ClassName&&) = default;                           \
0645   ClassName& operator=(const ClassName&) = default;           \
0646   ClassName& operator=(ClassName&&) = default;                \
0647   END_ALLOW_USE_DEPRECATED()
0648 
0649 
0650 #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 6)
0651 # define V8_ENUM_DEPRECATED(message)
0652 # define V8_ENUM_DEPRECATE_SOON(message)
0653 #else
0654 # define V8_ENUM_DEPRECATED(message) V8_DEPRECATED(message)
0655 # define V8_ENUM_DEPRECATE_SOON(message) V8_DEPRECATE_SOON(message)
0656 #endif
0657 
0658 
0659 // A macro to provide the compiler with branch prediction information.
0660 #if V8_HAS_BUILTIN_EXPECT
0661 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0))
0662 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1))
0663 #else
0664 # define V8_UNLIKELY(condition) (condition)
0665 # define V8_LIKELY(condition) (condition)
0666 #endif
0667 
0668 
0669 // Annotate a function indicating the caller must examine the return value.
0670 // Use like:
0671 //   int foo() V8_WARN_UNUSED_RESULT;
0672 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
0673 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
0674 #else
0675 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */
0676 #endif
0677 
0678 
0679 // Annotate functions/variables as weak to allow overriding the symbol.
0680 #if V8_HAS_ATTRIBUTE_WEAK
0681 #define V8_WEAK __attribute__((weak))
0682 #else
0683 #define V8_WEAK /* NOT SUPPORTED */
0684 #endif
0685 
0686 
0687 // Annotate a class or constructor indicating the caller must assign the
0688 // constructed instances.
0689 // Apply to the whole class like:
0690 //   class V8_NODISCARD Foo() { ... };
0691 // or apply to just one constructor like:
0692 //   V8_NODISCARD Foo() { ... };
0693 // [[nodiscard]] comes in C++17 but supported in clang with -std >= c++11.
0694 #if V8_HAS_CPP_ATTRIBUTE_NODISCARD
0695 #define V8_NODISCARD [[nodiscard]]
0696 #else
0697 #define V8_NODISCARD /* NOT SUPPORTED */
0698 #endif
0699 
0700 // The no_unique_address attribute allows tail padding in a non-static data
0701 // member to overlap other members of the enclosing class (and in the special
0702 // case when the type is empty, permits it to fully overlap other members). The
0703 // field is laid out as if a base class were encountered at the corresponding
0704 // point within the class (except that it does not share a vptr with the
0705 // enclosing object).
0706 //
0707 // Apply to a data member like:
0708 //
0709 //   class Foo {
0710 //    V8_NO_UNIQUE_ADDRESS Bar bar_;
0711 //   };
0712 //
0713 // [[no_unique_address]] comes in C++20 but supported in clang with
0714 // -std >= c++11.
0715 #if V8_HAS_CPP_ATTRIBUTE_NO_UNIQUE_ADDRESS
0716 #if defined(V8_CC_MSVC) && V8_HAS_CPP_ATTRIBUTE(msvc::no_unique_address)
0717 // Unfortunately MSVC ignores [[no_unique_address]] (see
0718 // https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/#msvc-extensions-and-abi),
0719 // and clang-cl matches it for ABI compatibility reasons. We need to prefer
0720 // [[msvc::no_unique_address]] when available if we actually want any effect.
0721 #define V8_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
0722 #else
0723 #define V8_NO_UNIQUE_ADDRESS [[no_unique_address]]
0724 #endif
0725 #else
0726 #define V8_NO_UNIQUE_ADDRESS /* NOT SUPPORTED */
0727 #endif
0728 
0729 // Marks a type as being eligible for the "trivial" ABI despite having a
0730 // non-trivial destructor or copy/move constructor. Such types can be relocated
0731 // after construction by simply copying their memory, which makes them eligible
0732 // to be passed in registers. The canonical example is std::unique_ptr.
0733 //
0734 // Use with caution; this has some subtle effects on constructor/destructor
0735 // ordering and will be very incorrect if the type relies on its address
0736 // remaining constant. When used as a function argument (by value), the value
0737 // may be constructed in the caller's stack frame, passed in a register, and
0738 // then used and destructed in the callee's stack frame. A similar thing can
0739 // occur when values are returned.
0740 //
0741 // TRIVIAL_ABI is not needed for types which have a trivial destructor and
0742 // copy/move constructors, since those are automatically trivial by the ABI
0743 // spec.
0744 //
0745 // It is also not likely to be effective on types too large to be passed in one
0746 // or two registers on typical target ABIs.
0747 //
0748 // See also:
0749 //   https://clang.llvm.org/docs/AttributeReference.html#trivial-abi
0750 //   https://libcxx.llvm.org/docs/DesignDocs/UniquePtrTrivialAbi.html
0751 #if defined(__clang__) && defined(__has_attribute)
0752 #if __has_attribute(trivial_abi)
0753 #define V8_TRIVIAL_ABI [[clang::trivial_abi]]
0754 #define V8_HAS_ATTRIBUTE_TRIVIAL_ABI 1
0755 #endif // __has_attribute(trivial_abi)
0756 #endif // defined(__clang__) && defined(__has_attribute)
0757 #if !defined(V8_TRIVIAL_ABI)
0758 #define V8_TRIVIAL_ABI
0759 #define V8_HAS_ATTRIBUTE_TRIVIAL_ABI 0
0760 #endif //!defined(V8_TRIVIAL_ABI)
0761 
0762 // Helper macro to define no_sanitize attributes only with clang.
0763 #if defined(__clang__) && defined(__has_attribute)
0764 #if __has_attribute(no_sanitize)
0765 #define V8_CLANG_NO_SANITIZE(what) __attribute__((no_sanitize(what)))
0766 #endif
0767 #endif
0768 #if !defined(V8_CLANG_NO_SANITIZE)
0769 #define V8_CLANG_NO_SANITIZE(what)
0770 #endif
0771 
0772 // Exposing private symbols requires exposing public symbols too.
0773 #ifdef BUILDING_V8_SHARED_PRIVATE
0774 #define BUILDING_V8_SHARED
0775 #endif
0776 
0777 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
0778 #error Inconsistent build configuration: To build the V8 shared library \
0779 set BUILDING_V8_SHARED, to include its headers for linking against the \
0780 V8 shared library set USING_V8_SHARED.
0781 #endif
0782 
0783 #ifdef V8_OS_WIN
0784 
0785 // Setup for Windows DLL export/import. When building the V8 DLL the
0786 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
0787 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
0788 // static library or building a program which uses the V8 static library neither
0789 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
0790 #ifdef BUILDING_V8_SHARED
0791 # define V8_EXPORT __declspec(dllexport)
0792 #elif USING_V8_SHARED
0793 # define V8_EXPORT __declspec(dllimport)
0794 #else
0795 # define V8_EXPORT
0796 #endif  // BUILDING_V8_SHARED
0797 
0798 #else  // V8_OS_WIN
0799 
0800 // Setup for Linux shared library export.
0801 #if V8_HAS_ATTRIBUTE_VISIBILITY && (defined(BUILDING_V8_SHARED) || USING_V8_SHARED)
0802 # define V8_EXPORT __attribute__((visibility("default")))
0803 #else
0804 # define V8_EXPORT
0805 # endif  // V8_HAS_ATTRIBUTE_VISIBILITY && ...
0806 
0807 #endif  // V8_OS_WIN
0808 
0809 // clang-format on
0810 
0811 // Processor architecture detection.  For more info on what's defined, see:
0812 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
0813 //   http://www.agner.org/optimize/calling_conventions.pdf
0814 //   or with gcc, run: "echo | gcc -E -dM -"
0815 // The V8_HOST_ARCH_* macros correspond to the architecture on which V8, as a
0816 // virtual machine and compiler, runs. Don't confuse this with the architecture
0817 // on which V8 is built.
0818 #if defined(_M_X64) || defined(__x86_64__)
0819 #define V8_HOST_ARCH_X64 1
0820 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4  // Check for x32.
0821 #define V8_HOST_ARCH_32_BIT 1
0822 #else
0823 #define V8_HOST_ARCH_64_BIT 1
0824 #endif
0825 #elif defined(_M_IX86) || defined(__i386__)
0826 #define V8_HOST_ARCH_IA32 1
0827 #define V8_HOST_ARCH_32_BIT 1
0828 #elif defined(__AARCH64EL__) || defined(_M_ARM64)
0829 #define V8_HOST_ARCH_ARM64 1
0830 #define V8_HOST_ARCH_64_BIT 1
0831 #elif defined(__ARMEL__)
0832 #define V8_HOST_ARCH_ARM 1
0833 #define V8_HOST_ARCH_32_BIT 1
0834 #elif defined(__mips64)
0835 #define V8_HOST_ARCH_MIPS64 1
0836 #define V8_HOST_ARCH_64_BIT 1
0837 #elif defined(__loongarch_lp64)
0838 #define V8_HOST_ARCH_LOONG64 1
0839 #define V8_HOST_ARCH_64_BIT 1
0840 #elif defined(__PPC64__) || defined(_ARCH_PPC64)
0841 #define V8_HOST_ARCH_PPC64 1
0842 #define V8_HOST_ARCH_64_BIT 1
0843 #elif defined(__s390x__)
0844 #define V8_HOST_ARCH_S390X 1
0845 #define V8_HOST_ARCH_64_BIT 1
0846 #elif defined(__riscv) || defined(__riscv__)
0847 #if __riscv_xlen == 64
0848 #define V8_HOST_ARCH_RISCV64 1
0849 #define V8_HOST_ARCH_64_BIT 1
0850 #elif __riscv_xlen == 32
0851 #define V8_HOST_ARCH_RISCV32 1
0852 #define V8_HOST_ARCH_32_BIT 1
0853 #else
0854 #error "Cannot detect Riscv's bitwidth"
0855 #endif
0856 #else
0857 #error "Host architecture was not detected as supported by v8"
0858 #endif
0859 
0860 // Target architecture detection. This corresponds to the architecture for which
0861 // V8's JIT will generate code (the last stage of the canadian cross-compiler).
0862 // The macros may be set externally. If not, detect in the same way as the host
0863 // architecture, that is, target the native environment as presented by the
0864 // compiler.
0865 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \
0866     !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 &&                    \
0867     !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390X &&                     \
0868     !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_LOONG64 &&                 \
0869     !V8_TARGET_ARCH_RISCV32
0870 #if defined(_M_X64) || defined(__x86_64__)
0871 #define V8_TARGET_ARCH_X64 1
0872 #elif defined(_M_IX86) || defined(__i386__)
0873 #define V8_TARGET_ARCH_IA32 1
0874 #elif defined(__AARCH64EL__) || defined(_M_ARM64)
0875 #define V8_TARGET_ARCH_ARM64 1
0876 #elif defined(__ARMEL__)
0877 #define V8_TARGET_ARCH_ARM 1
0878 #elif defined(__mips64)
0879 #define V8_TARGET_ARCH_MIPS64 1
0880 #elif defined(__loongarch_lp64)
0881 #define V8_TARGET_ARCH_LOONG64 1
0882 #elif defined(_ARCH_PPC64)
0883 #define V8_TARGET_ARCH_PPC64 1
0884 #elif defined(__s390x__)
0885 #define V8_TARGET_ARCH_S390X 1
0886 #elif defined(__riscv) || defined(__riscv__)
0887 #if __riscv_xlen == 64
0888 #define V8_TARGET_ARCH_RISCV64 1
0889 #elif __riscv_xlen == 32
0890 #define V8_TARGET_ARCH_RISCV32 1
0891 #endif
0892 #else
0893 #error Target architecture was not detected as supported by v8
0894 #endif
0895 #endif
0896 
0897 // Determine architecture pointer size.
0898 #if V8_TARGET_ARCH_IA32
0899 #define V8_TARGET_ARCH_32_BIT 1
0900 #elif V8_TARGET_ARCH_X64
0901 #if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT
0902 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4  // Check for x32.
0903 #define V8_TARGET_ARCH_32_BIT 1
0904 #else
0905 #define V8_TARGET_ARCH_64_BIT 1
0906 #endif
0907 #endif
0908 #elif V8_TARGET_ARCH_ARM
0909 #define V8_TARGET_ARCH_32_BIT 1
0910 #elif V8_TARGET_ARCH_ARM64
0911 #define V8_TARGET_ARCH_64_BIT 1
0912 #elif V8_TARGET_ARCH_MIPS
0913 #define V8_TARGET_ARCH_32_BIT 1
0914 #elif V8_TARGET_ARCH_MIPS64
0915 #define V8_TARGET_ARCH_64_BIT 1
0916 #elif V8_TARGET_ARCH_LOONG64
0917 #define V8_TARGET_ARCH_64_BIT 1
0918 #elif V8_TARGET_ARCH_PPC64
0919 #define V8_TARGET_ARCH_64_BIT 1
0920 #elif V8_TARGET_ARCH_S390X
0921 #define V8_TARGET_ARCH_64_BIT 1
0922 #elif V8_TARGET_ARCH_RISCV64
0923 #define V8_TARGET_ARCH_64_BIT 1
0924 #elif V8_TARGET_ARCH_RISCV32
0925 #define V8_TARGET_ARCH_32_BIT 1
0926 #else
0927 #error Unknown target architecture pointer size
0928 #endif
0929 
0930 // Check for supported combinations of host and target architectures.
0931 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
0932 #error Target architecture ia32 is only supported on ia32 host
0933 #endif
0934 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \
0935      !((V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64) && V8_HOST_ARCH_64_BIT))
0936 #error Target architecture x64 is only supported on x64 and arm64 host
0937 #endif
0938 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \
0939      !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT))
0940 #error Target architecture x32 is only supported on x64 host with x32 support
0941 #endif
0942 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM))
0943 #error Target architecture arm is only supported on arm and ia32 host
0944 #endif
0945 #if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64))
0946 #error Target architecture arm64 is only supported on arm64 and x64 host
0947 #endif
0948 #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64))
0949 #error Target architecture mips64 is only supported on mips64 and x64 host
0950 #endif
0951 #if (V8_TARGET_ARCH_RISCV64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV64))
0952 #error Target architecture riscv64 is only supported on riscv64 and x64 host
0953 #endif
0954 #if (V8_TARGET_ARCH_RISCV32 && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_RISCV32))
0955 #error Target architecture riscv32 is only supported on riscv32 and ia32 host
0956 #endif
0957 #if (V8_TARGET_ARCH_LOONG64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_LOONG64))
0958 #error Target architecture loong64 is only supported on loong64 and x64 host
0959 #endif
0960 
0961 // Determine architecture endianness.
0962 #if V8_TARGET_ARCH_IA32
0963 #define V8_TARGET_LITTLE_ENDIAN 1
0964 #elif V8_TARGET_ARCH_X64
0965 #define V8_TARGET_LITTLE_ENDIAN 1
0966 #elif V8_TARGET_ARCH_ARM
0967 #define V8_TARGET_LITTLE_ENDIAN 1
0968 #elif V8_TARGET_ARCH_ARM64
0969 #define V8_TARGET_LITTLE_ENDIAN 1
0970 #elif V8_TARGET_ARCH_LOONG64
0971 #define V8_TARGET_LITTLE_ENDIAN 1
0972 #elif V8_TARGET_ARCH_MIPS64
0973 #if defined(__MIPSEB__) || defined(V8_TARGET_ARCH_MIPS64_BE)
0974 #define V8_TARGET_BIG_ENDIAN 1
0975 #else
0976 #define V8_TARGET_LITTLE_ENDIAN 1
0977 #endif
0978 #elif V8_TARGET_ARCH_PPC64
0979 #if V8_OS_AIX
0980 #define V8_TARGET_BIG_ENDIAN 1
0981 #else
0982 #define V8_TARGET_LITTLE_ENDIAN 1
0983 #endif
0984 #elif V8_TARGET_ARCH_S390X
0985 #if V8_TARGET_ARCH_S390X_LE_SIM
0986 #define V8_TARGET_LITTLE_ENDIAN 1
0987 #else
0988 #define V8_TARGET_BIG_ENDIAN 1
0989 #endif
0990 #elif V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64
0991 #define V8_TARGET_LITTLE_ENDIAN 1
0992 #elif defined(__BYTE_ORDER__)
0993 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
0994 #define V8_TARGET_BIG_ENDIAN 1
0995 #else
0996 #define V8_TARGET_LITTLE_ENDIAN 1
0997 #endif
0998 #else
0999 #error Unknown target architecture endianness
1000 #endif
1001 
1002 #undef V8_HAS_CPP_ATTRIBUTE
1003 
1004 #if !defined(V8_STATIC_ROOTS)
1005 #define V8_STATIC_ROOTS_BOOL false
1006 #else
1007 #define V8_STATIC_ROOTS_BOOL true
1008 #endif
1009 #ifdef V8_TARGET_BIG_ENDIAN
1010 #define V8_TARGET_BIG_ENDIAN_BOOL true
1011 #else
1012 #define V8_TARGET_BIG_ENDIAN_BOOL false
1013 #endif
1014 
1015 #endif  // V8CONFIG_H_