From 108538f151c50f270e81f50537cb8ad5f0e0ee28 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Tue, 12 Nov 2013 17:18:05 +0000 Subject: [PATCH] Fix usage of EmitBranch in compare-minus-zero-and-branch. R=jkummerow@chromium.org BUG= Review URL: https://codereview.chromium.org/68933009 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17669 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 13 ++++++------- src/arm/lithium-codegen-arm.h | 2 ++ src/ia32/lithium-codegen-ia32.cc | 10 +++------- src/ia32/lithium-codegen-ia32.h | 2 ++ src/x64/lithium-codegen-x64.cc | 10 +++------- src/x64/lithium-codegen-x64.h | 2 ++ 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 9533d03..207dd8c 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2475,28 +2475,27 @@ void LCodeGen::DoCmpHoleAndBranch(LCmpHoleAndBranch* instr) { void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { Representation rep = instr->hydrogen()->value()->representation(); ASSERT(!rep.IsInteger32()); - Label if_false; Register scratch = ToRegister(instr->temp()); if (rep.IsDouble()) { DwVfpRegister value = ToDoubleRegister(instr->value()); __ VFPCompareAndSetFlags(value, 0.0); - __ b(ne, &if_false); + EmitFalseBranch(instr, ne); __ VmovHigh(scratch, value); __ cmp(scratch, Operand(0x80000000)); } else { Register value = ToRegister(instr->value()); - __ CheckMap( - value, scratch, Heap::kHeapNumberMapRootIndex, &if_false, DO_SMI_CHECK); + __ CheckMap(value, + scratch, + Heap::kHeapNumberMapRootIndex, + instr->FalseLabel(chunk()), + DO_SMI_CHECK); __ ldr(scratch, FieldMemOperand(value, HeapNumber::kExponentOffset)); __ ldr(ip, FieldMemOperand(value, HeapNumber::kMantissaOffset)); __ cmp(scratch, Operand(0x80000000)); __ cmp(ip, Operand(0x00000000), eq); } EmitBranch(instr, eq); - - __ bind(&if_false); - EmitFalseBranch(instr, al); } diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index cbd6b9c..7390a48 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -297,6 +297,8 @@ class LCodeGen: public LCodeGenBase { static Condition TokenToCondition(Token::Value op, bool is_unsigned); void EmitGoto(int block); + + // EmitBranch expects to be the last instruction of a block. template void EmitBranch(InstrType instr, Condition condition); template diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index bc46113..de52fad 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -2673,7 +2673,6 @@ void LCodeGen::DoCmpHoleAndBranch(LCmpHoleAndBranch* instr) { void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { Representation rep = instr->hydrogen()->value()->representation(); ASSERT(!rep.IsInteger32()); - Label if_false; Register scratch = ToRegister(instr->temp()); if (rep.IsDouble()) { @@ -2682,24 +2681,21 @@ void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { XMMRegister xmm_scratch = double_scratch0(); __ xorps(xmm_scratch, xmm_scratch); __ ucomisd(xmm_scratch, value); - __ j(not_equal, &if_false); + EmitFalseBranch(instr, not_equal); __ movmskpd(scratch, value); __ test(scratch, Immediate(1)); EmitBranch(instr, not_zero); } else { Register value = ToRegister(instr->value()); Handle map = masm()->isolate()->factory()->heap_number_map(); - __ CheckMap(value, map, &if_false, DO_SMI_CHECK); + __ CheckMap(value, map, instr->FalseLabel(chunk()), DO_SMI_CHECK); __ cmp(FieldOperand(value, HeapNumber::kExponentOffset), Immediate(0x80000000)); - __ j(not_equal, &if_false); + EmitFalseBranch(instr, not_equal); __ cmp(FieldOperand(value, HeapNumber::kMantissaOffset), Immediate(0x00000000)); EmitBranch(instr, equal); } - - __ bind(&if_false); - EmitFalseBranch(instr, no_condition); } diff --git a/src/ia32/lithium-codegen-ia32.h b/src/ia32/lithium-codegen-ia32.h index 6c9cde3..514b42e 100644 --- a/src/ia32/lithium-codegen-ia32.h +++ b/src/ia32/lithium-codegen-ia32.h @@ -320,6 +320,8 @@ class LCodeGen: public LCodeGenBase { static Condition TokenToCondition(Token::Value op, bool is_unsigned); void EmitGoto(int block); + + // EmitBranch expects to be the last instruction of a block. template void EmitBranch(InstrType instr, Condition cc); template diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 986cf83..dc6ddf9 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2249,31 +2249,27 @@ void LCodeGen::DoCmpHoleAndBranch(LCmpHoleAndBranch* instr) { void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { Representation rep = instr->hydrogen()->value()->representation(); ASSERT(!rep.IsInteger32()); - Label if_false; if (rep.IsDouble()) { XMMRegister value = ToDoubleRegister(instr->value()); XMMRegister xmm_scratch = double_scratch0(); __ xorps(xmm_scratch, xmm_scratch); __ ucomisd(xmm_scratch, value); - __ j(not_equal, &if_false); + EmitFalseBranch(instr, not_equal); __ movmskpd(kScratchRegister, value); __ testl(kScratchRegister, Immediate(1)); EmitBranch(instr, not_zero); } else { Register value = ToRegister(instr->value()); Handle map = masm()->isolate()->factory()->heap_number_map(); - __ CheckMap(value, map, &if_false, DO_SMI_CHECK); + __ CheckMap(value, map, instr->FalseLabel(chunk()), DO_SMI_CHECK); __ cmpl(FieldOperand(value, HeapNumber::kExponentOffset), Immediate(0x80000000)); - __ j(not_equal, &if_false); + EmitFalseBranch(instr, not_equal); __ cmpl(FieldOperand(value, HeapNumber::kMantissaOffset), Immediate(0x00000000)); EmitBranch(instr, equal); } - - __ bind(&if_false); - EmitFalseBranch(instr, always); } diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 060cbe8..ac238d0 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -270,6 +270,8 @@ class LCodeGen: public LCodeGenBase { static Condition TokenToCondition(Token::Value op, bool is_unsigned); void EmitGoto(int block); + + // EmitBranch expects to be the last instruction of a block. template void EmitBranch(InstrType instr, Condition cc); template -- 2.7.4