Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; | 792 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 793 | 793 |
| 794 | 794 |
| 795 // ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER | 795 // ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER |
| 796 const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1 | 796 const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1 |
| 797 | 797 |
| 798 | 798 |
| 799 // The order of this enum has to be kept in sync with the predicates below. | 799 // The order of this enum has to be kept in sync with the predicates below. |
| 800 enum VariableMode { | 800 enum VariableMode { |
| 801 // User declared variables: | 801 // User declared variables: |
| 802 VAR, // declared via 'var', and 'function' declarations | 802 VAR, // declared via 'var', and 'function' declarations |
|
Michael Starzinger
2016/04/18 22:49:16
Sometimes clang-format is working against us, but
| |
| 803 | 803 |
| 804 CONST_LEGACY, // declared via legacy 'const' declarations | 804 CONST_LEGACY, // declared via legacy 'const' declarations |
| 805 | 805 |
| 806 LET, // declared via 'let' declarations (first lexical) | 806 LET, // declared via 'let' declarations (first lexical) |
| 807 | 807 |
| 808 CONST, // declared via 'const' declarations | 808 CONST, // declared via 'const' declarations (last lexical) |
| 809 | |
| 810 IMPORT, // declared via 'import' declarations (last lexical) | |
| 811 | 809 |
| 812 // Variables introduced by the compiler: | 810 // Variables introduced by the compiler: |
| 813 TEMPORARY, // temporary variables (not user-visible), stack-allocated | 811 TEMPORARY, // temporary variables (not user-visible), stack-allocated |
| 814 // unless the scope as a whole has forced context allocation | 812 // unless the scope as a whole has forced context allocation |
| 815 | 813 |
| 816 DYNAMIC, // always require dynamic lookup (we don't know | 814 DYNAMIC, // always require dynamic lookup (we don't know |
| 817 // the declaration) | 815 // the declaration) |
| 818 | 816 |
| 819 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the | 817 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 820 // variable is global unless it has been shadowed | 818 // variable is global unless it has been shadowed |
| 821 // by an eval-introduced variable | 819 // by an eval-introduced variable |
| 822 | 820 |
| 823 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the | 821 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
| 824 // variable is local and where it is unless it | 822 // variable is local and where it is unless it |
| 825 // has been shadowed by an eval-introduced | 823 // has been shadowed by an eval-introduced |
| 826 // variable | 824 // variable |
| 827 }; | 825 }; |
| 828 | 826 |
| 829 | |
| 830 inline bool IsDynamicVariableMode(VariableMode mode) { | 827 inline bool IsDynamicVariableMode(VariableMode mode) { |
| 831 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; | 828 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
| 832 } | 829 } |
| 833 | 830 |
| 834 | 831 |
| 835 inline bool IsDeclaredVariableMode(VariableMode mode) { | 832 inline bool IsDeclaredVariableMode(VariableMode mode) { |
| 836 return mode >= VAR && mode <= IMPORT; | 833 return mode >= VAR && mode <= CONST; |
| 837 } | 834 } |
| 838 | 835 |
| 839 | 836 |
| 840 inline bool IsLexicalVariableMode(VariableMode mode) { | 837 inline bool IsLexicalVariableMode(VariableMode mode) { |
| 841 return mode >= LET && mode <= IMPORT; | 838 return mode >= LET && mode <= CONST; |
| 842 } | 839 } |
| 843 | 840 |
| 844 | 841 |
| 845 inline bool IsImmutableVariableMode(VariableMode mode) { | 842 inline bool IsImmutableVariableMode(VariableMode mode) { |
| 846 return mode == CONST || mode == CONST_LEGACY || mode == IMPORT; | 843 return mode == CONST || mode == CONST_LEGACY; |
| 847 } | 844 } |
| 848 | 845 |
| 849 | 846 |
| 850 enum class VariableLocation { | 847 enum class VariableLocation { |
| 851 // Before and during variable allocation, a variable whose location is | 848 // Before and during variable allocation, a variable whose location is |
| 852 // not yet determined. After allocation, a variable looked up as a | 849 // not yet determined. After allocation, a variable looked up as a |
| 853 // property on the global object (and possibly absent). name() is the | 850 // property on the global object (and possibly absent). name() is the |
| 854 // variable name, index() is invalid. | 851 // variable name, index() is invalid. |
| 855 UNALLOCATED, | 852 UNALLOCATED, |
| 856 | 853 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> | 1036 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> |
| 1040 kPointerSizeLog2); | 1037 kPointerSizeLog2); |
| 1041 } | 1038 } |
| 1042 | 1039 |
| 1043 } // namespace internal | 1040 } // namespace internal |
| 1044 } // namespace v8 | 1041 } // namespace v8 |
| 1045 | 1042 |
| 1046 namespace i = v8::internal; | 1043 namespace i = v8::internal; |
| 1047 | 1044 |
| 1048 #endif // V8_GLOBALS_H_ | 1045 #endif // V8_GLOBALS_H_ |
| OLD | NEW |