Bug 1010334 - Add recover functionality for Rsh; r=bbouvier
authorInanc Seylan <inanc.seylan@gmail.com>
Tue, 27 May 2014 11:39:50 +0200
changeset 185011 98fb71452e0c3ee41629708849f34e6fc56d9b92
parent 185010 2e98c6fdfa01880647b8eb6cdf998c274bbb339f
child 185012 9d5e37a42e3fd6cb240731d7035f60871fa05134
push id43996
push userbenj@benj.me
push dateTue, 27 May 2014 09:40:22 +0000
treeherdermozilla-inbound@98fb71452e0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1010334
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1010334 - Add recover functionality for Rsh; r=bbouvier
js/src/jit-test/tests/ion/dce-with-rinstructions.js
js/src/jit/MIR.h
js/src/jit/Recover.cpp
js/src/jit/Recover.h
--- a/js/src/jit-test/tests/ion/dce-with-rinstructions.js
+++ b/js/src/jit-test/tests/ion/dce-with-rinstructions.js
@@ -83,16 +83,35 @@ function rlsh_object(i) {
     var o = { valueOf: function() { return t; } };
     var x = o << 1;
     t = 1000;
     if (uceFault_lsh_object(i) || uceFault_lsh_object(i))
         assertEq(x, 198);
     return i;
 }
 
+var uceFault_rsh_number = eval(uneval(uceFault).replace('uceFault', 'uceFault_rsh_number'));
+function rrsh_number(i) {
+    var x = i >> 1;
+    if (uceFault_rsh_number(i) || uceFault_rsh_number(i))
+        assertEq(x, 49  /* = 99 >> 1 */);
+    return i;
+}
+
+var uceFault_rsh_object = eval(uneval(uceFault).replace('uceFault', 'uceFault_rsh_object'));
+function rrsh_object(i) {
+    var t = i;
+    var o = { valueOf: function () { return t; } };
+    var x = o >> 1; /* computed with t == i, not 1000 */
+    t = 1000;
+    if (uceFault_rsh_object(i) || uceFault_rsh_object(i))
+        assertEq(x, 49  /* = 99 >> 1 */);
+    return i;
+}
+
 var uceFault_ursh_number = eval(uneval(uceFault).replace('uceFault', 'uceFault_ursh_number'));
 function rursh_number(i) {
     var x = i >>> 1;
     if (uceFault_ursh_number(i) || uceFault_ursh_number(i))
         assertEq(x, 49  /* = 99 >>> 1 */);
     return i;
 }
 
@@ -148,16 +167,18 @@ for (i = 0; i < 100; i++) {
     rbitnot_number(i);
     rbitnot_object(i);
     rbitor_number(i);
     rbitor_object(i);
     rbitxor_number(i);
     rbitxor_object(i);
     rlsh_number(i);
     rlsh_object(i);
+    rrsh_number(i);
+    rrsh_object(i);
     rursh_number(i);
     rursh_object(i);
     radd_number(i);
     radd_float(i);
     radd_string(i);
     radd_object(i);
 }
 
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -3680,16 +3680,21 @@ class MRsh : public MShiftInstruction
     static MRsh *NewAsmJS(TempAllocator &alloc, MDefinition *left, MDefinition *right);
 
     MDefinition *foldIfZero(size_t operand) {
         // 0 >> x => 0
         // x >> 0 => x
         return getOperand(0);
     }
     void computeRange(TempAllocator &alloc);
+
+    bool writeRecoverData(CompactBufferWriter &writer) const;
+    bool canRecoverOnBailout() const {
+        return specialization_ < MIRType_Object;
+    }
 };
 
 class MUrsh : public MShiftInstruction
 {
     bool bailoutsDisabled_;
 
     MUrsh(MDefinition *left, MDefinition *right)
       : MShiftInstruction(left, right),
--- a/js/src/jit/Recover.cpp
+++ b/js/src/jit/Recover.cpp
@@ -239,16 +239,43 @@ RLsh::recover(JSContext *cx, SnapshotIte
         return false;
 
     RootedValue asValue(cx, js::Int32Value(result));
     iter.storeInstructionResult(asValue);
     return true;
 }
 
 bool
+MRsh::writeRecoverData(CompactBufferWriter &writer) const
+{
+    MOZ_ASSERT(canRecoverOnBailout());
+    writer.writeUnsigned(uint32_t(RInstruction::Recover_Rsh));
+    return true;
+}
+
+RRsh::RRsh(CompactBufferReader &reader)
+{ }
+
+bool
+RRsh::recover(JSContext *cx, SnapshotIterator &iter) const
+{
+    RootedValue lhs(cx, iter.read());
+    RootedValue rhs(cx, iter.read());
+    MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
+
+    int32_t result;
+    if (!js::BitRsh(cx, lhs, rhs, &result))
+        return false;
+
+    RootedValue rootedResult(cx, js::Int32Value(result));
+    iter.storeInstructionResult(rootedResult);
+    return true;
+}
+
+bool
 MUrsh::writeRecoverData(CompactBufferWriter &writer) const
 {
     MOZ_ASSERT(canRecoverOnBailout());
     writer.writeUnsigned(uint32_t(RInstruction::Recover_Ursh));
     return true;
 }
 
 RUrsh::RUrsh(CompactBufferReader &reader)
--- a/js/src/jit/Recover.h
+++ b/js/src/jit/Recover.h
@@ -17,16 +17,17 @@ namespace js {
 namespace jit {
 
 #define RECOVER_OPCODE_LIST(_)                  \
     _(ResumePoint)                              \
     _(BitNot)                                   \
     _(BitOr)                                    \
     _(BitXor)                                   \
     _(Lsh)                                      \
+    _(Rsh)                                      \
     _(Ursh)                                     \
     _(Add)                                      \
     _(NewObject)                                \
     _(NewDerivedTypedObject)
 
 class RResumePoint;
 class SnapshotIterator;
 
@@ -136,16 +137,28 @@ class RLsh MOZ_FINAL : public RInstructi
 
     virtual uint32_t numOperands() const {
         return 2;
     }
 
     bool recover(JSContext *cx, SnapshotIterator &iter) const;
 };
 
+class RRsh MOZ_FINAL : public RInstruction
+{
+  public:
+    RINSTRUCTION_HEADER_(Rsh)
+
+    virtual uint32_t numOperands() const {
+        return 2;
+    }
+
+    bool recover(JSContext *cx, SnapshotIterator &iter) const;
+};
+
 class RUrsh MOZ_FINAL : public RInstruction
 {
   public:
     RINSTRUCTION_HEADER_(Ursh)
 
     virtual uint32_t numOperands() const {
         return 2;
     }