kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1 | // Copyright 2011 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" |
| 32 | |
| 33 | namespace v8 { |
| 34 | namespace internal { |
| 35 | |
| 36 | // This file contains constants and global declarations related to the |
| 37 | // V8 system. |
| 38 | |
| 39 | // Mask for the sign bit in a smi. |
| 40 | const intptr_t kSmiSignMask = kIntptrSignBit; |
| 41 | |
| 42 | const int kObjectAlignmentBits = kPointerSizeLog2; |
| 43 | const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 44 | const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 45 | |
| 46 | // Desired alignment for pointers. |
| 47 | const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 48 | const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| 49 | |
| 50 | // Desired alignment for maps. |
| 51 | #if V8_HOST_ARCH_64_BIT |
| 52 | const intptr_t kMapAlignmentBits = kObjectAlignmentBits; |
| 53 | #else |
| 54 | const intptr_t kMapAlignmentBits = kObjectAlignmentBits + 3; |
| 55 | #endif |
| 56 | const intptr_t kMapAlignment = (1 << kMapAlignmentBits); |
| 57 | const intptr_t kMapAlignmentMask = kMapAlignment - 1; |
| 58 | |
| 59 | // Desired alignment for generated code is 32 bytes (to improve cache line |
| 60 | // utilization). |
| 61 | const int kCodeAlignmentBits = 5; |
| 62 | const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits; |
| 63 | const intptr_t kCodeAlignmentMask = kCodeAlignment - 1; |
| 64 | |
| 65 | // Tag information for Failure. |
| 66 | const int kFailureTag = 3; |
| 67 | const int kFailureTagSize = 2; |
| 68 | const intptr_t kFailureTagMask = (1 << kFailureTagSize) - 1; |
| 69 | |
| 70 | |
| 71 | // Zap-value: The value used for zapping dead objects. |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 72 | // Should be a recognizable hex value tagged as a failure. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 73 | #ifdef V8_HOST_ARCH_64_BIT |
| 74 | const Address kZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 75 | reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 76 | const Address kHandleZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 77 | reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 78 | const Address kFromSpaceZapValue = |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 79 | reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf)); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 80 | const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 81 | const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 82 | #else |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 83 | const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef); |
| 84 | const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf); |
| 85 | const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf); |
| 86 | const uint32_t kSlotsZapValue = 0xbeefdeef; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 87 | const uint32_t kDebugZapValue = 0xbadbaddb; |
| 88 | #endif |
| 89 | |
| 90 | |
| 91 | // Number of bits to represent the page size for paged spaces. The value of 13 |
| 92 | // gives 8K bytes per page. |
| 93 | const int kPageSizeBits = 13; |
| 94 | |
| 95 | // On Intel architecture, cache line size is 64 bytes. |
| 96 | // On ARM it may be less (32 bytes), but as far this constant is |
| 97 | // used for aligning data, it doesn't hurt to align on a greater value. |
| 98 | const int kProcessorCacheLineSize = 64; |
| 99 | |
| 100 | // Constants relevant to double precision floating point numbers. |
| 101 | |
| 102 | // Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no |
| 103 | // other bits set. |
| 104 | const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51; |
| 105 | // If looking only at the top 32 bits, the QNaN mask is bits 19 to 30. |
| 106 | const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32); |
| 107 | |
| 108 | |
| 109 | // ----------------------------------------------------------------------------- |
| 110 | // Forward declarations for frequently used classes |
| 111 | // (sorted alphabetically) |
| 112 | |
| 113 | class AccessorInfo; |
| 114 | class Allocation; |
| 115 | class Arguments; |
| 116 | class Assembler; |
| 117 | class AssertNoAllocation; |
| 118 | class BreakableStatement; |
| 119 | class Code; |
| 120 | class CodeGenerator; |
| 121 | class CodeStub; |
| 122 | class Context; |
| 123 | class Debug; |
| 124 | class Debugger; |
| 125 | class DebugInfo; |
| 126 | class Descriptor; |
| 127 | class DescriptorArray; |
| 128 | class Expression; |
| 129 | class ExternalReference; |
| 130 | class FixedArray; |
| 131 | class FunctionEntry; |
| 132 | class FunctionLiteral; |
| 133 | class FunctionTemplateInfo; |
| 134 | class NumberDictionary; |
| 135 | class StringDictionary; |
| 136 | template <typename T> class Handle; |
| 137 | class Heap; |
| 138 | class HeapObject; |
| 139 | class IC; |
| 140 | class InterceptorInfo; |
| 141 | class IterationStatement; |
| 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; |
| 152 | class NodeVisitor; |
| 153 | class Object; |
| 154 | class MaybeObject; |
| 155 | class OldSpace; |
| 156 | class Property; |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 157 | class Foreign; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 158 | class RegExpNode; |
| 159 | struct RegExpCompileData; |
| 160 | class RegExpTree; |
| 161 | class RegExpCompiler; |
| 162 | class RegExpVisitor; |
| 163 | class Scope; |
| 164 | template<class Allocator = FreeStoreAllocationPolicy> class ScopeInfo; |
| 165 | class SerializedScopeInfo; |
| 166 | class Script; |
| 167 | class Slot; |
| 168 | class Smi; |
| 169 | template <typename Config, class Allocator = FreeStoreAllocationPolicy> |
| 170 | class SplayTree; |
| 171 | class Statement; |
| 172 | class String; |
| 173 | class Struct; |
| 174 | class SwitchStatement; |
| 175 | class AstVisitor; |
| 176 | class Variable; |
| 177 | class VariableProxy; |
| 178 | class RelocInfo; |
| 179 | class Deserializer; |
| 180 | class MessageLocation; |
| 181 | class ObjectGroup; |
| 182 | class TickSample; |
| 183 | class VirtualMemory; |
| 184 | class Mutex; |
| 185 | |
| 186 | typedef bool (*WeakSlotCallback)(Object** pointer); |
| 187 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 188 | typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer); |
| 189 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 190 | // ----------------------------------------------------------------------------- |
| 191 | // Miscellaneous |
| 192 | |
| 193 | // NOTE: SpaceIterator depends on AllocationSpace enumeration values being |
| 194 | // consecutive. |
| 195 | enum AllocationSpace { |
| 196 | NEW_SPACE, // Semispaces collected with copying collector. |
| 197 | OLD_POINTER_SPACE, // May contain pointers to new space. |
| 198 | OLD_DATA_SPACE, // Must not have pointers to new space. |
| 199 | CODE_SPACE, // No pointers to new space, marked executable. |
| 200 | MAP_SPACE, // Only and all map objects. |
| 201 | CELL_SPACE, // Only and all cell objects. |
| 202 | LO_SPACE, // Promoted large objects. |
| 203 | |
| 204 | FIRST_SPACE = NEW_SPACE, |
| 205 | LAST_SPACE = LO_SPACE, |
| 206 | FIRST_PAGED_SPACE = OLD_POINTER_SPACE, |
| 207 | LAST_PAGED_SPACE = CELL_SPACE |
| 208 | }; |
| 209 | const int kSpaceTagSize = 3; |
| 210 | const int kSpaceTagMask = (1 << kSpaceTagSize) - 1; |
| 211 | |
| 212 | |
| 213 | // A flag that indicates whether objects should be pretenured when |
| 214 | // allocated (allocated directly into the old generation) or not |
| 215 | // (allocated in the young generation if the object size and type |
| 216 | // allows). |
| 217 | enum PretenureFlag { NOT_TENURED, TENURED }; |
| 218 | |
| 219 | enum GarbageCollector { SCAVENGER, MARK_COMPACTOR }; |
| 220 | |
| 221 | enum Executability { NOT_EXECUTABLE, EXECUTABLE }; |
| 222 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 223 | enum VisitMode { |
| 224 | VISIT_ALL, |
| 225 | VISIT_ALL_IN_SCAVENGE, |
| 226 | VISIT_ALL_IN_SWEEP_NEWSPACE, |
| 227 | VISIT_ONLY_STRONG |
| 228 | }; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 229 | |
| 230 | // Flag indicating whether code is built into the VM (one of the natives files). |
| 231 | enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE }; |
| 232 | |
| 233 | |
| 234 | // A CodeDesc describes a buffer holding instructions and relocation |
| 235 | // information. The instructions start at the beginning of the buffer |
| 236 | // and grow forward, the relocation information starts at the end of |
| 237 | // the buffer and grows backward. |
| 238 | // |
| 239 | // |<--------------- buffer_size ---------------->| |
| 240 | // |<-- instr_size -->| |<-- reloc_size -->| |
| 241 | // +==================+========+==================+ |
| 242 | // | instructions | free | reloc info | |
| 243 | // +==================+========+==================+ |
| 244 | // ^ |
| 245 | // | |
| 246 | // buffer |
| 247 | |
| 248 | struct CodeDesc { |
| 249 | byte* buffer; |
| 250 | int buffer_size; |
| 251 | int instr_size; |
| 252 | int reloc_size; |
| 253 | Assembler* origin; |
| 254 | }; |
| 255 | |
| 256 | |
| 257 | // Callback function on object slots, used for iterating heap object slots in |
| 258 | // HeapObjects, global pointers to heap objects, etc. The callback allows the |
| 259 | // callback function to change the value of the slot. |
| 260 | typedef void (*ObjectSlotCallback)(HeapObject** pointer); |
| 261 | |
| 262 | |
| 263 | // Callback function used for iterating objects in heap spaces, |
| 264 | // for example, scanning heap objects. |
| 265 | typedef int (*HeapObjectCallback)(HeapObject* obj); |
| 266 | |
| 267 | |
| 268 | // Callback function used for checking constraints when copying/relocating |
| 269 | // objects. Returns true if an object can be copied/relocated from its |
| 270 | // old_addr to a new_addr. |
| 271 | typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr); |
| 272 | |
| 273 | |
| 274 | // Callback function on inline caches, used for iterating over inline caches |
| 275 | // in compiled code. |
| 276 | typedef void (*InlineCacheCallback)(Code* code, Address ic); |
| 277 | |
| 278 | |
| 279 | // State for inline cache call sites. Aliased as IC::State. |
| 280 | enum InlineCacheState { |
| 281 | // Has never been executed. |
| 282 | UNINITIALIZED, |
| 283 | // Has been executed but monomorhic state has been delayed. |
| 284 | PREMONOMORPHIC, |
| 285 | // Has been executed and only one receiver type has been seen. |
| 286 | MONOMORPHIC, |
| 287 | // Like MONOMORPHIC but check failed due to prototype. |
| 288 | MONOMORPHIC_PROTOTYPE_FAILURE, |
| 289 | // Multiple receiver types have been seen. |
| 290 | MEGAMORPHIC, |
| 291 | // Special states for debug break or step in prepare stubs. |
| 292 | DEBUG_BREAK, |
| 293 | DEBUG_PREPARE_STEP_IN |
| 294 | }; |
| 295 | |
| 296 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 297 | enum CheckType { |
| 298 | RECEIVER_MAP_CHECK, |
| 299 | STRING_CHECK, |
| 300 | NUMBER_CHECK, |
| 301 | BOOLEAN_CHECK |
| 302 | }; |
| 303 | |
| 304 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 305 | enum InLoopFlag { |
| 306 | NOT_IN_LOOP, |
| 307 | IN_LOOP |
| 308 | }; |
| 309 | |
| 310 | |
| 311 | enum CallFunctionFlags { |
| 312 | NO_CALL_FUNCTION_FLAGS = 0, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 313 | // Receiver might implicitly be the global objects. If it is, the |
| 314 | // hole is passed to the call function stub. |
| 315 | RECEIVER_MIGHT_BE_IMPLICIT = 1 << 0 |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | |
| 319 | enum InlineCacheHolderFlag { |
| 320 | OWN_MAP, // For fast properties objects. |
| 321 | PROTOTYPE_MAP // For slow properties objects (except GlobalObjects). |
| 322 | }; |
| 323 | |
| 324 | |
| 325 | // Type of properties. |
| 326 | // Order of properties is significant. |
| 327 | // Must fit in the BitField PropertyDetails::TypeField. |
| 328 | // A copy of this is in mirror-debugger.js. |
| 329 | enum PropertyType { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 330 | NORMAL = 0, // only in slow mode |
| 331 | FIELD = 1, // only in fast mode |
| 332 | CONSTANT_FUNCTION = 2, // only in fast mode |
| 333 | CALLBACKS = 3, |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 334 | HANDLER = 4, // only in lookup results, not in descriptors |
| 335 | INTERCEPTOR = 5, // only in lookup results, not in descriptors |
| 336 | MAP_TRANSITION = 6, // only in fast mode |
| 337 | EXTERNAL_ARRAY_TRANSITION = 7, |
| 338 | CONSTANT_TRANSITION = 8, // only in fast mode |
| 339 | NULL_DESCRIPTOR = 9, // only in fast mode |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 340 | // All properties before MAP_TRANSITION are real. |
| 341 | FIRST_PHANTOM_PROPERTY_TYPE = MAP_TRANSITION, |
| 342 | // There are no IC stubs for NULL_DESCRIPTORS. Therefore, |
| 343 | // NULL_DESCRIPTOR can be used as the type flag for IC stubs for |
| 344 | // nonexistent properties. |
| 345 | NONEXISTENT = NULL_DESCRIPTOR |
| 346 | }; |
| 347 | |
| 348 | |
| 349 | // Whether to remove map transitions and constant transitions from a |
| 350 | // DescriptorArray. |
| 351 | enum TransitionFlag { |
| 352 | REMOVE_TRANSITIONS, |
| 353 | KEEP_TRANSITIONS |
| 354 | }; |
| 355 | |
| 356 | |
| 357 | // Union used for fast testing of specific double values. |
| 358 | union DoubleRepresentation { |
| 359 | double value; |
| 360 | int64_t bits; |
| 361 | DoubleRepresentation(double x) { value = x; } |
| 362 | }; |
| 363 | |
| 364 | |
| 365 | // Union used for customized checking of the IEEE double types |
| 366 | // inlined within v8 runtime, rather than going to the underlying |
| 367 | // platform headers and libraries |
| 368 | union IeeeDoubleLittleEndianArchType { |
| 369 | double d; |
| 370 | struct { |
| 371 | unsigned int man_low :32; |
| 372 | unsigned int man_high :20; |
| 373 | unsigned int exp :11; |
| 374 | unsigned int sign :1; |
| 375 | } bits; |
| 376 | }; |
| 377 | |
| 378 | |
| 379 | union IeeeDoubleBigEndianArchType { |
| 380 | double d; |
| 381 | struct { |
| 382 | unsigned int sign :1; |
| 383 | unsigned int exp :11; |
| 384 | unsigned int man_high :20; |
| 385 | unsigned int man_low :32; |
| 386 | } bits; |
| 387 | }; |
| 388 | |
| 389 | |
| 390 | // AccessorCallback |
| 391 | struct AccessorDescriptor { |
| 392 | MaybeObject* (*getter)(Object* object, void* data); |
| 393 | MaybeObject* (*setter)(JSObject* object, Object* value, void* data); |
| 394 | void* data; |
| 395 | }; |
| 396 | |
| 397 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 398 | // Logging and profiling. A StateTag represents a possible state of |
| 399 | // the VM. The logger maintains a stack of these. Creating a VMState |
| 400 | // object enters a state by pushing on the stack, and destroying a |
| 401 | // VMState object leaves a state by popping the current state from the |
| 402 | // stack. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 403 | |
| 404 | #define STATE_TAG_LIST(V) \ |
| 405 | V(JS) \ |
| 406 | V(GC) \ |
| 407 | V(COMPILER) \ |
| 408 | V(OTHER) \ |
| 409 | V(EXTERNAL) |
| 410 | |
| 411 | enum StateTag { |
| 412 | #define DEF_STATE_TAG(name) name, |
| 413 | STATE_TAG_LIST(DEF_STATE_TAG) |
| 414 | #undef DEF_STATE_TAG |
| 415 | // Pseudo-types. |
| 416 | state_tag_count |
| 417 | }; |
| 418 | |
| 419 | |
| 420 | // ----------------------------------------------------------------------------- |
| 421 | // Macros |
| 422 | |
| 423 | // Testers for test. |
| 424 | |
| 425 | #define HAS_SMI_TAG(value) \ |
| 426 | ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag) |
| 427 | |
| 428 | #define HAS_FAILURE_TAG(value) \ |
| 429 | ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag) |
| 430 | |
| 431 | // OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer |
| 432 | #define OBJECT_POINTER_ALIGN(value) \ |
| 433 | (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) |
| 434 | |
| 435 | // POINTER_SIZE_ALIGN returns the value aligned as a pointer. |
| 436 | #define POINTER_SIZE_ALIGN(value) \ |
| 437 | (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) |
| 438 | |
| 439 | // MAP_POINTER_ALIGN returns the value aligned as a map pointer. |
| 440 | #define MAP_POINTER_ALIGN(value) \ |
| 441 | (((value) + kMapAlignmentMask) & ~kMapAlignmentMask) |
| 442 | |
| 443 | // CODE_POINTER_ALIGN returns the value aligned as a generated code segment. |
| 444 | #define CODE_POINTER_ALIGN(value) \ |
| 445 | (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) |
| 446 | |
| 447 | // Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk") |
| 448 | // inside a C++ class and new and delete will be overloaded so logging is |
| 449 | // performed. |
| 450 | // This file (globals.h) is included before log.h, so we use direct calls to |
| 451 | // the Logger rather than the LOG macro. |
| 452 | #ifdef DEBUG |
| 453 | #define TRACK_MEMORY(name) \ |
| 454 | void* operator new(size_t size) { \ |
| 455 | void* result = ::operator new(size); \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 456 | Logger::NewEventStatic(name, result, size); \ |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 457 | return result; \ |
| 458 | } \ |
| 459 | void operator delete(void* object) { \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 460 | Logger::DeleteEventStatic(name, object); \ |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 461 | ::operator delete(object); \ |
| 462 | } |
| 463 | #else |
| 464 | #define TRACK_MEMORY(name) |
| 465 | #endif |
| 466 | |
| 467 | |
| 468 | // Feature flags bit positions. They are mostly based on the CPUID spec. |
| 469 | // (We assign CPUID itself to one of the currently reserved bits -- |
| 470 | // feel free to change this if needed.) |
| 471 | // On X86/X64, values below 32 are bits in EDX, values above 32 are bits in ECX. |
| 472 | enum CpuFeature { SSE4_1 = 32 + 19, // x86 |
| 473 | SSE3 = 32 + 0, // x86 |
| 474 | SSE2 = 26, // x86 |
| 475 | CMOV = 15, // x86 |
| 476 | RDTSC = 4, // x86 |
| 477 | CPUID = 10, // x86 |
| 478 | VFP3 = 1, // ARM |
| 479 | ARMv7 = 2, // ARM |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 480 | SAHF = 0, // x86 |
| 481 | FPU = 1}; // MIPS |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 482 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 483 | // The Strict Mode (ECMA-262 5th edition, 4.2.2). |
| 484 | enum StrictModeFlag { |
| 485 | kNonStrictMode, |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 486 | kStrictMode, |
| 487 | // This value is never used, but is needed to prevent GCC 4.5 from failing |
| 488 | // to compile when we assert that a flag is either kNonStrictMode or |
| 489 | // kStrictMode. |
| 490 | kInvalidStrictFlag |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 491 | }; |
| 492 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 493 | |
| 494 | // Used to specify if a macro instruction must perform a smi check on tagged |
| 495 | // values. |
| 496 | enum SmiCheckType { |
| 497 | DONT_DO_SMI_CHECK = 0, |
| 498 | DO_SMI_CHECK |
| 499 | }; |
| 500 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 501 | |
| 502 | // Used to specify whether a receiver is implicitly or explicitly |
| 503 | // provided to a call. |
| 504 | enum CallKind { |
| 505 | CALL_AS_METHOD = 0, |
| 506 | CALL_AS_FUNCTION |
| 507 | }; |
| 508 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 509 | |
| 510 | static const uint32_t kHoleNanUpper32 = 0x7FFFFFFF; |
| 511 | static const uint32_t kHoleNanLower32 = 0xFFFFFFFF; |
| 512 | static const uint32_t kNaNOrInfinityLowerBoundUpper32 = 0x7FF00000; |
| 513 | |
| 514 | const uint64_t kHoleNanInt64 = |
| 515 | (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 516 | const uint64_t kLastNonNaNInt64 = |
| 517 | (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32); |
| 518 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 519 | } } // namespace v8::internal |
| 520 | |
| 521 | #endif // V8_V8GLOBALS_H_ |