Bug 1627618 - Part 3: Add MSub::NewWasm for MSub users in wasm code. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 07 Apr 2020 08:35:32 +0000
changeset 522631 bd3e77b5b2e935b1a371f363e159187cf0fd5c1c
parent 522630 b801d8007636e2a979eb1c93dcb82e20fe468ba2
child 522632 2ba73b4b8fd79244ecca495e4ea27013eb5b1be6
push id37293
push userapavel@mozilla.com
push dateTue, 07 Apr 2020 21:44:02 +0000
treeherdermozilla-central@de63e64b9090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1627618
milestone77.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 1627618 - Part 3: Add MSub::NewWasm for MSub users in wasm code. r=jandem Similar to the previous part, add `MSub::NewWasm` to handle the wasm-specific initialisation bits, so that `MSub(MDefinition, MDefinition, MIRType)` only sets the return type and the specialisation. Differential Revision: https://phabricator.services.mozilla.com/D69780
js/src/jit/MIR.h
js/src/wasm/WasmIonCompile.cpp
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -5402,31 +5402,36 @@ class MAdd : public MBinaryArithInstruct
 };
 
 class MSub : public MBinaryArithInstruction {
   MSub(MDefinition* left, MDefinition* right)
       : MBinaryArithInstruction(classOpcode, left, right) {
     setResultType(MIRType::Value);
   }
 
-  MSub(MDefinition* left, MDefinition* right, MIRType type,
-       bool mustPreserveNaN = false)
+  MSub(MDefinition* left, MDefinition* right, MIRType type)
       : MSub(left, right) {
     specialization_ = type;
     setResultType(type);
-    setMustPreserveNaN(mustPreserveNaN);
-    if (type == MIRType::Int32) {
-      setTruncateKind(Truncate);
-    }
   }
 
  public:
   INSTRUCTION_HEADER(Sub)
   TRIVIAL_NEW_WRAPPERS
 
+  static MSub* NewWasm(TempAllocator& alloc, MDefinition* left,
+                       MDefinition* right, MIRType type, bool mustPreserveNaN) {
+    auto* ret = new (alloc) MSub(left, right, type);
+    ret->setMustPreserveNaN(mustPreserveNaN);
+    if (type == MIRType::Int32) {
+      ret->setTruncateKind(Truncate);
+    }
+    return ret;
+  }
+
   double getIdentity() override { return 0; }
 
   bool isFloat32Commutative() const override { return true; }
 
   bool fallible() const;
   void computeRange(TempAllocator& alloc) override;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
--- a/js/src/wasm/WasmIonCompile.cpp
+++ b/js/src/wasm/WasmIonCompile.cpp
@@ -354,17 +354,17 @@ class FunctionCompiler {
   }
 
   MDefinition* sub(MDefinition* lhs, MDefinition* rhs, MIRType type) {
     if (inDeadCode()) {
       return nullptr;
     }
 
     // wasm can't fold x - 0.0 because of NaN with custom payloads.
-    MSub* ins = MSub::New(alloc(), lhs, rhs, type, mustPreserveNaN(type));
+    MSub* ins = MSub::NewWasm(alloc(), lhs, rhs, type, mustPreserveNaN(type));
     curBlock_->add(ins);
     return ins;
   }
 
   MDefinition* nearbyInt(MDefinition* input, RoundingMode roundingMode) {
     if (inDeadCode()) {
       return nullptr;
     }