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

Side by Side Diff: src/variables.h

Issue 8423005: Remove some unnecessary binding initialization checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // A named slot in a heap context. name() is the variable name in the 70 // A named slot in a heap context. name() is the variable name in the
71 // context object on the heap, with lookup starting at the current 71 // context object on the heap, with lookup starting at the current
72 // context. index() is invalid. 72 // context. index() is invalid.
73 LOOKUP 73 LOOKUP
74 }; 74 };
75 75
76 Variable(Scope* scope, 76 Variable(Scope* scope,
77 Handle<String> name, 77 Handle<String> name,
78 VariableMode mode, 78 VariableMode mode,
79 bool is_valid_lhs, 79 bool is_valid_lhs,
80 Kind kind); 80 Kind kind,
81 InitializationFlag initialization_flag_);
Jakob Kummerow 2011/10/31 12:44:34 nit: no trailing underscore
Steven 2011/10/31 14:28:29 Done.
81 82
82 // Printing support 83 // Printing support
83 static const char* Mode2String(VariableMode mode); 84 static const char* Mode2String(VariableMode mode);
84 85
85 bool IsValidLeftHandSide() { return is_valid_LHS_; } 86 bool IsValidLeftHandSide() { return is_valid_LHS_; }
86 87
87 // The source code for an eval() call may refer to a variable that is 88 // The source code for an eval() call may refer to a variable that is
88 // in an outer scope about which we don't know anything (it may not 89 // in an outer scope about which we don't know anything (it may not
89 // be the global scope). scope() is NULL in that case. Currently the 90 // be the global scope). scope() is NULL in that case. Currently the
90 // scope is only used to follow the context chain length. 91 // scope is only used to follow the context chain length.
(...skipping 25 matching lines...) Expand all
116 bool is_dynamic() const { 117 bool is_dynamic() const {
117 return (mode_ == DYNAMIC || 118 return (mode_ == DYNAMIC ||
118 mode_ == DYNAMIC_GLOBAL || 119 mode_ == DYNAMIC_GLOBAL ||
119 mode_ == DYNAMIC_LOCAL); 120 mode_ == DYNAMIC_LOCAL);
120 } 121 }
121 bool is_const_mode() const { 122 bool is_const_mode() const {
122 return (mode_ == CONST || 123 return (mode_ == CONST ||
123 mode_ == CONST_HARMONY); 124 mode_ == CONST_HARMONY);
124 } 125 }
125 bool binding_needs_init() const { 126 bool binding_needs_init() const {
126 return (mode_ == LET || 127 return initialization_flag_ == NEEDS_INITIALIZATION;
127 mode_ == CONST ||
128 mode_ == CONST_HARMONY);
129 } 128 }
130 129
131 bool is_global() const; 130 bool is_global() const;
132 bool is_this() const { return kind_ == THIS; } 131 bool is_this() const { return kind_ == THIS; }
133 bool is_arguments() const { return kind_ == ARGUMENTS; } 132 bool is_arguments() const { return kind_ == ARGUMENTS; }
134 133
135 // True if the variable is named eval and not known to be shadowed. 134 // True if the variable is named eval and not known to be shadowed.
136 bool is_possibly_eval() const { 135 bool is_possibly_eval() const {
137 return IsVariable(FACTORY->eval_symbol()); 136 return IsVariable(FACTORY->eval_symbol());
138 } 137 }
139 138
140 Variable* local_if_not_shadowed() const { 139 Variable* local_if_not_shadowed() const {
141 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL); 140 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL);
142 return local_if_not_shadowed_; 141 return local_if_not_shadowed_;
143 } 142 }
144 143
145 void set_local_if_not_shadowed(Variable* local) { 144 void set_local_if_not_shadowed(Variable* local) {
146 local_if_not_shadowed_ = local; 145 local_if_not_shadowed_ = local;
147 } 146 }
148 147
149 Location location() const { return location_; } 148 Location location() const { return location_; }
150 int index() const { return index_; } 149 int index() const { return index_; }
150 InitializationFlag initialization_flag() const {
151 return initialization_flag_;
152 }
151 153
152 void AllocateTo(Location location, int index) { 154 void AllocateTo(Location location, int index) {
153 location_ = location; 155 location_ = location;
154 index_ = index; 156 index_ = index;
155 } 157 }
156 158
157 private: 159 private:
158 Scope* scope_; 160 Scope* scope_;
159 Handle<String> name_; 161 Handle<String> name_;
160 VariableMode mode_; 162 VariableMode mode_;
161 Kind kind_; 163 Kind kind_;
162 Location location_; 164 Location location_;
163 int index_; 165 int index_;
164 166
165 // If this field is set, this variable references the stored locally bound 167 // If this field is set, this variable references the stored locally bound
166 // variable, but it might be shadowed by variable bindings introduced by 168 // variable, but it might be shadowed by variable bindings introduced by
167 // non-strict 'eval' calls between the reference scope (inclusive) and the 169 // non-strict 'eval' calls between the reference scope (inclusive) and the
168 // binding scope (exclusive). 170 // binding scope (exclusive).
169 Variable* local_if_not_shadowed_; 171 Variable* local_if_not_shadowed_;
170 172
171 // Valid as a LHS? (const and this are not valid LHS, for example) 173 // Valid as a LHS? (const and this are not valid LHS, for example)
172 bool is_valid_LHS_; 174 bool is_valid_LHS_;
173 175
174 // Usage info. 176 // Usage info.
175 bool is_accessed_from_inner_scope_; // set by variable resolver 177 bool is_accessed_from_inner_scope_; // set by variable resolver
176 bool is_used_; 178 bool is_used_;
179 InitializationFlag initialization_flag_;
177 }; 180 };
178 181
179 182
180 } } // namespace v8::internal 183 } } // namespace v8::internal
181 184
182 #endif // V8_VARIABLES_H_ 185 #endif // V8_VARIABLES_H_
OLDNEW
« src/v8globals.h ('K') | « src/v8globals.h ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698