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