• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #if defined(__native_client__)
16 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
17 // generates ARM machine code, together with a portable ARM simulator
18 // compiled for the host architecture in question.
19 //
20 // Since Native Client is ILP-32 on all architectures we use
21 // V8_HOST_ARCH_IA32 on both 32- and 64-bit x86.
22 #define V8_HOST_ARCH_IA32 1
23 #define V8_HOST_ARCH_32_BIT 1
24 #else
25 #define V8_HOST_ARCH_X64 1
26 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4  // Check for x32.
27 #define V8_HOST_ARCH_32_BIT 1
28 #else
29 #define V8_HOST_ARCH_64_BIT 1
30 #endif
31 #endif  // __native_client__
32 #elif defined(__pnacl__)
33 // PNaCl is also ILP-32.
34 #define V8_HOST_ARCH_IA32 1
35 #define V8_HOST_ARCH_32_BIT 1
36 #elif defined(_M_IX86) || defined(__i386__)
37 #define V8_HOST_ARCH_IA32 1
38 #define V8_HOST_ARCH_32_BIT 1
39 #elif defined(__AARCH64EL__)
40 #define V8_HOST_ARCH_ARM64 1
41 #define V8_HOST_ARCH_64_BIT 1
42 #elif defined(__ARMEL__)
43 #define V8_HOST_ARCH_ARM 1
44 #define V8_HOST_ARCH_32_BIT 1
45 #elif defined(__mips64)
46 #define V8_HOST_ARCH_MIPS64 1
47 #define V8_HOST_ARCH_64_BIT 1
48 #elif defined(__MIPSEB__) || defined(__MIPSEL__)
49 #define V8_HOST_ARCH_MIPS 1
50 #define V8_HOST_ARCH_32_BIT 1
51 #elif defined(__PPC__) || defined(_ARCH_PPC)
52 #define V8_HOST_ARCH_PPC 1
53 #if defined(__PPC64__) || defined(_ARCH_PPC64)
54 #define V8_HOST_ARCH_64_BIT 1
55 #else
56 #define V8_HOST_ARCH_32_BIT 1
57 #endif
58 #elif defined(__s390__) || defined(__s390x__)
59 #define V8_HOST_ARCH_S390 1
60 #if defined(__s390x__)
61 #define V8_HOST_ARCH_64_BIT 1
62 #else
63 #define V8_HOST_ARCH_32_BIT 1
64 #endif
65 #else
66 #error "Host architecture was not detected as supported by v8"
67 #endif
68 
69 #if defined(__ARM_ARCH_7A__) || \
70     defined(__ARM_ARCH_7R__) || \
71     defined(__ARM_ARCH_7__)
72 # define CAN_USE_ARMV7_INSTRUCTIONS 1
73 # ifndef CAN_USE_VFP3_INSTRUCTIONS
74 #  define CAN_USE_VFP3_INSTRUCTIONS
75 # endif
76 #endif
77 
78 #if defined(__ARM_ARCH_8A__)
79 # define CAN_USE_ARMV8_INSTRUCTIONS 1
80 #endif
81 
82 
83 // Target architecture detection. This may be set externally. If not, detect
84 // in the same way as the host architecture, that is, target the native
85 // environment as presented by the compiler.
86 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_X87 &&   \
87     !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && \
88     !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_S390
89 #if defined(_M_X64) || defined(__x86_64__)
90 #define V8_TARGET_ARCH_X64 1
91 #elif defined(_M_IX86) || defined(__i386__)
92 #define V8_TARGET_ARCH_IA32 1
93 #elif defined(__AARCH64EL__)
94 #define V8_TARGET_ARCH_ARM64 1
95 #elif defined(__ARMEL__)
96 #define V8_TARGET_ARCH_ARM 1
97 #elif defined(__mips64)
98 #define V8_TARGET_ARCH_MIPS64 1
99 #elif defined(__MIPSEB__) || defined(__MIPSEL__)
100 #define V8_TARGET_ARCH_MIPS 1
101 #else
102 #error Target architecture was not detected as supported by v8
103 #endif
104 #endif
105 
106 // Determine architecture pointer size.
107 #if V8_TARGET_ARCH_IA32
108 #define V8_TARGET_ARCH_32_BIT 1
109 #elif V8_TARGET_ARCH_X64
110 #if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT
111 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4  // Check for x32.
112 #define V8_TARGET_ARCH_32_BIT 1
113 #else
114 #define V8_TARGET_ARCH_64_BIT 1
115 #endif
116 #endif
117 #elif V8_TARGET_ARCH_ARM
118 #define V8_TARGET_ARCH_32_BIT 1
119 #elif V8_TARGET_ARCH_ARM64
120 #define V8_TARGET_ARCH_64_BIT 1
121 #elif V8_TARGET_ARCH_MIPS
122 #define V8_TARGET_ARCH_32_BIT 1
123 #elif V8_TARGET_ARCH_MIPS64
124 #define V8_TARGET_ARCH_64_BIT 1
125 #elif V8_TARGET_ARCH_PPC
126 #if V8_TARGET_ARCH_PPC64
127 #define V8_TARGET_ARCH_64_BIT 1
128 #else
129 #define V8_TARGET_ARCH_32_BIT 1
130 #endif
131 #elif V8_TARGET_ARCH_S390
132 #if V8_TARGET_ARCH_S390X
133 #define V8_TARGET_ARCH_64_BIT 1
134 #else
135 #define V8_TARGET_ARCH_32_BIT 1
136 #endif
137 #elif V8_TARGET_ARCH_X87
138 #define V8_TARGET_ARCH_32_BIT 1
139 #else
140 #error Unknown target architecture pointer size
141 #endif
142 
143 // Check for supported combinations of host and target architectures.
144 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
145 #error Target architecture ia32 is only supported on ia32 host
146 #endif
147 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \
148      !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_64_BIT))
149 #error Target architecture x64 is only supported on x64 host
150 #endif
151 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \
152      !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT))
153 #error Target architecture x32 is only supported on x64 host with x32 support
154 #endif
155 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM))
156 #error Target architecture arm is only supported on arm and ia32 host
157 #endif
158 #if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64))
159 #error Target architecture arm64 is only supported on arm64 and x64 host
160 #endif
161 #if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS))
162 #error Target architecture mips is only supported on mips and ia32 host
163 #endif
164 #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64))
165 #error Target architecture mips64 is only supported on mips64 and x64 host
166 #endif
167 
168 // Determine architecture endianness.
169 #if V8_TARGET_ARCH_IA32
170 #define V8_TARGET_LITTLE_ENDIAN 1
171 #elif V8_TARGET_ARCH_X64
172 #define V8_TARGET_LITTLE_ENDIAN 1
173 #elif V8_TARGET_ARCH_ARM
174 #define V8_TARGET_LITTLE_ENDIAN 1
175 #elif V8_TARGET_ARCH_ARM64
176 #define V8_TARGET_LITTLE_ENDIAN 1
177 #elif V8_TARGET_ARCH_MIPS
178 #if defined(__MIPSEB__)
179 #define V8_TARGET_BIG_ENDIAN 1
180 #else
181 #define V8_TARGET_LITTLE_ENDIAN 1
182 #endif
183 #elif V8_TARGET_ARCH_MIPS64
184 #if defined(__MIPSEB__) || defined(V8_TARGET_ARCH_MIPS64_BE)
185 #define V8_TARGET_BIG_ENDIAN 1
186 #else
187 #define V8_TARGET_LITTLE_ENDIAN 1
188 #endif
189 #elif V8_TARGET_ARCH_X87
190 #define V8_TARGET_LITTLE_ENDIAN 1
191 #elif V8_TARGET_ARCH_PPC_LE
192 #define V8_TARGET_LITTLE_ENDIAN 1
193 #elif V8_TARGET_ARCH_PPC_BE
194 #define V8_TARGET_BIG_ENDIAN 1
195 #elif V8_TARGET_ARCH_S390
196 #if V8_TARGET_ARCH_S390_LE_SIM
197 #define V8_TARGET_LITTLE_ENDIAN 1
198 #else
199 #define V8_TARGET_BIG_ENDIAN 1
200 #endif
201 #else
202 #error Unknown target architecture endianness
203 #endif
204 
205 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) || \
206     defined(V8_TARGET_ARCH_X87)
207 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK 1
208 #else
209 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK 0
210 #endif
211 
212 // Number of bits to represent the page size for paged spaces. The value of 20
213 // gives 1Mb bytes per page.
214 #if V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX
215 // Bump up for Power Linux due to larger (64K) page size.
216 const int kPageSizeBits = 22;
217 #else
218 const int kPageSizeBits = 20;
219 #endif
220 
221 #endif  // V8_BASE_BUILD_CONFIG_H_
222