Fix inline assembly version of ushr
authorLars Knoll <lars.knoll@digia.com>
Sat, 16 Feb 2013 19:44:53 +0000 (20:44 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 25 Feb 2013 07:01:49 +0000 (08:01 +0100)
-1 >> 0 should return UINT_MAX, as the result is an
unsigned int according to spec. The only way the result
of the inline shr operation can be signed is by shifting
0 bytes. But the easiest implementation is to test the
result for signed-ness and then fall back to the slow
implementation.

Change-Id: Ic4614006d06cf01376ef95b6f23ca2c7216a2812
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qv4isel_masm_p.h

index c68ee91..91c908f 100644 (file)
@@ -648,14 +648,24 @@ public:
         load32(addr, ScratchRegister);
         and32(TrustedImm32(0x1f), ScratchRegister);
         urshift32(ScratchRegister, reg);
-        return Jump();
+#if CPU(X86) || CPU(X86_64)
+        m_assembler.testl_rr(reg, reg);
+        return Jump(m_assembler.jCC(x86Condition(Signed)));
+#else
+#error "Implement me: Branch if result is negative"
+#endif
     }
 
     Jump inline_ushr32(TrustedImm32 imm, RegisterID reg)
     {
         imm.m_value &= 0x1f;
         urshift32(imm, reg);
-        return Jump();
+#if CPU(X86) || CPU(X86_64)
+        m_assembler.testl_rr(reg, reg);
+        return Jump(m_assembler.jCC(x86Condition(Signed)));
+#else
+#error "Implement me: Branch if result is negative"
+#endif
     }
 
     Jump inline_and32(Address addr, RegisterID reg)