yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_V8GLOBALS_H_ |
| 29 | #define V8_V8GLOBALS_H_ |
| 30 | |
| 31 | #include "globals.h" |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 32 | #include "checks.h" |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 33 | |
| 34 | namespace v8 { |
| 35 | namespace internal { |
| 36 | |
| 37 | // This file contains constants and global declarations related to the |
| 38 | // V8 system. |
| 39 | |
| 40 | // Mask for the sign bit in a smi. |
| 41 | const intptr_t kSmiSignMask = kIntptrSignBit; |
| 42 | |
| 43 | const int kObjectAlignmentBits = kPointerSizeLog2; |
| 44 | const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 45 | const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 46 | |
| 47 | // Desired alignment for pointers. |
| 48 | const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 49 | const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| 50 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 51 | // Desired alignment for double values. |
| 52 | const intptr_t kDoubleAlignment = 8; |
| 53 | const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1; |
| 54 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 55 | // Desired alignment for maps. |
| 56 | #if V8_HOST_ARCH_64_BIT |
| 57 | const intptr_t kMapAlignmentBits = kObjectAlignmentBits; |
| 58 | #else |
| 59 | const intptr_t kMapAlignmentBits = kObjectAlignmentBits + 3; |
| 60 | #endif |
| 61 | const intptr_t kMapAlignment = (1 << kMapAlignmentBits); |
| 62 | const intptr_t kMapAlignmentMask = kMapAlignment - 1; |
| 63 | |
| 64 | // Desired alignment for generated code is 32 bytes (to improve cache line |
| 65 | // utilization). |
| 66 | const int kCodeAlignmentBits = 5; |
| 67 | const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits; |
| 68 | const intptr_t kCodeAlignmentMask = kCodeAlignment - 1; |
| 69 | |
| 70 | // Tag information for Failure. |
| 71 | const int kFailureTag = 3; |
| 72 | const int kFailureTagSize = 2; |
| 73 | const intptr_t kFailureTagMask = (1 << kFailureTagSize) - 1; |
| 74 | |
| 75 | |
| 76 | // Zap-value: The value used for zapping dead objects. |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 77 | // Should be a recognizable hex value tagged as a failure. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 78 | #ifdef V8_HOST_ARCH_64_BIT |
| 79 | const Address kZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 80 | reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 81 | const Address kHandleZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 82 | reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 83 | const Address kFromSpaceZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 84 | reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf)); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 85 | const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 86 | const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 87 | const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 88 | #else |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 89 | const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef); |
| 90 | const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf); |
| 91 | const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf); |
| 92 | const uint32_t kSlotsZapValue = 0xbeefdeef; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 93 | const uint32_t kDebugZapValue = 0xbadbaddb; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 94 | const uint32_t kFreeListZapValue = 0xfeed1eaf; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 95 | #endif |
| 96 | |
| 97 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 98 | // Number of bits to represent the page size for paged spaces. The value of 20 |
| 99 | // gives 1Mb bytes per page. |
| 100 | const int kPageSizeBits = 20; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 101 | |
| 102 | // On Intel architecture, cache line size is 64 bytes. |
| 103 | // On ARM it may be less (32 bytes), but as far this constant is |
| 104 | // used for aligning data, it doesn't hurt to align on a greater value. |
| 105 | const int kProcessorCacheLineSize = 64; |
| 106 | |
| 107 | // Constants relevant to double precision floating point numbers. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 108 | // If looking only at the top 32 bits, the QNaN mask is bits 19 to 30. |
| 109 | const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32); |
| 110 | |
| 111 | |
| 112 | // ----------------------------------------------------------------------------- |
| 113 | // Forward declarations for frequently used classes |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 114 | |
| 115 | class AccessorInfo; |
| 116 | class Allocation; |
| 117 | class Arguments; |
| 118 | class Assembler; |
| 119 | class AssertNoAllocation; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 120 | class Code; |
| 121 | class CodeGenerator; |
| 122 | class CodeStub; |
| 123 | class Context; |
| 124 | class Debug; |
| 125 | class Debugger; |
| 126 | class DebugInfo; |
| 127 | class Descriptor; |
| 128 | class DescriptorArray; |
yangguo@chromium.org | 99aa490 | 2012-07-06 16:21:55 +0000 | [diff] [blame] | 129 | class TransitionArray; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 130 | class ExternalReference; |
| 131 | class FixedArray; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 132 | class FunctionTemplateInfo; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 133 | class MemoryChunk; |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 134 | class SeededNumberDictionary; |
| 135 | class UnseededNumberDictionary; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 136 | class StringDictionary; |
| 137 | template <typename T> class Handle; |
| 138 | class Heap; |
| 139 | class HeapObject; |
| 140 | class IC; |
| 141 | class InterceptorInfo; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 142 | class JSArray; |
| 143 | class JSFunction; |
| 144 | class JSObject; |
| 145 | class LargeObjectSpace; |
| 146 | class LookupResult; |
| 147 | class MacroAssembler; |
| 148 | class Map; |
| 149 | class MapSpace; |
| 150 | class MarkCompactCollector; |
| 151 | class NewSpace; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 152 | class Object; |
| 153 | class MaybeObject; |
| 154 | class OldSpace; |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 155 | class Foreign; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 156 | class Scope; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 157 | class ScopeInfo; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 158 | class Script; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 159 | class Smi; |
| 160 | template <typename Config, class Allocator = FreeStoreAllocationPolicy> |
| 161 | class SplayTree; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 162 | class String; |
| 163 | class Struct; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 164 | class Variable; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 165 | class RelocInfo; |
| 166 | class Deserializer; |
| 167 | class MessageLocation; |
| 168 | class ObjectGroup; |
| 169 | class TickSample; |
| 170 | class VirtualMemory; |
| 171 | class Mutex; |
| 172 | |
| 173 | typedef bool (*WeakSlotCallback)(Object** pointer); |
| 174 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 175 | typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer); |
| 176 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 177 | // ----------------------------------------------------------------------------- |
| 178 | // Miscellaneous |
| 179 | |
| 180 | // NOTE: SpaceIterator depends on AllocationSpace enumeration values being |
| 181 | // consecutive. |
| 182 | enum AllocationSpace { |
| 183 | NEW_SPACE, // Semispaces collected with copying collector. |
| 184 | OLD_POINTER_SPACE, // May contain pointers to new space. |
| 185 | OLD_DATA_SPACE, // Must not have pointers to new space. |
| 186 | CODE_SPACE, // No pointers to new space, marked executable. |
| 187 | MAP_SPACE, // Only and all map objects. |
| 188 | CELL_SPACE, // Only and all cell objects. |
| 189 | LO_SPACE, // Promoted large objects. |
| 190 | |
| 191 | FIRST_SPACE = NEW_SPACE, |
| 192 | LAST_SPACE = LO_SPACE, |
| 193 | FIRST_PAGED_SPACE = OLD_POINTER_SPACE, |
| 194 | LAST_PAGED_SPACE = CELL_SPACE |
| 195 | }; |
| 196 | const int kSpaceTagSize = 3; |
| 197 | const int kSpaceTagMask = (1 << kSpaceTagSize) - 1; |
| 198 | |
| 199 | |
| 200 | // A flag that indicates whether objects should be pretenured when |
| 201 | // allocated (allocated directly into the old generation) or not |
| 202 | // (allocated in the young generation if the object size and type |
| 203 | // allows). |
| 204 | enum PretenureFlag { NOT_TENURED, TENURED }; |
| 205 | |
| 206 | enum GarbageCollector { SCAVENGER, MARK_COMPACTOR }; |
| 207 | |
| 208 | enum Executability { NOT_EXECUTABLE, EXECUTABLE }; |
| 209 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 210 | enum VisitMode { |
| 211 | VISIT_ALL, |
| 212 | VISIT_ALL_IN_SCAVENGE, |
| 213 | VISIT_ALL_IN_SWEEP_NEWSPACE, |
| 214 | VISIT_ONLY_STRONG |
| 215 | }; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 216 | |
| 217 | // Flag indicating whether code is built into the VM (one of the natives files). |
| 218 | enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE }; |
| 219 | |
| 220 | |
| 221 | // A CodeDesc describes a buffer holding instructions and relocation |
| 222 | // information. The instructions start at the beginning of the buffer |
| 223 | // and grow forward, the relocation information starts at the end of |
| 224 | // the buffer and grows backward. |
| 225 | // |
| 226 | // |<--------------- buffer_size ---------------->| |
| 227 | // |<-- instr_size -->| |<-- reloc_size -->| |
| 228 | // +==================+========+==================+ |
| 229 | // | instructions | free | reloc info | |
| 230 | // +==================+========+==================+ |
| 231 | // ^ |
| 232 | // | |
| 233 | // buffer |
| 234 | |
| 235 | struct CodeDesc { |
| 236 | byte* buffer; |
| 237 | int buffer_size; |
| 238 | int instr_size; |
| 239 | int reloc_size; |
| 240 | Assembler* origin; |
| 241 | }; |
| 242 | |
| 243 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 244 | // Callback function used for iterating objects in heap spaces, |
| 245 | // for example, scanning heap objects. |
| 246 | typedef int (*HeapObjectCallback)(HeapObject* obj); |
| 247 | |
| 248 | |
| 249 | // Callback function used for checking constraints when copying/relocating |
| 250 | // objects. Returns true if an object can be copied/relocated from its |
| 251 | // old_addr to a new_addr. |
| 252 | typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr); |
| 253 | |
| 254 | |
| 255 | // Callback function on inline caches, used for iterating over inline caches |
| 256 | // in compiled code. |
| 257 | typedef void (*InlineCacheCallback)(Code* code, Address ic); |
| 258 | |
| 259 | |
| 260 | // State for inline cache call sites. Aliased as IC::State. |
| 261 | enum InlineCacheState { |
| 262 | // Has never been executed. |
| 263 | UNINITIALIZED, |
| 264 | // Has been executed but monomorhic state has been delayed. |
| 265 | PREMONOMORPHIC, |
| 266 | // Has been executed and only one receiver type has been seen. |
| 267 | MONOMORPHIC, |
| 268 | // Like MONOMORPHIC but check failed due to prototype. |
| 269 | MONOMORPHIC_PROTOTYPE_FAILURE, |
| 270 | // Multiple receiver types have been seen. |
| 271 | MEGAMORPHIC, |
| 272 | // Special states for debug break or step in prepare stubs. |
| 273 | DEBUG_BREAK, |
| 274 | DEBUG_PREPARE_STEP_IN |
| 275 | }; |
| 276 | |
| 277 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 278 | enum CheckType { |
| 279 | RECEIVER_MAP_CHECK, |
| 280 | STRING_CHECK, |
| 281 | NUMBER_CHECK, |
| 282 | BOOLEAN_CHECK |
| 283 | }; |
| 284 | |
| 285 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 286 | enum CallFunctionFlags { |
| 287 | NO_CALL_FUNCTION_FLAGS = 0, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 288 | // Receiver might implicitly be the global objects. If it is, the |
| 289 | // hole is passed to the call function stub. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 290 | RECEIVER_MIGHT_BE_IMPLICIT = 1 << 0, |
| 291 | // The call target is cached in the instruction stream. |
| 292 | RECORD_CALL_TARGET = 1 << 1 |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 293 | }; |
| 294 | |
| 295 | |
| 296 | enum InlineCacheHolderFlag { |
| 297 | OWN_MAP, // For fast properties objects. |
| 298 | PROTOTYPE_MAP // For slow properties objects (except GlobalObjects). |
| 299 | }; |
| 300 | |
| 301 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 302 | // The Store Buffer (GC). |
| 303 | typedef enum { |
| 304 | kStoreBufferFullEvent, |
| 305 | kStoreBufferStartScanningPagesEvent, |
| 306 | kStoreBufferScanningPageEvent |
| 307 | } StoreBufferEvent; |
| 308 | |
| 309 | |
| 310 | typedef void (*StoreBufferCallback)(Heap* heap, |
| 311 | MemoryChunk* page, |
| 312 | StoreBufferEvent event); |
| 313 | |
| 314 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 315 | // Union used for fast testing of specific double values. |
| 316 | union DoubleRepresentation { |
| 317 | double value; |
| 318 | int64_t bits; |
| 319 | DoubleRepresentation(double x) { value = x; } |
| 320 | }; |
| 321 | |
| 322 | |
| 323 | // Union used for customized checking of the IEEE double types |
| 324 | // inlined within v8 runtime, rather than going to the underlying |
| 325 | // platform headers and libraries |
| 326 | union IeeeDoubleLittleEndianArchType { |
| 327 | double d; |
| 328 | struct { |
| 329 | unsigned int man_low :32; |
| 330 | unsigned int man_high :20; |
| 331 | unsigned int exp :11; |
| 332 | unsigned int sign :1; |
| 333 | } bits; |
| 334 | }; |
| 335 | |
| 336 | |
| 337 | union IeeeDoubleBigEndianArchType { |
| 338 | double d; |
| 339 | struct { |
| 340 | unsigned int sign :1; |
| 341 | unsigned int exp :11; |
| 342 | unsigned int man_high :20; |
| 343 | unsigned int man_low :32; |
| 344 | } bits; |
| 345 | }; |
| 346 | |
| 347 | |
| 348 | // AccessorCallback |
| 349 | struct AccessorDescriptor { |
| 350 | MaybeObject* (*getter)(Object* object, void* data); |
| 351 | MaybeObject* (*setter)(JSObject* object, Object* value, void* data); |
| 352 | void* data; |
| 353 | }; |
| 354 | |
| 355 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 356 | // Logging and profiling. A StateTag represents a possible state of |
| 357 | // the VM. The logger maintains a stack of these. Creating a VMState |
| 358 | // object enters a state by pushing on the stack, and destroying a |
| 359 | // VMState object leaves a state by popping the current state from the |
| 360 | // stack. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 361 | |
| 362 | #define STATE_TAG_LIST(V) \ |
| 363 | V(JS) \ |
| 364 | V(GC) \ |
| 365 | V(COMPILER) \ |
| 366 | V(OTHER) \ |
| 367 | V(EXTERNAL) |
| 368 | |
| 369 | enum StateTag { |
| 370 | #define DEF_STATE_TAG(name) name, |
| 371 | STATE_TAG_LIST(DEF_STATE_TAG) |
| 372 | #undef DEF_STATE_TAG |
| 373 | // Pseudo-types. |
| 374 | state_tag_count |
| 375 | }; |
| 376 | |
| 377 | |
| 378 | // ----------------------------------------------------------------------------- |
| 379 | // Macros |
| 380 | |
| 381 | // Testers for test. |
| 382 | |
| 383 | #define HAS_SMI_TAG(value) \ |
| 384 | ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag) |
| 385 | |
| 386 | #define HAS_FAILURE_TAG(value) \ |
| 387 | ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag) |
| 388 | |
| 389 | // OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer |
| 390 | #define OBJECT_POINTER_ALIGN(value) \ |
| 391 | (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) |
| 392 | |
| 393 | // POINTER_SIZE_ALIGN returns the value aligned as a pointer. |
| 394 | #define POINTER_SIZE_ALIGN(value) \ |
| 395 | (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) |
| 396 | |
| 397 | // MAP_POINTER_ALIGN returns the value aligned as a map pointer. |
| 398 | #define MAP_POINTER_ALIGN(value) \ |
| 399 | (((value) + kMapAlignmentMask) & ~kMapAlignmentMask) |
| 400 | |
| 401 | // CODE_POINTER_ALIGN returns the value aligned as a generated code segment. |
| 402 | #define CODE_POINTER_ALIGN(value) \ |
| 403 | (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) |
| 404 | |
| 405 | // Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk") |
| 406 | // inside a C++ class and new and delete will be overloaded so logging is |
| 407 | // performed. |
| 408 | // This file (globals.h) is included before log.h, so we use direct calls to |
| 409 | // the Logger rather than the LOG macro. |
| 410 | #ifdef DEBUG |
| 411 | #define TRACK_MEMORY(name) \ |
| 412 | void* operator new(size_t size) { \ |
| 413 | void* result = ::operator new(size); \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 414 | Logger::NewEventStatic(name, result, size); \ |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 415 | return result; \ |
| 416 | } \ |
| 417 | void operator delete(void* object) { \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 418 | Logger::DeleteEventStatic(name, object); \ |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 419 | ::operator delete(object); \ |
| 420 | } |
| 421 | #else |
| 422 | #define TRACK_MEMORY(name) |
| 423 | #endif |
| 424 | |
| 425 | |
| 426 | // Feature flags bit positions. They are mostly based on the CPUID spec. |
| 427 | // (We assign CPUID itself to one of the currently reserved bits -- |
| 428 | // feel free to change this if needed.) |
| 429 | // On X86/X64, values below 32 are bits in EDX, values above 32 are bits in ECX. |
| 430 | enum CpuFeature { SSE4_1 = 32 + 19, // x86 |
| 431 | SSE3 = 32 + 0, // x86 |
| 432 | SSE2 = 26, // x86 |
| 433 | CMOV = 15, // x86 |
| 434 | RDTSC = 4, // x86 |
| 435 | CPUID = 10, // x86 |
| 436 | VFP3 = 1, // ARM |
| 437 | ARMv7 = 2, // ARM |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 438 | SAHF = 0, // x86 |
| 439 | FPU = 1}; // MIPS |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 440 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 441 | |
| 442 | // Used to specify if a macro instruction must perform a smi check on tagged |
| 443 | // values. |
| 444 | enum SmiCheckType { |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 445 | DONT_DO_SMI_CHECK, |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 446 | DO_SMI_CHECK |
| 447 | }; |
| 448 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 449 | |
| 450 | // Used to specify whether a receiver is implicitly or explicitly |
| 451 | // provided to a call. |
| 452 | enum CallKind { |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 453 | CALL_AS_METHOD, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 454 | CALL_AS_FUNCTION |
| 455 | }; |
| 456 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 457 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 458 | enum ScopeType { |
| 459 | EVAL_SCOPE, // The top-level scope for an eval source. |
| 460 | FUNCTION_SCOPE, // The top-level scope for a function. |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 461 | MODULE_SCOPE, // The scope introduced by a module literal |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 462 | GLOBAL_SCOPE, // The top-level scope for a program or a top-level eval. |
| 463 | CATCH_SCOPE, // The scope introduced by catch. |
| 464 | BLOCK_SCOPE, // The scope introduced by a new block. |
| 465 | WITH_SCOPE // The scope introduced by with. |
| 466 | }; |
| 467 | |
| 468 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 469 | const uint32_t kHoleNanUpper32 = 0x7FFFFFFF; |
| 470 | const uint32_t kHoleNanLower32 = 0xFFFFFFFF; |
| 471 | const uint32_t kNaNOrInfinityLowerBoundUpper32 = 0x7FF00000; |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 472 | |
| 473 | const uint64_t kHoleNanInt64 = |
| 474 | (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 475 | const uint64_t kLastNonNaNInt64 = |
| 476 | (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32); |
| 477 | |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 478 | |
| 479 | enum VariableMode { |
| 480 | // User declared variables: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 481 | VAR, // declared via 'var', and 'function' declarations |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 482 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 483 | CONST, // declared via 'const' declarations |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 484 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 485 | CONST_HARMONY, // declared via 'const' declarations in harmony mode |
| 486 | |
| 487 | LET, // declared via 'let' declarations |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 488 | |
| 489 | // Variables introduced by the compiler: |
| 490 | DYNAMIC, // always require dynamic lookup (we don't know |
| 491 | // the declaration) |
| 492 | |
| 493 | DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 494 | // variable is global unless it has been shadowed |
| 495 | // by an eval-introduced variable |
| 496 | |
| 497 | DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the |
| 498 | // variable is local and where it is unless it |
| 499 | // has been shadowed by an eval-introduced |
| 500 | // variable |
| 501 | |
| 502 | INTERNAL, // like VAR, but not user-visible (may or may not |
| 503 | // be in a context) |
| 504 | |
| 505 | TEMPORARY // temporary variables (not user-visible), never |
| 506 | // in a context |
| 507 | }; |
| 508 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 509 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 510 | // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
| 511 | // and immutable bindings that can be in two states: initialized and |
| 512 | // uninitialized. In ES5 only immutable bindings have these two states. When |
| 513 | // accessing a binding, it needs to be checked for initialization. However in |
| 514 | // the following cases the binding is initialized immediately after creation |
| 515 | // so the initialization check can always be skipped: |
| 516 | // 1. Var declared local variables. |
| 517 | // var foo; |
| 518 | // 2. A local variable introduced by a function declaration. |
| 519 | // function foo() {} |
| 520 | // 3. Parameters |
| 521 | // function x(foo) {} |
| 522 | // 4. Catch bound variables. |
| 523 | // try {} catch (foo) {} |
| 524 | // 6. Function variables of named function expressions. |
| 525 | // var x = function foo() {} |
| 526 | // 7. Implicit binding of 'this'. |
| 527 | // 8. Implicit binding of 'arguments' in functions. |
| 528 | // |
| 529 | // ES5 specified object environment records which are introduced by ES elements |
| 530 | // such as Program and WithStatement that associate identifier bindings with the |
| 531 | // properties of some object. In the specification only mutable bindings exist |
| 532 | // (which may be non-writable) and have no distinct initialization step. However |
| 533 | // V8 allows const declarations in global code with distinct creation and |
| 534 | // initialization steps which are represented by non-writable properties in the |
| 535 | // global object. As a result also these bindings need to be checked for |
| 536 | // initialization. |
| 537 | // |
| 538 | // The following enum specifies a flag that indicates if the binding needs a |
| 539 | // distinct initialization step (kNeedsInitialization) or if the binding is |
| 540 | // immediately initialized upon creation (kCreatedInitialized). |
| 541 | enum InitializationFlag { |
| 542 | kNeedsInitialization, |
| 543 | kCreatedInitialized |
| 544 | }; |
| 545 | |
| 546 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 547 | enum ClearExceptionFlag { |
| 548 | KEEP_EXCEPTION, |
| 549 | CLEAR_EXCEPTION |
| 550 | }; |
| 551 | |
| 552 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 553 | } } // namespace v8::internal |
| 554 | |
| 555 | #endif // V8_V8GLOBALS_H_ |