Revision: 14349
Author:   [email protected]
Date:     Fri Apr 19 05:02:12 2013
Log: 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
http://code.google.com/p/v8/source/detail?r=14349

Modified:
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.h
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Apr 18 08:09:48 2013 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Fri Apr 19 05:02:12 2013
@@ -2183,17 +2183,16 @@
 }


-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::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));
   }
 }

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Thu Apr 18 08:44:38 2013 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Fri Apr 19 05:02:12 2013
@@ -201,7 +201,7 @@
   Register scratch0() { return r9; }
   DwVfpRegister double_scratch0() { return kScratchDoubleReg; }

-  int GetNextEmittedBlock(int block);
+  int GetNextEmittedBlock();
   LInstruction* GetNextInstruction();

   void EmitClassOfTest(Label* if_true,
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Apr 18 06:45:19 2013 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Fri Apr 19 05:02:12 2013
@@ -2056,17 +2056,16 @@
 }


-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::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));
   }
 }

=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Thu Apr 18 08:44:38 2013 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Fri Apr 19 05:02:12 2013
@@ -191,7 +191,7 @@
   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,
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Apr 18 06:45:19 2013 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Fri Apr 19 05:02:12 2013
@@ -1756,10 +1756,9 @@
 }


-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 @@

 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::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::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));
   }
 }

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Apr 18 16:47:40 2013 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Fri Apr 19 05:02:12 2013
@@ -196,7 +196,7 @@
   Register scratch1() { return kLithiumScratchReg2; }
   DoubleRegister double_scratch0() { return kLithiumScratchDouble; }

-  int GetNextEmittedBlock(int block);
+  int GetNextEmittedBlock();
   LInstruction* GetNextInstruction();

   void EmitClassOfTest(Label* if_true,
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Apr 18 06:45:19 2013 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Fri Apr 19 05:02:12 2013
@@ -1822,17 +1822,16 @@
 }


-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::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));
   }
 }

=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Thu Apr 18 08:44:38 2013 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Fri Apr 19 05:02:12 2013
@@ -162,7 +162,7 @@
   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,

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to