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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 1413703007: [Interpreter] Fix a register allocation bug and add a DCHECK. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1054 }
1055 1055
1056 1056
1057 Register TemporaryRegisterScope::NewRegister() { 1057 Register TemporaryRegisterScope::NewRegister() {
1058 int allocated = builder_->BorrowTemporaryRegister(); 1058 int allocated = builder_->BorrowTemporaryRegister();
1059 allocated_.push_back(allocated); 1059 allocated_.push_back(allocated);
1060 return Register(allocated); 1060 return Register(allocated);
1061 } 1061 }
1062 1062
1063 1063
1064 bool TemporaryRegisterScope::AllocatedRegister(Register reg) const {
oth 2015/10/27 12:30:23 Suggest renaming to RegisterIsAllocated() to match
rmcilroy 2015/10/27 13:13:24 Renamed to RegisterIsAllocatedInThisScope() to be
1065 for (auto i = allocated_.begin(); i != allocated_.end(); i++) {
1066 if (*i == reg.index()) return true;
1067 }
1068 return false;
1069 }
1070
1071
1064 void TemporaryRegisterScope::PrepareForConsecutiveAllocations(size_t count) { 1072 void TemporaryRegisterScope::PrepareForConsecutiveAllocations(size_t count) {
1065 if (static_cast<int>(count) > next_consecutive_count_) { 1073 if (static_cast<int>(count) > next_consecutive_count_) {
1066 next_consecutive_register_ = 1074 next_consecutive_register_ =
1067 builder_->PrepareForConsecutiveTemporaryRegisters(count); 1075 builder_->PrepareForConsecutiveTemporaryRegisters(count);
1068 next_consecutive_count_ = static_cast<int>(count); 1076 next_consecutive_count_ = static_cast<int>(count);
1069 } 1077 }
1070 } 1078 }
1071 1079
1072 1080
1073 Register TemporaryRegisterScope::NextConsecutiveRegister() { 1081 Register TemporaryRegisterScope::NextConsecutiveRegister() {
1074 DCHECK_GE(next_consecutive_register_, 0); 1082 DCHECK_GE(next_consecutive_register_, 0);
1075 DCHECK_GT(next_consecutive_count_, 0); 1083 DCHECK_GT(next_consecutive_count_, 0);
1076 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); 1084 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_);
1077 allocated_.push_back(next_consecutive_register_); 1085 allocated_.push_back(next_consecutive_register_);
1078 next_consecutive_count_--; 1086 next_consecutive_count_--;
1079 return Register(next_consecutive_register_++); 1087 return Register(next_consecutive_register_++);
1080 } 1088 }
1081 1089
1082 } // namespace interpreter 1090 } // namespace interpreter
1083 } // namespace internal 1091 } // namespace internal
1084 } // namespace v8 1092 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698