From 0af76e96ea0d0fe22e139d558f0ec1c704e5ce4c Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 19 Apr 2013 12:02:12 +0000 Subject: [PATCH] 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 --- src/arm/lithium-codegen-arm.cc | 16 +++++++--------- src/arm/lithium-codegen-arm.h | 2 +- src/ia32/lithium-codegen-ia32.cc | 16 +++++++--------- src/ia32/lithium-codegen-ia32.h | 2 +- src/mips/lithium-codegen-mips.cc | 18 ++++++++---------- src/mips/lithium-codegen-mips.h | 2 +- src/x64/lithium-codegen-x64.cc | 16 +++++++--------- src/x64/lithium-codegen-x64.h | 2 +- 8 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index c6ba517..e220678 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -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)); } } diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index 5f720a9..c104132 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -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, diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 665c85e..221882c 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -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)); } } diff --git a/src/ia32/lithium-codegen-ia32.h b/src/ia32/lithium-codegen-ia32.h index 3e1bc35..a59b368 100644 --- a/src/ia32/lithium-codegen-ia32.h +++ b/src/ia32/lithium-codegen-ia32.h @@ -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, diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 7794931..bf227a2 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -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)); } } diff --git a/src/mips/lithium-codegen-mips.h b/src/mips/lithium-codegen-mips.h index 9634aa6..0dbfe65 100644 --- a/src/mips/lithium-codegen-mips.h +++ b/src/mips/lithium-codegen-mips.h @@ -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, diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 3e8fd5c..21b0fcd 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -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)); } } diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 3cad2cc..a988a7a 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -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, -- 2.7.4