Bug 1301400: Baseline Wasm Compiler: Part 16: Implement ExtendI64 and WrapI64, r=lth
authorHannes Verschore <hv1989@gmail.com>
Thu, 29 Sep 2016 22:33:23 +0200
changeset 315916 ef547be7cb2f35d01bfffd9eaeeeacc1cdb98c17
parent 315915 1acadee786e9c7fb213339159546826d419a350f
child 315917 78cc9391941160535c0fe339d6563a75ad9007a7
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 16: Implement ExtendI64 and WrapI64, r=lth
js/src/asmjs/WasmBaselineCompile.cpp
--- a/js/src/asmjs/WasmBaselineCompile.cpp
+++ b/js/src/asmjs/WasmBaselineCompile.cpp
@@ -2612,32 +2612,42 @@ class BaseCompiler
         MOZ_CRASH("BaseCompiler platform hook: reinterpretF64AsI64");
 #endif
     }
 
     void wrapI64ToI32(RegI64 src, RegI32 dest) {
 #if defined(JS_CODEGEN_X64)
         // movl clears the high bits if the two registers are the same.
         masm.movl(src.reg.reg, dest.reg);
+#elif defined(JS_NUNBOX32)
+        masm.move32(src.reg.low, dest.reg);
 #else
         MOZ_CRASH("BaseCompiler platform hook: wrapI64ToI32");
 #endif
     }
 
     void extendI32ToI64(RegI32 src, RegI64 dest) {
 #if defined(JS_CODEGEN_X64)
         masm.movslq(src.reg, dest.reg.reg);
+#elif defined(JS_CODEGEN_X86)
+        MOZ_ASSERT(dest.reg.low == src.reg);
+        MOZ_ASSERT(dest.reg.low == eax);
+        MOZ_ASSERT(dest.reg.high == edx);
+        masm.cdq();
 #else
         MOZ_CRASH("BaseCompiler platform hook: extendI32ToI64");
 #endif
     }
 
     void extendU32ToI64(RegI32 src, RegI64 dest) {
 #if defined(JS_CODEGEN_X64)
         masm.movl(src.reg, dest.reg.reg);
+#elif defined(JS_NUNBOX32)
+        masm.move32(src.reg, dest.reg.low);
+        masm.move32(Imm32(0), dest.reg.high);
 #else
         MOZ_CRASH("BaseCompiler platform hook: extendU32ToI64");
 #endif
     }
 
     class OutOfLineTruncateF32OrF64ToI32 : public OutOfLineCode
     {
         AnyReg src;
@@ -4367,35 +4377,44 @@ BaseCompiler::emitTruncateF64ToI64()
 }
 
 void
 BaseCompiler::emitWrapI64ToI32()
 {
     RegI64 r0 = popI64();
     RegI32 i0 = fromI64(r0);
     wrapI64ToI32(r0, i0);
+    freeI64Except(r0, i0);
     pushI32(i0);
 }
 
 void
 BaseCompiler::emitExtendI32ToI64()
 {
+#if defined(JS_CODEGEN_X86)
+    need2xI32(specific_edx, specific_eax);
+    RegI32 r0 = popI32ToSpecific(specific_eax);
+    RegI64 x0 = RegI64(Register64(specific_edx.reg, specific_eax.reg));
+#else
     RegI32 r0 = popI32();
     RegI64 x0 = fromI32(r0);
+#endif
     extendI32ToI64(r0, x0);
     pushI64(x0);
+    // Note: no need to free r0, since it is part of x0
 }
 
 void
 BaseCompiler::emitExtendU32ToI64()
 {
     RegI32 r0 = popI32();
     RegI64 x0 = fromI32(r0);
     extendU32ToI64(r0, x0);
     pushI64(x0);
+    // Note: no need to free r0, since it is part of x0
 }
 
 void
 BaseCompiler::emitReinterpretF32AsI32()
 {
     RegF32 r0 = popF32();
     RegI32 i0 = needI32();
     masm.moveFloat32ToGPR(r0.reg, i0.reg);