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 // Processor architecture detection. For more info on what's defined, see: 11 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 12 // http://www.agner.org/optimize/calling_conventions.pdf 13 // or with gcc, run: "echo | gcc -E -dM -" 14 #if defined(_M_X64) || defined(__x86_64__) 15 #define V8_HOST_ARCH_X64 1 16 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 17 #define V8_HOST_ARCH_32_BIT 1 18 #else 19 #define V8_HOST_ARCH_64_BIT 1 20 #endif 21 #elif defined(_M_IX86) || defined(__i386__) 22 #define V8_HOST_ARCH_IA32 1 23 #define V8_HOST_ARCH_32_BIT 1 24 #elif defined(__AARCH64EL__) || defined(_M_ARM64) 25 #define V8_HOST_ARCH_ARM64 1 26 #define V8_HOST_ARCH_64_BIT 1 27 #elif defined(__ARMEL__) 28 #define V8_HOST_ARCH_ARM 1 29 #define V8_HOST_ARCH_32_BIT 1 30 #elif defined(__mips64) 31 #define V8_HOST_ARCH_MIPS64 1 32 #define V8_HOST_ARCH_64_BIT 1 33 #elif defined(__MIPSEB__) || defined(__MIPSEL__) 34 #define V8_HOST_ARCH_MIPS 1 35 #define V8_HOST_ARCH_32_BIT 1 36 #elif defined(__PPC64__) || defined(_ARCH_PPC64) 37 #define V8_HOST_ARCH_PPC64 1 38 #define V8_HOST_ARCH_64_BIT 1 39 #elif defined(__PPC__) || defined(_ARCH_PPC) 40 #define V8_HOST_ARCH_PPC 1 41 #define V8_HOST_ARCH_32_BIT 1 42 #elif defined(__s390__) || defined(__s390x__) 43 #define V8_HOST_ARCH_S390 1 44 #if defined(__s390x__) 45 #define V8_HOST_ARCH_64_BIT 1 46 #else 47 #define V8_HOST_ARCH_32_BIT 1 48 #endif 49 #else 50 #error "Host architecture was not detected as supported by v8" 51 #endif 52 53 #if defined(__ARM_ARCH_7A__) || \ 54 defined(__ARM_ARCH_7R__) || \ 55 defined(__ARM_ARCH_7__) 56 # define CAN_USE_ARMV7_INSTRUCTIONS 1 57 #ifdef __ARM_ARCH_EXT_IDIV__ 58 #define CAN_USE_SUDIV 1 59 #endif 60 # ifndef CAN_USE_VFP3_INSTRUCTIONS 61 #define CAN_USE_VFP3_INSTRUCTIONS 1 62 # endif 63 #endif 64 65 #if defined(__ARM_ARCH_8A__) 66 #define CAN_USE_ARMV7_INSTRUCTIONS 1 67 #define CAN_USE_SUDIV 1 68 # define CAN_USE_ARMV8_INSTRUCTIONS 1 69 #ifndef CAN_USE_VFP3_INSTRUCTIONS 70 #define CAN_USE_VFP3_INSTRUCTIONS 1 71 #endif 72 #endif 73 74 75 // Target architecture detection. This may be set externally. If not, detect 76 // in the same way as the host architecture, that is, target the native 77 // environment as presented by the compiler. 78 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ 79 !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ 80 !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 81 #if defined(_M_X64) || defined(__x86_64__) 82 #define V8_TARGET_ARCH_X64 1 83 #elif defined(_M_IX86) || defined(__i386__) 84 #define V8_TARGET_ARCH_IA32 1 85 #elif defined(__AARCH64EL__) || defined(_M_ARM64) 86 #define V8_TARGET_ARCH_ARM64 1 87 #elif defined(__ARMEL__) 88 #define V8_TARGET_ARCH_ARM 1 89 #elif defined(__mips64) 90 #define V8_TARGET_ARCH_MIPS64 1 91 #elif defined(__MIPSEB__) || defined(__MIPSEL__) 92 #define V8_TARGET_ARCH_MIPS 1 93 #elif defined(_ARCH_PPC64) 94 #define V8_TARGET_ARCH_PPC64 1 95 #elif defined(_ARCH_PPC) 96 #define V8_TARGET_ARCH_PPC 1 97 #else 98 #error Target architecture was not detected as supported by v8 99 #endif 100 #endif 101 102 // Determine architecture pointer size. 103 #if V8_TARGET_ARCH_IA32 104 #define V8_TARGET_ARCH_32_BIT 1 105 #elif V8_TARGET_ARCH_X64 106 #if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT 107 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4 // Check for x32. 108 #define V8_TARGET_ARCH_32_BIT 1 109 #else 110 #define V8_TARGET_ARCH_64_BIT 1 111 #endif 112 #endif 113 #elif V8_TARGET_ARCH_ARM 114 #define V8_TARGET_ARCH_32_BIT 1 115 #elif V8_TARGET_ARCH_ARM64 116 #define V8_TARGET_ARCH_64_BIT 1 117 #elif V8_TARGET_ARCH_MIPS 118 #define V8_TARGET_ARCH_32_BIT 1 119 #elif V8_TARGET_ARCH_MIPS64 120 #define V8_TARGET_ARCH_64_BIT 1 121 #elif V8_TARGET_ARCH_PPC 122 #define V8_TARGET_ARCH_32_BIT 1 123 #elif V8_TARGET_ARCH_PPC64 124 #define V8_TARGET_ARCH_64_BIT 1 125 #elif V8_TARGET_ARCH_S390 126 #if V8_TARGET_ARCH_S390X 127 #define V8_TARGET_ARCH_64_BIT 1 128 #else 129 #define V8_TARGET_ARCH_32_BIT 1 130 #endif 131 #else 132 #error Unknown target architecture pointer size 133 #endif 134 135 // Check for supported combinations of host and target architectures. 136 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32 137 #error Target architecture ia32 is only supported on ia32 host 138 #endif 139 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \ 140 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_64_BIT)) 141 #error Target architecture x64 is only supported on x64 host 142 #endif 143 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \ 144 !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT)) 145 #error Target architecture x32 is only supported on x64 host with x32 support 146 #endif 147 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM)) 148 #error Target architecture arm is only supported on arm and ia32 host 149 #endif 150 #if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64)) 151 #error Target architecture arm64 is only supported on arm64 and x64 host 152 #endif 153 #if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS)) 154 #error Target architecture mips is only supported on mips and ia32 host 155 #endif 156 #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) 157 #error Target architecture mips64 is only supported on mips64 and x64 host 158 #endif 159 160 // Determine architecture endianness. 161 #if V8_TARGET_ARCH_IA32 162 #define V8_TARGET_LITTLE_ENDIAN 1 163 #elif V8_TARGET_ARCH_X64 164 #define V8_TARGET_LITTLE_ENDIAN 1 165 #elif V8_TARGET_ARCH_ARM 166 #define V8_TARGET_LITTLE_ENDIAN 1 167 #elif V8_TARGET_ARCH_ARM64 168 #define V8_TARGET_LITTLE_ENDIAN 1 169 #elif V8_TARGET_ARCH_MIPS 170 #if defined(__MIPSEB__) 171 #define V8_TARGET_BIG_ENDIAN 1 172 #else 173 #define V8_TARGET_LITTLE_ENDIAN 1 174 #endif 175 #elif V8_TARGET_ARCH_MIPS64 176 #if defined(__MIPSEB__) || defined(V8_TARGET_ARCH_MIPS64_BE) 177 #define V8_TARGET_BIG_ENDIAN 1 178 #else 179 #define V8_TARGET_LITTLE_ENDIAN 1 180 #endif 181 #elif __BIG_ENDIAN__ // FOR PPCGR on AIX 182 #define V8_TARGET_BIG_ENDIAN 1 183 #elif V8_TARGET_ARCH_PPC_LE 184 #define V8_TARGET_LITTLE_ENDIAN 1 185 #elif V8_TARGET_ARCH_PPC_BE 186 #define V8_TARGET_BIG_ENDIAN 1 187 #elif V8_TARGET_ARCH_S390 188 #if V8_TARGET_ARCH_S390_LE_SIM 189 #define V8_TARGET_LITTLE_ENDIAN 1 190 #else 191 #define V8_TARGET_BIG_ENDIAN 1 192 #endif 193 #else 194 #error Unknown target architecture endianness 195 #endif 196 197 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) 198 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK true 199 #else 200 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK false 201 #endif 202 constexpr int kReturnAddressStackSlotCount = 203 V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK ? 1 : 0; 204 205 // Number of bits to represent the page size for paged spaces. 206 #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) 207 // PPC has large (64KB) physical pages. 208 const int kPageSizeBits = 19; 209 #else 210 // Arm64 supports up to 64k OS pages on Linux, however 4k pages are more common 211 // so we keep the V8 page size at 256k. Nonetheless, we need to make sure we 212 // don't decrease it further in the future due to reserving 3 OS pages for every 213 // executable V8 page. 214 const int kPageSizeBits = 18; 215 #endif 216 217 #endif // V8_BASE_BUILD_CONFIG_H_ 218