Bug 1465770 - mips32: convertDoubleToInt32 cp1_fcsr error. r=dragan.mladjenovic
authorqiaopengcheng <qiaopengcheng-hf@loongson.cn>
Fri, 01 Jun 2018 02:58:00 -0400
changeset 469121 af6951f3fd418e6f363eaca1fb286658c627e57f
parent 469120 ca30bde6447ee796c14d0777a1a1fcd64fab690f
child 469122 f585271d250d8750240e8ab4ec8e462e56eac21e
push id187
push userfmarier@mozilla.com
push dateMon, 04 Jun 2018 22:28:11 +0000
reviewersdragan
bugs1465770
milestone62.0a1
Bug 1465770 - mips32: convertDoubleToInt32 cp1_fcsr error. r=dragan.mladjenovic
js/src/jit/mips32/MacroAssembler-mips32.cpp
--- a/js/src/jit/mips32/MacroAssembler-mips32.cpp
+++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp
@@ -127,21 +127,26 @@ MacroAssemblerMIPSCompat::convertDoubleT
     if (negativeZeroCheck) {
         moveFromDoubleHi(src, dest);
         moveFromDoubleLo(src, SecondScratchReg);
         ma_xor(dest, Imm32(INT32_MIN));
         ma_or(dest, SecondScratchReg);
         ma_b(dest, Imm32(0), fail, Assembler::Equal);
     }
 
-    // Truncate double to int ; if result is inexact fail
+    // Truncate double to int ; if result is inexact or invalid fail.
     as_truncwd(ScratchFloat32Reg, src);
     as_cfc1(ScratchRegister, Assembler::FCSR);
     moveFromFloat32(ScratchFloat32Reg, dest);
-    ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseI, 1);
+    ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseI, 6);
+    // Here adding the masking andi instruction just for a precaution.
+    // For the instruction of trunc.*.*, the Floating Point Exceptions can be
+    // only Inexact, Invalid Operation, Unimplemented Operation.
+    // Leaving it maybe is also ok.
+    as_andi(ScratchRegister, ScratchRegister, 0x11);
     ma_b(ScratchRegister, Imm32(0), fail, Assembler::NotEqual);
 }
 
 // Checks whether a float32 is representable as a 32-bit integer. If so, the
 // integer is written to the output register. Otherwise, a bailout is taken to
 // the given snapshot. This function overwrites the scratch float register.
 void
 MacroAssemblerMIPSCompat::convertFloat32ToInt32(FloatRegister src, Register dest,