Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/v8globals.h

Issue 306443002: Revert "Merge v8globals.h and globals.h" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_GLOBALS_H_ 5 #ifndef V8_V8GLOBALS_H_
6 #define V8_GLOBALS_H_ 6 #define V8_V8GLOBALS_H_
7 7
8 #include "../include/v8stdint.h" 8 #include "globals.h"
9
10 #include "base/macros.h"
11 #include "checks.h" 9 #include "checks.h"
12 10
13 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
14 // warning flag and certain versions of GCC due to a bug:
15 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
16 // For now, we use the more involved template-based version from <limits>, but
17 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
18 #if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0)
19 # include <limits> // NOLINT
20 # define V8_INFINITY std::numeric_limits<double>::infinity()
21 #elif V8_LIBC_MSVCRT
22 # define V8_INFINITY HUGE_VAL
23 #else
24 # define V8_INFINITY INFINITY
25 #endif
26
27 namespace v8 { 11 namespace v8 {
28 namespace internal { 12 namespace internal {
29 13
30 // Processor architecture detection. For more info on what's defined, see: 14 // This file contains constants and global declarations related to the
31 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 15 // V8 system.
32 // http://www.agner.org/optimize/calling_conventions.pdf
33 // or with gcc, run: "echo | gcc -E -dM -"
34 #if defined(_M_X64) || defined(__x86_64__)
35 #if defined(__native_client__)
36 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
37 // generates ARM machine code, together with a portable ARM simulator
38 // compiled for the host architecture in question.
39 //
40 // Since Native Client is ILP-32 on all architectures we use
41 // V8_HOST_ARCH_IA32 on both 32- and 64-bit x86.
42 #define V8_HOST_ARCH_IA32 1
43 #define V8_HOST_ARCH_32_BIT 1
44 #define V8_HOST_CAN_READ_UNALIGNED 1
45 #else
46 #define V8_HOST_ARCH_X64 1
47 #define V8_HOST_ARCH_64_BIT 1
48 #define V8_HOST_CAN_READ_UNALIGNED 1
49 #endif // __native_client__
50 #elif defined(_M_IX86) || defined(__i386__)
51 #define V8_HOST_ARCH_IA32 1
52 #define V8_HOST_ARCH_32_BIT 1
53 #define V8_HOST_CAN_READ_UNALIGNED 1
54 #elif defined(__AARCH64EL__)
55 #define V8_HOST_ARCH_ARM64 1
56 #define V8_HOST_ARCH_64_BIT 1
57 #define V8_HOST_CAN_READ_UNALIGNED 1
58 #elif defined(__ARMEL__)
59 #define V8_HOST_ARCH_ARM 1
60 #define V8_HOST_ARCH_32_BIT 1
61 #elif defined(__MIPSEB__) || defined(__MIPSEL__)
62 #define V8_HOST_ARCH_MIPS 1
63 #define V8_HOST_ARCH_32_BIT 1
64 #else
65 #error "Host architecture was not detected as supported by v8"
66 #endif
67
68 #if defined(__ARM_ARCH_7A__) || \
69 defined(__ARM_ARCH_7R__) || \
70 defined(__ARM_ARCH_7__)
71 # define CAN_USE_ARMV7_INSTRUCTIONS 1
72 # ifndef CAN_USE_VFP3_INSTRUCTIONS
73 # define CAN_USE_VFP3_INSTRUCTIONS
74 # endif
75 #endif
76
77
78 // Target architecture detection. This may be set externally. If not, detect
79 // in the same way as the host architecture, that is, target the native
80 // environment as presented by the compiler.
81 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_X87 &&\
82 !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS
83 #if defined(_M_X64) || defined(__x86_64__)
84 #define V8_TARGET_ARCH_X64 1
85 #elif defined(_M_IX86) || defined(__i386__)
86 #define V8_TARGET_ARCH_IA32 1
87 #elif defined(__AARCH64EL__)
88 #define V8_TARGET_ARCH_ARM64 1
89 #elif defined(__ARMEL__)
90 #define V8_TARGET_ARCH_ARM 1
91 #elif defined(__MIPSEB__) || defined(__MIPSEL__)
92 #define V8_TARGET_ARCH_MIPS 1
93 #else
94 #error Target architecture was not detected as supported by v8
95 #endif
96 #endif
97
98 // Check for supported combinations of host and target architectures.
99 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32
100 #error Target architecture ia32 is only supported on ia32 host
101 #endif
102 #if V8_TARGET_ARCH_X64 && !V8_HOST_ARCH_X64
103 #error Target architecture x64 is only supported on x64 host
104 #endif
105 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM))
106 #error Target architecture arm is only supported on arm and ia32 host
107 #endif
108 #if (V8_TARGET_ARCH_ARM64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_ARM64))
109 #error Target architecture arm64 is only supported on arm64 and x64 host
110 #endif
111 #if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS))
112 #error Target architecture mips is only supported on mips and ia32 host
113 #endif
114
115 // Determine whether we are running in a simulated environment.
116 // Setting USE_SIMULATOR explicitly from the build script will force
117 // the use of a simulated environment.
118 #if !defined(USE_SIMULATOR)
119 #if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64)
120 #define USE_SIMULATOR 1
121 #endif
122 #if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM)
123 #define USE_SIMULATOR 1
124 #endif
125 #if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS)
126 #define USE_SIMULATOR 1
127 #endif
128 #endif
129
130 // Determine architecture endianness.
131 #if V8_TARGET_ARCH_IA32
132 #define V8_TARGET_LITTLE_ENDIAN 1
133 #elif V8_TARGET_ARCH_X64
134 #define V8_TARGET_LITTLE_ENDIAN 1
135 #elif V8_TARGET_ARCH_ARM
136 #define V8_TARGET_LITTLE_ENDIAN 1
137 #elif V8_TARGET_ARCH_ARM64
138 #define V8_TARGET_LITTLE_ENDIAN 1
139 #elif V8_TARGET_ARCH_MIPS
140 #if defined(__MIPSEB__)
141 #define V8_TARGET_BIG_ENDIAN 1
142 #else
143 #define V8_TARGET_LITTLE_ENDIAN 1
144 #endif
145 #elif V8_TARGET_ARCH_X87
146 #define V8_TARGET_LITTLE_ENDIAN 1
147 #else
148 #error Unknown target architecture endianness
149 #endif
150
151 // Determine whether the architecture uses an out-of-line constant pool.
152 #define V8_OOL_CONSTANT_POOL 0
153
154 // Support for alternative bool type. This is only enabled if the code is
155 // compiled with USE_MYBOOL defined. This catches some nasty type bugs.
156 // For instance, 'bool b = "false";' results in b == true! This is a hidden
157 // source of bugs.
158 // However, redefining the bool type does have some negative impact on some
159 // platforms. It gives rise to compiler warnings (i.e. with
160 // MSVC) in the API header files when mixing code that uses the standard
161 // bool with code that uses the redefined version.
162 // This does not actually belong in the platform code, but needs to be
163 // defined here because the platform code uses bool, and platform.h is
164 // include very early in the main include file.
165
166 #ifdef USE_MYBOOL
167 typedef unsigned int __my_bool__;
168 #define bool __my_bool__ // use 'indirection' to avoid name clashes
169 #endif
170
171 typedef uint8_t byte;
172 typedef byte* Address;
173
174 // Define our own macros for writing 64-bit constants. This is less fragile
175 // than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it
176 // works on compilers that don't have it (like MSVC).
177 #if V8_CC_MSVC
178 # define V8_UINT64_C(x) (x ## UI64)
179 # define V8_INT64_C(x) (x ## I64)
180 # if V8_HOST_ARCH_64_BIT
181 # define V8_INTPTR_C(x) (x ## I64)
182 # define V8_PTR_PREFIX "ll"
183 # else
184 # define V8_INTPTR_C(x) (x)
185 # define V8_PTR_PREFIX ""
186 # endif // V8_HOST_ARCH_64_BIT
187 #elif V8_CC_MINGW64
188 # define V8_UINT64_C(x) (x ## ULL)
189 # define V8_INT64_C(x) (x ## LL)
190 # define V8_INTPTR_C(x) (x ## LL)
191 # define V8_PTR_PREFIX "I64"
192 #elif V8_HOST_ARCH_64_BIT
193 # if V8_OS_MACOSX
194 # define V8_UINT64_C(x) (x ## ULL)
195 # define V8_INT64_C(x) (x ## LL)
196 # else
197 # define V8_UINT64_C(x) (x ## UL)
198 # define V8_INT64_C(x) (x ## L)
199 # endif
200 # define V8_INTPTR_C(x) (x ## L)
201 # define V8_PTR_PREFIX "l"
202 #else
203 # define V8_UINT64_C(x) (x ## ULL)
204 # define V8_INT64_C(x) (x ## LL)
205 # define V8_INTPTR_C(x) (x)
206 # define V8_PTR_PREFIX ""
207 #endif
208
209 // The following macro works on both 32 and 64-bit platforms.
210 // Usage: instead of writing 0x1234567890123456
211 // write V8_2PART_UINT64_C(0x12345678,90123456);
212 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
213
214 #define V8PRIxPTR V8_PTR_PREFIX "x"
215 #define V8PRIdPTR V8_PTR_PREFIX "d"
216 #define V8PRIuPTR V8_PTR_PREFIX "u"
217
218 // Fix for Mac OS X defining uintptr_t as "unsigned long":
219 #if V8_OS_MACOSX
220 #undef V8PRIxPTR
221 #define V8PRIxPTR "lx"
222 #endif
223
224 #if V8_OS_MACOSX || defined(__FreeBSD__) || defined(__OpenBSD__)
225 #define USING_BSD_ABI
226 #endif
227
228 // -----------------------------------------------------------------------------
229 // Constants
230
231 const int KB = 1024;
232 const int MB = KB * KB;
233 const int GB = KB * KB * KB;
234 const int kMaxInt = 0x7FFFFFFF;
235 const int kMinInt = -kMaxInt - 1;
236 const int kMaxInt8 = (1 << 7) - 1;
237 const int kMinInt8 = -(1 << 7);
238 const int kMaxUInt8 = (1 << 8) - 1;
239 const int kMinUInt8 = 0;
240 const int kMaxInt16 = (1 << 15) - 1;
241 const int kMinInt16 = -(1 << 15);
242 const int kMaxUInt16 = (1 << 16) - 1;
243 const int kMinUInt16 = 0;
244
245 const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
246
247 const int kCharSize = sizeof(char); // NOLINT
248 const int kShortSize = sizeof(short); // NOLINT
249 const int kIntSize = sizeof(int); // NOLINT
250 const int kInt32Size = sizeof(int32_t); // NOLINT
251 const int kInt64Size = sizeof(int64_t); // NOLINT
252 const int kDoubleSize = sizeof(double); // NOLINT
253 const int kIntptrSize = sizeof(intptr_t); // NOLINT
254 const int kPointerSize = sizeof(void*); // NOLINT
255 const int kRegisterSize = kPointerSize;
256 const int kPCOnStackSize = kRegisterSize;
257 const int kFPOnStackSize = kRegisterSize;
258
259 const int kDoubleSizeLog2 = 3;
260
261 #if V8_HOST_ARCH_64_BIT
262 const int kPointerSizeLog2 = 3;
263 const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
264 const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
265 const bool kIs64BitArch = true;
266 #else
267 const int kPointerSizeLog2 = 2;
268 const intptr_t kIntptrSignBit = 0x80000000;
269 const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
270 const bool kIs64BitArch = false;
271 #endif
272
273 const int kBitsPerByte = 8;
274 const int kBitsPerByteLog2 = 3;
275 const int kBitsPerPointer = kPointerSize * kBitsPerByte;
276 const int kBitsPerInt = kIntSize * kBitsPerByte;
277
278 // IEEE 754 single precision floating point number bit layout.
279 const uint32_t kBinary32SignMask = 0x80000000u;
280 const uint32_t kBinary32ExponentMask = 0x7f800000u;
281 const uint32_t kBinary32MantissaMask = 0x007fffffu;
282 const int kBinary32ExponentBias = 127;
283 const int kBinary32MaxExponent = 0xFE;
284 const int kBinary32MinExponent = 0x01;
285 const int kBinary32MantissaBits = 23;
286 const int kBinary32ExponentShift = 23;
287
288 // Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no
289 // other bits set.
290 const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
291
292 // Latin1/UTF-16 constants
293 // Code-point values in Unicode 4.0 are 21 bits wide.
294 // Code units in UTF-16 are 16 bits wide.
295 typedef uint16_t uc16;
296 typedef int32_t uc32;
297 const int kOneByteSize = kCharSize;
298 const int kUC16Size = sizeof(uc16); // NOLINT
299
300
301 // Round up n to be a multiple of sz, where sz is a power of 2.
302 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
303
304
305 // The USE(x) template is used to silence C++ compiler warnings
306 // issued for (yet) unused variables (typically parameters).
307 template <typename T>
308 inline void USE(T) { }
309
310
311 // FUNCTION_ADDR(f) gets the address of a C function f.
312 #define FUNCTION_ADDR(f) \
313 (reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f)))
314
315
316 // FUNCTION_CAST<F>(addr) casts an address into a function
317 // of type F. Used to invoke generated code from within C.
318 template <typename F>
319 F FUNCTION_CAST(Address addr) {
320 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr));
321 }
322
323
324 // -----------------------------------------------------------------------------
325 // Forward declarations for frequently used classes
326 // (sorted alphabetically)
327
328 class FreeStoreAllocationPolicy;
329 template <typename T, class P = FreeStoreAllocationPolicy> class List;
330
331 // -----------------------------------------------------------------------------
332 // Declarations for use in both the preparser and the rest of V8.
333
334 // The Strict Mode (ECMA-262 5th edition, 4.2.2).
335
336 enum StrictMode { SLOPPY, STRICT };
337
338 16
339 // Mask for the sign bit in a smi. 17 // Mask for the sign bit in a smi.
340 const intptr_t kSmiSignMask = kIntptrSignBit; 18 const intptr_t kSmiSignMask = kIntptrSignBit;
341 19
342 const int kObjectAlignmentBits = kPointerSizeLog2; 20 const int kObjectAlignmentBits = kPointerSizeLog2;
343 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; 21 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
344 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; 22 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
345 23
346 // Desired alignment for pointers. 24 // Desired alignment for pointers.
347 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); 25 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 549
872 enum MinusZeroMode { 550 enum MinusZeroMode {
873 TREAT_MINUS_ZERO_AS_ZERO, 551 TREAT_MINUS_ZERO_AS_ZERO,
874 FAIL_ON_MINUS_ZERO 552 FAIL_ON_MINUS_ZERO
875 }; 553 };
876 554
877 } } // namespace v8::internal 555 } } // namespace v8::internal
878 556
879 namespace i = v8::internal; 557 namespace i = v8::internal;
880 558
881 #endif // V8_GLOBALS_H_ 559 #endif // V8_V8GLOBALS_H_
OLDNEW
« no previous file with comments | « src/v8.h ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698