| 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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; | 710 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 711 | 711 |
| 712 | 712 |
| 713 // The order of this enum has to be kept in sync with the predicates below. | 713 // The order of this enum has to be kept in sync with the predicates below. |
| 714 enum VariableMode { | 714 enum VariableMode { |
| 715 // User declared variables: | 715 // User declared variables: |
| 716 VAR, // declared via 'var', and 'function' declarations | 716 VAR, // declared via 'var', and 'function' declarations |
| 717 | 717 |
| 718 CONST_LEGACY, // declared via legacy 'const' declarations | 718 CONST_LEGACY, // declared via legacy 'const' declarations |
| 719 | 719 |
| 720 LET, // declared via 'let' declarations | 720 LET, // declared via 'let' declarations (first lexical) |
| 721 | 721 |
| 722 CONST, // declared via 'const' declarations | 722 CONST, // declared via 'const' declarations |
| 723 | 723 |
| 724 IMPORT, // declared via 'import' declarations (last lexical) |
| 725 |
| 724 // Variables introduced by the compiler: | 726 // Variables introduced by the compiler: |
| 725 INTERNAL, // like VAR, but not user-visible (may or may not | 727 INTERNAL, // like VAR, but not user-visible (may or may not |
| 726 // be in a context) | 728 // be in a context) |
| 727 | 729 |
| 728 TEMPORARY, // temporary variables (not user-visible), stack-allocated | 730 TEMPORARY, // temporary variables (not user-visible), stack-allocated |
| 729 // unless the scope as a whole has forced context allocation | 731 // unless the scope as a whole has forced context allocation |
| 730 | 732 |
| 731 DYNAMIC, // always require dynamic lookup (we don't know | 733 DYNAMIC, // always require dynamic lookup (we don't know |
| 732 // the declaration) | 734 // the declaration) |
| 733 | 735 |
| 734 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the | 736 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 735 // variable is global unless it has been shadowed | 737 // variable is global unless it has been shadowed |
| 736 // by an eval-introduced variable | 738 // by an eval-introduced variable |
| 737 | 739 |
| 738 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the | 740 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
| 739 // variable is local and where it is unless it | 741 // variable is local and where it is unless it |
| 740 // has been shadowed by an eval-introduced | 742 // has been shadowed by an eval-introduced |
| 741 // variable | 743 // variable |
| 742 }; | 744 }; |
| 743 | 745 |
| 744 | 746 |
| 745 inline bool IsDynamicVariableMode(VariableMode mode) { | 747 inline bool IsDynamicVariableMode(VariableMode mode) { |
| 746 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; | 748 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
| 747 } | 749 } |
| 748 | 750 |
| 749 | 751 |
| 750 inline bool IsDeclaredVariableMode(VariableMode mode) { | 752 inline bool IsDeclaredVariableMode(VariableMode mode) { |
| 751 return mode >= VAR && mode <= CONST; | 753 return mode >= VAR && mode <= IMPORT; |
| 752 } | 754 } |
| 753 | 755 |
| 754 | 756 |
| 755 inline bool IsLexicalVariableMode(VariableMode mode) { | 757 inline bool IsLexicalVariableMode(VariableMode mode) { |
| 756 return mode == LET || mode == CONST; | 758 return mode >= LET && mode <= IMPORT; |
| 757 } | 759 } |
| 758 | 760 |
| 759 | 761 |
| 760 inline bool IsImmutableVariableMode(VariableMode mode) { | 762 inline bool IsImmutableVariableMode(VariableMode mode) { |
| 761 return mode == CONST || mode == CONST_LEGACY; | 763 return mode == CONST || mode == CONST_LEGACY || mode == IMPORT; |
| 762 } | 764 } |
| 763 | 765 |
| 764 | 766 |
| 765 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable | 767 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
| 766 // and immutable bindings that can be in two states: initialized and | 768 // and immutable bindings that can be in two states: initialized and |
| 767 // uninitialized. In ES5 only immutable bindings have these two states. When | 769 // uninitialized. In ES5 only immutable bindings have these two states. When |
| 768 // accessing a binding, it needs to be checked for initialization. However in | 770 // accessing a binding, it needs to be checked for initialization. However in |
| 769 // the following cases the binding is initialized immediately after creation | 771 // the following cases the binding is initialized immediately after creation |
| 770 // so the initialization check can always be skipped: | 772 // so the initialization check can always be skipped: |
| 771 // 1. Var declared local variables. | 773 // 1. Var declared local variables. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 DCHECK(IsValidFunctionKind(kind)); | 898 DCHECK(IsValidFunctionKind(kind)); |
| 897 return kind & | 899 return kind & |
| 898 (FunctionKind::kBaseConstructor | FunctionKind::kSubclassConstructor | | 900 (FunctionKind::kBaseConstructor | FunctionKind::kSubclassConstructor | |
| 899 FunctionKind::kDefaultConstructor); | 901 FunctionKind::kDefaultConstructor); |
| 900 } | 902 } |
| 901 } } // namespace v8::internal | 903 } } // namespace v8::internal |
| 902 | 904 |
| 903 namespace i = v8::internal; | 905 namespace i = v8::internal; |
| 904 | 906 |
| 905 #endif // V8_GLOBALS_H_ | 907 #endif // V8_GLOBALS_H_ |
| OLD | NEW |