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

Side by Side Diff: src/ast/scopes.cc

Issue 2693313002: [ast] Mark temporaries as maybe-assigned by default. (Closed)
Patch Set: Make the powerful variant private. Created 3 years, 10 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
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | 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 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 variables_.Add(zone(), function_); 701 variables_.Add(zone(), function_);
702 } 702 }
703 return function_; 703 return function_;
704 } 704 }
705 705
706 Variable* DeclarationScope::DeclareGeneratorObjectVar( 706 Variable* DeclarationScope::DeclareGeneratorObjectVar(
707 const AstRawString* name) { 707 const AstRawString* name) {
708 DCHECK(is_function_scope() || is_module_scope()); 708 DCHECK(is_function_scope() || is_module_scope());
709 DCHECK_NULL(generator_object_var()); 709 DCHECK_NULL(generator_object_var());
710 710
711 Variable* result = EnsureRareData()->generator_object = NewTemporary(name); 711 Variable* result = EnsureRareData()->generator_object =
712 NewTemporary(name, kNotAssigned);
712 result->set_is_used(); 713 result->set_is_used();
713 return result; 714 return result;
714 } 715 }
715 716
716 Variable* DeclarationScope::DeclarePromiseVar(const AstRawString* name) { 717 Variable* DeclarationScope::DeclarePromiseVar(const AstRawString* name) {
717 DCHECK(is_function_scope()); 718 DCHECK(is_function_scope());
718 DCHECK_NULL(promise_var()); 719 DCHECK_NULL(promise_var());
719 Variable* result = EnsureRareData()->promise = NewTemporary(name); 720 Variable* result = EnsureRareData()->promise = NewTemporary(name);
720 result->set_is_used(); 721 result->set_is_used();
721 return result; 722 return result;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 current->set_next_unresolved(next->next_unresolved()); 1199 current->set_next_unresolved(next->next_unresolved());
1199 var->set_next_unresolved(nullptr); 1200 var->set_next_unresolved(nullptr);
1200 return true; 1201 return true;
1201 } 1202 }
1202 current = next; 1203 current = next;
1203 } 1204 }
1204 return false; 1205 return false;
1205 } 1206 }
1206 1207
1207 Variable* Scope::NewTemporary(const AstRawString* name) { 1208 Variable* Scope::NewTemporary(const AstRawString* name) {
1209 return NewTemporary(name, kMaybeAssigned);
1210 }
1211
1212 Variable* Scope::NewTemporary(const AstRawString* name,
1213 MaybeAssignedFlag maybe_assigned) {
1208 DeclarationScope* scope = GetClosureScope(); 1214 DeclarationScope* scope = GetClosureScope();
1209 Variable* var = new (zone()) 1215 Variable* var = new (zone())
1210 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); 1216 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized);
1211 scope->AddLocal(var); 1217 scope->AddLocal(var);
1218 if (maybe_assigned == kMaybeAssigned) var->set_maybe_assigned();
1212 return var; 1219 return var;
1213 } 1220 }
1214 1221
1215 Declaration* Scope::CheckConflictingVarDeclarations() { 1222 Declaration* Scope::CheckConflictingVarDeclarations() {
1216 for (Declaration* decl : decls_) { 1223 for (Declaration* decl : decls_) {
1217 VariableMode mode = decl->proxy()->var()->mode(); 1224 VariableMode mode = decl->proxy()->var()->mode();
1218 if (IsLexicalVariableMode(mode) && !is_block_scope()) continue; 1225 if (IsLexicalVariableMode(mode) && !is_block_scope()) continue;
1219 1226
1220 // Iterate through all scopes until and including the declaration scope. 1227 // Iterate through all scopes until and including the declaration scope.
1221 Scope* previous = NULL; 1228 Scope* previous = NULL;
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 Variable* function = 2289 Variable* function =
2283 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2290 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2284 bool is_function_var_in_context = 2291 bool is_function_var_in_context =
2285 function != nullptr && function->IsContextSlot(); 2292 function != nullptr && function->IsContextSlot();
2286 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2293 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2287 (is_function_var_in_context ? 1 : 0); 2294 (is_function_var_in_context ? 1 : 0);
2288 } 2295 }
2289 2296
2290 } // namespace internal 2297 } // namespace internal
2291 } // namespace v8 2298 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698