| 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 | 871 |
| 872 const uint64_t kHoleNanInt64 = | 872 const uint64_t kHoleNanInt64 = |
| 873 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; | 873 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32; |
| 874 | 874 |
| 875 | 875 |
| 876 // ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER | 876 // ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER |
| 877 const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1 | 877 const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1 |
| 878 | 878 |
| 879 | 879 |
| 880 // The order of this enum has to be kept in sync with the predicates below. | 880 // The order of this enum has to be kept in sync with the predicates below. |
| 881 enum VariableMode : uint8_t { | 881 enum VariableMode { |
| 882 // User declared variables: | 882 // User declared variables: |
| 883 VAR, // declared via 'var', and 'function' declarations | 883 VAR, // declared via 'var', and 'function' declarations |
| 884 | 884 |
| 885 CONST_LEGACY, // declared via legacy 'const' declarations | 885 CONST_LEGACY, // declared via legacy 'const' declarations |
| 886 | 886 |
| 887 LET, // declared via 'let' declarations (first lexical) | 887 LET, // declared via 'let' declarations (first lexical) |
| 888 | 888 |
| 889 CONST, // declared via 'const' declarations (last lexical) | 889 CONST, // declared via 'const' declarations (last lexical) |
| 890 | 890 |
| 891 // Variables introduced by the compiler: | 891 // Variables introduced by the compiler: |
| 892 TEMPORARY, // temporary variables (not user-visible), stack-allocated | 892 TEMPORARY, // temporary variables (not user-visible), stack-allocated |
| 893 // unless the scope as a whole has forced context allocation | 893 // unless the scope as a whole has forced context allocation |
| 894 | 894 |
| 895 DYNAMIC, // always require dynamic lookup (we don't know | 895 DYNAMIC, // always require dynamic lookup (we don't know |
| 896 // the declaration) | 896 // the declaration) |
| 897 | 897 |
| 898 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the | 898 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the |
| 899 // variable is global unless it has been shadowed | 899 // variable is global unless it has been shadowed |
| 900 // by an eval-introduced variable | 900 // by an eval-introduced variable |
| 901 | 901 |
| 902 DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the | 902 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the |
| 903 // variable is local and where it is unless it | 903 // variable is local and where it is unless it |
| 904 // has been shadowed by an eval-introduced | 904 // has been shadowed by an eval-introduced |
| 905 // variable | 905 // variable |
| 906 | |
| 907 kLastVariableMode = DYNAMIC_LOCAL | |
| 908 }; | 906 }; |
| 909 | 907 |
| 910 inline bool IsDynamicVariableMode(VariableMode mode) { | 908 inline bool IsDynamicVariableMode(VariableMode mode) { |
| 911 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; | 909 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL; |
| 912 } | 910 } |
| 913 | 911 |
| 914 | 912 |
| 915 inline bool IsDeclaredVariableMode(VariableMode mode) { | 913 inline bool IsDeclaredVariableMode(VariableMode mode) { |
| 916 return mode >= VAR && mode <= CONST; | 914 return mode >= VAR && mode <= CONST; |
| 917 } | 915 } |
| 918 | 916 |
| 919 | 917 |
| 920 inline bool IsLexicalVariableMode(VariableMode mode) { | 918 inline bool IsLexicalVariableMode(VariableMode mode) { |
| 921 return mode >= LET && mode <= CONST; | 919 return mode >= LET && mode <= CONST; |
| 922 } | 920 } |
| 923 | 921 |
| 924 | 922 |
| 925 inline bool IsImmutableVariableMode(VariableMode mode) { | 923 inline bool IsImmutableVariableMode(VariableMode mode) { |
| 926 return mode == CONST || mode == CONST_LEGACY; | 924 return mode == CONST || mode == CONST_LEGACY; |
| 927 } | 925 } |
| 928 | 926 |
| 929 enum class VariableLocation : uint8_t { | 927 enum class VariableLocation { |
| 930 // Before and during variable allocation, a variable whose location is | 928 // Before and during variable allocation, a variable whose location is |
| 931 // not yet determined. After allocation, a variable looked up as a | 929 // not yet determined. After allocation, a variable looked up as a |
| 932 // property on the global object (and possibly absent). name() is the | 930 // property on the global object (and possibly absent). name() is the |
| 933 // variable name, index() is invalid. | 931 // variable name, index() is invalid. |
| 934 UNALLOCATED, | 932 UNALLOCATED, |
| 935 | 933 |
| 936 // A slot in the parameter section on the stack. index() is the | 934 // A slot in the parameter section on the stack. index() is the |
| 937 // parameter index, counting left-to-right. The receiver is index -1; | 935 // parameter index, counting left-to-right. The receiver is index -1; |
| 938 // the first parameter is index 0. | 936 // the first parameter is index 0. |
| 939 PARAMETER, | 937 PARAMETER, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 952 // index in the context object on the heap, starting at 0. scope() is the | 950 // index in the context object on the heap, starting at 0. scope() is the |
| 953 // corresponding script scope. | 951 // corresponding script scope. |
| 954 GLOBAL, | 952 GLOBAL, |
| 955 | 953 |
| 956 // A named slot in a heap context. name() is the variable name in the | 954 // A named slot in a heap context. name() is the variable name in the |
| 957 // context object on the heap, with lookup starting at the current | 955 // context object on the heap, with lookup starting at the current |
| 958 // context. index() is invalid. | 956 // context. index() is invalid. |
| 959 LOOKUP, | 957 LOOKUP, |
| 960 | 958 |
| 961 // A named slot in a module's export table. | 959 // A named slot in a module's export table. |
| 962 MODULE, | 960 MODULE |
| 963 | |
| 964 kLastVariableLocation = MODULE | |
| 965 }; | 961 }; |
| 966 | 962 |
| 967 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable | 963 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable |
| 968 // and immutable bindings that can be in two states: initialized and | 964 // and immutable bindings that can be in two states: initialized and |
| 969 // uninitialized. In ES5 only immutable bindings have these two states. When | 965 // uninitialized. In ES5 only immutable bindings have these two states. When |
| 970 // accessing a binding, it needs to be checked for initialization. However in | 966 // accessing a binding, it needs to be checked for initialization. However in |
| 971 // the following cases the binding is initialized immediately after creation | 967 // the following cases the binding is initialized immediately after creation |
| 972 // so the initialization check can always be skipped: | 968 // so the initialization check can always be skipped: |
| 973 // 1. Var declared local variables. | 969 // 1. Var declared local variables. |
| 974 // var foo; | 970 // var foo; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 988 // properties of some object. In the specification only mutable bindings exist | 984 // properties of some object. In the specification only mutable bindings exist |
| 989 // (which may be non-writable) and have no distinct initialization step. However | 985 // (which may be non-writable) and have no distinct initialization step. However |
| 990 // V8 allows const declarations in global code with distinct creation and | 986 // V8 allows const declarations in global code with distinct creation and |
| 991 // initialization steps which are represented by non-writable properties in the | 987 // initialization steps which are represented by non-writable properties in the |
| 992 // global object. As a result also these bindings need to be checked for | 988 // global object. As a result also these bindings need to be checked for |
| 993 // initialization. | 989 // initialization. |
| 994 // | 990 // |
| 995 // The following enum specifies a flag that indicates if the binding needs a | 991 // The following enum specifies a flag that indicates if the binding needs a |
| 996 // distinct initialization step (kNeedsInitialization) or if the binding is | 992 // distinct initialization step (kNeedsInitialization) or if the binding is |
| 997 // immediately initialized upon creation (kCreatedInitialized). | 993 // immediately initialized upon creation (kCreatedInitialized). |
| 998 enum InitializationFlag : uint8_t { kNeedsInitialization, kCreatedInitialized }; | 994 enum InitializationFlag { |
| 995 kNeedsInitialization, |
| 996 kCreatedInitialized |
| 997 }; |
| 999 | 998 |
| 1000 enum MaybeAssignedFlag : uint8_t { kNotAssigned, kMaybeAssigned }; | 999 |
| 1000 enum MaybeAssignedFlag { kNotAssigned, kMaybeAssigned }; |
| 1001 |
| 1001 | 1002 |
| 1002 // Serialized in PreparseData, so numeric values should not be changed. | 1003 // Serialized in PreparseData, so numeric values should not be changed. |
| 1003 enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 }; | 1004 enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 }; |
| 1004 | 1005 |
| 1005 | 1006 |
| 1006 enum MinusZeroMode { | 1007 enum MinusZeroMode { |
| 1007 TREAT_MINUS_ZERO_AS_ZERO, | 1008 TREAT_MINUS_ZERO_AS_ZERO, |
| 1008 FAIL_ON_MINUS_ZERO | 1009 FAIL_ON_MINUS_ZERO |
| 1009 }; | 1010 }; |
| 1010 | 1011 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 public: | 1156 public: |
| 1156 enum { kNone = 0x00, kSignedSmall = 0x01, kNumber = 0x3, kAny = 0x7 }; | 1157 enum { kNone = 0x00, kSignedSmall = 0x01, kNumber = 0x3, kAny = 0x7 }; |
| 1157 }; | 1158 }; |
| 1158 | 1159 |
| 1159 } // namespace internal | 1160 } // namespace internal |
| 1160 } // namespace v8 | 1161 } // namespace v8 |
| 1161 | 1162 |
| 1162 namespace i = v8::internal; | 1163 namespace i = v8::internal; |
| 1163 | 1164 |
| 1164 #endif // V8_GLOBALS_H_ | 1165 #endif // V8_GLOBALS_H_ |
| OLD | NEW |