Bug 1252313 - Fix wasm i64 shift ops with a constant rhs. r=bbouvier
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 01 Mar 2016 14:17:26 +0100
changeset 324510 df6847768408ed5a157913f2db8b23c495549540
parent 324509 e3a41a0486eebca77e59e90d1585ffe9c53e4851
child 324511 02e9d9afda63b8da07cf28a3d55a8e680968ec9a
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1252313
milestone47.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 1252313 - Fix wasm i64 shift ops with a constant rhs. r=bbouvier
js/src/jit-test/tests/wasm/basic-integer.js
js/src/jit/MIR.cpp
js/src/jit/x64/CodeGenerator-x64.cpp
--- a/js/src/jit-test/tests/wasm/basic-integer.js
+++ b/js/src/jit-test/tests/wasm/basic-integer.js
@@ -10,16 +10,26 @@ function testUnary(type, opcode, op, exp
 
 function testBinary(type, opcode, lhs, rhs, expect) {
   if (type === 'i64') {
     // i64 cannot be imported/exported, so we use a wrapper function.
     assertEq(wasmEvalText(`(module
                             (func (param i64) (param i64) (result i64) (i64.${opcode} (get_local 0) (get_local 1)))
                             (func (result i32) (i64.eq (call 0 (i64.const ${lhs}) (i64.const ${rhs})) (i64.const ${expect})))
                             (export "" 1))`)(), 1);
+    // The same, but now the RHS is a constant.
+    assertEq(wasmEvalText(`(module
+                            (func (param i64) (result i64) (i64.${opcode} (get_local 0) (i64.const ${rhs})))
+                            (func (result i32) (i64.eq (call 0 (i64.const ${lhs})) (i64.const ${expect})))
+                            (export "" 1))`)(), 1);
+    // LHS and RHS are constants.
+    assertEq(wasmEvalText(`(module
+                            (func (result i64) (i64.${opcode} (i64.const ${lhs}) (i64.const ${rhs})))
+                            (func (result i32) (i64.eq (call 0) (i64.const ${expect})))
+                            (export "" 1))`)(), 1);
   } else {
     assertEq(wasmEvalText('(module (func (param ' + type + ') (param ' + type + ') (result ' + type + ') (' + type + '.' + opcode + ' (get_local 0) (get_local 1))) (export "" 0))')(lhs, rhs), expect);
   }
 }
 
 function testComparison(type, opcode, lhs, rhs, expect) {
   if (type === 'i64') {
     // i64 cannot be imported/exported, so we use a wrapper function.
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -894,16 +894,19 @@ MConstant::printOpcode(GenericPrinter& o
         out.printf("null");
         break;
       case MIRType_Boolean:
         out.printf(toBoolean() ? "true" : "false");
         break;
       case MIRType_Int32:
         out.printf("0x%x", toInt32());
         break;
+      case MIRType_Int64:
+        out.printf("0x%" PRIx64, toInt64());
+        break;
       case MIRType_Double:
         out.printf("%.16g", toDouble());
         break;
       case MIRType_Float32:
       {
         float val = toFloat32();
         out.printf("%.16g", val);
         break;
--- a/js/src/jit/x64/CodeGenerator-x64.cpp
+++ b/js/src/jit/x64/CodeGenerator-x64.cpp
@@ -281,17 +281,17 @@ CodeGeneratorX64::visitBitOpI64(LBitOpI6
 
 void
 CodeGeneratorX64::visitShiftI64(LShiftI64* lir)
 {
     Register lhs = ToRegister(lir->getOperand(0));
     const LAllocation* rhs = lir->getOperand(1);
 
     if (rhs->isConstant()) {
-        int32_t shift = ToInt32(rhs) & 0x3F;
+        int32_t shift = int32_t(ToInt64(rhs) & 0x3F);
         switch (lir->bitop()) {
           case JSOP_LSH:
             if (shift)
                 masm.shlq(Imm32(shift), lhs);
             break;
           case JSOP_RSH:
             if (shift)
                 masm.sarq(Imm32(shift), lhs);