From e23ac61f6065ffa82b028b7847725537588bb8c8 Mon Sep 17 00:00:00 2001 From: "plind44@gmail.com" Date: Tue, 12 Nov 2013 19:05:38 +0000 Subject: [PATCH] MIPS: Introduce %_IsMinusZero. Port r17639 (45b8a52) BUG= R=plind44@gmail.com Review URL: https://codereview.chromium.org/61203006 Patch from Balazs Kilvady . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17671 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/full-codegen-mips.cc | 30 ++++++++++++++++++++++++++++++ src/mips/lithium-codegen-mips.cc | 27 +++++++++++++++++++++++++++ src/mips/lithium-mips.cc | 10 ++++++++++ src/mips/lithium-mips.h | 17 +++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 56c9240..8c7a4c3 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3133,6 +3133,36 @@ void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { } +void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) { + ZoneList* args = expr->arguments(); + ASSERT(args->length() == 1); + + VisitForAccumulatorValue(args->at(0)); + + Label materialize_true, materialize_false; + Label* if_true = NULL; + Label* if_false = NULL; + Label* fall_through = NULL; + context()->PrepareTest(&materialize_true, &materialize_false, + &if_true, &if_false, &fall_through); + + __ CheckMap(v0, a1, Heap::kHeapNumberMapRootIndex, if_false, DO_SMI_CHECK); + __ lw(a2, FieldMemOperand(v0, HeapNumber::kExponentOffset)); + __ lw(a1, FieldMemOperand(v0, HeapNumber::kMantissaOffset)); + __ li(t0, 0x80000000); + Label not_nan; + __ Branch(¬_nan, ne, a2, Operand(t0)); + __ mov(t0, zero_reg); + __ mov(a2, a1); + __ bind(¬_nan); + + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); + Split(eq, a2, Operand(t0), if_true, if_false, fall_through); + + context()->Plug(if_true, if_false); +} + + void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { ZoneList* args = expr->arguments(); ASSERT(args->length() == 1); diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index b1cf42c..a3bcdf6 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2311,6 +2311,33 @@ 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()) { + DoubleRegister value = ToDoubleRegister(instr->value()); + __ BranchF(&if_false, NULL, ne, value, kDoubleRegZero); + __ FmoveHigh(scratch, value); + __ li(at, 0x80000000); + } else { + Register value = ToRegister(instr->value()); + __ CheckMap( + value, scratch, Heap::kHeapNumberMapRootIndex, &if_false, DO_SMI_CHECK); + __ lw(scratch, FieldMemOperand(value, HeapNumber::kExponentOffset)); + __ Branch(&if_false, ne, scratch, Operand(0x80000000)); + __ lw(scratch, FieldMemOperand(value, HeapNumber::kMantissaOffset)); + __ mov(at, zero_reg); + } + EmitBranch(instr, eq, scratch, Operand(at)); + + __ bind(&if_false); + EmitFalseBranchF(instr, al, kDoubleRegZero, kDoubleRegZero); +} + + Condition LCodeGen::EmitIsObject(Register input, Register temp1, Register temp2, diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 943d947..70dd60d 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1703,6 +1703,16 @@ LInstruction* LChunkBuilder::DoCompareHoleAndBranch( } +LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch( + HCompareMinusZeroAndBranch* instr) { + LInstruction* goto_instr = CheckElideControlInstruction(instr); + if (goto_instr != NULL) return goto_instr; + LOperand* value = UseRegister(instr->value()); + LOperand* scratch = TempRegister(); + return new(zone()) LCompareMinusZeroAndBranch(value, scratch); +} + + LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { ASSERT(instr->value()->representation().IsTagged()); LOperand* temp = TempRegister(); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 5678bb7..8c82a9d 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -72,6 +72,7 @@ class LCodeGen; V(ClampIToUint8) \ V(ClampTToUint8) \ V(ClassOfTestAndBranch) \ + V(CompareMinusZeroAndBranch) \ V(CompareNumericAndBranch) \ V(CmpObjectEqAndBranch) \ V(CmpHoleAndBranch) \ @@ -923,6 +924,22 @@ class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> { }; +class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> { + public: + LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) { + inputs_[0] = value; + temps_[0] = temp; + } + + LOperand* value() { return inputs_[0]; } + LOperand* temp() { return temps_[0]; } + + DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch, + "cmp-minus-zero-and-branch") + DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch) +}; + + class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> { public: LIsObjectAndBranch(LOperand* value, LOperand* temp) { -- 2.7.4