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

Side by Side Diff: src/scopes.cc

Issue 1215423002: Fix ScopeInfo::StackSlotIndex to skip over non-locals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/scopeinfo.cc ('k') | no next file » | 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 Variable* result = variables_.Lookup(name); 377 Variable* result = variables_.Lookup(name);
378 if (result != NULL || scope_info_.is_null()) { 378 if (result != NULL || scope_info_.is_null()) {
379 return result; 379 return result;
380 } 380 }
381 Handle<String> name_handle = name->string(); 381 Handle<String> name_handle = name->string();
382 // The Scope is backed up by ScopeInfo. This means it cannot operate in a 382 // The Scope is backed up by ScopeInfo. This means it cannot operate in a
383 // heap-independent mode, and all strings must be internalized immediately. So 383 // heap-independent mode, and all strings must be internalized immediately. So
384 // it's ok to get the Handle<String> here. 384 // it's ok to get the Handle<String> here.
385 // If we have a serialized scope info, we might find the variable there. 385 // If we have a serialized scope info, we might find the variable there.
386 // There should be no local slot with the given name. 386 // There should be no local slot with the given name.
387 DCHECK(scope_info_->StackSlotIndex(*name_handle) < 0 || is_block_scope()); 387 DCHECK(scope_info_->StackLocalSlotIndex(*name_handle) < 0);
388 388
389 // Check context slot lookup. 389 // Check context slot lookup.
390 VariableMode mode; 390 VariableMode mode;
391 Variable::Location location = Variable::CONTEXT; 391 Variable::Location location = Variable::CONTEXT;
392 InitializationFlag init_flag; 392 InitializationFlag init_flag;
393 MaybeAssignedFlag maybe_assigned_flag; 393 MaybeAssignedFlag maybe_assigned_flag;
394 int index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode, 394 int index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode,
395 &init_flag, &maybe_assigned_flag); 395 &init_flag, &maybe_assigned_flag);
396 if (index < 0) { 396 if (index < 0) {
397 // Check parameters. 397 // Check parameters.
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 } 1557 }
1558 1558
1559 1559
1560 int Scope::ContextLocalCount() const { 1560 int Scope::ContextLocalCount() const {
1561 if (num_heap_slots() == 0) return 0; 1561 if (num_heap_slots() == 0) return 0;
1562 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1562 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1563 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1563 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1564 } 1564 }
1565 } // namespace internal 1565 } // namespace internal
1566 } // namespace v8 1566 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698