v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
build_config.h
Go to the documentation of this file.
1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_BASE_BUILD_CONFIG_H_
6#define V8_BASE_BUILD_CONFIG_H_
7
8#include "include/v8config.h"
9
10#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || \
11 defined(__ARM_ARCH_7__)
12#define CAN_USE_ARMV7_INSTRUCTIONS 1
13#ifdef __ARM_ARCH_EXT_IDIV__
14#define CAN_USE_SUDIV 1
15#endif
16#ifndef CAN_USE_VFP3_INSTRUCTIONS
17#define CAN_USE_VFP3_INSTRUCTIONS 1
18#endif
19#endif
20
21#if defined(__ARM_ARCH_8A__)
22#define CAN_USE_ARMV7_INSTRUCTIONS 1
23#define CAN_USE_SUDIV 1
24#define CAN_USE_ARMV8_INSTRUCTIONS 1
25#ifndef CAN_USE_VFP3_INSTRUCTIONS
26#define CAN_USE_VFP3_INSTRUCTIONS 1
27#endif
28#endif
29
30// pthread_jit_write_protect is only available on arm64 Mac.
31#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_MACOS)
32#define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 1
33#else
34#define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0
35#endif
36
37// BrowserEngineCore JIT write protect is only available on iOS 17.4 and later.
38#if defined(V8_HOST_ARCH_ARM64) && defined(V8_OS_IOS) && \
39 defined(__IPHONE_17_4) && \
40 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_17_4
41#define V8_HAS_BECORE_JIT_WRITE_PROTECT 1
42#else
43#define V8_HAS_BECORE_JIT_WRITE_PROTECT 0
44#endif
45
46#if defined(V8_OS_LINUX) && defined(V8_HOST_ARCH_X64)
47#define V8_HAS_PKU_JIT_WRITE_PROTECT 1
48#else
49#define V8_HAS_PKU_JIT_WRITE_PROTECT 0
50#endif
51
52#if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64)
53#define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK true
54#else
55#define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK false
56#endif
59
60// Number of bits to represent the page size for paged spaces.
61#if defined(V8_HOST_ARCH_PPC64) && !defined(V8_OS_AIX)
62// Native PPC linux has large (64KB) physical pages.
63// Simulator (and Aix) need to use the same value as x64.
64constexpr int kPageSizeBits = 19;
65#elif defined(ENABLE_HUGEPAGE)
66// When enabling huge pages, adjust V8 page size to take up exactly one huge
67// page. This avoids huge-page-internal fragmentation for unused address ranges.
68constexpr int kHugePageBits = 21;
69constexpr int kHugePageSize = 1 << kHugePageBits;
70constexpr int kPageSizeBits = kHugePageBits;
71#else
72// Arm64 supports up to 64k OS pages on Linux, however 4k pages are more common
73// so we keep the V8 page size at 256k. Nonetheless, we need to make sure we
74// don't decrease it further in the future due to reserving 3 OS pages for every
75// executable V8 page.
76constexpr int kPageSizeBits = 18;
77#endif
78
79constexpr int kRegularPageSize = 1 << kPageSizeBits;
80
81// The minimal supported page size by the operation system. Any region aligned
82// to that size needs to be individually protectable via
83// {base::OS::SetPermission} and friends.
84#if (defined(V8_OS_MACOS) && defined(V8_HOST_ARCH_ARM64)) || \
85 (defined(V8_OS_ANDROID) && \
86 (defined(V8_HOST_ARCH_ARM64) || defined(V8_HOST_ARCH_X64))) || \
87 defined(V8_HOST_ARCH_LOONG64) || defined(V8_HOST_ARCH_MIPS64) || \
88 defined(V8_OS_IOS)
89// Android 64 bit has experimental support for 16kB pages.
90// MacOS & iOS on arm64 uses 16kB pages.
91// LOONG64 and MIPS64 also use 16kB pages.
92constexpr int kMinimumOSPageSize = 16 * 1024;
93#elif defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID) && \
94 (defined(V8_HOST_ARCH_ARM64) || defined(V8_HOST_ARCH_PPC64))
95// Linux on arm64 (excluding android) and PPC64 can be configured for up to 64kB
96// pages.
97constexpr int kMinimumOSPageSize = 64 * 1024;
98#else
99// Everything else uses 4kB pages.
100constexpr int kMinimumOSPageSize = 4 * 1024;
101#endif
102
103#endif // V8_BASE_BUILD_CONFIG_H_
#define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK
constexpr int kRegularPageSize
constexpr int kPageSizeBits
constexpr int kMinimumOSPageSize
constexpr int kReturnAddressStackSlotCount