OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_GLOBALS_H_ | 5 #ifndef V8_GLOBALS_H_ |
6 #define V8_GLOBALS_H_ | 6 #define V8_GLOBALS_H_ |
7 | 7 |
8 #include "../include/v8stdint.h" | 8 #include "../include/v8stdint.h" |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "checks.h" |
11 | 12 |
12 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' | 13 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' |
13 // warning flag and certain versions of GCC due to a bug: | 14 // warning flag and certain versions of GCC due to a bug: |
14 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 | 15 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 |
15 // For now, we use the more involved template-based version from <limits>, but | 16 // For now, we use the more involved template-based version from <limits>, but |
16 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) | 17 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) |
17 #if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0) | 18 #if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0) |
18 # include <limits> // NOLINT | 19 # include <limits> // NOLINT |
19 # define V8_INFINITY std::numeric_limits<double>::infinity() | 20 # define V8_INFINITY std::numeric_limits<double>::infinity() |
20 #elif V8_LIBC_MSVCRT | 21 #elif V8_LIBC_MSVCRT |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 template <typename T, class P = FreeStoreAllocationPolicy> class List; | 329 template <typename T, class P = FreeStoreAllocationPolicy> class List; |
329 | 330 |
330 // ----------------------------------------------------------------------------- | 331 // ----------------------------------------------------------------------------- |
331 // Declarations for use in both the preparser and the rest of V8. | 332 // Declarations for use in both the preparser and the rest of V8. |
332 | 333 |
333 // The Strict Mode (ECMA-262 5th edition, 4.2.2). | 334 // The Strict Mode (ECMA-262 5th edition, 4.2.2). |
334 | 335 |
335 enum StrictMode { SLOPPY, STRICT }; | 336 enum StrictMode { SLOPPY, STRICT }; |
336 | 337 |
337 | 338 |
| 339 // Mask for the sign bit in a smi. |
| 340 const intptr_t kSmiSignMask = kIntptrSignBit; |
| 341 |
| 342 const int kObjectAlignmentBits = kPointerSizeLog2; |
| 343 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 344 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 345 |
| 346 // Desired alignment for pointers. |
| 347 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 348 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| 349 |
| 350 // Desired alignment for double values. |
| 351 const intptr_t kDoubleAlignment = 8; |
| 352 const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1; |
| 353 |
| 354 // Desired alignment for generated code is 32 bytes (to improve cache line |
| 355 // utilization). |
| 356 const int kCodeAlignmentBits = 5; |
| 357 const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits; |
| 358 const intptr_t kCodeAlignmentMask = kCodeAlignment - 1; |
| 359 |
| 360 // Tag information for Failure. |
| 361 // TODO(yangguo): remove this from space owner calculation. |
| 362 const int kFailureTag = 3; |
| 363 const int kFailureTagSize = 2; |
| 364 const intptr_t kFailureTagMask = (1 << kFailureTagSize) - 1; |
| 365 |
| 366 |
| 367 // Zap-value: The value used for zapping dead objects. |
| 368 // Should be a recognizable hex value tagged as a failure. |
| 369 #ifdef V8_HOST_ARCH_64_BIT |
| 370 const Address kZapValue = |
| 371 reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef)); |
| 372 const Address kHandleZapValue = |
| 373 reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf)); |
| 374 const Address kGlobalHandleZapValue = |
| 375 reinterpret_cast<Address>(V8_UINT64_C(0x1baffed00baffedf)); |
| 376 const Address kFromSpaceZapValue = |
| 377 reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf)); |
| 378 const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb); |
| 379 const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef); |
| 380 const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf; |
| 381 #else |
| 382 const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef); |
| 383 const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf); |
| 384 const Address kGlobalHandleZapValue = reinterpret_cast<Address>(0xbaffedf); |
| 385 const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf); |
| 386 const uint32_t kSlotsZapValue = 0xbeefdeef; |
| 387 const uint32_t kDebugZapValue = 0xbadbaddb; |
| 388 const uint32_t kFreeListZapValue = 0xfeed1eaf; |
| 389 #endif |
| 390 |
| 391 const int kCodeZapValue = 0xbadc0de; |
| 392 |
| 393 // Number of bits to represent the page size for paged spaces. The value of 20 |
| 394 // gives 1Mb bytes per page. |
| 395 const int kPageSizeBits = 20; |
| 396 |
| 397 // On Intel architecture, cache line size is 64 bytes. |
| 398 // On ARM it may be less (32 bytes), but as far this constant is |
| 399 // used for aligning data, it doesn't hurt to align on a greater value. |
| 400 #define PROCESSOR_CACHE_LINE_SIZE 64 |
| 401 |
| 402 // Constants relevant to double precision floating point numbers. |
| 403 // If looking only at the top 32 bits, the QNaN mask is bits 19 to 30. |
| 404 const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32); |
| 405 |
| 406 |
| 407 // ----------------------------------------------------------------------------- |
| 408 // Forward declarations for frequently used classes |
| 409 |
| 410 class AccessorInfo; |
| 411 class Allocation; |
| 412 class Arguments; |
| 413 class Assembler; |
| 414 class Code; |
| 415 class CodeGenerator; |
| 416 class CodeStub; |
| 417 class Context; |
| 418 class Debug; |
| 419 class Debugger; |
| 420 class DebugInfo; |
| 421 class Descriptor; |
| 422 class DescriptorArray; |
| 423 class TransitionArray; |
| 424 class ExternalReference; |
| 425 class FixedArray; |
| 426 class FunctionTemplateInfo; |
| 427 class MemoryChunk; |
| 428 class SeededNumberDictionary; |
| 429 class UnseededNumberDictionary; |
| 430 class NameDictionary; |
| 431 template <typename T> class MaybeHandle; |
| 432 template <typename T> class Handle; |
| 433 class Heap; |
| 434 class HeapObject; |
| 435 class IC; |
| 436 class InterceptorInfo; |
| 437 class Isolate; |
| 438 class JSReceiver; |
| 439 class JSArray; |
| 440 class JSFunction; |
| 441 class JSObject; |
| 442 class LargeObjectSpace; |
| 443 class LookupResult; |
| 444 class MacroAssembler; |
| 445 class Map; |
| 446 class MapSpace; |
| 447 class MarkCompactCollector; |
| 448 class NewSpace; |
| 449 class Object; |
| 450 class OldSpace; |
| 451 class Foreign; |
| 452 class Scope; |
| 453 class ScopeInfo; |
| 454 class Script; |
| 455 class Smi; |
| 456 template <typename Config, class Allocator = FreeStoreAllocationPolicy> |
| 457 class SplayTree; |
| 458 class String; |
| 459 class Name; |
| 460 class Struct; |
| 461 class Variable; |
| 462 class RelocInfo; |
| 463 class Deserializer; |
| 464 class MessageLocation; |
| 465 class VirtualMemory; |
| 466 class Mutex; |
| 467 class RecursiveMutex; |
| 468 |
| 469 typedef bool (*WeakSlotCallback)(Object** pointer); |
| 470 |
| 471 typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer); |
| 472 |
| 473 // ----------------------------------------------------------------------------- |
| 474 // Miscellaneous |
| 475 |
| 476 // NOTE: SpaceIterator depends on AllocationSpace enumeration values being |
| 477 // consecutive. |
| 478 enum AllocationSpace { |
| 479 NEW_SPACE, // Semispaces collected with copying collector. |
| 480 OLD_POINTER_SPACE, // May contain pointers to new space. |
| 481 OLD_DATA_SPACE, // Must not have pointers to new space. |
| 482 CODE_SPACE, // No pointers to new space, marked executable. |
| 483 MAP_SPACE, // Only and all map objects. |
| 484 CELL_SPACE, // Only and all cell objects. |
| 485 PROPERTY_CELL_SPACE, // Only and all global property cell objects. |
| 486 LO_SPACE, // Promoted large objects. |
| 487 INVALID_SPACE, // Only used in AllocationResult to signal success. |
| 488 |
| 489 FIRST_SPACE = NEW_SPACE, |
| 490 LAST_SPACE = LO_SPACE, |
| 491 FIRST_PAGED_SPACE = OLD_POINTER_SPACE, |
| 492 LAST_PAGED_SPACE = PROPERTY_CELL_SPACE |
| 493 }; |
| 494 const int kSpaceTagSize = 3; |
| 495 const int kSpaceTagMask = (1 << kSpaceTagSize) - 1; |
| 496 |
| 497 |
| 498 // A flag that indicates whether objects should be pretenured when |
| 499 // allocated (allocated directly into the old generation) or not |
| 500 // (allocated in the young generation if the object size and type |
| 501 // allows). |
| 502 enum PretenureFlag { NOT_TENURED, TENURED }; |
| 503 |
| 504 enum MinimumCapacity { |
| 505 USE_DEFAULT_MINIMUM_CAPACITY, |
| 506 USE_CUSTOM_MINIMUM_CAPACITY |
| 507 }; |
| 508 |
| 509 enum GarbageCollector { SCAVENGER, MARK_COMPACTOR }; |
| 510 |
| 511 enum Executability { NOT_EXECUTABLE, EXECUTABLE }; |
| 512 |
| 513 enum VisitMode { |
| 514 VISIT_ALL, |
| 515 VISIT_ALL_IN_SCAVENGE, |
| 516 VISIT_ALL_IN_SWEEP_NEWSPACE, |
| 517 VISIT_ONLY_STRONG |
| 518 }; |
| 519 |
| 520 // Flag indicating whether code is built into the VM (one of the natives files). |
| 521 enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE }; |
| 522 |
| 523 |
| 524 // A CodeDesc describes a buffer holding instructions and relocation |
| 525 // information. The instructions start at the beginning of the buffer |
| 526 // and grow forward, the relocation information starts at the end of |
| 527 // the buffer and grows backward. |
| 528 // |
| 529 // |<--------------- buffer_size ---------------->| |
| 530 // |<-- instr_size -->| |<-- reloc_size -->| |
| 531 // +==================+========+==================+ |
| 532 // | instructions | free | reloc info | |
| 533 // +==================+========+==================+ |
| 534 // ^ |
| 535 // | |
| 536 // buffer |
| 537 |
| 538 struct CodeDesc { |
| 539 byte* buffer; |
| 540 int buffer_size; |
| 541 int instr_size; |
| 542 int reloc_size; |
| 543 Assembler* origin; |
| 544 }; |
| 545 |
| 546 |
| 547 // Callback function used for iterating objects in heap spaces, |
| 548 // for example, scanning heap objects. |
| 549 typedef int (*HeapObjectCallback)(HeapObject* obj); |
| 550 |
| 551 |
| 552 // Callback function used for checking constraints when copying/relocating |
| 553 // objects. Returns true if an object can be copied/relocated from its |
| 554 // old_addr to a new_addr. |
| 555 typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr); |
| 556 |
| 557 |
| 558 // Callback function on inline caches, used for iterating over inline caches |
| 559 // in compiled code. |
| 560 typedef void (*InlineCacheCallback)(Code* code, Address ic); |
| 561 |
| 562 |
| 563 // State for inline cache call sites. Aliased as IC::State. |
| 564 enum InlineCacheState { |
| 565 // Has never been executed. |
| 566 UNINITIALIZED, |
| 567 // Has been executed but monomorhic state has been delayed. |
| 568 PREMONOMORPHIC, |
| 569 // Has been executed and only one receiver type has been seen. |
| 570 MONOMORPHIC, |
| 571 // Like MONOMORPHIC but check failed due to prototype. |
| 572 MONOMORPHIC_PROTOTYPE_FAILURE, |
| 573 // Multiple receiver types have been seen. |
| 574 POLYMORPHIC, |
| 575 // Many receiver types have been seen. |
| 576 MEGAMORPHIC, |
| 577 // A generic handler is installed and no extra typefeedback is recorded. |
| 578 GENERIC, |
| 579 // Special state for debug break or step in prepare stubs. |
| 580 DEBUG_STUB |
| 581 }; |
| 582 |
| 583 |
| 584 enum CallFunctionFlags { |
| 585 NO_CALL_FUNCTION_FLAGS, |
| 586 CALL_AS_METHOD, |
| 587 // Always wrap the receiver and call to the JSFunction. Only use this flag |
| 588 // both the receiver type and the target method are statically known. |
| 589 WRAP_AND_CALL |
| 590 }; |
| 591 |
| 592 |
| 593 enum CallConstructorFlags { |
| 594 NO_CALL_CONSTRUCTOR_FLAGS, |
| 595 // The call target is cached in the instruction stream. |
| 596 RECORD_CONSTRUCTOR_TARGET |
| 597 }; |
| 598 |
| 599 |
| 600 enum InlineCacheHolderFlag { |
| 601 OWN_MAP, // For fast properties objects. |
| 602 PROTOTYPE_MAP // For slow properties objects (except GlobalObjects). |
| 603 }; |
| 604 |
| 605 |
| 606 // The Store Buffer (GC). |
| 607 typedef enum { |
| 608 kStoreBufferFullEvent, |
| 609 kStoreBufferStartScanningPagesEvent, |
| 610 kStoreBufferScanningPageEvent |
| 611 } StoreBufferEvent; |
| 612 |
| 613 |
| 614 typedef void (*StoreBufferCallback)(Heap* heap, |
| 615 MemoryChunk* page, |
| 616 StoreBufferEvent event); |
| 617 |
| 618 |
| 619 // Union used for fast testing of specific double values. |
| 620 union DoubleRepresentation { |
| 621 double value; |
| 622 int64_t bits; |
| 623 DoubleRepresentation(double x) { value = x; } |
| 624 bool operator==(const DoubleRepresentation& other) const { |
| 625 return bits == other.bits; |
| 626 } |
| 627 }; |
| 628 |
| 629 |
| 630 // Union used for customized checking of the IEEE double types |
| 631 // inlined within v8 runtime, rather than going to the underlying |
| 632 // platform headers and libraries |
| 633 union IeeeDoubleLittleEndianArchType { |
| 634 double d; |
| 635 struct { |
| 636 unsigned int man_low :32; |
| 637 unsigned int man_high :20; |
| 638 unsigned int exp :11; |
| 639 unsigned int sign :1; |
| 640 } bits; |
| 641 }; |
| 642 |
| 643 |
| 644 union IeeeDoubleBigEndianArchType { |
| 645 double d; |
| 646 struct { |
| 647 unsigned int sign :1; |
| 648 unsigned int exp :11; |
| 649 unsigned int man_high :20; |
| 650 unsigned int man_low :32; |
| 651 } bits; |
| 652 }; |
| 653 |
| 654 |
| 655 // AccessorCallback |
| 656 struct AccessorDescriptor { |
| 657 Object* (*getter)(Isolate* isolate, Object* object, void* data); |
| 658 Object* (*setter)( |
| 659 Isolate* isolate, JSObject* object, Object* value, void* data); |
| 660 void* data; |
| 661 }; |
| 662 |
| 663 |
| 664 // Logging and profiling. A StateTag represents a possible state of |
| 665 // the VM. The logger maintains a stack of these. Creating a VMState |
| 666 // object enters a state by pushing on the stack, and destroying a |
| 667 // VMState object leaves a state by popping the current state from the |
| 668 // stack. |
| 669 |
| 670 enum StateTag { |
| 671 JS, |
| 672 GC, |
| 673 COMPILER, |
| 674 OTHER, |
| 675 EXTERNAL, |
| 676 IDLE |
| 677 }; |
| 678 |
| 679 |
| 680 // ----------------------------------------------------------------------------- |
| 681 // Macros |
| 682 |
| 683 // Testers for test. |
| 684 |
| 685 #define HAS_SMI_TAG(value) \ |
| 686 ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag) |
| 687 |
| 688 #define HAS_FAILURE_TAG(value) \ |
| 689 ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag) |
| 690 |
| 691 // OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer |
| 692 #define OBJECT_POINTER_ALIGN(value) \ |
| 693 (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) |
| 694 |
| 695 // POINTER_SIZE_ALIGN returns the value aligned as a pointer. |
| 696 #define POINTER_SIZE_ALIGN(value) \ |
| 697 (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) |
| 698 |
| 699 // CODE_POINTER_ALIGN returns the value aligned as a generated code segment. |
| 700 #define CODE_POINTER_ALIGN(value) \ |
| 701 (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) |
| 702 |
| 703 // Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk") |
| 704 // inside a C++ class and new and delete will be overloaded so logging is |
| 705 // performed. |
| 706 // This file (globals.h) is included before log.h, so we use direct calls to |
| 707 // the Logger rather than the LOG macro. |
| 708 #ifdef DEBUG |
| 709 #define TRACK_MEMORY(name) \ |
| 710 void* operator new(size_t size) { \ |
| 711 void* result = ::operator new(size); \ |
| 712 Logger::NewEventStatic(name, result, size); \ |
| 713 return result; \ |
| 714 } \ |
| 715 void operator delete(void* object) { \ |
| 716 Logger::DeleteEventStatic(name, object); \ |
| 717 ::operator delete(object); \ |
| 718 } |
| 719 #else |
| 720 #define TRACK_MEMORY(name) |
| 721 #endif |
| 722 |
| 723 |
| 724 // CPU feature flags. |
| 725 enum CpuFeature { |
| 726 // x86 |
| 727 SSE4_1, |
| 728 SSE3, |
| 729 SAHF, |
| 730 // ARM |
| 731 VFP3, |
| 732 ARMv7, |
| 733 SUDIV, |
| 734 UNALIGNED_ACCESSES, |
| 735 MOVW_MOVT_IMMEDIATE_LOADS, |
| 736 VFP32DREGS, |
| 737 NEON, |
| 738 // MIPS |
| 739 FPU, |
| 740 // ARM64 |
| 741 ALWAYS_ALIGN_CSP, |
| 742 NUMBER_OF_CPU_FEATURES |
| 743 }; |
| 744 |
| 745 |
| 746 // Used to specify if a macro instruction must perform a smi check on tagged |
| 747 // values. |
| 748 enum SmiCheckType { |
| 749 DONT_DO_SMI_CHECK, |
| 750 DO_SMI_CHECK |
| 751 }; |
| 752 |
| 753 |
| 754 enum ScopeType { |
| 755 EVAL_SCOPE, // The top-level scope for an eval source. |
| 756 FUNCTION_SCOPE, // The top-level scope for a function. |
| 757 MODULE_SCOPE, // The scope introduced by a module literal |
| 758 GLOBAL_SCOPE, // The top-level scope for a program or a top-level eval. |
| 759 CATCH_SCOPE, // The scope introduced by catch. |
| 760 BLOCK_SCOPE, // The scope introduced by a new block. |
| 761 WITH_SCOPE // The scope introduced by with. |
| 762 }; |
| 763 |
| 764 |
| 765 const uint32_t kHoleNanUpper32 = 0x7FFFFFFF; |
| 766 const uint32_t kHoleNanLower32 = 0xFFFFFFFF; |
| 767 const uint32_t kNaNOrInfinityLowerBoundUpper32 = 0x7FF00000; |
| 768 |
| 769 const uint64_t kHoleNanInt64 = |
| 770 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 771 const uint64_t kLastNonNaNInt64 = |
| 772 (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32); |
| 773 |
| 774 |
| 775 // The order of this enum has to be kept in sync with the predicates below. |
| 776 enum VariableMode { |
| 777 // User declared variables: |
| 778 VAR, // declared via 'var', and 'function' declarations |
| 779 |
| 780 CONST_LEGACY, // declared via legacy 'const' declarations |
| 781 |
| 782 LET, // declared via 'let' declarations (first lexical) |
| 783 |
| 784 CONST, // declared via 'const' declarations |
| 785 |
| 786 MODULE, // declared via 'module' declaration (last lexical) |
| 787 |
| 788 // Variables introduced by the compiler: |
| 789 INTERNAL, // like VAR, but not user-visible (may or may not |
| 790 // be in a context) |
| 791 |
| 792 TEMPORARY, // temporary variables (not user-visible), stack-allocated |
| 793 // unless the scope as a whole has forced context allocation |
| 794 |
| 795 DYNAMIC, // always require dynamic lookup (we don't know |
| 796 // the declaration) |
| 797 |
| 798 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 799 // variable is global unless it has been shadowed |
| 800 // by an eval-introduced variable |
| 801 |
| 802 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
| 803 // variable is local and where it is unless it |
| 804 // has been shadowed by an eval-introduced |
| 805 // variable |
| 806 }; |
| 807 |
| 808 |
| 809 inline bool IsDynamicVariableMode(VariableMode mode) { |
| 810 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
| 811 } |
| 812 |
| 813 |
| 814 inline bool IsDeclaredVariableMode(VariableMode mode) { |
| 815 return mode >= VAR && mode <= MODULE; |
| 816 } |
| 817 |
| 818 |
| 819 inline bool IsLexicalVariableMode(VariableMode mode) { |
| 820 return mode >= LET && mode <= MODULE; |
| 821 } |
| 822 |
| 823 |
| 824 inline bool IsImmutableVariableMode(VariableMode mode) { |
| 825 return (mode >= CONST && mode <= MODULE) || mode == CONST_LEGACY; |
| 826 } |
| 827 |
| 828 |
| 829 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
| 830 // and immutable bindings that can be in two states: initialized and |
| 831 // uninitialized. In ES5 only immutable bindings have these two states. When |
| 832 // accessing a binding, it needs to be checked for initialization. However in |
| 833 // the following cases the binding is initialized immediately after creation |
| 834 // so the initialization check can always be skipped: |
| 835 // 1. Var declared local variables. |
| 836 // var foo; |
| 837 // 2. A local variable introduced by a function declaration. |
| 838 // function foo() {} |
| 839 // 3. Parameters |
| 840 // function x(foo) {} |
| 841 // 4. Catch bound variables. |
| 842 // try {} catch (foo) {} |
| 843 // 6. Function variables of named function expressions. |
| 844 // var x = function foo() {} |
| 845 // 7. Implicit binding of 'this'. |
| 846 // 8. Implicit binding of 'arguments' in functions. |
| 847 // |
| 848 // ES5 specified object environment records which are introduced by ES elements |
| 849 // such as Program and WithStatement that associate identifier bindings with the |
| 850 // properties of some object. In the specification only mutable bindings exist |
| 851 // (which may be non-writable) and have no distinct initialization step. However |
| 852 // V8 allows const declarations in global code with distinct creation and |
| 853 // initialization steps which are represented by non-writable properties in the |
| 854 // global object. As a result also these bindings need to be checked for |
| 855 // initialization. |
| 856 // |
| 857 // The following enum specifies a flag that indicates if the binding needs a |
| 858 // distinct initialization step (kNeedsInitialization) or if the binding is |
| 859 // immediately initialized upon creation (kCreatedInitialized). |
| 860 enum InitializationFlag { |
| 861 kNeedsInitialization, |
| 862 kCreatedInitialized |
| 863 }; |
| 864 |
| 865 |
| 866 enum ClearExceptionFlag { |
| 867 KEEP_EXCEPTION, |
| 868 CLEAR_EXCEPTION |
| 869 }; |
| 870 |
| 871 |
| 872 enum MinusZeroMode { |
| 873 TREAT_MINUS_ZERO_AS_ZERO, |
| 874 FAIL_ON_MINUS_ZERO |
| 875 }; |
| 876 |
338 } } // namespace v8::internal | 877 } } // namespace v8::internal |
339 | 878 |
| 879 namespace i = v8::internal; |
| 880 |
340 #endif // V8_GLOBALS_H_ | 881 #endif // V8_GLOBALS_H_ |
OLD | NEW |