Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-04 09:15:24

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