erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 28 | #ifndef V8_GLOBALS_H_ |
| 29 | #define V8_GLOBALS_H_ |
| 30 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 31 | #include "../include/v8stdint.h" |
| 32 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 33 | namespace v8 { |
| 34 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 35 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 36 | // Processor architecture detection. For more info on what's defined, see: |
| 37 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 38 | // http://www.agner.org/optimize/calling_conventions.pdf |
| 39 | // or with gcc, run: "echo | gcc -E -dM -" |
| 40 | #if defined(_M_X64) || defined(__x86_64__) |
| 41 | #define V8_HOST_ARCH_X64 1 |
| 42 | #define V8_HOST_ARCH_64_BIT 1 |
| 43 | #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 44 | #elif defined(_M_IX86) || defined(__i386__) |
| 45 | #define V8_HOST_ARCH_IA32 1 |
| 46 | #define V8_HOST_ARCH_32_BIT 1 |
| 47 | #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 48 | #elif defined(__ARMEL__) |
| 49 | #define V8_HOST_ARCH_ARM 1 |
| 50 | #define V8_HOST_ARCH_32_BIT 1 |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 51 | // Some CPU-OS combinations allow unaligned access on ARM. We assume |
| 52 | // that unaligned accesses are not allowed unless the build system |
| 53 | // defines the CAN_USE_UNALIGNED_ACCESSES macro to be non-zero. |
| 54 | #if CAN_USE_UNALIGNED_ACCESSES |
| 55 | #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 56 | #endif |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 57 | #elif defined(_MIPS_ARCH_MIPS32R2) |
| 58 | #define V8_HOST_ARCH_MIPS 1 |
| 59 | #define V8_HOST_ARCH_32_BIT 1 |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 60 | #else |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 61 | #error Host architecture was not detected as supported by v8 |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 62 | #endif |
| 63 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 64 | // Target architecture detection. This may be set externally. If not, detect |
| 65 | // in the same way as the host architecture, that is, target the native |
| 66 | // environment as presented by the compiler. |
| 67 | #if !defined(V8_TARGET_ARCH_X64) && !defined(V8_TARGET_ARCH_IA32) && \ |
| 68 | !defined(V8_TARGET_ARCH_ARM) && !defined(V8_TARGET_ARCH_MIPS) |
| 69 | #if defined(_M_X64) || defined(__x86_64__) |
| 70 | #define V8_TARGET_ARCH_X64 1 |
| 71 | #elif defined(_M_IX86) || defined(__i386__) |
| 72 | #define V8_TARGET_ARCH_IA32 1 |
| 73 | #elif defined(__ARMEL__) |
| 74 | #define V8_TARGET_ARCH_ARM 1 |
| 75 | #elif defined(_MIPS_ARCH_MIPS32R2) |
| 76 | #define V8_TARGET_ARCH_MIPS 1 |
| 77 | #else |
| 78 | #error Target architecture was not detected as supported by v8 |
| 79 | #endif |
| 80 | #endif |
| 81 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 82 | // Check for supported combinations of host and target architectures. |
| 83 | #if defined(V8_TARGET_ARCH_IA32) && !defined(V8_HOST_ARCH_IA32) |
| 84 | #error Target architecture ia32 is only supported on ia32 host |
| 85 | #endif |
| 86 | #if defined(V8_TARGET_ARCH_X64) && !defined(V8_HOST_ARCH_X64) |
| 87 | #error Target architecture x64 is only supported on x64 host |
| 88 | #endif |
| 89 | #if (defined(V8_TARGET_ARCH_ARM) && \ |
| 90 | !(defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_ARM))) |
| 91 | #error Target architecture arm is only supported on arm and ia32 host |
| 92 | #endif |
| 93 | #if (defined(V8_TARGET_ARCH_MIPS) && \ |
| 94 | !(defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_MIPS))) |
| 95 | #error Target architecture mips is only supported on mips and ia32 host |
| 96 | #endif |
| 97 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 98 | // Determine whether we are running in a simulated environment. |
| 99 | // Setting USE_SIMULATOR explicitly from the build script will force |
| 100 | // the use of a simulated environment. |
| 101 | #if !defined(USE_SIMULATOR) |
| 102 | #if (defined(V8_TARGET_ARCH_ARM) && !defined(V8_HOST_ARCH_ARM)) |
| 103 | #define USE_SIMULATOR 1 |
| 104 | #endif |
| 105 | #if (defined(V8_TARGET_ARCH_MIPS) && !defined(V8_HOST_ARCH_MIPS)) |
| 106 | #define USE_SIMULATOR 1 |
| 107 | #endif |
| 108 | #endif |
| 109 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 110 | // Define unaligned read for the target architectures supporting it. |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 111 | #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_IA32) |
| 112 | #define V8_TARGET_CAN_READ_UNALIGNED 1 |
| 113 | #elif V8_TARGET_ARCH_ARM |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 114 | // Some CPU-OS combinations allow unaligned access on ARM. We assume |
| 115 | // that unaligned accesses are not allowed unless the build system |
| 116 | // defines the CAN_USE_UNALIGNED_ACCESSES macro to be non-zero. |
| 117 | #if CAN_USE_UNALIGNED_ACCESSES |
| 118 | #define V8_TARGET_CAN_READ_UNALIGNED 1 |
| 119 | #endif |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 120 | #elif V8_TARGET_ARCH_MIPS |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 121 | #else |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 122 | #error Target architecture is not supported by v8 |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 123 | #endif |
| 124 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 125 | // Support for alternative bool type. This is only enabled if the code is |
| 126 | // compiled with USE_MYBOOL defined. This catches some nasty type bugs. |
| 127 | // For instance, 'bool b = "false";' results in b == true! This is a hidden |
| 128 | // source of bugs. |
| 129 | // However, redefining the bool type does have some negative impact on some |
| 130 | // platforms. It gives rise to compiler warnings (i.e. with |
| 131 | // MSVC) in the API header files when mixing code that uses the standard |
| 132 | // bool with code that uses the redefined version. |
| 133 | // This does not actually belong in the platform code, but needs to be |
| 134 | // defined here because the platform code uses bool, and platform.h is |
| 135 | // include very early in the main include file. |
| 136 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 137 | #ifdef USE_MYBOOL |
| 138 | typedef unsigned int __my_bool__; |
| 139 | #define bool __my_bool__ // use 'indirection' to avoid name clashes |
| 140 | #endif |
| 141 | |
| 142 | typedef uint8_t byte; |
| 143 | typedef byte* Address; |
| 144 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 145 | // Define our own macros for writing 64-bit constants. This is less fragile |
| 146 | // than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it |
| 147 | // works on compilers that don't have it (like MSVC). |
| 148 | #if V8_HOST_ARCH_64_BIT |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 149 | #ifdef _MSC_VER |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 150 | #define V8_UINT64_C(x) (x ## UI64) |
| 151 | #define V8_INT64_C(x) (x ## I64) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 152 | #define V8_INTPTR_C(x) (x ## I64) |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 153 | #define V8_PTR_PREFIX "ll" |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 154 | #else // _MSC_VER |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 155 | #define V8_UINT64_C(x) (x ## UL) |
| 156 | #define V8_INT64_C(x) (x ## L) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 157 | #define V8_INTPTR_C(x) (x ## L) |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 158 | #define V8_PTR_PREFIX "l" |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 159 | #endif // _MSC_VER |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 160 | #else // V8_HOST_ARCH_64_BIT |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 161 | #define V8_INTPTR_C(x) (x) |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 162 | #define V8_PTR_PREFIX "" |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 163 | #endif // V8_HOST_ARCH_64_BIT |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 164 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 165 | // The following macro works on both 32 and 64-bit platforms. |
| 166 | // Usage: instead of writing 0x1234567890123456 |
| 167 | // write V8_2PART_UINT64_C(0x12345678,90123456); |
| 168 | #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) |
| 169 | |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 170 | #define V8PRIxPTR V8_PTR_PREFIX "x" |
| 171 | #define V8PRIdPTR V8_PTR_PREFIX "d" |
| 172 | |
| 173 | // Fix for Mac OS X defining uintptr_t as "unsigned long": |
| 174 | #if defined(__APPLE__) && defined(__MACH__) |
| 175 | #undef V8PRIxPTR |
| 176 | #define V8PRIxPTR "lx" |
| 177 | #endif |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 178 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 179 | #if (defined(__APPLE__) && defined(__MACH__)) || \ |
| 180 | defined(__FreeBSD__) || defined(__OpenBSD__) |
| 181 | #define USING_BSD_ABI |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 182 | #endif |
| 183 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 184 | // ----------------------------------------------------------------------------- |
| 185 | // Constants |
| 186 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 187 | const int KB = 1024; |
| 188 | const int MB = KB * KB; |
| 189 | const int GB = KB * KB * KB; |
| 190 | const int kMaxInt = 0x7FFFFFFF; |
| 191 | const int kMinInt = -kMaxInt - 1; |
| 192 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 193 | const uint32_t kMaxUInt32 = 0xFFFFFFFFu; |
| 194 | |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 195 | const int kCharSize = sizeof(char); // NOLINT |
| 196 | const int kShortSize = sizeof(short); // NOLINT |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 197 | const int kIntSize = sizeof(int); // NOLINT |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 198 | const int kDoubleSize = sizeof(double); // NOLINT |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 199 | const int kIntptrSize = sizeof(intptr_t); // NOLINT |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 200 | const int kPointerSize = sizeof(void*); // NOLINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 201 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 202 | #if V8_HOST_ARCH_64_BIT |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 203 | const int kPointerSizeLog2 = 3; |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 204 | const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 205 | const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF); |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 206 | #else |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 207 | const int kPointerSizeLog2 = 2; |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 208 | const intptr_t kIntptrSignBit = 0x80000000; |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 209 | const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu; |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 210 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 211 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 212 | const int kBitsPerByte = 8; |
| 213 | const int kBitsPerByteLog2 = 3; |
| 214 | const int kBitsPerPointer = kPointerSize * kBitsPerByte; |
| 215 | const int kBitsPerInt = kIntSize * kBitsPerByte; |
| 216 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 217 | // IEEE 754 single precision floating point number bit layout. |
| 218 | const uint32_t kBinary32SignMask = 0x80000000u; |
| 219 | const uint32_t kBinary32ExponentMask = 0x7f800000u; |
| 220 | const uint32_t kBinary32MantissaMask = 0x007fffffu; |
| 221 | const int kBinary32ExponentBias = 127; |
| 222 | const int kBinary32MaxExponent = 0xFE; |
| 223 | const int kBinary32MinExponent = 0x01; |
| 224 | const int kBinary32MantissaBits = 23; |
| 225 | const int kBinary32ExponentShift = 23; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 226 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 227 | // ASCII/UC16 constants |
| 228 | // Code-point values in Unicode 4.0 are 21 bits wide. |
| 229 | typedef uint16_t uc16; |
| 230 | typedef int32_t uc32; |
| 231 | const int kASCIISize = kCharSize; |
| 232 | const int kUC16Size = sizeof(uc16); // NOLINT |
| 233 | const uc32 kMaxAsciiCharCode = 0x7f; |
| 234 | const uint32_t kMaxAsciiCharCodeU = 0x7fu; |
| 235 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 236 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 237 | // The expression OFFSET_OF(type, field) computes the byte-offset |
| 238 | // of the specified field relative to the containing type. This |
| 239 | // corresponds to 'offsetof' (in stddef.h), except that it doesn't |
| 240 | // use 0 or NULL, which causes a problem with the compiler warnings |
| 241 | // we have enabled (which is also why 'offsetof' doesn't seem to work). |
| 242 | // Here we simply use the non-zero value 4, which seems to work. |
| 243 | #define OFFSET_OF(type, field) \ |
| 244 | (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4) |
| 245 | |
| 246 | |
| 247 | // The expression ARRAY_SIZE(a) is a compile-time constant of type |
| 248 | // size_t which represents the number of elements of the given |
| 249 | // array. You should only use ARRAY_SIZE on statically allocated |
| 250 | // arrays. |
| 251 | #define ARRAY_SIZE(a) \ |
| 252 | ((sizeof(a) / sizeof(*(a))) / \ |
| 253 | static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) |
| 254 | |
| 255 | |
| 256 | // The USE(x) template is used to silence C++ compiler warnings |
| 257 | // issued for (yet) unused variables (typically parameters). |
| 258 | template <typename T> |
| 259 | static inline void USE(T) { } |
| 260 | |
| 261 | |
| 262 | // FUNCTION_ADDR(f) gets the address of a C function f. |
| 263 | #define FUNCTION_ADDR(f) \ |
| 264 | (reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f))) |
| 265 | |
| 266 | |
| 267 | // FUNCTION_CAST<F>(addr) casts an address into a function |
| 268 | // of type F. Used to invoke generated code from within C. |
| 269 | template <typename F> |
| 270 | F FUNCTION_CAST(Address addr) { |
| 271 | return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | // A macro to disallow the evil copy constructor and operator= functions |
| 276 | // This should be used in the private: declarations for a class |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 277 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 278 | TypeName(const TypeName&); \ |
| 279 | void operator=(const TypeName&) |
| 280 | |
| 281 | |
| 282 | // A macro to disallow all the implicit constructors, namely the |
| 283 | // default constructor, copy constructor and operator= functions. |
| 284 | // |
| 285 | // This should be used in the private: declarations for a class |
| 286 | // that wants to prevent anyone from instantiating it. This is |
| 287 | // especially useful for classes containing only static methods. |
| 288 | #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
| 289 | TypeName(); \ |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 290 | DISALLOW_COPY_AND_ASSIGN(TypeName) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 291 | |
| 292 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 293 | // Define used for helping GCC to make better inlining. Don't bother for debug |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 294 | // builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation |
| 295 | // errors in debug build. |
| 296 | #if defined(__GNUC__) && !defined(DEBUG) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 297 | #if (__GNUC__ >= 4) |
| 298 | #define INLINE(header) inline header __attribute__((always_inline)) |
sgjesse@chromium.org | 76ae699 | 2010-08-05 15:54:25 +0000 | [diff] [blame] | 299 | #define NO_INLINE(header) header __attribute__((noinline)) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 300 | #else |
| 301 | #define INLINE(header) inline __attribute__((always_inline)) header |
sgjesse@chromium.org | 76ae699 | 2010-08-05 15:54:25 +0000 | [diff] [blame] | 302 | #define NO_INLINE(header) __attribute__((noinline)) header |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 303 | #endif |
| 304 | #else |
| 305 | #define INLINE(header) inline header |
sgjesse@chromium.org | 76ae699 | 2010-08-05 15:54:25 +0000 | [diff] [blame] | 306 | #define NO_INLINE(header) header |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 307 | #endif |
| 308 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 309 | |
| 310 | #if defined(__GNUC__) && __GNUC__ >= 4 |
| 311 | #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) |
| 312 | #else |
| 313 | #define MUST_USE_RESULT |
| 314 | #endif |
| 315 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 316 | // ----------------------------------------------------------------------------- |
| 317 | // Forward declarations for frequently used classes |
| 318 | // (sorted alphabetically) |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 319 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 320 | class FreeStoreAllocationPolicy; |
| 321 | template <typename T, class P = FreeStoreAllocationPolicy> class List; |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 322 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 323 | } } // namespace v8::internal |
| 324 | |
| 325 | #endif // V8_GLOBALS_H_ |