From ad4273ba8f74b62c5019378a2c25b11214b9980b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 18 Apr 2014 11:13:44 -0700 Subject: [PATCH] Bug 998167 - IonMonkey: Fix signed integer undefined behavior r=nbp --- js/src/jit/MIR.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index a441feb3933a..f98db880657d 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -95,16 +95,14 @@ EvaluateConstantOperands(TempAllocator &alloc, MBinaryInstruction *ins, bool *pt ret = Int32Value(lhs.toInt32() ^ rhs.toInt32()); break; case MDefinition::Op_Lsh: - ret = Int32Value(lhs.toInt32() << (rhs.toInt32() & 0x1F)); + ret = Int32Value(uint32_t(lhs.toInt32()) << (rhs.toInt32() & 0x1F)); break; case MDefinition::Op_Rsh: ret = Int32Value(lhs.toInt32() >> (rhs.toInt32() & 0x1F)); break; - case MDefinition::Op_Ursh: { - uint32_t unsignedLhs = (uint32_t)lhs.toInt32(); - ret.setNumber(uint32_t(unsignedLhs >> (rhs.toInt32() & 0x1F))); + case MDefinition::Op_Ursh: + ret.setNumber(uint32_t(lhs.toInt32()) >> (rhs.toInt32() & 0x1F)); break; - } case MDefinition::Op_Add: ret.setNumber(lhs.toNumber() + rhs.toNumber()); break;