| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_GLOBALS_H_ | 28 #ifndef V8_GLOBALS_H_ |
| 29 #define V8_GLOBALS_H_ | 29 #define V8_GLOBALS_H_ |
| 30 | 30 |
| 31 // ---------------------------------------------------------------------------- | 31 // Define V8_INFINITY |
| 32 // Operating system detection (V8_OS_x) | 32 #define V8_INFINITY INFINITY |
| 33 // | |
| 34 // ANDROID - Android | |
| 35 // BSD4 - Any BSD 4.4 system | |
| 36 // CYGWIN - Cygwin | |
| 37 // DARWIN - Darwin / Mac OS X | |
| 38 // FREEBSD - FreeBSD | |
| 39 // LINUX - Linux | |
| 40 // NACL - Native Client | |
| 41 // NETBSD - NetBSD | |
| 42 // OPENBSD - OpenBSD | |
| 43 // SOLARIS - Solaris | |
| 44 // UNIX - Any UNIX BSD/SYSV system | |
| 45 // WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) | |
| 46 | 33 |
| 47 #if defined(ANDROID) || defined(__ANDROID__) | 34 // GCC specific stuff |
| 48 # define V8_OS_ANDROID 1 | 35 #ifdef __GNUC__ |
| 49 # define V8_OS_LINUX 1 | 36 |
| 50 # define V8_OS_UNIX 1 | 37 #define __GNUC_VERSION_FOR_INFTY__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) |
| 51 #elif defined(__APPLE__) && defined(__MACH__) | 38 |
| 52 # define V8_OS_DARWIN 1 | 39 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' |
| 53 # define V8_OS_BSD4 1 | 40 // warning flag and certain versions of GCC due to a bug: |
| 54 # define V8_OS_UNIX 1 | 41 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 |
| 55 #elif defined(__CYGWIN__) | 42 // For now, we use the more involved template-based version from <limits>, but |
| 56 # define V8_OS_CYGWIN 1 | 43 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) |
| 57 # define V8_OS_UNIX 1 | 44 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro |
| 58 #elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__) | 45 #if __GNUC_VERSION_FOR_INFTY__ >= 29600 && __GNUC_VERSION_FOR_INFTY__ < 40100 |
| 59 # define V8_OS_WIN32 1 | 46 #include <limits> |
| 60 # define V8_OS_WIN64 1 | 47 #undef V8_INFINITY |
| 61 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \ | 48 #define V8_INFINITY std::numeric_limits<double>::infinity() |
| 62 (defined(__MWERKS__) && defined(__INTEL__)) | 49 #endif |
| 63 # define V8_OS_WIN32 1 | 50 #undef __GNUC_VERSION_FOR_INFTY__ |
| 64 #elif defined(__sun) || defined(sun) | 51 |
| 65 # define V8_OS_SOLARIS 1 | 52 #endif // __GNUC__ |
| 66 # define V8_OS_UNIX 1 | 53 |
| 67 #elif defined(__native_client__) | 54 #ifdef _MSC_VER |
| 68 # define V8_OS_NACL 1 | 55 #undef V8_INFINITY |
| 69 # define V8_OS_UNIX 1 | 56 #define V8_INFINITY HUGE_VAL |
| 70 #elif defined(__linux__) || defined(__linux) | |
| 71 # define V8_OS_LINUX 1 | |
| 72 # define V8_OS_UNIX 1 | |
| 73 #elif defined(__FreeBSD__) || defined(__DragonFly__) | |
| 74 # define V8_OS_FREEBSD 1 | |
| 75 # define V8_OS_BSD4 1 | |
| 76 # define V8_OS_UNIX 1 | |
| 77 #elif defined(__NetBSD__) | |
| 78 # define V8_OS_NETBSD 1 | |
| 79 # define V8_OS_BSD4 1 | |
| 80 # define V8_OS_UNIX 1 | |
| 81 #elif defined(__OpenBSD__) | |
| 82 # define V8_OS_OPENBSD 1 | |
| 83 # define V8_OS_BSD4 1 | |
| 84 # define V8_OS_UNIX 1 | |
| 85 #else | |
| 86 # error Operating system was not detected as supported by v8 | |
| 87 #endif | 57 #endif |
| 88 | 58 |
| 89 | 59 |
| 90 // ---------------------------------------------------------------------------- | 60 #include "../include/v8stdint.h" |
| 91 // Compiler detection (V8_CC_x) | |
| 92 // | |
| 93 // CLANG - C++ front-end for the LLVM compiler | |
| 94 // GNU - GNU C++ or compatible | |
| 95 // INTEL - Intel C++ for Linux or Windows | |
| 96 // MINGW - Minimalistic GNU for Windows Compiler | |
| 97 // MIPS - MIPSpro C++ | |
| 98 // MSVC - Microsoft Visual C/C++ or compatible | |
| 99 // RVCT - ARM Realview Compiler Suite | |
| 100 | 61 |
| 101 #if defined(_MSC_VER) | 62 namespace v8 { |
| 102 # define V8_CC_MSVC 1 | 63 namespace internal { |
| 103 # if defined(__INTEL_COMPILER) | |
| 104 # define V8_CC_INTEL 1 | |
| 105 # endif | |
| 106 #elif defined(__GNUC__) | |
| 107 # define V8_CC_GNU 1 | |
| 108 # if defined(__MINGW64__) | |
| 109 # define V8_CC_MINGW 1 | |
| 110 # define V8_CC_MINGW64 1 | |
| 111 # elif defined(__MINGW32__) | |
| 112 # define V8_CC_MINGW 1 | |
| 113 # define V8_CC_MINGW32 1 | |
| 114 # elif defined(__ARMCC__) || defined(__CC_ARM) | |
| 115 # define V8_CC_RVCT 1 // ARM Realview Compiler Suite also masquerades as GCC | |
| 116 # elif defined(__INTEL_COMPILER) | |
| 117 # define V8_CC_INTEL 1 // Intel C++ also masquerades as GCC 3.2.0 | |
| 118 # elif defined(__clang__) | |
| 119 # define V8_CC_CLANG 1 // Clang also masquerades as GCC 4.2.1 | |
| 120 # ifndef __has_extension | |
| 121 # define __has_extension __has_feature // Compatibility with older releases | |
| 122 # endif | |
| 123 # endif | |
| 124 #elif defined(__ARMCC__) || defined(__CC_ARM) | |
| 125 # define V8_CC_RVCT 1 | |
| 126 #elif defined(__INTEL_COMPILER) | |
| 127 # define V8_CC_INTEL 1 | |
| 128 #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) | |
| 129 # define V8_CC_SUN 1 | |
| 130 #else | |
| 131 # error Compiler was not detected as supported by v8 | |
| 132 #endif | |
| 133 | 64 |
| 134 #if V8_CC_GNU | 65 // Processor architecture detection. For more info on what's defined, see: |
| 135 # define V8_GNUC_PREREQ(major, minor) \ | |
| 136 (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) | |
| 137 #else | |
| 138 # define V8_GNUC_PREREQ(major, minor) 0 | |
| 139 #endif // V8_CC_GNU | |
| 140 | |
| 141 | |
| 142 // ---------------------------------------------------------------------------- | |
| 143 // Compiler features | |
| 144 | |
| 145 // C++11 deleted functions | |
| 146 #if __cplusplus >= 201103L | |
| 147 # define V8_CXX_DELETED_FUNCTIONS 1 | |
| 148 #elif V8_CC_CLANG | |
| 149 # define V8_CXX_DELETED_FUNCTIONS __has_feature(cxx_deleted_functions) | |
| 150 #else | |
| 151 # define V8_CXX_DELETED_FUNCTIONS (defined(__GXX_EXPERIMENTAL_CXX0X__) && \ | |
| 152 V8_GNUC_PREREQ(4, 4)) | |
| 153 #endif | |
| 154 | |
| 155 // C++11 static_assert() | |
| 156 #if __cplusplus >= 201103L | |
| 157 # define V8_CXX_STATIC_ASSERT 1 | |
| 158 #elif V8_CC_CLANG | |
| 159 # define V8_CXX_STATIC_ASSERT (__has_extension(cxx_static_assert) || \ | |
| 160 __has_feature(cxx_static_assert)) | |
| 161 #else | |
| 162 # define V8_CXX_STATIC_ASSERT (defined(__GXX_EXPERIMENTAL_CXX0X__) && \ | |
| 163 V8_GNUC_PREREQ(4, 3)) | |
| 164 #endif | |
| 165 | |
| 166 | |
| 167 // ---------------------------------------------------------------------------- | |
| 168 // Host architecture detection. For more info on what's defined, see: | |
| 169 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 66 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 170 // http://www.agner.org/optimize/calling_conventions.pdf | 67 // http://www.agner.org/optimize/calling_conventions.pdf |
| 171 // or with gcc, run: "echo | gcc -E -dM -" | 68 // or with gcc, run: "echo | gcc -E -dM -" |
| 172 | |
| 173 #if defined(_M_X64) || defined(__x86_64__) | 69 #if defined(_M_X64) || defined(__x86_64__) |
| 174 # if V8_OS_NACL | 70 #if defined(__native_client__) |
| 175 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8 | 71 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8 |
| 176 // generates ARM machine code, together with a portable ARM simulator | 72 // generates ARM machine code, together with a portable ARM simulator |
| 177 // compiled for the host architecture in question. | 73 // compiled for the host architecture in question. |
| 178 // | 74 // |
| 179 // Since Native Client is ILP-32 on all architectures we use | 75 // Since Native Client is ILP-32 on all architectures we use |
| 180 // V8_HOST_ARCH_IA32 on both 32- and 64-bit x86. | 76 // V8_HOST_ARCH_IA32 on both 32- and 64-bit x86. |
| 181 # define V8_HOST_ARCH_IA32 1 | 77 #define V8_HOST_ARCH_IA32 1 |
| 182 # define V8_HOST_ARCH_32_BIT 1 | 78 #define V8_HOST_ARCH_32_BIT 1 |
| 183 # define V8_HOST_CAN_READ_UNALIGNED 1 | 79 #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 184 # else | 80 #else |
| 185 # define V8_HOST_ARCH_X64 1 | 81 #define V8_HOST_ARCH_X64 1 |
| 186 # define V8_HOST_ARCH_64_BIT 1 | 82 #define V8_HOST_ARCH_64_BIT 1 |
| 187 # define V8_HOST_CAN_READ_UNALIGNED 1 | 83 #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 188 # endif // V8_OS_NACL | 84 #endif // __native_client__ |
| 189 #elif defined(_M_IX86) || defined(__i386__) | 85 #elif defined(_M_IX86) || defined(__i386__) |
| 190 # define V8_HOST_ARCH_IA32 1 | 86 #define V8_HOST_ARCH_IA32 1 |
| 191 # define V8_HOST_ARCH_32_BIT 1 | 87 #define V8_HOST_ARCH_32_BIT 1 |
| 192 # define V8_HOST_CAN_READ_UNALIGNED 1 | 88 #define V8_HOST_CAN_READ_UNALIGNED 1 |
| 193 #elif defined(__ARMEL__) | 89 #elif defined(__ARMEL__) |
| 194 # define V8_HOST_ARCH_ARM 1 | 90 #define V8_HOST_ARCH_ARM 1 |
| 195 # define V8_HOST_ARCH_32_BIT 1 | 91 #define V8_HOST_ARCH_32_BIT 1 |
| 196 #elif defined(__MIPSEL__) | 92 #elif defined(__MIPSEL__) |
| 197 # define V8_HOST_ARCH_MIPS 1 | 93 #define V8_HOST_ARCH_MIPS 1 |
| 198 # define V8_HOST_ARCH_32_BIT 1 | 94 #define V8_HOST_ARCH_32_BIT 1 |
| 199 #else | 95 #else |
| 200 # error Host architecture was not detected as supported by v8 | 96 #error Host architecture was not detected as supported by v8 |
| 201 #endif | 97 #endif |
| 202 | 98 |
| 203 #if defined(__ARM_ARCH_7A__) || \ | 99 #if defined(__ARM_ARCH_7A__) || \ |
| 204 defined(__ARM_ARCH_7R__) || \ | 100 defined(__ARM_ARCH_7R__) || \ |
| 205 defined(__ARM_ARCH_7__) | 101 defined(__ARM_ARCH_7__) |
| 206 # define CAN_USE_ARMV7_INSTRUCTIONS 1 | 102 # define CAN_USE_ARMV7_INSTRUCTIONS 1 |
| 207 # ifndef CAN_USE_VFP3_INSTRUCTIONS | 103 # ifndef CAN_USE_VFP3_INSTRUCTIONS |
| 208 # define CAN_USE_VFP3_INSTRUCTIONS 1 | 104 # define CAN_USE_VFP3_INSTRUCTIONS |
| 209 # endif | 105 # endif |
| 210 #endif | 106 #endif |
| 211 | 107 |
| 212 | 108 |
| 213 // ---------------------------------------------------------------------------- | |
| 214 // Target architecture detection. This may be set externally. If not, detect | 109 // Target architecture detection. This may be set externally. If not, detect |
| 215 // in the same way as the host architecture, that is, target the native | 110 // in the same way as the host architecture, that is, target the native |
| 216 // environment as presented by the compiler. | 111 // environment as presented by the compiler. |
| 217 | |
| 218 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && \ | 112 #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && \ |
| 219 !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS | 113 !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS |
| 220 # if defined(_M_X64) || defined(__x86_64__) | 114 #if defined(_M_X64) || defined(__x86_64__) |
| 221 # define V8_TARGET_ARCH_X64 1 | 115 #define V8_TARGET_ARCH_X64 1 |
| 222 # elif defined(_M_IX86) || defined(__i386__) | 116 #elif defined(_M_IX86) || defined(__i386__) |
| 223 # define V8_TARGET_ARCH_IA32 1 | 117 #define V8_TARGET_ARCH_IA32 1 |
| 224 # elif defined(__ARMEL__) | 118 #elif defined(__ARMEL__) |
| 225 # define V8_TARGET_ARCH_ARM 1 | 119 #define V8_TARGET_ARCH_ARM 1 |
| 226 # elif defined(__MIPSEL__) | 120 #elif defined(__MIPSEL__) |
| 227 # define V8_TARGET_ARCH_MIPS 1 | 121 #define V8_TARGET_ARCH_MIPS 1 |
| 228 # else | 122 #else |
| 229 # error Target architecture was not detected as supported by v8 | 123 #error Target architecture was not detected as supported by v8 |
| 230 # endif | 124 #endif |
| 231 #endif | 125 #endif |
| 232 | 126 |
| 233 // Check for supported combinations of host and target architectures. | 127 // Check for supported combinations of host and target architectures. |
| 234 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32 | 128 #if V8_TARGET_ARCH_IA32 && !V8_HOST_ARCH_IA32 |
| 235 # error Target architecture ia32 is only supported on ia32 host | 129 #error Target architecture ia32 is only supported on ia32 host |
| 236 #elif V8_TARGET_ARCH_X64 && !V8_HOST_ARCH_X64 | 130 #endif |
| 237 # error Target architecture x64 is only supported on x64 host | 131 #if V8_TARGET_ARCH_X64 && !V8_HOST_ARCH_X64 |
| 238 #elif V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM) | 132 #error Target architecture x64 is only supported on x64 host |
| 239 # error Target architecture arm is only supported on arm and ia32 host | 133 #endif |
| 240 #elif V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS) | 134 #if (V8_TARGET_ARCH_ARM && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_ARM)) |
| 241 # error Target architecture mips is only supported on mips and ia32 host | 135 #error Target architecture arm is only supported on arm and ia32 host |
| 136 #endif |
| 137 #if (V8_TARGET_ARCH_MIPS && !(V8_HOST_ARCH_IA32 || V8_HOST_ARCH_MIPS)) |
| 138 #error Target architecture mips is only supported on mips and ia32 host |
| 242 #endif | 139 #endif |
| 243 | 140 |
| 244 // Determine whether we are running in a simulated environment. | 141 // Determine whether we are running in a simulated environment. |
| 245 // Setting USE_SIMULATOR explicitly from the build script will force | 142 // Setting USE_SIMULATOR explicitly from the build script will force |
| 246 // the use of a simulated environment. | 143 // the use of a simulated environment. |
| 247 #if !defined(USE_SIMULATOR) | 144 #if !defined(USE_SIMULATOR) |
| 248 # if V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM | 145 #if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM) |
| 249 # define USE_SIMULATOR 1 | 146 #define USE_SIMULATOR 1 |
| 250 # elif V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS | 147 #endif |
| 251 # define USE_SIMULATOR 1 | 148 #if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS) |
| 252 # endif | 149 #define USE_SIMULATOR 1 |
| 150 #endif |
| 253 #endif | 151 #endif |
| 254 | 152 |
| 255 // Determine architecture endiannes (we only support little-endian). | 153 // Determine architecture endiannes (we only support little-endian). |
| 256 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || \ | 154 #if V8_TARGET_ARCH_IA32 |
| 257 V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | 155 #define V8_TARGET_LITTLE_ENDIAN 1 |
| 258 # define V8_TARGET_LITTLE_ENDIAN 1 | 156 #elif V8_TARGET_ARCH_X64 |
| 157 #define V8_TARGET_LITTLE_ENDIAN 1 |
| 158 #elif V8_TARGET_ARCH_ARM |
| 159 #define V8_TARGET_LITTLE_ENDIAN 1 |
| 160 #elif V8_TARGET_ARCH_MIPS |
| 161 #define V8_TARGET_LITTLE_ENDIAN 1 |
| 259 #else | 162 #else |
| 260 # error Unknown target architecture endiannes | 163 #error Unknown target architecture endiannes |
| 261 #endif | 164 #endif |
| 262 | 165 |
| 263 | |
| 264 // ---------------------------------------------------------------------------- | |
| 265 // Define our own macros for writing 64-bit constants. This is less fragile | |
| 266 // than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it | |
| 267 // works on compilers that don't have it (like MSVC). | |
| 268 #if V8_HOST_ARCH_64_BIT | |
| 269 # if V8_CC_MSVC | |
| 270 # define V8_UINT64_C(x) (x ## UI64) | |
| 271 # define V8_INT64_C(x) (x ## I64) | |
| 272 # define V8_INTPTR_C(x) (x ## I64) | |
| 273 # define V8_PTR_PREFIX "ll" | |
| 274 # elif V8_CC_MINGW | |
| 275 # define V8_UINT64_C(x) (x ## ULL) | |
| 276 # define V8_INT64_C(x) (x ## LL) | |
| 277 # define V8_INTPTR_C(x) (x ## LL) | |
| 278 # define V8_PTR_PREFIX "I64" | |
| 279 # else | |
| 280 # define V8_UINT64_C(x) (x ## UL) | |
| 281 # define V8_INT64_C(x) (x ## L) | |
| 282 # define V8_INTPTR_C(x) (x ## L) | |
| 283 # define V8_PTR_PREFIX "l" | |
| 284 # endif | |
| 285 #else // V8_HOST_ARCH_64_BIT | |
| 286 # define V8_INTPTR_C(x) (x) | |
| 287 # define V8_PTR_PREFIX "" | |
| 288 #endif // V8_HOST_ARCH_64_BIT | |
| 289 | |
| 290 // The following macro works on both 32 and 64-bit platforms. | |
| 291 // Usage: instead of writing 0x1234567890123456 | |
| 292 // write V8_2PART_UINT64_C(0x12345678,90123456); | |
| 293 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) | |
| 294 | |
| 295 #if V8_OS_DARWIN | |
| 296 // Fix for Mac OS X defining uintptr_t as "unsigned long": | |
| 297 # define V8PRIxPTR "lx" | |
| 298 #else | |
| 299 # define V8PRIxPTR V8_PTR_PREFIX "x" | |
| 300 #endif // V8_OS_DARWIN | |
| 301 #define V8PRIdPTR V8_PTR_PREFIX "d" | |
| 302 #define V8PRIuPTR V8_PTR_PREFIX "u" | |
| 303 | |
| 304 | |
| 305 // ---------------------------------------------------------------------------- | |
| 306 // Define V8_INFINITY | |
| 307 #if V8_GNUC_PREREQ(2, 96) && !V8_GNUC_PREREQ(4, 1) | |
| 308 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' | |
| 309 // warning flag and certain versions of GCC due to a bug: | |
| 310 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 | |
| 311 // For now, we use the more involved template-based version from <limits>, but | |
| 312 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) | |
| 313 # include <limits> | |
| 314 # define V8_INFINITY std::numeric_limits<double>::infinity() | |
| 315 #elif V8_CC_MSVC | |
| 316 # define V8_INFINITY HUGE_VAL | |
| 317 #else | |
| 318 # define V8_INFINITY INFINITY | |
| 319 #endif | |
| 320 | |
| 321 | |
| 322 #include "../include/v8stdint.h" | |
| 323 | |
| 324 namespace v8 { | |
| 325 namespace internal { | |
| 326 | |
| 327 // Support for alternative bool type. This is only enabled if the code is | 166 // Support for alternative bool type. This is only enabled if the code is |
| 328 // compiled with USE_MYBOOL defined. This catches some nasty type bugs. | 167 // compiled with USE_MYBOOL defined. This catches some nasty type bugs. |
| 329 // For instance, 'bool b = "false";' results in b == true! This is a hidden | 168 // For instance, 'bool b = "false";' results in b == true! This is a hidden |
| 330 // source of bugs. | 169 // source of bugs. |
| 331 // However, redefining the bool type does have some negative impact on some | 170 // However, redefining the bool type does have some negative impact on some |
| 332 // platforms. It gives rise to compiler warnings (i.e. with | 171 // platforms. It gives rise to compiler warnings (i.e. with |
| 333 // MSVC) in the API header files when mixing code that uses the standard | 172 // MSVC) in the API header files when mixing code that uses the standard |
| 334 // bool with code that uses the redefined version. | 173 // bool with code that uses the redefined version. |
| 335 // This does not actually belong in the platform code, but needs to be | 174 // This does not actually belong in the platform code, but needs to be |
| 336 // defined here because the platform code uses bool, and platform.h is | 175 // defined here because the platform code uses bool, and platform.h is |
| 337 // include very early in the main include file. | 176 // include very early in the main include file. |
| 338 | 177 |
| 339 #ifdef USE_MYBOOL | 178 #ifdef USE_MYBOOL |
| 340 typedef unsigned int __my_bool__; | 179 typedef unsigned int __my_bool__; |
| 341 #define bool __my_bool__ // use 'indirection' to avoid name clashes | 180 #define bool __my_bool__ // use 'indirection' to avoid name clashes |
| 342 #endif | 181 #endif |
| 343 | 182 |
| 344 typedef uint8_t byte; | 183 typedef uint8_t byte; |
| 345 typedef byte* Address; | 184 typedef byte* Address; |
| 346 | 185 |
| 186 // Define our own macros for writing 64-bit constants. This is less fragile |
| 187 // than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it |
| 188 // works on compilers that don't have it (like MSVC). |
| 189 #if V8_HOST_ARCH_64_BIT |
| 190 #if defined(_MSC_VER) |
| 191 #define V8_UINT64_C(x) (x ## UI64) |
| 192 #define V8_INT64_C(x) (x ## I64) |
| 193 #define V8_INTPTR_C(x) (x ## I64) |
| 194 #define V8_PTR_PREFIX "ll" |
| 195 #elif defined(__MINGW64__) |
| 196 #define V8_UINT64_C(x) (x ## ULL) |
| 197 #define V8_INT64_C(x) (x ## LL) |
| 198 #define V8_INTPTR_C(x) (x ## LL) |
| 199 #define V8_PTR_PREFIX "I64" |
| 200 #else |
| 201 #define V8_UINT64_C(x) (x ## UL) |
| 202 #define V8_INT64_C(x) (x ## L) |
| 203 #define V8_INTPTR_C(x) (x ## L) |
| 204 #define V8_PTR_PREFIX "l" |
| 205 #endif |
| 206 #else // V8_HOST_ARCH_64_BIT |
| 207 #define V8_INTPTR_C(x) (x) |
| 208 #define V8_PTR_PREFIX "" |
| 209 #endif // V8_HOST_ARCH_64_BIT |
| 210 |
| 211 // The following macro works on both 32 and 64-bit platforms. |
| 212 // Usage: instead of writing 0x1234567890123456 |
| 213 // write V8_2PART_UINT64_C(0x12345678,90123456); |
| 214 #define V8_2PART_UINT64_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) |
| 215 |
| 216 #define V8PRIxPTR V8_PTR_PREFIX "x" |
| 217 #define V8PRIdPTR V8_PTR_PREFIX "d" |
| 218 #define V8PRIuPTR V8_PTR_PREFIX "u" |
| 219 |
| 220 // Fix for Mac OS X defining uintptr_t as "unsigned long": |
| 221 #if defined(__APPLE__) && defined(__MACH__) |
| 222 #undef V8PRIxPTR |
| 223 #define V8PRIxPTR "lx" |
| 224 #endif |
| 225 |
| 226 #if (defined(__APPLE__) && defined(__MACH__)) || \ |
| 227 defined(__FreeBSD__) || defined(__OpenBSD__) |
| 228 #define USING_BSD_ABI |
| 229 #endif |
| 230 |
| 347 // ----------------------------------------------------------------------------- | 231 // ----------------------------------------------------------------------------- |
| 348 // Constants | 232 // Constants |
| 349 | 233 |
| 350 const int KB = 1024; | 234 const int KB = 1024; |
| 351 const int MB = KB * KB; | 235 const int MB = KB * KB; |
| 352 const int GB = KB * KB * KB; | 236 const int GB = KB * KB * KB; |
| 353 const int kMaxInt = 0x7FFFFFFF; | 237 const int kMaxInt = 0x7FFFFFFF; |
| 354 const int kMinInt = -kMaxInt - 1; | 238 const int kMinInt = -kMaxInt - 1; |
| 355 | 239 |
| 356 const uint32_t kMaxUInt32 = 0xFFFFFFFFu; | 240 const uint32_t kMaxUInt32 = 0xFFFFFFFFu; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 323 |
| 440 | 324 |
| 441 // FUNCTION_CAST<F>(addr) casts an address into a function | 325 // FUNCTION_CAST<F>(addr) casts an address into a function |
| 442 // of type F. Used to invoke generated code from within C. | 326 // of type F. Used to invoke generated code from within C. |
| 443 template <typename F> | 327 template <typename F> |
| 444 F FUNCTION_CAST(Address addr) { | 328 F FUNCTION_CAST(Address addr) { |
| 445 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); | 329 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
| 446 } | 330 } |
| 447 | 331 |
| 448 | 332 |
| 449 #if V8_CXX_DELETED_FUNCTIONS | 333 #if __cplusplus >= 201103L |
| 450 # define DISALLOW_BY_DELETE = delete | 334 #define DISALLOW_BY_DELETE = delete |
| 451 #else | 335 #else |
| 452 # define DISALLOW_BY_DELETE | 336 #define DISALLOW_BY_DELETE |
| 453 #endif | 337 #endif |
| 454 | 338 |
| 455 | 339 |
| 456 // A macro to disallow the evil copy constructor and operator= functions | 340 // A macro to disallow the evil copy constructor and operator= functions |
| 457 // This should be used in the private: declarations for a class | 341 // This should be used in the private: declarations for a class |
| 458 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 342 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 459 TypeName(const TypeName&) DISALLOW_BY_DELETE; \ | 343 TypeName(const TypeName&) DISALLOW_BY_DELETE; \ |
| 460 void operator=(const TypeName&) DISALLOW_BY_DELETE | 344 void operator=(const TypeName&) DISALLOW_BY_DELETE |
| 461 | 345 |
| 462 | 346 |
| 463 // A macro to disallow all the implicit constructors, namely the | 347 // A macro to disallow all the implicit constructors, namely the |
| 464 // default constructor, copy constructor and operator= functions. | 348 // default constructor, copy constructor and operator= functions. |
| 465 // | 349 // |
| 466 // This should be used in the private: declarations for a class | 350 // This should be used in the private: declarations for a class |
| 467 // that wants to prevent anyone from instantiating it. This is | 351 // that wants to prevent anyone from instantiating it. This is |
| 468 // especially useful for classes containing only static methods. | 352 // especially useful for classes containing only static methods. |
| 469 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ | 353 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
| 470 TypeName() DISALLOW_BY_DELETE; \ | 354 TypeName() DISALLOW_BY_DELETE; \ |
| 471 DISALLOW_COPY_AND_ASSIGN(TypeName) | 355 DISALLOW_COPY_AND_ASSIGN(TypeName) |
| 472 | 356 |
| 473 | 357 |
| 474 // Define used for helping GCC to make better inlining. Don't bother for debug | 358 // Define used for helping GCC to make better inlining. Don't bother for debug |
| 475 // builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation | 359 // builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation |
| 476 // errors in debug build. | 360 // errors in debug build. |
| 477 #if V8_GNUC_PREREQ(4, 0) && !defined(DEBUG) | 361 #if defined(__GNUC__) && !defined(DEBUG) |
| 478 # define INLINE(header) inline header __attribute__((always_inline)) | 362 #if (__GNUC__ >= 4) |
| 479 # define NO_INLINE(header) header __attribute__((noinline)) | 363 #define INLINE(header) inline header __attribute__((always_inline)) |
| 480 #elif V8_CC_GNU && !defined(DEBUG) | 364 #define NO_INLINE(header) header __attribute__((noinline)) |
| 481 # define INLINE(header) inline __attribute__((always_inline)) header | |
| 482 # define NO_INLINE(header) __attribute__((noinline)) header | |
| 483 #elif V8_CC_MSVC && !defined(DEBUG) | |
| 484 # define INLINE(header) __forceinline header | |
| 485 # define NO_INLINE(header) header | |
| 486 #else | 365 #else |
| 487 # define INLINE(header) inline header | 366 #define INLINE(header) inline __attribute__((always_inline)) header |
| 488 # define NO_INLINE(header) header | 367 #define NO_INLINE(header) __attribute__((noinline)) header |
| 368 #endif |
| 369 #elif defined(_MSC_VER) && !defined(DEBUG) |
| 370 #define INLINE(header) __forceinline header |
| 371 #define NO_INLINE(header) header |
| 372 #else |
| 373 #define INLINE(header) inline header |
| 374 #define NO_INLINE(header) header |
| 489 #endif | 375 #endif |
| 490 | 376 |
| 491 | 377 |
| 492 #if V8_GNUC_PREREQ(4, 0) | 378 #if defined(__GNUC__) && __GNUC__ >= 4 |
| 493 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) | 379 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) |
| 494 #else | 380 #else |
| 495 #define MUST_USE_RESULT | 381 #define MUST_USE_RESULT |
| 496 #endif | 382 #endif |
| 497 | 383 |
| 498 | 384 |
| 499 // Define DISABLE_ASAN macros. | 385 // Define DISABLE_ASAN macros. |
| 500 #if defined(__has_feature) | 386 #if defined(__has_feature) |
| 501 #if __has_feature(address_sanitizer) | 387 #if __has_feature(address_sanitizer) |
| 502 #define DISABLE_ASAN __attribute__((no_address_safety_analysis)) | 388 #define DISABLE_ASAN __attribute__((no_address_safety_analysis)) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // the backend, so both modes are represented by the kStrictMode value. | 443 // the backend, so both modes are represented by the kStrictMode value. |
| 558 enum StrictModeFlag { | 444 enum StrictModeFlag { |
| 559 kNonStrictMode, | 445 kNonStrictMode, |
| 560 kStrictMode | 446 kStrictMode |
| 561 }; | 447 }; |
| 562 | 448 |
| 563 | 449 |
| 564 } } // namespace v8::internal | 450 } } // namespace v8::internal |
| 565 | 451 |
| 566 #endif // V8_GLOBALS_H_ | 452 #endif // V8_GLOBALS_H_ |
| OLD | NEW |