Fix performace regression due to missed peephole optimization
authorkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 11 Sep 2008 15:16:08 +0000 (15:16 +0000)
committerkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 11 Sep 2008 15:16:08 +0000 (15:16 +0000)
opportunity.
Review URL: http://codereview.chromium.org/2002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@286 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/codegen-arm.cc
src/codegen-ia32.cc

index 47d922d..e4cad6b 100644 (file)
@@ -948,6 +948,7 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
     ASSERT(var()->mode() != Variable::DYNAMIC);
 
     Label exit;
+    bool may_skip_write = false;
     if (init_state == CONST_INIT) {
       ASSERT(var()->mode() == Variable::CONST);
       // Only the first const initialization must be executed (the slot
@@ -957,6 +958,7 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
       masm->ldr(r2, ArmCodeGenerator::SlotOperand(masm, scope, this, r2));
       masm->cmp(r2, Operand(Factory::the_hole_value()));
       masm->b(ne, &exit);
+      may_skip_write = true;
     }
 
     // We must execute the store.
@@ -981,7 +983,9 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
       masm->mov(r3, Operand(offset));
       masm->RecordWrite(r2, r3, r1);
     }
-    masm->bind(&exit);
+    // If we definitely did not jump over the assignment, we do not need to
+    // bind the exit label.  Doing so can defeat peephole optimization.
+    if (may_skip_write) masm->bind(&exit);
   }
 }
 
index a0f0e51..42fe7ca 100644 (file)
@@ -975,6 +975,7 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
     ASSERT(var()->mode() != Variable::DYNAMIC);
 
     Label exit;
+    bool may_skip_write = false;
     if (init_state == CONST_INIT) {
       ASSERT(var()->mode() == Variable::CONST);
       // Only the first const initialization must be executed (the slot
@@ -984,6 +985,7 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
       masm->mov(eax, Ia32CodeGenerator::SlotOperand(masm, scope, this, ecx));
       masm->cmp(eax, Factory::the_hole_value());
       masm->j(not_equal, &exit);
+      may_skip_write = true;
     }
 
     // We must execute the store.
@@ -1003,7 +1005,9 @@ void Slot::GenerateStoreCode(MacroAssembler* masm,
       int offset = FixedArray::kHeaderSize + index() * kPointerSize;
       masm->RecordWrite(ecx, offset, eax, ebx);
     }
-    masm->bind(&exit);
+    // If we definitely did not jump over the assignment, we do not need to
+    // bind the exit label.  Doing so can defeat peephole optimization.
+    if (may_skip_write) masm->bind(&exit);
   }
 }