Bug 1301400: Baseline Wasm Compiler: Part 9: Implement MultiplyI64, r=lth
authorh4writer <hv1989@gmail.com>
Thu, 29 Sep 2016 22:33:22 +0200
changeset 315909 c05925c3a813714fd3812b2e86669af453d10fdb
parent 315908 72b020fd3ce14ea2a8e5c5548899a281c3f07f2e
child 315910 64597bec5f4ee761798acbbe3f9690831ec7f5c7
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1301400
milestone52.0a1
Bug 1301400: Baseline Wasm Compiler: Part 9: Implement MultiplyI64, r=lth
js/src/asmjs/WasmBaselineCompile.cpp
--- a/js/src/asmjs/WasmBaselineCompile.cpp
+++ b/js/src/asmjs/WasmBaselineCompile.cpp
@@ -2367,24 +2367,22 @@ class BaseCompiler
         popStackBeforeBranch(ctl_[0].framePushed);
         masm.jump(&returnLabel_);
     }
 
     void subtractI64(RegI64 rhs, RegI64 srcDest) {
         masm.sub64(rhs.reg, srcDest.reg);
     }
 
-    void multiplyI64(RegI64 rhs, RegI64 srcDest) {
+    void multiplyI64(RegI64 rhs, RegI64 srcDest, RegI32 temp) {
 #if defined(JS_CODEGEN_X64)
         MOZ_ASSERT(srcDest.reg.reg == rax);
         MOZ_ASSERT(isAvailable(rdx));
-        masm.imulq(rhs.reg.reg, srcDest.reg.reg);
-#else
-        MOZ_CRASH("BaseCompiler platform hook: multiplyI64");
 #endif
+        masm.mul64(rhs.reg, srcDest.reg, temp.reg);
     }
 
     void checkDivideByZeroI32(RegI32 rhs, RegI32 srcDest, Label* done) {
         if (isCompilingAsmJS()) {
             // Truncated division by zero is zero (Infinity|0 == 0)
             Label notDivByZero;
             masm.branchTest32(Assembler::NonZero, rhs.reg, rhs.reg, &notDivByZero);
             masm.move32(Imm32(0), srcDest.reg);
@@ -3464,28 +3462,34 @@ BaseCompiler::emitMultiplyI32()
     pushI32(r0);
 }
 
 void
 BaseCompiler::emitMultiplyI64()
 {
     // TODO / OPTIMIZE: Multiplication by constant is common (bug 1275442)
     RegI64 r0, r1;
+    RegI32 temp;
 #if defined(JS_CODEGEN_X64)
     // srcDest must be rax, and rdx will be clobbered.
     need2xI64(specific_rax, specific_rdx);
     r1 = popI64();
     r0 = popI64ToSpecific(specific_rax);
     freeI64(specific_rdx);
 #elif defined(JS_CODEGEN_X86)
-    MOZ_CRASH("BaseCompiler platform hook: emitMultiplyI64");
+    need2xI32(specific_eax, specific_edx);
+    r1 = popI64();
+    r0 = popI64ToSpecific(RegI64(Register64(specific_edx.reg, specific_eax.reg)));
+    temp = needI32();
 #else
     pop2xI64(&r0, &r1);
 #endif
-    multiplyI64(r1, r0);
+    multiplyI64(r1, r0, temp);
+    if (temp.reg != Register::Invalid())
+        freeI32(temp);
     freeI64(r1);
     pushI64(r0);
 }
 
 void
 BaseCompiler::emitMultiplyF32()
 {
     RegF32 r0, r1;