From 4afbecf50eaaec9d2ce16aae51ac57f302a57259 Mon Sep 17 00:00:00 2001 From: "kmillikin@chromium.org" Date: Thu, 11 Sep 2008 15:16:08 +0000 Subject: [PATCH] Fix performace regression due to missed peephole optimization 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 | 6 +++++- src/codegen-ia32.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/codegen-arm.cc b/src/codegen-arm.cc index 47d922d..e4cad6b 100644 --- a/src/codegen-arm.cc +++ b/src/codegen-arm.cc @@ -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); } } diff --git a/src/codegen-ia32.cc b/src/codegen-ia32.cc index a0f0e51..42fe7ca 100644 --- a/src/codegen-ia32.cc +++ b/src/codegen-ia32.cc @@ -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); } } -- 2.7.4