diff --git a/js/src/jit-test/tests/wasm/integer.js b/js/src/jit-test/tests/wasm/integer.js index 650d8c28b498..d02e6bbd7063 100644 --- a/js/src/jit-test/tests/wasm/integer.js +++ b/js/src/jit-test/tests/wasm/integer.js @@ -207,8 +207,6 @@ assertEq(testTrunc(13.37), 1); testBinary64('rotl', "0x1234567812345678", 4, "0x2345678123456781"); testBinary64('rotl', "0x1234567812345678", 60, "0x8123456781234567"); testBinary64('rotr', "0x1234567812345678", 60, "0x2345678123456781"); - testBinary64('rotl', "0x0000000000001000", 127, "0x0000000000000800"); - testBinary64('rotr', "0x0000000000001000", 127, "0x0000000000002000"); testBinary64('rotr', 40, 0, 40); testBinary64('rotl', 40, 0, 40); testBinary64('and', 42, 0, 0); diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index bf03870f9732..ad033cc9a639 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -766,7 +766,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void add64(Register64 src, Register64 dest) PER_ARCH; inline void add64(Imm32 imm, Register64 dest) PER_ARCH; - inline void add64(Imm64 imm, Register64 dest) PER_ARCH; + inline void add64(Imm64 imm, Register64 dest) DEFINED_ON(x86, x64, arm, mips32, mips64); inline void add64(const Operand& src, Register64 dest) DEFINED_ON(x64, mips64); inline void addFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; @@ -785,7 +785,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void subPtr(const Address& addr, Register dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64); inline void sub64(Register64 src, Register64 dest) PER_ARCH; - inline void sub64(Imm64 imm, Register64 dest) PER_ARCH; + inline void sub64(Imm64 imm, Register64 dest) DEFINED_ON(x86, x64, arm, mips32, mips64); inline void sub64(const Operand& src, Register64 dest) DEFINED_ON(x64, mips64); inline void subFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; @@ -900,7 +900,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void rotateLeft64(Imm32 count, Register64 input, Register64 dest) DEFINED_ON(x64); inline void rotateLeft64(Register count, Register64 input, Register64 dest) DEFINED_ON(x64); inline void rotateLeft64(Imm32 count, Register64 input, Register64 dest, Register temp) - PER_ARCH; + DEFINED_ON(x86, x64, arm, mips32, mips64); inline void rotateLeft64(Register count, Register64 input, Register64 dest, Register temp) PER_ARCH; @@ -909,7 +909,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void rotateRight64(Imm32 count, Register64 input, Register64 dest) DEFINED_ON(x64); inline void rotateRight64(Register count, Register64 input, Register64 dest) DEFINED_ON(x64); inline void rotateRight64(Imm32 count, Register64 input, Register64 dest, Register temp) - PER_ARCH; + DEFINED_ON(x86, x64, arm, mips32, mips64); inline void rotateRight64(Register count, Register64 input, Register64 dest, Register temp) PER_ARCH; diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index e08393fcc41a..ebbd75c24637 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -306,12 +306,6 @@ MacroAssembler::add64(Imm32 imm, Register64 dest) Add(ARMRegister(dest.reg, 64), ARMRegister(dest.reg, 64), Operand(imm.value)); } -void -MacroAssembler::add64(Imm64 imm, Register64 dest) -{ - Add(ARMRegister(dest.reg, 64), ARMRegister(dest.reg, 64), Operand(imm.value)); -} - void MacroAssembler::addDouble(FloatRegister src, FloatRegister dest) { @@ -387,12 +381,6 @@ MacroAssembler::sub64(Register64 src, Register64 dest) MOZ_CRASH("NYI: sub64"); } -void -MacroAssembler::sub64(Imm64 imm, Register64 dest) -{ - MOZ_CRASH("NYI: sub64"); -} - void MacroAssembler::subDouble(FloatRegister src, FloatRegister dest) { @@ -737,24 +725,12 @@ MacroAssembler::rotateLeft64(Register count, Register64 input, Register64 dest, MOZ_CRASH("NYI: rotateLeft64"); } -void -MacroAssembler::rotateLeft64(Imm32 count, Register64 input, Register64 dest, Register temp) -{ - MOZ_CRASH("NYI: rotateLeft64"); -} - void MacroAssembler::rotateRight64(Register count, Register64 input, Register64 dest, Register temp) { MOZ_CRASH("NYI: rotateRight64"); } -void -MacroAssembler::rotateRight64(Imm32 count, Register64 input, Register64 dest, Register temp) -{ - MOZ_CRASH("NYI: rotateRight64"); -} - // =============================================================== // Bit counting functions diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp index a5776bcd5299..4ac4e9e04fd3 100644 --- a/js/src/wasm/WasmBaselineCompile.cpp +++ b/js/src/wasm/WasmBaselineCompile.cpp @@ -1692,15 +1692,6 @@ class BaseCompiler return true; } - MOZ_MUST_USE bool popConstI64(int64_t& c) { - Stk& v = stk_.back(); - if (v.kind() != Stk::ConstI64) - return false; - c = v.i64val(); - stk_.popBack(); - return true; - } - // TODO / OPTIMIZE (Bug 1316818): At the moment we use ReturnReg // for JoinReg. It is possible other choices would lead to better // register allocation, as ReturnReg is often first in the @@ -3983,23 +3974,18 @@ BaseCompiler::emitAddI32() void BaseCompiler::emitAddI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.add64(Imm64(c), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64(&r0, &r1); - masm.add64(r1, r0); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Ditto check for constant here (Bug 1316803) + RegI64 r0, r1; + pop2xI64(&r0, &r1); + masm.add64(r1, r0); + freeI64(r1); + pushI64(r0); } void BaseCompiler::emitAddF64() { + // TODO / OPTIMIZE: Ditto check for constant here (Bug 1316803) RegF64 r0, r1; pop2xF64(&r0, &r1); masm.addDouble(r1, r0); @@ -4010,6 +3996,7 @@ BaseCompiler::emitAddF64() void BaseCompiler::emitAddF32() { + // TODO / OPTIMIZE: Ditto check for constant here (Bug 1316803) RegF32 r0, r1; pop2xF32(&r0, &r1); masm.addFloat32(r1, r0); @@ -4020,35 +4007,21 @@ BaseCompiler::emitAddF32() void BaseCompiler::emitSubtractI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.sub32(Imm32(c), r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32(&r0, &r1); - masm.sub32(r1, r0); - freeI32(r1); - pushI32(r0); - } + RegI32 r0, r1; + pop2xI32(&r0, &r1); + masm.sub32(r1, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitSubtractI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.sub64(Imm64(c), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64(&r0, &r1); - masm.sub64(r1, r0); - freeI64(r1); - pushI64(r0); - } + RegI64 r0, r1; + pop2xI64(&r0, &r1); + masm.sub64(r1, r0); + freeI64(r1); + pushI64(r0); } void @@ -4418,103 +4391,61 @@ BaseCompiler::emitCopysignF64() void BaseCompiler::emitOrI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.or32(Imm32(c), r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32(&r0, &r1); - masm.or32(r1, r0); - freeI32(r1); - pushI32(r0); - } + RegI32 r0, r1; + pop2xI32(&r0, &r1); + masm.or32(r1, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitOrI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.or64(Imm64(c), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64(&r0, &r1); - masm.or64(r1, r0); - freeI64(r1); - pushI64(r0); - } + RegI64 r0, r1; + pop2xI64(&r0, &r1); + masm.or64(r1, r0); + freeI64(r1); + pushI64(r0); } void BaseCompiler::emitAndI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.and32(Imm32(c), r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32(&r0, &r1); - masm.and32(r1, r0); - freeI32(r1); - pushI32(r0); - } + RegI32 r0, r1; + pop2xI32(&r0, &r1); + masm.and32(r1, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitAndI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.and64(Imm64(c), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64(&r0, &r1); - masm.and64(r1, r0); - freeI64(r1); - pushI64(r0); - } + RegI64 r0, r1; + pop2xI64(&r0, &r1); + masm.and64(r1, r0); + freeI64(r1); + pushI64(r0); } void BaseCompiler::emitXorI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.xor32(Imm32(c), r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32(&r0, &r1); - masm.xor32(r1, r0); - freeI32(r1); - pushI32(r0); - } + RegI32 r0, r1; + pop2xI32(&r0, &r1); + masm.xor32(r1, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitXorI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.xor64(Imm64(c), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64(&r0, &r1); - masm.xor64(r1, r0); - freeI64(r1); - pushI64(r0); - } + RegI64 r0, r1; + pop2xI64(&r0, &r1); + masm.xor64(r1, r0); + freeI64(r1); + pushI64(r0); } void @@ -4538,18 +4469,12 @@ BaseCompiler::emitShlI32() void BaseCompiler::emitShlI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.lshift64(Imm32(c & 63), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64ForShiftOrRotate(&r0, &r1); - masm.lshift64(lowPart(r1), r0); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI64 r0, r1; + pop2xI64ForShiftOrRotate(&r0, &r1); + masm.lshift64(lowPart(r1), r0); + freeI64(r1); + pushI64(r0); } void @@ -4573,18 +4498,12 @@ BaseCompiler::emitShrI32() void BaseCompiler::emitShrI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.rshift64Arithmetic(Imm32(c & 63), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64ForShiftOrRotate(&r0, &r1); - masm.rshift64Arithmetic(lowPart(r1), r0); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI64 r0, r1; + pop2xI64ForShiftOrRotate(&r0, &r1); + masm.rshift64Arithmetic(lowPart(r1), r0); + freeI64(r1); + pushI64(r0); } void @@ -4608,86 +4527,56 @@ BaseCompiler::emitShrU32() void BaseCompiler::emitShrU64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.rshift64(Imm32(c & 63), r); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64ForShiftOrRotate(&r0, &r1); - masm.rshift64(lowPart(r1), r0); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI64 r0, r1; + pop2xI64ForShiftOrRotate(&r0, &r1); + masm.rshift64(lowPart(r1), r0); + freeI64(r1); + pushI64(r0); } void BaseCompiler::emitRotrI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.rotateRight(Imm32(c & 31), r, r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32ForShiftOrRotate(&r0, &r1); - masm.rotateRight(r1, r0, r0); - freeI32(r1); - pushI32(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI32 r0, r1; + pop2xI32ForShiftOrRotate(&r0, &r1); + masm.rotateRight(r1, r0, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitRotrI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.rotateRight64(Imm32(c & 63), r, r, InvalidReg); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64ForShiftOrRotate(&r0, &r1); - masm.rotateRight64(lowPart(r1), r0, r0, maybeHighPart(r1)); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI64 r0, r1; + pop2xI64ForShiftOrRotate(&r0, &r1); + masm.rotateRight64(lowPart(r1), r0, r0, maybeHighPart(r1)); + freeI64(r1); + pushI64(r0); } void BaseCompiler::emitRotlI32() { - int32_t c; - if (popConstI32(c)) { - RegI32 r = popI32(); - masm.rotateLeft(Imm32(c & 31), r, r); - pushI32(r); - } else { - RegI32 r0, r1; - pop2xI32ForShiftOrRotate(&r0, &r1); - masm.rotateLeft(r1, r0, r0); - freeI32(r1); - pushI32(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI32 r0, r1; + pop2xI32ForShiftOrRotate(&r0, &r1); + masm.rotateLeft(r1, r0, r0); + freeI32(r1); + pushI32(r0); } void BaseCompiler::emitRotlI64() { - int64_t c; - if (popConstI64(c)) { - RegI64 r = popI64(); - masm.rotateLeft64(Imm32(c & 63), r, r, InvalidReg); - pushI64(r); - } else { - RegI64 r0, r1; - pop2xI64ForShiftOrRotate(&r0, &r1); - masm.rotateLeft64(lowPart(r1), r0, r0, maybeHighPart(r1)); - freeI64(r1); - pushI64(r0); - } + // TODO / OPTIMIZE: Constant rhs (Bug 1316803) + RegI64 r0, r1; + pop2xI64ForShiftOrRotate(&r0, &r1); + masm.rotateLeft64(lowPart(r1), r0, r0, maybeHighPart(r1)); + freeI64(r1); + pushI64(r0); } void