Bug 1627618 - Part 14: Add MUrsh::NewWasm for MUrsh users in wasm code. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 07 Apr 2020 08:40:27 +0000
changeset 522659 97f42d9e462be7c96bb8a9ed6864f9229a07ac16
parent 522658 4802a1f034483e52f749b8981d837e60caf8804c
child 522660 cfdd8f0aa45cbc08492f37e52bc6c70a11f894a7
push id112239
push userccoroiu@mozilla.com
push dateTue, 07 Apr 2020 15:04:11 +0000
treeherderautoland@5b653e25e757 [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 14: Add MUrsh::NewWasm for MUrsh users in wasm code. r=jandem Similar to `MAdd::NewWasm` and `MSub::NewWasm` from earlier patches, add a separate `MUrsh::NewWasm` function to handle wasm-specific initialisation for `MUrsh`. That frees up the `MUrsh(MDefinition, MDefinition, MIRType)` constructor to only set the specialisation without performing any wasm-specific actions. Differential Revision: https://phabricator.services.mozilla.com/D69794
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/wasm/WasmIonCompile.cpp
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -3659,16 +3659,23 @@ MRsh* MRsh::New(TempAllocator& alloc, MD
 MUrsh* MUrsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right) {
   return new (alloc) MUrsh(left, right, MIRType::Int32);
 }
 
 MUrsh* MUrsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                   MIRType type) {
   MUrsh* ins = new (alloc) MUrsh(left, right, type);
   ins->specializeAs(type);
+  return ins;
+}
+
+MUrsh* MUrsh::NewWasm(TempAllocator& alloc, MDefinition* left,
+                      MDefinition* right, MIRType type) {
+  MUrsh* ins = new (alloc) MUrsh(left, right, type);
+  ins->specializeAs(type);
 
   // Since Ion has no UInt32 type, we use Int32 and we have a special
   // exception to the type rules: we can return values in
   // (INT32_MIN,UINT32_MAX] and still claim that we have an Int32 type
   // without bailing out. This is necessary because Ion has no UInt32
   // type and we can't have bailouts in wasm code.
   ins->bailoutsDisabled_ = true;
 
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -4660,16 +4660,18 @@ class MUrsh : public MShiftInstruction {
         bailoutsDisabled_(false) {}
 
  public:
   INSTRUCTION_HEADER(Ursh)
   static MUrsh* New(TempAllocator& alloc, MDefinition* left,
                     MDefinition* right);
   static MUrsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                     MIRType type);
+  static MUrsh* NewWasm(TempAllocator& alloc, MDefinition* left,
+                        MDefinition* right, MIRType type);
 
   MDefinition* foldIfZero(size_t operand) override {
     // 0 >>> x => 0
     if (operand == 0) {
       return getOperand(0);
     }
 
     return this;
--- a/js/src/wasm/WasmIonCompile.cpp
+++ b/js/src/wasm/WasmIonCompile.cpp
@@ -335,16 +335,25 @@ class FunctionCompiler {
     if (inDeadCode()) {
       return nullptr;
     }
     T* ins = T::New(alloc(), lhs, rhs, type);
     curBlock_->add(ins);
     return ins;
   }
 
+  MDefinition* ursh(MDefinition* lhs, MDefinition* rhs, MIRType type) {
+    if (inDeadCode()) {
+      return nullptr;
+    }
+    auto* ins = MUrsh::NewWasm(alloc(), lhs, rhs, type);
+    curBlock_->add(ins);
+    return ins;
+  }
+
   MDefinition* add(MDefinition* lhs, MDefinition* rhs, MIRType type) {
     if (inDeadCode()) {
       return nullptr;
     }
     auto* ins = MAdd::NewWasm(alloc(), lhs, rhs, type);
     curBlock_->add(ins);
     return ins;
   }
@@ -2577,16 +2586,28 @@ static bool EmitBitwise(FunctionCompiler
   if (!f.iter().readBinary(operandType, &lhs, &rhs)) {
     return false;
   }
 
   f.iter().setResult(f.binary<MIRClass>(lhs, rhs, mirType));
   return true;
 }
 
+static bool EmitUrsh(FunctionCompiler& f, ValType operandType,
+                     MIRType mirType) {
+  MDefinition* lhs;
+  MDefinition* rhs;
+  if (!f.iter().readBinary(operandType, &lhs, &rhs)) {
+    return false;
+  }
+
+  f.iter().setResult(f.ursh(lhs, rhs, mirType));
+  return true;
+}
+
 static bool EmitMul(FunctionCompiler& f, ValType operandType, MIRType mirType) {
   MDefinition* lhs;
   MDefinition* rhs;
   if (!f.iter().readBinary(operandType, &lhs, &rhs)) {
     return false;
   }
 
   f.iter().setResult(
@@ -4123,17 +4144,17 @@ static bool EmitBodyExprs(FunctionCompil
         CHECK(EmitBitwise<MBitOr>(f, ValType::I32, MIRType::Int32));
       case uint16_t(Op::I32Xor):
         CHECK(EmitBitwise<MBitXor>(f, ValType::I32, MIRType::Int32));
       case uint16_t(Op::I32Shl):
         CHECK(EmitBitwise<MLsh>(f, ValType::I32, MIRType::Int32));
       case uint16_t(Op::I32ShrS):
         CHECK(EmitBitwise<MRsh>(f, ValType::I32, MIRType::Int32));
       case uint16_t(Op::I32ShrU):
-        CHECK(EmitBitwise<MUrsh>(f, ValType::I32, MIRType::Int32));
+        CHECK(EmitUrsh(f, ValType::I32, MIRType::Int32));
       case uint16_t(Op::I32Rotl):
       case uint16_t(Op::I32Rotr):
         CHECK(EmitRotate(f, ValType::I32, Op(op.b0) == Op::I32Rotl));
       case uint16_t(Op::I64Clz):
         CHECK(EmitUnaryWithType<MClz>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64Ctz):
         CHECK(EmitUnaryWithType<MCtz>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64Popcnt):
@@ -4158,17 +4179,17 @@ static bool EmitBodyExprs(FunctionCompil
         CHECK(EmitBitwise<MBitOr>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64Xor):
         CHECK(EmitBitwise<MBitXor>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64Shl):
         CHECK(EmitBitwise<MLsh>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64ShrS):
         CHECK(EmitBitwise<MRsh>(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64ShrU):
-        CHECK(EmitBitwise<MUrsh>(f, ValType::I64, MIRType::Int64));
+        CHECK(EmitUrsh(f, ValType::I64, MIRType::Int64));
       case uint16_t(Op::I64Rotl):
       case uint16_t(Op::I64Rotr):
         CHECK(EmitRotate(f, ValType::I64, Op(op.b0) == Op::I64Rotl));
       case uint16_t(Op::F32Abs):
         CHECK(EmitUnaryWithType<MAbs>(f, ValType::F32, MIRType::Float32));
       case uint16_t(Op::F32Neg):
         CHECK(EmitUnaryWithType<MWasmNeg>(f, ValType::F32, MIRType::Float32));
       case uint16_t(Op::F32Ceil):