Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: src/globals.h

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

Powered by Google App Engine
This is Rietveld 408576698