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

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

Issue 2232343002: [ast] Never declare non-lexical variables as kNeedsInitialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « no previous file | src/ast/variables.h » ('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/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1242 }
1243 #endif // DEBUG 1243 #endif // DEBUG
1244 1244
1245 1245
1246 Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) { 1246 Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
1247 if (dynamics_ == NULL) dynamics_ = new (zone()) DynamicScopePart(zone()); 1247 if (dynamics_ == NULL) dynamics_ = new (zone()) DynamicScopePart(zone());
1248 VariableMap* map = dynamics_->GetMap(mode); 1248 VariableMap* map = dynamics_->GetMap(mode);
1249 Variable* var = map->Lookup(name); 1249 Variable* var = map->Lookup(name);
1250 if (var == NULL) { 1250 if (var == NULL) {
1251 // Declare a new non-local. 1251 // Declare a new non-local.
1252 InitializationFlag init_flag = (mode == VAR) 1252 DCHECK(!IsLexicalVariableMode(mode));
1253 ? kCreatedInitialized : kNeedsInitialization; 1253 var = map->Declare(zone(), NULL, name, mode, Variable::NORMAL,
1254 var = map->Declare(zone(), NULL, name, mode, Variable::NORMAL, init_flag); 1254 kCreatedInitialized);
1255 // Allocate it by giving it a dynamic lookup. 1255 // Allocate it by giving it a dynamic lookup.
1256 var->AllocateTo(VariableLocation::LOOKUP, -1); 1256 var->AllocateTo(VariableLocation::LOOKUP, -1);
1257 } 1257 }
1258 return var; 1258 return var;
1259 } 1259 }
1260 1260
1261 Variable* Scope::LookupRecursive(VariableProxy* proxy, 1261 Variable* Scope::LookupRecursive(VariableProxy* proxy,
1262 BindingKind* binding_kind, 1262 BindingKind* binding_kind,
1263 AstNodeFactory* factory, 1263 AstNodeFactory* factory,
1264 Scope* outer_scope_end) { 1264 Scope* outer_scope_end) {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 function != nullptr && function->IsContextSlot(); 1787 function != nullptr && function->IsContextSlot();
1788 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1788 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1789 (is_function_var_in_context ? 1 : 0); 1789 (is_function_var_in_context ? 1 : 0);
1790 } 1790 }
1791 1791
1792 1792
1793 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1793 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1794 1794
1795 } // namespace internal 1795 } // namespace internal
1796 } // namespace v8 1796 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/ast/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698