Bug 1396342 - Wasm baseline, fix division-by-64-bit constant bug. r=luke
authorLars T Hansen <lhansen@mozilla.com>
Mon, 04 Sep 2017 12:50:35 +0200
changeset 378875 60fd99ec9e7122492a243b8bce904db586a930ed
parent 378874 c309a6360b2f662758ce201d6aa034daf654cee9
child 378876 8822dc7f2d3ccc881625676aee1a907365494af4
push id32443
push userarchaeopteryx@coole-files.de
push dateTue, 05 Sep 2017 09:41:20 +0000
treeherdermozilla-central@3ecda4678c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1396342
milestone57.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 1396342 - Wasm baseline, fix division-by-64-bit constant bug. r=luke
js/src/jit-test/tests/wasm/integer.js
js/src/wasm/WasmBaselineCompile.cpp
--- a/js/src/jit-test/tests/wasm/integer.js
+++ b/js/src/jit-test/tests/wasm/integer.js
@@ -179,16 +179,17 @@ assertEq(testTrunc(13.37), 1);
     testBinary64('mul', "0x7fffffff", 2, "0xfffffffe");
     testBinary64('div_s', -40, 2, -20);
     testBinary64('div_s', -40, 8, -5);
     testBinary64('div_s', -40, 7, -5);
     testBinary64('div_s', 40, 8, 5);
     testBinary64('div_s', 40, 7, 5);
     testBinary64('div_s', "0x1234567887654321", 2, "0x91a2b3c43b2a190");
     testBinary64('div_s', "0x1234567887654321", "0x1000000000", "0x1234567");
+    testBinary64('div_s', -1, "0x100000000", 0);
     testBinary64('div_u', -40, 2, "0x7fffffffffffffec");
     testBinary64('div_u', "0x1234567887654321", 9, "0x205d0b80f0b4059");
     testBinary64('div_u', 40, 2, 20);
     testBinary64('div_u', 40, 8, 5);
     testBinary64('rem_s', 40, -3, 1);
     testBinary64('rem_s', 0, -3, 0);
     testBinary64('rem_s', 5, 2, 1);
     testBinary64('rem_s', 65, 64, 1);
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -4254,17 +4254,17 @@ BaseCompiler::emitQuotientI64()
     int64_t c;
     uint_fast8_t power;
     if (popConstPositivePowerOfTwoI64(&c, &power, 0)) {
         if (power != 0) {
             RegI64 r = popI64();
             Label positive;
             masm.branchTest64(Assembler::NotSigned, r, r, Register::Invalid(),
                               &positive);
-            masm.add64(Imm32(c-1), r);
+            masm.add64(Imm64(c-1), r);
             masm.bind(&positive);
 
             masm.rshift64Arithmetic(Imm32(power & 63), r);
             pushI64(r);
         }
     } else {
         bool isConst = peekConstI64(&c);
         RegI64 r0, r1;