Simplified LCodeGen::GetNextEmittedBlock and LCodeGen::EmitGoto a bit.

GetNextEmittedBlock is always called with the same argument (an instance
variable), so let's remove it. In EmitGoto, avoid assignment to an argument.

This CL is split off another CL for easier reviewing.

Review URL: https://codereview.chromium.org/14246031

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14349 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c0fca4e8
......@@ -2183,17 +2183,16 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
}
int LCodeGen::GetNextEmittedBlock(int block) {
for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
LLabel* label = chunk_->GetLabel(i);
if (!label->HasReplacement()) return i;
int LCodeGen::GetNextEmittedBlock() {
for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
if (!chunk_->GetLabel(i)->HasReplacement()) return i;
}
return -1;
}
void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
int next_block = GetNextEmittedBlock(current_block_);
int next_block = GetNextEmittedBlock();
right_block = chunk_->LookupDestination(right_block);
left_block = chunk_->LookupDestination(left_block);
......@@ -2330,10 +2329,9 @@ void LCodeGen::DoBranch(LBranch* instr) {
void LCodeGen::EmitGoto(int block) {
block = chunk_->LookupDestination(block);
int next_block = GetNextEmittedBlock(current_block_);
if (block != next_block) {
__ jmp(chunk_->GetAssemblyLabel(block));
int destination = chunk_->LookupDestination(block);
if (destination != GetNextEmittedBlock()) {
__ jmp(chunk_->GetAssemblyLabel(destination));
}
}
......
......@@ -201,7 +201,7 @@ class LCodeGen BASE_EMBEDDED {
Register scratch0() { return r9; }
DwVfpRegister double_scratch0() { return kScratchDoubleReg; }
int GetNextEmittedBlock(int block);
int GetNextEmittedBlock();
LInstruction* GetNextInstruction();
void EmitClassOfTest(Label* if_true,
......
......@@ -2056,17 +2056,16 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
}
int LCodeGen::GetNextEmittedBlock(int block) {
for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
LLabel* label = chunk_->GetLabel(i);
if (!label->HasReplacement()) return i;
int LCodeGen::GetNextEmittedBlock() {
for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
if (!chunk_->GetLabel(i)->HasReplacement()) return i;
}
return -1;
}
void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
int next_block = GetNextEmittedBlock(current_block_);
int next_block = GetNextEmittedBlock();
right_block = chunk_->LookupDestination(right_block);
left_block = chunk_->LookupDestination(left_block);
......@@ -2204,10 +2203,9 @@ void LCodeGen::DoBranch(LBranch* instr) {
void LCodeGen::EmitGoto(int block) {
block = chunk_->LookupDestination(block);
int next_block = GetNextEmittedBlock(current_block_);
if (block != next_block) {
__ jmp(chunk_->GetAssemblyLabel(block));
int destination = chunk_->LookupDestination(block);
if (destination != GetNextEmittedBlock()) {
__ jmp(chunk_->GetAssemblyLabel(destination));
}
}
......
......@@ -191,7 +191,7 @@ class LCodeGen BASE_EMBEDDED {
Scope* scope() const { return scope_; }
HGraph* graph() const { return chunk_->graph(); }
int GetNextEmittedBlock(int block);
int GetNextEmittedBlock();
void EmitClassOfTest(Label* if_true,
Label* if_false,
......
......@@ -1756,10 +1756,9 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
}
int LCodeGen::GetNextEmittedBlock(int block) {
for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
LLabel* label = chunk_->GetLabel(i);
if (!label->HasReplacement()) return i;
int LCodeGen::GetNextEmittedBlock() {
for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
if (!chunk_->GetLabel(i)->HasReplacement()) return i;
}
return -1;
}
......@@ -1767,7 +1766,7 @@ int LCodeGen::GetNextEmittedBlock(int block) {
void LCodeGen::EmitBranch(int left_block, int right_block,
Condition cc, Register src1, const Operand& src2) {
int next_block = GetNextEmittedBlock(current_block_);
int next_block = GetNextEmittedBlock();
right_block = chunk_->LookupDestination(right_block);
left_block = chunk_->LookupDestination(left_block);
if (right_block == left_block) {
......@@ -1786,7 +1785,7 @@ void LCodeGen::EmitBranch(int left_block, int right_block,
void LCodeGen::EmitBranchF(int left_block, int right_block,
Condition cc, FPURegister src1, FPURegister src2) {
int next_block = GetNextEmittedBlock(current_block_);
int next_block = GetNextEmittedBlock();
right_block = chunk_->LookupDestination(right_block);
left_block = chunk_->LookupDestination(left_block);
if (right_block == left_block) {
......@@ -1916,10 +1915,9 @@ void LCodeGen::DoBranch(LBranch* instr) {
void LCodeGen::EmitGoto(int block) {
block = chunk_->LookupDestination(block);
int next_block = GetNextEmittedBlock(current_block_);
if (block != next_block) {
__ jmp(chunk_->GetAssemblyLabel(block));
int destination = chunk_->LookupDestination(block);
if (destination != GetNextEmittedBlock()) {
__ jmp(chunk_->GetAssemblyLabel(destination));
}
}
......
......@@ -196,7 +196,7 @@ class LCodeGen BASE_EMBEDDED {
Register scratch1() { return kLithiumScratchReg2; }
DoubleRegister double_scratch0() { return kLithiumScratchDouble; }
int GetNextEmittedBlock(int block);
int GetNextEmittedBlock();
LInstruction* GetNextInstruction();
void EmitClassOfTest(Label* if_true,
......
......@@ -1822,17 +1822,16 @@ void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
}
int LCodeGen::GetNextEmittedBlock(int block) {
for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
LLabel* label = chunk_->GetLabel(i);
if (!label->HasReplacement()) return i;
int LCodeGen::GetNextEmittedBlock() {
for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
if (!chunk_->GetLabel(i)->HasReplacement()) return i;
}
return -1;
}
void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
int next_block = GetNextEmittedBlock(current_block_);
int next_block = GetNextEmittedBlock();
right_block = chunk_->LookupDestination(right_block);
left_block = chunk_->LookupDestination(left_block);
......@@ -1962,10 +1961,9 @@ void LCodeGen::DoBranch(LBranch* instr) {
void LCodeGen::EmitGoto(int block) {
block = chunk_->LookupDestination(block);
int next_block = GetNextEmittedBlock(current_block_);
if (block != next_block) {
__ jmp(chunk_->GetAssemblyLabel(block));
int destination = chunk_->LookupDestination(block);
if (destination != GetNextEmittedBlock()) {
__ jmp(chunk_->GetAssemblyLabel(destination));
}
}
......
......@@ -162,7 +162,7 @@ class LCodeGen BASE_EMBEDDED {
Scope* scope() const { return scope_; }
HGraph* graph() const { return chunk_->graph(); }
int GetNextEmittedBlock(int block);
int GetNextEmittedBlock();
void EmitClassOfTest(Label* if_true,
Label* if_false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment