Bug 1594204 - Split out 'emitMemCopy' function for dedicated optimizations. r=lth
☠☠ backed out by f6aa348ba29a ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Thu, 14 Nov 2019 18:56:41 +0000
changeset 502041 6295568b6ea47d638c4346effd4731d37366547b
parent 502040 80763bd78330a116ee0e201bed08eecbeceabe4b
child 502042 74cc3a413cb0f2da50eb95dff6b6656ce4edabfc
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1594204
milestone72.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 1594204 - Split out 'emitMemCopy' function for dedicated optimizations. r=lth Differential Revision: https://phabricator.services.mozilla.com/D50380
js/src/wasm/WasmBaselineCompile.cpp
js/src/wasm/WasmIonCompile.cpp
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -7262,17 +7262,18 @@ class BaseCompiler final : public BaseCo
                                   AtomicOp op);
   MOZ_MUST_USE bool emitAtomicStore(ValType type, Scalar::Type viewType);
   MOZ_MUST_USE bool emitWait(ValType type, uint32_t byteSize);
   MOZ_MUST_USE bool emitWake();
   MOZ_MUST_USE bool emitFence();
   MOZ_MUST_USE bool emitAtomicXchg(ValType type, Scalar::Type viewType);
   void emitAtomicXchg64(MemoryAccessDesc* access, WantResult wantResult);
   MOZ_MUST_USE bool bulkmemOpsEnabled();
-  MOZ_MUST_USE bool emitMemOrTableCopy(bool isMem);
+  MOZ_MUST_USE bool emitMemCopy();
+  MOZ_MUST_USE bool emitTableCopy();
   MOZ_MUST_USE bool emitDataOrElemDrop(bool isData);
   MOZ_MUST_USE bool emitMemFill();
   MOZ_MUST_USE bool emitMemOrTableInit(bool isMem);
 #ifdef ENABLE_WASM_REFTYPES
   MOZ_MUST_USE bool emitTableFill();
   MOZ_MUST_USE bool emitTableGet();
   MOZ_MUST_USE bool emitTableGrow();
   MOZ_MUST_USE bool emitTableSet();
@@ -10660,52 +10661,69 @@ bool BaseCompiler::bulkmemOpsEnabled() {
 #ifndef ENABLE_WASM_BULKMEM_OPS
   if (env_.sharedMemoryEnabled == Shareable::False) {
     return iter_.fail("bulk memory ops disabled");
   }
 #endif
   return true;
 }
 
-bool BaseCompiler::emitMemOrTableCopy(bool isMem) {
+bool BaseCompiler::emitMemCopy() {
   if (!bulkmemOpsEnabled()) {
     return false;
   }
 
   uint32_t lineOrBytecode = readCallSiteLineOrBytecode();
 
   uint32_t dstMemOrTableIndex = 0;
   uint32_t srcMemOrTableIndex = 0;
   Nothing nothing;
-  if (!iter_.readMemOrTableCopy(isMem, &dstMemOrTableIndex, &nothing,
+  if (!iter_.readMemOrTableCopy(true, &dstMemOrTableIndex, &nothing,
                                 &srcMemOrTableIndex, &nothing, &nothing)) {
     return false;
   }
 
   if (deadCode_) {
     return true;
   }
 
-  if (isMem) {
-    MOZ_ASSERT(srcMemOrTableIndex == 0);
-    MOZ_ASSERT(dstMemOrTableIndex == 0);
-    pushHeapBase();
-    if (!emitInstanceCall(
-            lineOrBytecode,
-            usesSharedMemory() ? SASigMemCopyShared : SASigMemCopy,
-            /*pushReturnedValue=*/false)) {
-      return false;
-    }
-  } else {
-    pushI32(dstMemOrTableIndex);
-    pushI32(srcMemOrTableIndex);
-    if (!emitInstanceCall(lineOrBytecode, SASigTableCopy,
-                          /*pushReturnedValue=*/false)) {
-      return false;
-    }
+  pushHeapBase();
+  if (!emitInstanceCall(lineOrBytecode,
+                        usesSharedMemory() ? SASigMemCopyShared : SASigMemCopy,
+                        /*pushReturnedValue=*/false)) {
+    return false;
+  }
+
+  return true;
+}
+
+bool BaseCompiler::emitTableCopy() {
+  if (!bulkmemOpsEnabled()) {
+    return false;
+  }
+
+  uint32_t lineOrBytecode = readCallSiteLineOrBytecode();
+
+  uint32_t dstMemOrTableIndex = 0;
+  uint32_t srcMemOrTableIndex = 0;
+  Nothing nothing;
+  if (!iter_.readMemOrTableCopy(false, &dstMemOrTableIndex, &nothing,
+                                &srcMemOrTableIndex, &nothing, &nothing)) {
+    return false;
+  }
+
+  if (deadCode_) {
+    return true;
+  }
+
+  pushI32(dstMemOrTableIndex);
+  pushI32(srcMemOrTableIndex);
+  if (!emitInstanceCall(lineOrBytecode, SASigTableCopy,
+                        /*pushReturnedValue=*/false)) {
+    return false;
   }
 
   return true;
 }
 
 bool BaseCompiler::emitDataOrElemDrop(bool isData) {
   if (!bulkmemOpsEnabled()) {
     return false;
@@ -12002,25 +12020,25 @@ bool BaseCompiler::emitBody() {
                 SymbolicAddress::SaturatingTruncateDoubleToUint64, ValType::F64,
                 ValType::I64));
 #else
             CHECK_NEXT(emitConversionOOM(
                 emitTruncateF64ToI64<TRUNC_UNSIGNED | TRUNC_SATURATING>,
                 ValType::F64, ValType::I64));
 #endif
           case uint32_t(MiscOp::MemCopy):
-            CHECK_NEXT(emitMemOrTableCopy(/*isMem=*/true));
+            CHECK_NEXT(emitMemCopy());
           case uint32_t(MiscOp::DataDrop):
             CHECK_NEXT(emitDataOrElemDrop(/*isData=*/true));
           case uint32_t(MiscOp::MemFill):
             CHECK_NEXT(emitMemFill());
           case uint32_t(MiscOp::MemInit):
             CHECK_NEXT(emitMemOrTableInit(/*isMem=*/true));
           case uint32_t(MiscOp::TableCopy):
-            CHECK_NEXT(emitMemOrTableCopy(/*isMem=*/false));
+            CHECK_NEXT(emitTableCopy());
           case uint32_t(MiscOp::ElemDrop):
             CHECK_NEXT(emitDataOrElemDrop(/*isData=*/false));
           case uint32_t(MiscOp::TableInit):
             CHECK_NEXT(emitMemOrTableInit(/*isMem=*/false));
 #ifdef ENABLE_WASM_REFTYPES
           case uint32_t(MiscOp::TableFill):
             CHECK_NEXT(emitTableFill());
           case uint32_t(MiscOp::TableGrow):
--- a/js/src/wasm/WasmIonCompile.cpp
+++ b/js/src/wasm/WasmIonCompile.cpp
@@ -2895,75 +2895,115 @@ static bool EmitAtomicXchg(FunctionCompi
   if (!f.inDeadCode() && !ins) {
     return false;
   }
 
   f.iter().setResult(ins);
   return true;
 }
 
-static bool EmitMemOrTableCopy(FunctionCompiler& f, bool isMem) {
+static bool EmitMemCopy(FunctionCompiler& f) {
   // Bulk memory must be available if shared memory is enabled.
 #ifndef ENABLE_WASM_BULKMEM_OPS
   if (f.env().sharedMemoryEnabled == Shareable::False) {
     return f.iter().fail("bulk memory ops disabled");
   }
 #endif
 
   MDefinition *dst, *src, *len;
   uint32_t dstTableIndex;
   uint32_t srcTableIndex;
-  if (!f.iter().readMemOrTableCopy(isMem, &dstTableIndex, &dst, &srcTableIndex,
+  if (!f.iter().readMemOrTableCopy(true, &dstTableIndex, &dst, &srcTableIndex,
                                    &src, &len)) {
     return false;
   }
 
   if (f.inDeadCode()) {
     return true;
   }
 
   uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
 
   const SymbolicAddressSignature& callee =
-      isMem ? (f.env().usesSharedMemory() ? SASigMemCopyShared : SASigMemCopy)
-            : SASigTableCopy;
+      (f.env().usesSharedMemory() ? SASigMemCopyShared : SASigMemCopy);
   CallCompileState args;
   if (!f.passInstance(callee.argTypes[0], &args)) {
     return false;
   }
 
   if (!f.passArg(dst, callee.argTypes[1], &args)) {
     return false;
   }
   if (!f.passArg(src, callee.argTypes[2], &args)) {
     return false;
   }
   if (!f.passArg(len, callee.argTypes[3], &args)) {
     return false;
   }
-  if (isMem) {
-    MDefinition* memoryBase = f.memoryBase();
-    if (!f.passArg(memoryBase, callee.argTypes[4], &args)) {
-      return false;
-    }
-  } else {
-    MDefinition* dti = f.constant(Int32Value(dstTableIndex), MIRType::Int32);
-    if (!dti) {
-      return false;
-    }
-    if (!f.passArg(dti, callee.argTypes[4], &args)) {
-      return false;
-    }
-    MDefinition* sti = f.constant(Int32Value(srcTableIndex), MIRType::Int32);
-    if (!sti) {
-      return false;
-    }
-    if (!f.passArg(sti, callee.argTypes[5], &args)) {
-      return false;
-    }
+  MDefinition* memoryBase = f.memoryBase();
+  if (!f.passArg(memoryBase, callee.argTypes[4], &args)) {
+    return false;
+  }
+  if (!f.finishCall(&args)) {
+    return false;
+  }
+
+  return f.builtinInstanceMethodCall(callee, lineOrBytecode, args);
+}
+
+static bool EmitTableCopy(FunctionCompiler& f) {
+  // Bulk memory must be available if shared memory is enabled.
+#ifndef ENABLE_WASM_BULKMEM_OPS
+  if (f.env().sharedMemoryEnabled == Shareable::False) {
+    return f.iter().fail("bulk memory ops disabled");
+  }
+#endif
+
+  MDefinition *dst, *src, *len;
+  uint32_t dstTableIndex;
+  uint32_t srcTableIndex;
+  if (!f.iter().readMemOrTableCopy(false, &dstTableIndex, &dst, &srcTableIndex,
+                                   &src, &len)) {
+    return false;
+  }
+
+  if (f.inDeadCode()) {
+    return true;
+  }
+
+  uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
+
+  const SymbolicAddressSignature& callee = SASigTableCopy;
+  CallCompileState args;
+  if (!f.passInstance(callee.argTypes[0], &args)) {
+    return false;
+  }
+
+  if (!f.passArg(dst, callee.argTypes[1], &args)) {
+    return false;
+  }
+  if (!f.passArg(src, callee.argTypes[2], &args)) {
+    return false;
+  }
+  if (!f.passArg(len, callee.argTypes[3], &args)) {
+    return false;
+  }
+  MDefinition* dti = f.constant(Int32Value(dstTableIndex), MIRType::Int32);
+  if (!dti) {
+    return false;
+  }
+  if (!f.passArg(dti, callee.argTypes[4], &args)) {
+    return false;
+  }
+  MDefinition* sti = f.constant(Int32Value(srcTableIndex), MIRType::Int32);
+  if (!sti) {
+    return false;
+  }
+  if (!f.passArg(sti, callee.argTypes[5], &args)) {
+    return false;
   }
   if (!f.finishCall(&args)) {
     return false;
   }
 
   return f.builtinInstanceMethodCall(callee, lineOrBytecode, args);
 }
 
@@ -3901,25 +3941,25 @@ static bool EmitBodyExprs(FunctionCompil
           case uint32_t(MiscOp::I64TruncUSatF32):
             CHECK(EmitTruncate(f, ValType::F32, ValType::I64,
                                MiscOp(op.b1) == MiscOp::I64TruncUSatF32, true));
           case uint32_t(MiscOp::I64TruncSSatF64):
           case uint32_t(MiscOp::I64TruncUSatF64):
             CHECK(EmitTruncate(f, ValType::F64, ValType::I64,
                                MiscOp(op.b1) == MiscOp::I64TruncUSatF64, true));
           case uint32_t(MiscOp::MemCopy):
-            CHECK(EmitMemOrTableCopy(f, /*isMem=*/true));
+            CHECK(EmitMemCopy(f));
           case uint32_t(MiscOp::DataDrop):
             CHECK(EmitDataOrElemDrop(f, /*isData=*/true));
           case uint32_t(MiscOp::MemFill):
             CHECK(EmitMemFill(f));
           case uint32_t(MiscOp::MemInit):
             CHECK(EmitMemOrTableInit(f, /*isMem=*/true));
           case uint32_t(MiscOp::TableCopy):
-            CHECK(EmitMemOrTableCopy(f, /*isMem=*/false));
+            CHECK(EmitTableCopy(f));
           case uint32_t(MiscOp::ElemDrop):
             CHECK(EmitDataOrElemDrop(f, /*isData=*/false));
           case uint32_t(MiscOp::TableInit):
             CHECK(EmitMemOrTableInit(f, /*isMem=*/false));
 #ifdef ENABLE_WASM_REFTYPES
           case uint32_t(MiscOp::TableFill):
             CHECK(EmitTableFill(f));
           case uint32_t(MiscOp::TableGrow):