• 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 #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__)
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(__PPC__) || defined(_ARCH_PPC)
37 #define V8_HOST_ARCH_PPC 1
38 #if defined(__PPC64__) || defined(_ARCH_PPC64)
39 #define V8_HOST_ARCH_64_BIT 1
40 #else
41 #define V8_HOST_ARCH_32_BIT 1
42 #endif
43 #elif defined(__s390__) || defined(__s390x__)
44 #define V8_HOST_ARCH_S390 1
45 #if defined(__s390x__)
46 #define V8_HOST_ARCH_64_BIT 1
47 #else
48 #define V8_HOST_ARCH_32_BIT 1
49 #endif
50 #else
51 #error "Host architecture was not detected as supported by v8"
52 #endif
53 
54 #if defined(__ARM_ARCH_7A__) || \
55     defined(__ARM_ARCH_7R__) || \
56     defined(__ARM_ARCH_7__)
57 # define CAN_USE_ARMV7_INSTRUCTIONS 1
58 #ifdef __ARM_ARCH_EXT_IDIV__
59 #define CAN_USE_SUDIV 1
60 #endif
61 # ifndef CAN_USE_VFP3_INSTRUCTIONS
62 #define CAN_USE_VFP3_INSTRUCTIONS 1
63 # endif
64 #endif
65 
66 #if defined(__ARM_ARCH_8A__)
67 #define CAN_USE_ARMV7_INSTRUCTIONS 1
68 #define CAN_USE_SUDIV 1
69 # define CAN_USE_ARMV8_INSTRUCTIONS 1
70 #ifndef CAN_USE_VFP3_INSTRUCTIONS
71 #define CAN_USE_VFP3_INSTRUCTIONS 1
72 #endif
73 #endif
74 
75 
76 // Target architecture detection. This may be set externally. If not, detect
77 // in the same way as the host architecture, that is, target the native
78 // environment as presented by the compiler.
79 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM &&      \
80     !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \
81     !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_S390
82 #if defined(_M_X64) || defined(__x86_64__)
83 #define V8_TARGET_ARCH_X64 1
84 #elif defined(_M_IX86) || defined(__i386__)
85 #define V8_TARGET_ARCH_IA32 1
86 #elif defined(__AARCH64EL__)
87 #define V8_TARGET_ARCH_ARM64 1
88 #elif defined(__ARMEL__)
89 #define V8_TARGET_ARCH_ARM 1
90 #elif defined(__mips64)
91 #define V8_TARGET_ARCH_MIPS64 1
92 #elif defined(__MIPSEB__) || defined(__MIPSEL__)
93 #define V8_TARGET_ARCH_MIPS 1
94 #elif defined(_ARCH_PPC)
95 #define V8_TARGET_ARCH_PPC 1
96 #else
97 #error Target architecture was not detected as supported by v8
98 #endif
99 #endif
100 
101 // Determine architecture pointer size.
102 #if V8_TARGET_ARCH_IA32
103 #define V8_TARGET_ARCH_32_BIT 1
104 #elif V8_TARGET_ARCH_X64
105 #if !V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_64_BIT
106 #if defined(__x86_64__) && __SIZEOF_POINTER__ == 4  // Check for x32.
107 #define V8_TARGET_ARCH_32_BIT 1
108 #else
109 #define V8_TARGET_ARCH_64_BIT 1
110 #endif
111 #endif
112 #elif V8_TARGET_ARCH_ARM
113 #define V8_TARGET_ARCH_32_BIT 1
114 #elif V8_TARGET_ARCH_ARM64
115 #define V8_TARGET_ARCH_64_BIT 1
116 #elif V8_TARGET_ARCH_MIPS
117 #define V8_TARGET_ARCH_32_BIT 1
118 #elif V8_TARGET_ARCH_MIPS64
119 #define V8_TARGET_ARCH_64_BIT 1
120 #elif V8_TARGET_ARCH_PPC
121 #if V8_TARGET_ARCH_PPC64
122 #define V8_TARGET_ARCH_64_BIT 1
123 #else
124 #define V8_TARGET_ARCH_32_BIT 1
125 #endif
126 #elif V8_TARGET_ARCH_S390
127 #if V8_TARGET_ARCH_S390X
128 #define V8_TARGET_ARCH_64_BIT 1
129 #else
130 #define V8_TARGET_ARCH_32_BIT 1
131 #endif
132 #else
133 #error Unknown target architecture pointer size
134 #endif
135 
136 // Check for supported combinations of host and target architectures.
137 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
138 #error Target architecture ia32 is only supported on ia32 host
139 #endif
140 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_64_BIT && \
141      !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_64_BIT))
142 #error Target architecture x64 is only supported on x64 host
143 #endif
144 #if (V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT && \
145      !(V8_HOST_ARCH_X64 && V8_HOST_ARCH_32_BIT))
146 #error Target architecture x32 is only supported on x64 host with x32 support
147 #endif
148 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM))
149 #error Target architecture arm is only supported on arm and ia32 host
150 #endif
151 #if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64))
152 #error Target architecture arm64 is only supported on arm64 and x64 host
153 #endif
154 #if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS))
155 #error Target architecture mips is only supported on mips and ia32 host
156 #endif
157 #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64))
158 #error Target architecture mips64 is only supported on mips64 and x64 host
159 #endif
160 
161 // Determine architecture endianness.
162 #if V8_TARGET_ARCH_IA32
163 #define V8_TARGET_LITTLE_ENDIAN 1
164 #elif V8_TARGET_ARCH_X64
165 #define V8_TARGET_LITTLE_ENDIAN 1
166 #elif V8_TARGET_ARCH_ARM
167 #define V8_TARGET_LITTLE_ENDIAN 1
168 #elif V8_TARGET_ARCH_ARM64
169 #define V8_TARGET_LITTLE_ENDIAN 1
170 #elif V8_TARGET_ARCH_MIPS
171 #if defined(__MIPSEB__)
172 #define V8_TARGET_BIG_ENDIAN 1
173 #else
174 #define V8_TARGET_LITTLE_ENDIAN 1
175 #endif
176 #elif V8_TARGET_ARCH_MIPS64
177 #if defined(__MIPSEB__) || defined(V8_TARGET_ARCH_MIPS64_BE)
178 #define V8_TARGET_BIG_ENDIAN 1
179 #else
180 #define V8_TARGET_LITTLE_ENDIAN 1
181 #endif
182 #elif __BIG_ENDIAN__  // FOR PPCGR on AIX
183 #define V8_TARGET_BIG_ENDIAN 1
184 #elif V8_TARGET_ARCH_PPC_LE
185 #define V8_TARGET_LITTLE_ENDIAN 1
186 #elif V8_TARGET_ARCH_PPC_BE
187 #define V8_TARGET_BIG_ENDIAN 1
188 #elif V8_TARGET_ARCH_S390
189 #if V8_TARGET_ARCH_S390_LE_SIM
190 #define V8_TARGET_LITTLE_ENDIAN 1
191 #else
192 #define V8_TARGET_BIG_ENDIAN 1
193 #endif
194 #else
195 #error Unknown target architecture endianness
196 #endif
197 
198 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64)
199 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK 1
200 #else
201 #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK 0
202 #endif
203 
204 // Number of bits to represent the page size for paged spaces. The value of 19
205 // gives 512Kb bytes per page.
206 const int kPageSizeBits = 19;
207 
208 #endif  // V8_BASE_BUILD_CONFIG_H_
209