Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_GLOBALS_H_ |
| 6 | #define V8_GLOBALS_H_ |
| 7 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 10 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 11 | #include <ostream> |
| 12 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 13 | #include "src/base/build_config.h" |
| 14 | #include "src/base/logging.h" |
| 15 | #include "src/base/macros.h" |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 16 | |
| 17 | // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' |
| 18 | // warning flag and certain versions of GCC due to a bug: |
| 19 | // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 |
| 20 | // For now, we use the more involved template-based version from <limits>, but |
| 21 | // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 22 | #if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0) |
| 23 | # include <limits> // NOLINT |
| 24 | # define V8_INFINITY std::numeric_limits<double>::infinity() |
| 25 | #elif V8_LIBC_MSVCRT |
| 26 | # define V8_INFINITY HUGE_VAL |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 27 | #elif V8_OS_AIX |
| 28 | #define V8_INFINITY (__builtin_inff()) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 29 | #else |
| 30 | # define V8_INFINITY INFINITY |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 31 | #endif |
| 32 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 33 | namespace v8 { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 34 | |
| 35 | namespace base { |
| 36 | class Mutex; |
| 37 | class RecursiveMutex; |
| 38 | class VirtualMemory; |
| 39 | } |
| 40 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 41 | namespace internal { |
| 42 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 43 | // Determine whether we are running in a simulated environment. |
| 44 | // Setting USE_SIMULATOR explicitly from the build script will force |
| 45 | // the use of a simulated environment. |
| 46 | #if !defined(USE_SIMULATOR) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 47 | #if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64) |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 48 | #define USE_SIMULATOR 1 |
| 49 | #endif |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 50 | #if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM) |
| 51 | #define USE_SIMULATOR 1 |
| 52 | #endif |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 53 | #if (V8_TARGET_ARCH_PPC && !V8_HOST_ARCH_PPC) |
| 54 | #define USE_SIMULATOR 1 |
| 55 | #endif |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 56 | #if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS) |
| 57 | #define USE_SIMULATOR 1 |
| 58 | #endif |
| 59 | #if (V8_TARGET_ARCH_MIPS64 && !V8_HOST_ARCH_MIPS64) |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 60 | #define USE_SIMULATOR 1 |
| 61 | #endif |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 62 | #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) |
| 63 | #define USE_SIMULATOR 1 |
| 64 | #endif |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 65 | #endif |
| 66 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 67 | // Determine whether the architecture uses an embedded constant pool |
| 68 | // (contiguous constant pool embedded in code object). |
| 69 | #if V8_TARGET_ARCH_PPC |
| 70 | #define V8_EMBEDDED_CONSTANT_POOL 1 |
| 71 | #else |
| 72 | #define V8_EMBEDDED_CONSTANT_POOL 0 |
| 73 | #endif |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 74 | |
| 75 | #ifdef V8_TARGET_ARCH_ARM |
| 76 | // Set stack limit lower for ARM than for other architectures because |
| 77 | // stack allocating MacroAssembler takes 120K bytes. |
| 78 | // See issue crbug.com/405338 |
| 79 | #define V8_DEFAULT_STACK_SIZE_KB 864 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 80 | #else |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 81 | // Slightly less than 1MB, since Windows' default stack size for |
| 82 | // the main execution thread is 1MB for both 32 and 64-bit. |
| 83 | #define V8_DEFAULT_STACK_SIZE_KB 984 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 86 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 87 | // Determine whether double field unboxing feature is enabled. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 88 | #if V8_TARGET_ARCH_64_BIT |
| 89 | #define V8_DOUBLE_FIELDS_UNBOXING 1 |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 90 | #else |
| 91 | #define V8_DOUBLE_FIELDS_UNBOXING 0 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 92 | #endif |
| 93 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 94 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 95 | typedef uint8_t byte; |
| 96 | typedef byte* Address; |
| 97 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 98 | // ----------------------------------------------------------------------------- |
| 99 | // Constants |
| 100 | |
| 101 | const int KB = 1024; |
| 102 | const int MB = KB * KB; |
| 103 | const int GB = KB * KB * KB; |
| 104 | const int kMaxInt = 0x7FFFFFFF; |
| 105 | const int kMinInt = -kMaxInt - 1; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 106 | const int kMaxInt8 = (1 << 7) - 1; |
| 107 | const int kMinInt8 = -(1 << 7); |
| 108 | const int kMaxUInt8 = (1 << 8) - 1; |
| 109 | const int kMinUInt8 = 0; |
| 110 | const int kMaxInt16 = (1 << 15) - 1; |
| 111 | const int kMinInt16 = -(1 << 15); |
| 112 | const int kMaxUInt16 = (1 << 16) - 1; |
| 113 | const int kMinUInt16 = 0; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 114 | |
| 115 | const uint32_t kMaxUInt32 = 0xFFFFFFFFu; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 116 | const int kMinUInt32 = 0; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 117 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 118 | const int kCharSize = sizeof(char); // NOLINT |
| 119 | const int kShortSize = sizeof(short); // NOLINT |
| 120 | const int kIntSize = sizeof(int); // NOLINT |
| 121 | const int kInt32Size = sizeof(int32_t); // NOLINT |
| 122 | const int kInt64Size = sizeof(int64_t); // NOLINT |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 123 | const int kFloatSize = sizeof(float); // NOLINT |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 124 | const int kDoubleSize = sizeof(double); // NOLINT |
| 125 | const int kIntptrSize = sizeof(intptr_t); // NOLINT |
| 126 | const int kPointerSize = sizeof(void*); // NOLINT |
| 127 | #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT |
| 128 | const int kRegisterSize = kPointerSize + kPointerSize; |
| 129 | #else |
| 130 | const int kRegisterSize = kPointerSize; |
| 131 | #endif |
| 132 | const int kPCOnStackSize = kRegisterSize; |
| 133 | const int kFPOnStackSize = kRegisterSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 134 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 135 | #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
| 136 | const int kElidedFrameSlots = kPCOnStackSize / kPointerSize; |
| 137 | #else |
| 138 | const int kElidedFrameSlots = 0; |
| 139 | #endif |
| 140 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 141 | const int kDoubleSizeLog2 = 3; |
| 142 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 143 | #if V8_HOST_ARCH_64_BIT |
| 144 | const int kPointerSizeLog2 = 3; |
| 145 | const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 146 | const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 147 | const bool kRequiresCodeRange = true; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 148 | #if V8_TARGET_ARCH_MIPS64 |
| 149 | // To use pseudo-relative jumps such as j/jal instructions which have 28-bit |
| 150 | // encoded immediate, the addresses have to be in range of 256MB aligned |
| 151 | // region. Used only for large object space. |
| 152 | const size_t kMaximalCodeRangeSize = 256 * MB; |
| 153 | #else |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 154 | const size_t kMaximalCodeRangeSize = 512 * MB; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 155 | #endif |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 156 | #if V8_OS_WIN |
| 157 | const size_t kMinimumCodeRangeSize = 4 * MB; |
| 158 | const size_t kReservedCodeRangePages = 1; |
| 159 | #else |
| 160 | const size_t kMinimumCodeRangeSize = 3 * MB; |
| 161 | const size_t kReservedCodeRangePages = 0; |
| 162 | #endif |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 163 | #else |
| 164 | const int kPointerSizeLog2 = 2; |
| 165 | const intptr_t kIntptrSignBit = 0x80000000; |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 166 | const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 167 | #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT |
| 168 | // x32 port also requires code range. |
| 169 | const bool kRequiresCodeRange = true; |
| 170 | const size_t kMaximalCodeRangeSize = 256 * MB; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 171 | const size_t kMinimumCodeRangeSize = 3 * MB; |
| 172 | const size_t kReservedCodeRangePages = 0; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 173 | #else |
| 174 | const bool kRequiresCodeRange = false; |
| 175 | const size_t kMaximalCodeRangeSize = 0 * MB; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 176 | const size_t kMinimumCodeRangeSize = 0 * MB; |
| 177 | const size_t kReservedCodeRangePages = 0; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 178 | #endif |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 179 | #endif |
| 180 | |
| 181 | STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 182 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 183 | const int kBitsPerByte = 8; |
| 184 | const int kBitsPerByteLog2 = 3; |
| 185 | const int kBitsPerPointer = kPointerSize * kBitsPerByte; |
| 186 | const int kBitsPerInt = kIntSize * kBitsPerByte; |
| 187 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 188 | // IEEE 754 single precision floating point number bit layout. |
| 189 | const uint32_t kBinary32SignMask = 0x80000000u; |
| 190 | const uint32_t kBinary32ExponentMask = 0x7f800000u; |
| 191 | const uint32_t kBinary32MantissaMask = 0x007fffffu; |
| 192 | const int kBinary32ExponentBias = 127; |
| 193 | const int kBinary32MaxExponent = 0xFE; |
| 194 | const int kBinary32MinExponent = 0x01; |
| 195 | const int kBinary32MantissaBits = 23; |
| 196 | const int kBinary32ExponentShift = 23; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 198 | // Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no |
| 199 | // other bits set. |
| 200 | const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51; |
| 201 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 202 | // Latin1/UTF-16 constants |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 203 | // Code-point values in Unicode 4.0 are 21 bits wide. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 204 | // Code units in UTF-16 are 16 bits wide. |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 205 | typedef uint16_t uc16; |
| 206 | typedef int32_t uc32; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 207 | const int kOneByteSize = kCharSize; |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 208 | const int kUC16Size = sizeof(uc16); // NOLINT |
Steve Block | 9fac840 | 2011-05-12 15:51:54 +0100 | [diff] [blame] | 209 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 210 | // 128 bit SIMD value size. |
| 211 | const int kSimd128Size = 16; |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 212 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 213 | // Round up n to be a multiple of sz, where sz is a power of 2. |
| 214 | #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 215 | |
| 216 | |
| 217 | // FUNCTION_ADDR(f) gets the address of a C function f. |
| 218 | #define FUNCTION_ADDR(f) \ |
| 219 | (reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f))) |
| 220 | |
| 221 | |
| 222 | // FUNCTION_CAST<F>(addr) casts an address into a function |
| 223 | // of type F. Used to invoke generated code from within C. |
| 224 | template <typename F> |
| 225 | F FUNCTION_CAST(Address addr) { |
| 226 | return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
| 227 | } |
| 228 | |
| 229 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 230 | // Determine whether the architecture uses function descriptors |
| 231 | // which provide a level of indirection between the function pointer |
| 232 | // and the function entrypoint. |
| 233 | #if V8_HOST_ARCH_PPC && \ |
| 234 | (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN)) |
| 235 | #define USES_FUNCTION_DESCRIPTORS 1 |
| 236 | #define FUNCTION_ENTRYPOINT_ADDRESS(f) \ |
| 237 | (reinterpret_cast<v8::internal::Address*>( \ |
| 238 | &(reinterpret_cast<intptr_t*>(f)[0]))) |
| 239 | #else |
| 240 | #define USES_FUNCTION_DESCRIPTORS 0 |
| 241 | #endif |
| 242 | |
| 243 | |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 244 | // ----------------------------------------------------------------------------- |
| 245 | // Forward declarations for frequently used classes |
| 246 | // (sorted alphabetically) |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 247 | |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 248 | class FreeStoreAllocationPolicy; |
| 249 | template <typename T, class P = FreeStoreAllocationPolicy> class List; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 250 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 251 | // ----------------------------------------------------------------------------- |
| 252 | // Declarations for use in both the preparser and the rest of V8. |
| 253 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 254 | // The Strict Mode (ECMA-262 5th edition, 4.2.2). |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 255 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 256 | enum LanguageMode { SLOPPY, STRICT, LANGUAGE_END = 3 }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 257 | |
| 258 | |
| 259 | inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) { |
| 260 | switch (mode) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 261 | case SLOPPY: return os << "sloppy"; |
| 262 | case STRICT: return os << "strict"; |
| 263 | default: UNREACHABLE(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 264 | } |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 265 | return os; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
| 269 | inline bool is_sloppy(LanguageMode language_mode) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 270 | return language_mode == SLOPPY; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | |
| 274 | inline bool is_strict(LanguageMode language_mode) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 275 | return language_mode != SLOPPY; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | |
| 279 | inline bool is_valid_language_mode(int language_mode) { |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 280 | return language_mode == SLOPPY || language_mode == STRICT; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 284 | inline LanguageMode construct_language_mode(bool strict_bit) { |
| 285 | return static_cast<LanguageMode>(strict_bit); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 286 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 287 | |
| 288 | |
| 289 | // Mask for the sign bit in a smi. |
| 290 | const intptr_t kSmiSignMask = kIntptrSignBit; |
| 291 | |
| 292 | const int kObjectAlignmentBits = kPointerSizeLog2; |
| 293 | const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 294 | const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 295 | |
| 296 | // Desired alignment for pointers. |
| 297 | const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 298 | const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| 299 | |
| 300 | // Desired alignment for double values. |
| 301 | const intptr_t kDoubleAlignment = 8; |
| 302 | const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1; |
| 303 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 304 | // Desired alignment for 128 bit SIMD values. |
| 305 | const intptr_t kSimd128Alignment = 16; |
| 306 | const intptr_t kSimd128AlignmentMask = kSimd128Alignment - 1; |
| 307 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 308 | // Desired alignment for generated code is 32 bytes (to improve cache line |
| 309 | // utilization). |
| 310 | const int kCodeAlignmentBits = 5; |
| 311 | const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits; |
| 312 | const intptr_t kCodeAlignmentMask = kCodeAlignment - 1; |
| 313 | |
| 314 | // The owner field of a page is tagged with the page header tag. We need that |
| 315 | // to find out if a slot is part of a large object. If we mask out the lower |
| 316 | // 0xfffff bits (1M pages), go to the owner offset, and see that this field |
| 317 | // is tagged with the page header tag, we can just look up the owner. |
| 318 | // Otherwise, we know that we are somewhere (not within the first 1M) in a |
| 319 | // large object. |
| 320 | const int kPageHeaderTag = 3; |
| 321 | const int kPageHeaderTagSize = 2; |
| 322 | const intptr_t kPageHeaderTagMask = (1 << kPageHeaderTagSize) - 1; |
| 323 | |
| 324 | |
| 325 | // Zap-value: The value used for zapping dead objects. |
| 326 | // Should be a recognizable hex value tagged as a failure. |
| 327 | #ifdef V8_HOST_ARCH_64_BIT |
| 328 | const Address kZapValue = |
| 329 | reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef)); |
| 330 | const Address kHandleZapValue = |
| 331 | reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf)); |
| 332 | const Address kGlobalHandleZapValue = |
| 333 | reinterpret_cast<Address>(V8_UINT64_C(0x1baffed00baffedf)); |
| 334 | const Address kFromSpaceZapValue = |
| 335 | reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf)); |
| 336 | const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb); |
| 337 | const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef); |
| 338 | const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf; |
| 339 | #else |
| 340 | const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef); |
| 341 | const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf); |
| 342 | const Address kGlobalHandleZapValue = reinterpret_cast<Address>(0xbaffedf); |
| 343 | const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf); |
| 344 | const uint32_t kSlotsZapValue = 0xbeefdeef; |
| 345 | const uint32_t kDebugZapValue = 0xbadbaddb; |
| 346 | const uint32_t kFreeListZapValue = 0xfeed1eaf; |
| 347 | #endif |
| 348 | |
| 349 | const int kCodeZapValue = 0xbadc0de; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 350 | const uint32_t kPhantomReferenceZap = 0xca11bac; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 351 | |
| 352 | // On Intel architecture, cache line size is 64 bytes. |
| 353 | // On ARM it may be less (32 bytes), but as far this constant is |
| 354 | // used for aligning data, it doesn't hurt to align on a greater value. |
| 355 | #define PROCESSOR_CACHE_LINE_SIZE 64 |
| 356 | |
| 357 | // Constants relevant to double precision floating point numbers. |
| 358 | // If looking only at the top 32 bits, the QNaN mask is bits 19 to 30. |
| 359 | const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32); |
| 360 | |
| 361 | |
| 362 | // ----------------------------------------------------------------------------- |
| 363 | // Forward declarations for frequently used classes |
| 364 | |
| 365 | class AccessorInfo; |
| 366 | class Allocation; |
| 367 | class Arguments; |
| 368 | class Assembler; |
| 369 | class Code; |
| 370 | class CodeGenerator; |
| 371 | class CodeStub; |
| 372 | class Context; |
| 373 | class Debug; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 374 | class DebugInfo; |
| 375 | class Descriptor; |
| 376 | class DescriptorArray; |
| 377 | class TransitionArray; |
| 378 | class ExternalReference; |
| 379 | class FixedArray; |
| 380 | class FunctionTemplateInfo; |
| 381 | class MemoryChunk; |
| 382 | class SeededNumberDictionary; |
| 383 | class UnseededNumberDictionary; |
| 384 | class NameDictionary; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 385 | class GlobalDictionary; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 386 | template <typename T> class MaybeHandle; |
| 387 | template <typename T> class Handle; |
| 388 | class Heap; |
| 389 | class HeapObject; |
| 390 | class IC; |
| 391 | class InterceptorInfo; |
| 392 | class Isolate; |
| 393 | class JSReceiver; |
| 394 | class JSArray; |
| 395 | class JSFunction; |
| 396 | class JSObject; |
| 397 | class LargeObjectSpace; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 398 | class MacroAssembler; |
| 399 | class Map; |
| 400 | class MapSpace; |
| 401 | class MarkCompactCollector; |
| 402 | class NewSpace; |
| 403 | class Object; |
| 404 | class OldSpace; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 405 | class ParameterCount; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 406 | class Foreign; |
| 407 | class Scope; |
| 408 | class ScopeInfo; |
| 409 | class Script; |
| 410 | class Smi; |
| 411 | template <typename Config, class Allocator = FreeStoreAllocationPolicy> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 412 | class SplayTree; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 413 | class String; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 414 | class Symbol; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 415 | class Name; |
| 416 | class Struct; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 417 | class TypeFeedbackVector; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 418 | class Variable; |
| 419 | class RelocInfo; |
| 420 | class Deserializer; |
| 421 | class MessageLocation; |
| 422 | |
| 423 | typedef bool (*WeakSlotCallback)(Object** pointer); |
| 424 | |
| 425 | typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer); |
| 426 | |
| 427 | // ----------------------------------------------------------------------------- |
| 428 | // Miscellaneous |
| 429 | |
| 430 | // NOTE: SpaceIterator depends on AllocationSpace enumeration values being |
| 431 | // consecutive. |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 432 | // Keep this enum in sync with the ObjectSpace enum in v8.h |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 433 | enum AllocationSpace { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 434 | NEW_SPACE, // Semispaces collected with copying collector. |
| 435 | OLD_SPACE, // May contain pointers to new space. |
| 436 | CODE_SPACE, // No pointers to new space, marked executable. |
| 437 | MAP_SPACE, // Only and all map objects. |
| 438 | LO_SPACE, // Promoted large objects. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 439 | |
| 440 | FIRST_SPACE = NEW_SPACE, |
| 441 | LAST_SPACE = LO_SPACE, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 442 | FIRST_PAGED_SPACE = OLD_SPACE, |
| 443 | LAST_PAGED_SPACE = MAP_SPACE |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 444 | }; |
| 445 | const int kSpaceTagSize = 3; |
| 446 | const int kSpaceTagMask = (1 << kSpaceTagSize) - 1; |
| 447 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 448 | enum AllocationAlignment { |
| 449 | kWordAligned, |
| 450 | kDoubleAligned, |
| 451 | kDoubleUnaligned, |
| 452 | kSimd128Unaligned |
| 453 | }; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 454 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 455 | // Supported write barrier modes. |
| 456 | enum WriteBarrierKind : uint8_t { |
| 457 | kNoWriteBarrier, |
| 458 | kMapWriteBarrier, |
| 459 | kPointerWriteBarrier, |
| 460 | kFullWriteBarrier |
| 461 | }; |
| 462 | |
| 463 | inline size_t hash_value(WriteBarrierKind kind) { |
| 464 | return static_cast<uint8_t>(kind); |
| 465 | } |
| 466 | |
| 467 | inline std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { |
| 468 | switch (kind) { |
| 469 | case kNoWriteBarrier: |
| 470 | return os << "NoWriteBarrier"; |
| 471 | case kMapWriteBarrier: |
| 472 | return os << "MapWriteBarrier"; |
| 473 | case kPointerWriteBarrier: |
| 474 | return os << "PointerWriteBarrier"; |
| 475 | case kFullWriteBarrier: |
| 476 | return os << "FullWriteBarrier"; |
| 477 | } |
| 478 | UNREACHABLE(); |
| 479 | return os; |
| 480 | } |
| 481 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 482 | // A flag that indicates whether objects should be pretenured when |
| 483 | // allocated (allocated directly into the old generation) or not |
| 484 | // (allocated in the young generation if the object size and type |
| 485 | // allows). |
| 486 | enum PretenureFlag { NOT_TENURED, TENURED }; |
| 487 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 488 | inline std::ostream& operator<<(std::ostream& os, const PretenureFlag& flag) { |
| 489 | switch (flag) { |
| 490 | case NOT_TENURED: |
| 491 | return os << "NotTenured"; |
| 492 | case TENURED: |
| 493 | return os << "Tenured"; |
| 494 | } |
| 495 | UNREACHABLE(); |
| 496 | return os; |
| 497 | } |
| 498 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 499 | enum MinimumCapacity { |
| 500 | USE_DEFAULT_MINIMUM_CAPACITY, |
| 501 | USE_CUSTOM_MINIMUM_CAPACITY |
| 502 | }; |
| 503 | |
| 504 | enum GarbageCollector { SCAVENGER, MARK_COMPACTOR }; |
| 505 | |
| 506 | enum Executability { NOT_EXECUTABLE, EXECUTABLE }; |
| 507 | |
| 508 | enum VisitMode { |
| 509 | VISIT_ALL, |
| 510 | VISIT_ALL_IN_SCAVENGE, |
| 511 | VISIT_ALL_IN_SWEEP_NEWSPACE, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 512 | VISIT_ONLY_STRONG, |
| 513 | VISIT_ONLY_STRONG_FOR_SERIALIZATION, |
| 514 | VISIT_ONLY_STRONG_ROOT_LIST, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 515 | }; |
| 516 | |
| 517 | // Flag indicating whether code is built into the VM (one of the natives files). |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 518 | enum NativesFlag { NOT_NATIVES_CODE, EXTENSION_CODE, NATIVES_CODE }; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 519 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 520 | // JavaScript defines two kinds of 'nil'. |
| 521 | enum NilValue { kNullValue, kUndefinedValue }; |
| 522 | |
| 523 | // ParseRestriction is used to restrict the set of valid statements in a |
| 524 | // unit of compilation. Restriction violations cause a syntax error. |
| 525 | enum ParseRestriction { |
| 526 | NO_PARSE_RESTRICTION, // All expressions are allowed. |
| 527 | ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression. |
| 528 | }; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 529 | |
| 530 | // A CodeDesc describes a buffer holding instructions and relocation |
| 531 | // information. The instructions start at the beginning of the buffer |
| 532 | // and grow forward, the relocation information starts at the end of |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 533 | // the buffer and grows backward. A constant pool may exist at the |
| 534 | // end of the instructions. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 535 | // |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 536 | // |<--------------- buffer_size ----------------------------------->| |
| 537 | // |<------------- instr_size ---------->| |<-- reloc_size -->| |
| 538 | // | |<- const_pool_size ->| | |
| 539 | // +=====================================+========+==================+ |
| 540 | // | instructions | data | free | reloc info | |
| 541 | // +=====================================+========+==================+ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 542 | // ^ |
| 543 | // | |
| 544 | // buffer |
| 545 | |
| 546 | struct CodeDesc { |
| 547 | byte* buffer; |
| 548 | int buffer_size; |
| 549 | int instr_size; |
| 550 | int reloc_size; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 551 | int constant_pool_size; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 552 | Assembler* origin; |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 553 | }; |
| 554 | |
| 555 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 556 | // Callback function used for checking constraints when copying/relocating |
| 557 | // objects. Returns true if an object can be copied/relocated from its |
| 558 | // old_addr to a new_addr. |
| 559 | typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr); |
| 560 | |
| 561 | |
| 562 | // Callback function on inline caches, used for iterating over inline caches |
| 563 | // in compiled code. |
| 564 | typedef void (*InlineCacheCallback)(Code* code, Address ic); |
| 565 | |
| 566 | |
| 567 | // State for inline cache call sites. Aliased as IC::State. |
| 568 | enum InlineCacheState { |
| 569 | // Has never been executed. |
| 570 | UNINITIALIZED, |
| 571 | // Has been executed but monomorhic state has been delayed. |
| 572 | PREMONOMORPHIC, |
| 573 | // Has been executed and only one receiver type has been seen. |
| 574 | MONOMORPHIC, |
| 575 | // Check failed due to prototype (or map deprecation). |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 576 | RECOMPUTE_HANDLER, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 577 | // Multiple receiver types have been seen. |
| 578 | POLYMORPHIC, |
| 579 | // Many receiver types have been seen. |
| 580 | MEGAMORPHIC, |
| 581 | // A generic handler is installed and no extra typefeedback is recorded. |
| 582 | GENERIC, |
| 583 | // Special state for debug break or step in prepare stubs. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 584 | DEBUG_STUB |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 585 | }; |
| 586 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 587 | enum CacheHolderFlag { |
| 588 | kCacheOnPrototype, |
| 589 | kCacheOnPrototypeReceiverIsDictionary, |
| 590 | kCacheOnPrototypeReceiverIsPrimitive, |
| 591 | kCacheOnReceiver |
| 592 | }; |
| 593 | |
| 594 | |
| 595 | // The Store Buffer (GC). |
| 596 | typedef enum { |
| 597 | kStoreBufferFullEvent, |
| 598 | kStoreBufferStartScanningPagesEvent, |
| 599 | kStoreBufferScanningPageEvent |
| 600 | } StoreBufferEvent; |
| 601 | |
| 602 | |
| 603 | typedef void (*StoreBufferCallback)(Heap* heap, |
| 604 | MemoryChunk* page, |
| 605 | StoreBufferEvent event); |
| 606 | |
| 607 | |
| 608 | // Union used for fast testing of specific double values. |
| 609 | union DoubleRepresentation { |
| 610 | double value; |
| 611 | int64_t bits; |
| 612 | DoubleRepresentation(double x) { value = x; } |
| 613 | bool operator==(const DoubleRepresentation& other) const { |
| 614 | return bits == other.bits; |
| 615 | } |
| 616 | }; |
| 617 | |
| 618 | |
| 619 | // Union used for customized checking of the IEEE double types |
| 620 | // inlined within v8 runtime, rather than going to the underlying |
| 621 | // platform headers and libraries |
| 622 | union IeeeDoubleLittleEndianArchType { |
| 623 | double d; |
| 624 | struct { |
| 625 | unsigned int man_low :32; |
| 626 | unsigned int man_high :20; |
| 627 | unsigned int exp :11; |
| 628 | unsigned int sign :1; |
| 629 | } bits; |
| 630 | }; |
| 631 | |
| 632 | |
| 633 | union IeeeDoubleBigEndianArchType { |
| 634 | double d; |
| 635 | struct { |
| 636 | unsigned int sign :1; |
| 637 | unsigned int exp :11; |
| 638 | unsigned int man_high :20; |
| 639 | unsigned int man_low :32; |
| 640 | } bits; |
| 641 | }; |
| 642 | |
| 643 | |
| 644 | // AccessorCallback |
| 645 | struct AccessorDescriptor { |
| 646 | Object* (*getter)(Isolate* isolate, Object* object, void* data); |
| 647 | Object* (*setter)( |
| 648 | Isolate* isolate, JSObject* object, Object* value, void* data); |
| 649 | void* data; |
| 650 | }; |
| 651 | |
| 652 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 653 | // ----------------------------------------------------------------------------- |
| 654 | // Macros |
| 655 | |
| 656 | // Testers for test. |
| 657 | |
| 658 | #define HAS_SMI_TAG(value) \ |
| 659 | ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag) |
| 660 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 661 | // OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer |
| 662 | #define OBJECT_POINTER_ALIGN(value) \ |
| 663 | (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) |
| 664 | |
| 665 | // POINTER_SIZE_ALIGN returns the value aligned as a pointer. |
| 666 | #define POINTER_SIZE_ALIGN(value) \ |
| 667 | (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) |
| 668 | |
| 669 | // CODE_POINTER_ALIGN returns the value aligned as a generated code segment. |
| 670 | #define CODE_POINTER_ALIGN(value) \ |
| 671 | (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) |
| 672 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 673 | // DOUBLE_POINTER_ALIGN returns the value algined for double pointers. |
| 674 | #define DOUBLE_POINTER_ALIGN(value) \ |
| 675 | (((value) + kDoubleAlignmentMask) & ~kDoubleAlignmentMask) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 676 | |
| 677 | |
| 678 | // CPU feature flags. |
| 679 | enum CpuFeature { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 680 | // x86 |
| 681 | SSE4_1, |
| 682 | SSE3, |
| 683 | SAHF, |
| 684 | AVX, |
| 685 | FMA3, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 686 | BMI1, |
| 687 | BMI2, |
| 688 | LZCNT, |
| 689 | POPCNT, |
| 690 | ATOM, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 691 | // ARM |
| 692 | VFP3, |
| 693 | ARMv7, |
| 694 | ARMv8, |
| 695 | SUDIV, |
| 696 | MLS, |
| 697 | UNALIGNED_ACCESSES, |
| 698 | MOVW_MOVT_IMMEDIATE_LOADS, |
| 699 | VFP32DREGS, |
| 700 | NEON, |
| 701 | // MIPS, MIPS64 |
| 702 | FPU, |
| 703 | FP64FPU, |
| 704 | MIPSr1, |
| 705 | MIPSr2, |
| 706 | MIPSr6, |
| 707 | // ARM64 |
| 708 | ALWAYS_ALIGN_CSP, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 709 | // PPC |
| 710 | FPR_GPR_MOV, |
| 711 | LWSYNC, |
| 712 | ISELECT, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 713 | // S390 |
| 714 | DISTINCT_OPS, |
| 715 | GENERAL_INSTR_EXT, |
| 716 | FLOATING_POINT_EXT, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 717 | NUMBER_OF_CPU_FEATURES |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 718 | }; |
| 719 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 720 | // Defines hints about receiver values based on structural knowledge. |
| 721 | enum class ConvertReceiverMode : unsigned { |
| 722 | kNullOrUndefined, // Guaranteed to be null or undefined. |
| 723 | kNotNullOrUndefined, // Guaranteed to never be null or undefined. |
| 724 | kAny // No specific knowledge about receiver. |
| 725 | }; |
| 726 | |
| 727 | inline size_t hash_value(ConvertReceiverMode mode) { |
| 728 | return bit_cast<unsigned>(mode); |
| 729 | } |
| 730 | |
| 731 | inline std::ostream& operator<<(std::ostream& os, ConvertReceiverMode mode) { |
| 732 | switch (mode) { |
| 733 | case ConvertReceiverMode::kNullOrUndefined: |
| 734 | return os << "NULL_OR_UNDEFINED"; |
| 735 | case ConvertReceiverMode::kNotNullOrUndefined: |
| 736 | return os << "NOT_NULL_OR_UNDEFINED"; |
| 737 | case ConvertReceiverMode::kAny: |
| 738 | return os << "ANY"; |
| 739 | } |
| 740 | UNREACHABLE(); |
| 741 | return os; |
| 742 | } |
| 743 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 744 | // Defines whether tail call optimization is allowed. |
| 745 | enum class TailCallMode : unsigned { kAllow, kDisallow }; |
| 746 | |
| 747 | inline size_t hash_value(TailCallMode mode) { return bit_cast<unsigned>(mode); } |
| 748 | |
| 749 | inline std::ostream& operator<<(std::ostream& os, TailCallMode mode) { |
| 750 | switch (mode) { |
| 751 | case TailCallMode::kAllow: |
| 752 | return os << "ALLOW_TAIL_CALLS"; |
| 753 | case TailCallMode::kDisallow: |
| 754 | return os << "DISALLOW_TAIL_CALLS"; |
| 755 | } |
| 756 | UNREACHABLE(); |
| 757 | return os; |
| 758 | } |
| 759 | |
| 760 | // Defines specifics about arguments object or rest parameter creation. |
| 761 | enum class CreateArgumentsType : uint8_t { |
| 762 | kMappedArguments, |
| 763 | kUnmappedArguments, |
| 764 | kRestParameter |
| 765 | }; |
| 766 | |
| 767 | inline size_t hash_value(CreateArgumentsType type) { |
| 768 | return bit_cast<uint8_t>(type); |
| 769 | } |
| 770 | |
| 771 | inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) { |
| 772 | switch (type) { |
| 773 | case CreateArgumentsType::kMappedArguments: |
| 774 | return os << "MAPPED_ARGUMENTS"; |
| 775 | case CreateArgumentsType::kUnmappedArguments: |
| 776 | return os << "UNMAPPED_ARGUMENTS"; |
| 777 | case CreateArgumentsType::kRestParameter: |
| 778 | return os << "REST_PARAMETER"; |
| 779 | } |
| 780 | UNREACHABLE(); |
| 781 | return os; |
| 782 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 783 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 784 | // Used to specify if a macro instruction must perform a smi check on tagged |
| 785 | // values. |
| 786 | enum SmiCheckType { |
| 787 | DONT_DO_SMI_CHECK, |
| 788 | DO_SMI_CHECK |
| 789 | }; |
| 790 | |
| 791 | |
| 792 | enum ScopeType { |
| 793 | EVAL_SCOPE, // The top-level scope for an eval source. |
| 794 | FUNCTION_SCOPE, // The top-level scope for a function. |
| 795 | MODULE_SCOPE, // The scope introduced by a module literal |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 796 | SCRIPT_SCOPE, // The top-level scope for a script or a top-level eval. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 797 | CATCH_SCOPE, // The scope introduced by catch. |
| 798 | BLOCK_SCOPE, // The scope introduced by a new block. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 799 | WITH_SCOPE // The scope introduced by with. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 800 | }; |
| 801 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 802 | // The mips architecture prior to revision 5 has inverted encoding for sNaN. |
| 803 | #if (V8_TARGET_ARCH_MIPS && !defined(_MIPS_ARCH_MIPS32R6)) || \ |
| 804 | (V8_TARGET_ARCH_MIPS64 && !defined(_MIPS_ARCH_MIPS64R6)) |
| 805 | const uint32_t kHoleNanUpper32 = 0xFFFF7FFF; |
| 806 | const uint32_t kHoleNanLower32 = 0xFFFF7FFF; |
| 807 | #else |
| 808 | const uint32_t kHoleNanUpper32 = 0xFFF7FFFF; |
| 809 | const uint32_t kHoleNanLower32 = 0xFFF7FFFF; |
| 810 | #endif |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 811 | |
| 812 | const uint64_t kHoleNanInt64 = |
| 813 | (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 814 | |
| 815 | |
| 816 | // ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER |
| 817 | const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 818 | |
| 819 | |
| 820 | // The order of this enum has to be kept in sync with the predicates below. |
| 821 | enum VariableMode { |
| 822 | // User declared variables: |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 823 | VAR, // declared via 'var', and 'function' declarations |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 824 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 825 | CONST_LEGACY, // declared via legacy 'const' declarations |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 826 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 827 | LET, // declared via 'let' declarations (first lexical) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 828 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 829 | CONST, // declared via 'const' declarations (last lexical) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 830 | |
| 831 | // Variables introduced by the compiler: |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 832 | TEMPORARY, // temporary variables (not user-visible), stack-allocated |
| 833 | // unless the scope as a whole has forced context allocation |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 834 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 835 | DYNAMIC, // always require dynamic lookup (we don't know |
| 836 | // the declaration) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 837 | |
| 838 | DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 839 | // variable is global unless it has been shadowed |
| 840 | // by an eval-introduced variable |
| 841 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 842 | DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
| 843 | // variable is local and where it is unless it |
| 844 | // has been shadowed by an eval-introduced |
| 845 | // variable |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 846 | }; |
| 847 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 848 | inline bool IsDynamicVariableMode(VariableMode mode) { |
| 849 | return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
| 850 | } |
| 851 | |
| 852 | |
| 853 | inline bool IsDeclaredVariableMode(VariableMode mode) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 854 | return mode >= VAR && mode <= CONST; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | |
| 858 | inline bool IsLexicalVariableMode(VariableMode mode) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 859 | return mode >= LET && mode <= CONST; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | |
| 863 | inline bool IsImmutableVariableMode(VariableMode mode) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 864 | return mode == CONST || mode == CONST_LEGACY; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 868 | enum class VariableLocation { |
| 869 | // Before and during variable allocation, a variable whose location is |
| 870 | // not yet determined. After allocation, a variable looked up as a |
| 871 | // property on the global object (and possibly absent). name() is the |
| 872 | // variable name, index() is invalid. |
| 873 | UNALLOCATED, |
| 874 | |
| 875 | // A slot in the parameter section on the stack. index() is the |
| 876 | // parameter index, counting left-to-right. The receiver is index -1; |
| 877 | // the first parameter is index 0. |
| 878 | PARAMETER, |
| 879 | |
| 880 | // A slot in the local section on the stack. index() is the variable |
| 881 | // index in the stack frame, starting at 0. |
| 882 | LOCAL, |
| 883 | |
| 884 | // An indexed slot in a heap context. index() is the variable index in |
| 885 | // the context object on the heap, starting at 0. scope() is the |
| 886 | // corresponding scope. |
| 887 | CONTEXT, |
| 888 | |
| 889 | // An indexed slot in a script context that contains a respective global |
| 890 | // property cell. name() is the variable name, index() is the variable |
| 891 | // index in the context object on the heap, starting at 0. scope() is the |
| 892 | // corresponding script scope. |
| 893 | GLOBAL, |
| 894 | |
| 895 | // A named slot in a heap context. name() is the variable name in the |
| 896 | // context object on the heap, with lookup starting at the current |
| 897 | // context. index() is invalid. |
| 898 | LOOKUP |
| 899 | }; |
| 900 | |
| 901 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 902 | // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
| 903 | // and immutable bindings that can be in two states: initialized and |
| 904 | // uninitialized. In ES5 only immutable bindings have these two states. When |
| 905 | // accessing a binding, it needs to be checked for initialization. However in |
| 906 | // the following cases the binding is initialized immediately after creation |
| 907 | // so the initialization check can always be skipped: |
| 908 | // 1. Var declared local variables. |
| 909 | // var foo; |
| 910 | // 2. A local variable introduced by a function declaration. |
| 911 | // function foo() {} |
| 912 | // 3. Parameters |
| 913 | // function x(foo) {} |
| 914 | // 4. Catch bound variables. |
| 915 | // try {} catch (foo) {} |
| 916 | // 6. Function variables of named function expressions. |
| 917 | // var x = function foo() {} |
| 918 | // 7. Implicit binding of 'this'. |
| 919 | // 8. Implicit binding of 'arguments' in functions. |
| 920 | // |
| 921 | // ES5 specified object environment records which are introduced by ES elements |
| 922 | // such as Program and WithStatement that associate identifier bindings with the |
| 923 | // properties of some object. In the specification only mutable bindings exist |
| 924 | // (which may be non-writable) and have no distinct initialization step. However |
| 925 | // V8 allows const declarations in global code with distinct creation and |
| 926 | // initialization steps which are represented by non-writable properties in the |
| 927 | // global object. As a result also these bindings need to be checked for |
| 928 | // initialization. |
| 929 | // |
| 930 | // The following enum specifies a flag that indicates if the binding needs a |
| 931 | // distinct initialization step (kNeedsInitialization) or if the binding is |
| 932 | // immediately initialized upon creation (kCreatedInitialized). |
| 933 | enum InitializationFlag { |
| 934 | kNeedsInitialization, |
| 935 | kCreatedInitialized |
| 936 | }; |
| 937 | |
| 938 | |
| 939 | enum MaybeAssignedFlag { kNotAssigned, kMaybeAssigned }; |
| 940 | |
| 941 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 942 | // Serialized in PreparseData, so numeric values should not be changed. |
| 943 | enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 }; |
| 944 | |
| 945 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 946 | enum MinusZeroMode { |
| 947 | TREAT_MINUS_ZERO_AS_ZERO, |
| 948 | FAIL_ON_MINUS_ZERO |
| 949 | }; |
| 950 | |
| 951 | |
| 952 | enum Signedness { kSigned, kUnsigned }; |
| 953 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 954 | enum FunctionKind { |
| 955 | kNormalFunction = 0, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 956 | kArrowFunction = 1 << 0, |
| 957 | kGeneratorFunction = 1 << 1, |
| 958 | kConciseMethod = 1 << 2, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 959 | kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 960 | kDefaultConstructor = 1 << 3, |
| 961 | kSubclassConstructor = 1 << 4, |
| 962 | kBaseConstructor = 1 << 5, |
| 963 | kGetterFunction = 1 << 6, |
| 964 | kSetterFunction = 1 << 7, |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 965 | kAsyncFunction = 1 << 8, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 966 | kAccessorFunction = kGetterFunction | kSetterFunction, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 967 | kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor, |
| 968 | kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor, |
| 969 | kClassConstructor = |
| 970 | kBaseConstructor | kSubclassConstructor | kDefaultConstructor, |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 971 | kAsyncArrowFunction = kArrowFunction | kAsyncFunction, |
| 972 | kAsyncConciseMethod = kAsyncFunction | kConciseMethod |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 973 | }; |
| 974 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 975 | inline bool IsValidFunctionKind(FunctionKind kind) { |
| 976 | return kind == FunctionKind::kNormalFunction || |
| 977 | kind == FunctionKind::kArrowFunction || |
| 978 | kind == FunctionKind::kGeneratorFunction || |
| 979 | kind == FunctionKind::kConciseMethod || |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 980 | kind == FunctionKind::kConciseGeneratorMethod || |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 981 | kind == FunctionKind::kGetterFunction || |
| 982 | kind == FunctionKind::kSetterFunction || |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 983 | kind == FunctionKind::kAccessorFunction || |
| 984 | kind == FunctionKind::kDefaultBaseConstructor || |
| 985 | kind == FunctionKind::kDefaultSubclassConstructor || |
| 986 | kind == FunctionKind::kBaseConstructor || |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 987 | kind == FunctionKind::kSubclassConstructor || |
| 988 | kind == FunctionKind::kAsyncFunction || |
| 989 | kind == FunctionKind::kAsyncArrowFunction || |
| 990 | kind == FunctionKind::kAsyncConciseMethod; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | |
| 994 | inline bool IsArrowFunction(FunctionKind kind) { |
| 995 | DCHECK(IsValidFunctionKind(kind)); |
| 996 | return kind & FunctionKind::kArrowFunction; |
| 997 | } |
| 998 | |
| 999 | |
| 1000 | inline bool IsGeneratorFunction(FunctionKind kind) { |
| 1001 | DCHECK(IsValidFunctionKind(kind)); |
| 1002 | return kind & FunctionKind::kGeneratorFunction; |
| 1003 | } |
| 1004 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 1005 | inline bool IsAsyncFunction(FunctionKind kind) { |
| 1006 | DCHECK(IsValidFunctionKind(kind)); |
| 1007 | return kind & FunctionKind::kAsyncFunction; |
| 1008 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1009 | |
| 1010 | inline bool IsConciseMethod(FunctionKind kind) { |
| 1011 | DCHECK(IsValidFunctionKind(kind)); |
| 1012 | return kind & FunctionKind::kConciseMethod; |
| 1013 | } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1014 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1015 | inline bool IsGetterFunction(FunctionKind kind) { |
| 1016 | DCHECK(IsValidFunctionKind(kind)); |
| 1017 | return kind & FunctionKind::kGetterFunction; |
| 1018 | } |
| 1019 | |
| 1020 | inline bool IsSetterFunction(FunctionKind kind) { |
| 1021 | DCHECK(IsValidFunctionKind(kind)); |
| 1022 | return kind & FunctionKind::kSetterFunction; |
| 1023 | } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1024 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1025 | inline bool IsAccessorFunction(FunctionKind kind) { |
| 1026 | DCHECK(IsValidFunctionKind(kind)); |
| 1027 | return kind & FunctionKind::kAccessorFunction; |
| 1028 | } |
| 1029 | |
| 1030 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1031 | inline bool IsDefaultConstructor(FunctionKind kind) { |
| 1032 | DCHECK(IsValidFunctionKind(kind)); |
| 1033 | return kind & FunctionKind::kDefaultConstructor; |
| 1034 | } |
| 1035 | |
| 1036 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1037 | inline bool IsBaseConstructor(FunctionKind kind) { |
| 1038 | DCHECK(IsValidFunctionKind(kind)); |
| 1039 | return kind & FunctionKind::kBaseConstructor; |
| 1040 | } |
| 1041 | |
| 1042 | |
| 1043 | inline bool IsSubclassConstructor(FunctionKind kind) { |
| 1044 | DCHECK(IsValidFunctionKind(kind)); |
| 1045 | return kind & FunctionKind::kSubclassConstructor; |
| 1046 | } |
| 1047 | |
| 1048 | |
| 1049 | inline bool IsClassConstructor(FunctionKind kind) { |
| 1050 | DCHECK(IsValidFunctionKind(kind)); |
| 1051 | return kind & FunctionKind::kClassConstructor; |
| 1052 | } |
| 1053 | |
| 1054 | |
| 1055 | inline bool IsConstructable(FunctionKind kind, LanguageMode mode) { |
| 1056 | if (IsAccessorFunction(kind)) return false; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1057 | if (IsConciseMethod(kind)) return false; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1058 | if (IsArrowFunction(kind)) return false; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1059 | if (IsGeneratorFunction(kind)) return false; |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 1060 | if (IsAsyncFunction(kind)) return false; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1061 | return true; |
| 1062 | } |
| 1063 | |
| 1064 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1065 | inline uint32_t ObjectHash(Address address) { |
| 1066 | // All objects are at least pointer aligned, so we can remove the trailing |
| 1067 | // zeros. |
| 1068 | return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> |
| 1069 | kPointerSizeLog2); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1070 | } |
| 1071 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1072 | } // namespace internal |
| 1073 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1074 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1075 | namespace i = v8::internal; |
| 1076 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1077 | #endif // V8_GLOBALS_H_ |