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

Side by Side Diff: src/globals.h

Issue 2199283002: [modules] Introduce new VariableLocation for module imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment 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
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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
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 // TODO(neis): Is it correct to make this one of the lexical modes?
889 IMPORT, // declared via 'import' declarations (except namespace imports)
890
891 CONST, // declared via 'const' declarations (last lexical) 888 CONST, // declared via 'const' declarations (last lexical)
892 889
893 // Variables introduced by the compiler: 890 // Variables introduced by the compiler:
894 TEMPORARY, // temporary variables (not user-visible), stack-allocated 891 TEMPORARY, // temporary variables (not user-visible), stack-allocated
895 // unless the scope as a whole has forced context allocation 892 // unless the scope as a whole has forced context allocation
896 893
897 DYNAMIC, // always require dynamic lookup (we don't know 894 DYNAMIC, // always require dynamic lookup (we don't know
898 // the declaration) 895 // the declaration)
899 896
900 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the 897 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the
(...skipping 15 matching lines...) Expand all
916 return mode >= VAR && mode <= CONST; 913 return mode >= VAR && mode <= CONST;
917 } 914 }
918 915
919 916
920 inline bool IsLexicalVariableMode(VariableMode mode) { 917 inline bool IsLexicalVariableMode(VariableMode mode) {
921 return mode >= LET && mode <= CONST; 918 return mode >= LET && mode <= CONST;
922 } 919 }
923 920
924 921
925 inline bool IsImmutableVariableMode(VariableMode mode) { 922 inline bool IsImmutableVariableMode(VariableMode mode) {
926 return mode == CONST || mode == CONST_LEGACY || mode == IMPORT; 923 return mode == CONST || mode == CONST_LEGACY;
927 } 924 }
928 925
929
930 enum class VariableLocation { 926 enum class VariableLocation {
931 // Before and during variable allocation, a variable whose location is 927 // Before and during variable allocation, a variable whose location is
932 // not yet determined. After allocation, a variable looked up as a 928 // not yet determined. After allocation, a variable looked up as a
933 // property on the global object (and possibly absent). name() is the 929 // property on the global object (and possibly absent). name() is the
934 // variable name, index() is invalid. 930 // variable name, index() is invalid.
935 UNALLOCATED, 931 UNALLOCATED,
936 932
937 // A slot in the parameter section on the stack. index() is the 933 // A slot in the parameter section on the stack. index() is the
938 // parameter index, counting left-to-right. The receiver is index -1; 934 // parameter index, counting left-to-right. The receiver is index -1;
939 // the first parameter is index 0. 935 // the first parameter is index 0.
(...skipping 10 matching lines...) Expand all
950 946
951 // An indexed slot in a script context that contains a respective global 947 // An indexed slot in a script context that contains a respective global
952 // property cell. name() is the variable name, index() is the variable 948 // property cell. name() is the variable name, index() is the variable
953 // index in the context object on the heap, starting at 0. scope() is the 949 // index in the context object on the heap, starting at 0. scope() is the
954 // corresponding script scope. 950 // corresponding script scope.
955 GLOBAL, 951 GLOBAL,
956 952
957 // A named slot in a heap context. name() is the variable name in the 953 // A named slot in a heap context. name() is the variable name in the
958 // context object on the heap, with lookup starting at the current 954 // context object on the heap, with lookup starting at the current
959 // context. index() is invalid. 955 // context. index() is invalid.
960 LOOKUP 956 LOOKUP,
957
958 // A named slot in a module's export table.
959 MODULE
961 }; 960 };
962 961
963
964 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable 962 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable
965 // and immutable bindings that can be in two states: initialized and 963 // and immutable bindings that can be in two states: initialized and
966 // uninitialized. In ES5 only immutable bindings have these two states. When 964 // uninitialized. In ES5 only immutable bindings have these two states. When
967 // accessing a binding, it needs to be checked for initialization. However in 965 // accessing a binding, it needs to be checked for initialization. However in
968 // the following cases the binding is initialized immediately after creation 966 // the following cases the binding is initialized immediately after creation
969 // so the initialization check can always be skipped: 967 // so the initialization check can always be skipped:
970 // 1. Var declared local variables. 968 // 1. Var declared local variables.
971 // var foo; 969 // var foo;
972 // 2. A local variable introduced by a function declaration. 970 // 2. A local variable introduced by a function declaration.
973 // function foo() {} 971 // function foo() {}
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> 1146 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >>
1149 kPointerSizeLog2); 1147 kPointerSizeLog2);
1150 } 1148 }
1151 1149
1152 } // namespace internal 1150 } // namespace internal
1153 } // namespace v8 1151 } // namespace v8
1154 1152
1155 namespace i = v8::internal; 1153 namespace i = v8::internal;
1156 1154
1157 #endif // V8_GLOBALS_H_ 1155 #endif // V8_GLOBALS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698