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

Side by Side Diff: src/scopeinfo.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/objects.h ('k') | src/scopes.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 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 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/scopeinfo.h" 10 #include "src/scopeinfo.h"
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 DCHECK(0 <= var && var < StrongModeFreeVariableCount()); 460 DCHECK(0 <= var && var < StrongModeFreeVariableCount());
461 int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2 + 1; 461 int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2 + 1;
462 int32_t value = 0; 462 int32_t value = 0;
463 bool ok = get(info_index)->ToInt32(&value); 463 bool ok = get(info_index)->ToInt32(&value);
464 USE(ok); 464 USE(ok);
465 DCHECK(ok); 465 DCHECK(ok);
466 return value; 466 return value;
467 } 467 }
468 468
469 469
470 int ScopeInfo::StackSlotIndex(String* name) { 470 int ScopeInfo::StackLocalSlotIndex(String* name) {
471 DCHECK(name->IsInternalizedString()); 471 DCHECK(name->IsInternalizedString());
472 if (length() > 0) { 472 if (length() > 0) {
473 int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value(); 473 int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value();
474 int start = StackLocalEntriesIndex(); 474 int start = StackLocalEntriesIndex() + first_slot_index;
475 int end = StackLocalEntriesIndex() + StackLocalCount(); 475 int end = StackLocalEntriesIndex() + StackLocalCount();
476 for (int i = start; i < end; ++i) { 476 for (int i = start; i < end; ++i) {
477 if (name == get(i)) { 477 if (name == get(i)) {
478 return i - start + first_slot_index; 478 return i - start + first_slot_index;
479 } 479 }
480 } 480 }
481 } 481 }
482 return -1; 482 return -1;
483 } 483 }
484 484
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 info->set_mode(i, var->mode()); 782 info->set_mode(i, var->mode());
783 DCHECK(var->index() >= 0); 783 DCHECK(var->index() >= 0);
784 info->set_index(i, var->index()); 784 info->set_index(i, var->index());
785 } 785 }
786 DCHECK(i == info->length()); 786 DCHECK(i == info->length());
787 return info; 787 return info;
788 } 788 }
789 789
790 } // namespace internal 790 } // namespace internal
791 } // namespace v8 791 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698