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

Side by Side Diff: src/ast/variables.h

Issue 2460233003: [modules] Assign cell indices at validation time. (Closed)
Patch Set: Created 4 years, 1 month 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_AST_VARIABLES_H_ 5 #ifndef V8_AST_VARIABLES_H_
6 #define V8_AST_VARIABLES_H_ 6 #define V8_AST_VARIABLES_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/zone/zone.h" 10 #include "src/zone/zone.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 VariableLocation location() const { 93 VariableLocation location() const {
94 return LocationField::decode(bit_field_); 94 return LocationField::decode(bit_field_);
95 } 95 }
96 VariableKind kind() const { return VariableKindField::decode(bit_field_); } 96 VariableKind kind() const { return VariableKindField::decode(bit_field_); }
97 InitializationFlag initialization_flag() const { 97 InitializationFlag initialization_flag() const {
98 return InitializationFlagField::decode(bit_field_); 98 return InitializationFlagField::decode(bit_field_);
99 } 99 }
100 100
101 int index() const { return index_; } 101 int index() const { return index_; }
102 102
103 // Sentinel index values for module exports and imports.
104 enum { kModuleExportIndex, kModuleImportIndex };
105
106 bool IsExport() const { 103 bool IsExport() const {
107 DCHECK(location() == VariableLocation::MODULE); 104 DCHECK_EQ(location(), VariableLocation::MODULE);
108 return index() == kModuleExportIndex; 105 DCHECK_NE(index(), 0);
adamk 2016/10/31 18:25:04 So this 0 appears in lots of places, but as I thin
neis 2016/11/03 10:43:48 There's a comment now in modules.h.
106 return index() > 0;
109 } 107 }
110 108
111 void AllocateTo(VariableLocation location, int index) { 109 void AllocateTo(VariableLocation location, int index) {
112 DCHECK(IsUnallocated() || 110 DCHECK(IsUnallocated() ||
113 (this->location() == location && this->index() == index)); 111 (this->location() == location && this->index() == index));
114 DCHECK_IMPLIES(location == VariableLocation::MODULE, 112 DCHECK_IMPLIES(location == VariableLocation::MODULE, index != 0);
115 index == kModuleExportIndex || index == kModuleImportIndex);
116 bit_field_ = LocationField::update(bit_field_, location); 113 bit_field_ = LocationField::update(bit_field_, location);
117 DCHECK_EQ(location, this->location()); 114 DCHECK_EQ(location, this->location());
118 index_ = index; 115 index_ = index;
119 } 116 }
120 117
121 static InitializationFlag DefaultInitializationFlag(VariableMode mode) { 118 static InitializationFlag DefaultInitializationFlag(VariableMode mode) {
122 DCHECK(IsDeclaredVariableMode(mode)); 119 DCHECK(IsDeclaredVariableMode(mode));
123 return mode == VAR ? kCreatedInitialized : kNeedsInitialization; 120 return mode == VAR ? kCreatedInitialized : kNeedsInitialization;
124 } 121 }
125 122
(...skipping 22 matching lines...) Expand all
148 class InitializationFlagField 145 class InitializationFlagField
149 : public BitField16<InitializationFlag, IsUsedField::kNext, 2> {}; 146 : public BitField16<InitializationFlag, IsUsedField::kNext, 2> {};
150 class MaybeAssignedFlagField 147 class MaybeAssignedFlagField
151 : public BitField16<MaybeAssignedFlag, InitializationFlagField::kNext, 148 : public BitField16<MaybeAssignedFlag, InitializationFlagField::kNext,
152 2> {}; 149 2> {};
153 }; 150 };
154 } // namespace internal 151 } // namespace internal
155 } // namespace v8 152 } // namespace v8
156 153
157 #endif // V8_AST_VARIABLES_H_ 154 #endif // V8_AST_VARIABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698