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

Unified Diff: src/interpreter/bytecode-array-builder.cc

Issue 1283313003: [interpreter]: Update BytecodeArrayBuilder register handling. (Closed) Base URL: ssh://rmcilroy.lon.corp.google.com///usr/local/google/code/v8_full/v8@master
Patch Set: Fix define in OperandTypeToString Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index 2bd1318ba1b7b044d00fea60c6935de56378bb76..8cc0772db97d4b0a98180c57d5c0ffa28d8cc726 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -39,8 +39,8 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value binop,
- int reg) {
- Output(BytecodeForBinaryOperation(binop), reg);
+ Register reg) {
+ Output(BytecodeForBinaryOperation(binop), reg.ToOperand());
return *this;
}
@@ -91,15 +91,15 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadFalse() {
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadAccumulatorWithRegister(
- int reg) {
- Output(Bytecode::kLdar, reg);
+ Register reg) {
+ Output(Bytecode::kLdar, reg.ToOperand());
return *this;
}
BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister(
- int reg) {
- Output(Bytecode::kStar, reg);
+ Register reg) {
+ Output(Bytecode::kStar, reg.ToOperand());
return *this;
}
@@ -112,18 +112,18 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Return() {
int BytecodeArrayBuilder::BorrowTemporaryRegister() {
DCHECK_GE(local_register_count_, 0);
- int temporary_register = temporary_register_next_++;
+ int temporary_reg_index = temporary_register_next_++;
int count = temporary_register_next_ - local_register_count_;
if (count > temporary_register_count_) {
temporary_register_count_ = count;
}
- return temporary_register;
+ return temporary_reg_index;
}
-void BytecodeArrayBuilder::ReturnTemporaryRegister(int reg) {
- DCHECK_EQ(reg, temporary_register_next_ - 1);
- temporary_register_next_ = reg;
+void BytecodeArrayBuilder::ReturnTemporaryRegister(int reg_index) {
+ DCHECK_EQ(reg_index, temporary_register_next_ - 1);
+ temporary_register_next_ = reg_index;
}
@@ -136,7 +136,8 @@ bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
case OperandType::kImm8:
return true;
case OperandType::kReg:
- return operand_value < temporary_register_next_;
+ return Register::FromOperand(operand_value).index() <
+ temporary_register_next_;
}
UNREACHABLE();
return false;
@@ -200,20 +201,20 @@ Bytecode BytecodeArrayBuilder::BytecodeForBinaryOperation(Token::Value op) {
TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder)
- : builder_(builder), count_(0), register_(-1) {}
+ : builder_(builder), count_(0), last_register_index_(-1) {}
TemporaryRegisterScope::~TemporaryRegisterScope() {
while (count_-- != 0) {
- builder_->ReturnTemporaryRegister(register_--);
+ builder_->ReturnTemporaryRegister(last_register_index_--);
}
}
-int TemporaryRegisterScope::NewRegister() {
+Register TemporaryRegisterScope::NewRegister() {
count_++;
- register_ = builder_->BorrowTemporaryRegister();
- return register_;
+ last_register_index_ = builder_->BorrowTemporaryRegister();
+ return Register(last_register_index_);
}
} // namespace interpreter

Powered by Google App Engine
This is Rietveld 408576698