Bug 1542740: Convert BinaryArithIRGenerator to use AttachDecision r=mgaudet
authorIain Ireland <iireland@mozilla.com>
Fri, 26 Apr 2019 14:29:56 +0000
changeset 471532 c9e126b6fe3d2383bed37ff0a355f5a31600ac09
parent 471531 94bdb9f0377ae71e261b3e25760e9f3c3020bcee
child 471533 7a8e62330019d4596274635543d36c0b01a559bd
push id84143
push useriireland@mozilla.com
push dateFri, 26 Apr 2019 15:09:46 +0000
treeherderautoland@85d43344501f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1542740
milestone68.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 1542740: Convert BinaryArithIRGenerator to use AttachDecision r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D27309
js/src/jit/BaselineIC.cpp
js/src/jit/CacheIR.cpp
js/src/jit/CacheIR.h
js/src/jit/IonIC.cpp
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -5791,19 +5791,19 @@ bool DoBinaryArithFallback(JSContext* cx
     default:
       MOZ_CRASH("Unhandled baseline arith op");
   }
 
   if (ret.isDouble()) {
     stub->setSawDoubleResult();
   }
 
-  TryAttachStubOld<BinaryArithIRGenerator>("BinaryArith", cx, frame, stub,
-                                           BaselineCacheIRStubKind::Regular, op,
-                                           lhs, rhs, ret);
+  TryAttachStub<BinaryArithIRGenerator>("BinaryArith", cx, frame, stub,
+                                        BaselineCacheIRStubKind::Regular, op,
+                                        lhs, rhs, ret);
   return true;
 }
 
 bool FallbackICCodeCompiler::emit_BinaryArith() {
   MOZ_ASSERT(R0 == JSReturnOperand);
 
   // Restore the tail call register.
   EmitRestoreTailCallReg(masm);
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -6252,68 +6252,55 @@ void BinaryArithIRGenerator::trackAttach
   if (const CacheIRSpewer::Guard& sp = CacheIRSpewer::Guard(*this, name)) {
     sp.opcodeProperty("op", op_);
     sp.valueProperty("rhs", rhs_);
     sp.valueProperty("lhs", lhs_);
   }
 #endif
 }
 
-bool BinaryArithIRGenerator::tryAttachStub() {
+AttachDecision BinaryArithIRGenerator::tryAttachStub() {
   AutoAssertNoPendingException aanpe(cx_);
   // Arithmetic operations with Int32 operands
-  if (tryAttachInt32()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachInt32());
+
   // Bitwise operations with Int32 operands
-  if (tryAttachBitwise()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachBitwise());
 
   // Arithmetic operations with Double operands. This needs to come after
   // tryAttachInt32, as the guards overlap, and we'd prefer to attach the
   // more specialized Int32 IC if it is possible.
-  if (tryAttachDouble()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachDouble());
 
   // String x String
-  if (tryAttachStringConcat()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachStringConcat());
 
   // String x Object
-  if (tryAttachStringObjectConcat()) {
-    return true;
-  }
-
-  if (tryAttachStringNumberConcat()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachStringObjectConcat());
+
+  TRY_ATTACH(tryAttachStringNumberConcat());
 
   // String + Boolean
-  if (tryAttachStringBooleanConcat()) {
-    return true;
-  }
+  TRY_ATTACH(tryAttachStringBooleanConcat());
 
   trackAttached(IRGenerator::NotAttached);
-  return false;
-}
-
-bool BinaryArithIRGenerator::tryAttachBitwise() {
+  return AttachDecision::NoAction;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachBitwise() {
   // Only bit-wise and shifts.
   if (op_ != JSOP_BITOR && op_ != JSOP_BITXOR && op_ != JSOP_BITAND &&
       op_ != JSOP_LSH && op_ != JSOP_RSH && op_ != JSOP_URSH) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Check guard conditions
   if (!(lhs_.isNumber() || lhs_.isBoolean()) ||
       !(rhs_.isNumber() || rhs_.isBoolean())) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // All ops, with the exception of URSH produce Int32 values.
   MOZ_ASSERT_IF(op_ != JSOP_URSH, res_.isInt32());
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
@@ -6358,29 +6345,29 @@ bool BinaryArithIRGenerator::tryAttachBi
       writer.int32URightShiftResult(lhsIntId, rhsIntId, res_.isDouble());
       trackAttached("BinaryArith.Bitwise.UnsignedRightShift");
       break;
     default:
       MOZ_CRASH("Unhandled op in tryAttachBitwise");
   }
 
   writer.returnFromIC();
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachDouble() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachDouble() {
   // Check valid opcodes
   if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
       op_ != JSOP_DIV && op_ != JSOP_MOD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Check guard conditions
   if (!lhs_.isNumber() || !rhs_.isNumber()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   writer.guardIsNumber(lhsId);
   writer.guardIsNumber(rhsId);
 
@@ -6404,35 +6391,35 @@ bool BinaryArithIRGenerator::tryAttachDo
     case JSOP_MOD:
       writer.doubleModResult(lhsId, rhsId);
       trackAttached("BinaryArith.Double.Mod");
       break;
     default:
       MOZ_CRASH("Unhandled Op");
   }
   writer.returnFromIC();
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachInt32() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachInt32() {
   // Check guard conditions
   if (!(lhs_.isInt32() || lhs_.isBoolean()) ||
       !(rhs_.isInt32() || rhs_.isBoolean())) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // These ICs will failure() if result can't be encoded in an Int32:
   // If sample result is not Int32, we should avoid IC.
   if (!res_.isInt32()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (op_ != JSOP_ADD && op_ != JSOP_SUB && op_ != JSOP_MUL &&
       op_ != JSOP_DIV && op_ != JSOP_MOD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   auto guardToInt32 = [&](ValOperandId id, HandleValue v) {
     if (v.isInt32()) {
       return writer.guardIsInt32(id);
@@ -6465,28 +6452,28 @@ bool BinaryArithIRGenerator::tryAttachIn
       writer.int32ModResult(lhsIntId, rhsIntId);
       trackAttached("BinaryArith.Int32.Mod");
       break;
     default:
       MOZ_CRASH("Unhandled op in tryAttachInt32");
   }
 
   writer.returnFromIC();
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachStringNumberConcat() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachStringNumberConcat() {
   // Only Addition
   if (op_ != JSOP_ADD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if (!(lhs_.isString() && rhs_.isNumber()) &&
       !(lhs_.isNumber() && rhs_.isString())) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   auto guardToString = [&](ValOperandId id, HandleValue v) {
     if (v.isString()) {
       return writer.guardIsString(id);
@@ -6504,28 +6491,28 @@ bool BinaryArithIRGenerator::tryAttachSt
 
   StringOperandId lhsStrId = guardToString(lhsId, lhs_);
   StringOperandId rhsStrId = guardToString(rhsId, rhs_);
 
   writer.callStringConcatResult(lhsStrId, rhsStrId);
 
   writer.returnFromIC();
   trackAttached("BinaryArith.StringNumberConcat");
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachStringBooleanConcat() {
   // Only Addition
   if (op_ != JSOP_ADD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   if ((!lhs_.isString() || !rhs_.isBoolean()) &&
       (!lhs_.isBoolean() || !rhs_.isString())) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   auto guardToString = [&](ValOperandId id, HandleValue v) {
     if (v.isString()) {
       return writer.guardIsString(id);
@@ -6537,53 +6524,53 @@ bool BinaryArithIRGenerator::tryAttachSt
 
   StringOperandId lhsStrId = guardToString(lhsId, lhs_);
   StringOperandId rhsStrId = guardToString(rhsId, rhs_);
 
   writer.callStringConcatResult(lhsStrId, rhsStrId);
 
   writer.returnFromIC();
   trackAttached("BinaryArith.StringBooleanConcat");
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachStringConcat() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachStringConcat() {
   // Only Addition
   if (op_ != JSOP_ADD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Check guards
   if (!lhs_.isString() || !rhs_.isString()) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   StringOperandId lhsStrId = writer.guardIsString(lhsId);
   StringOperandId rhsStrId = writer.guardIsString(rhsId);
 
   writer.callStringConcatResult(lhsStrId, rhsStrId);
 
   writer.returnFromIC();
   trackAttached("BinaryArith.StringConcat");
-  return true;
-}
-
-bool BinaryArithIRGenerator::tryAttachStringObjectConcat() {
+  return AttachDecision::Attach;
+}
+
+AttachDecision BinaryArithIRGenerator::tryAttachStringObjectConcat() {
   // Only Addition
   if (op_ != JSOP_ADD) {
-    return false;
+    return AttachDecision::NoAction;
   }
 
   // Check Guards
   if (!(lhs_.isObject() && rhs_.isString()) &&
       !(lhs_.isString() && rhs_.isObject()))
-    return false;
+    return AttachDecision::NoAction;
 
   ValOperandId lhsId(writer.setInputOperandId(0));
   ValOperandId rhsId(writer.setInputOperandId(1));
 
   // This guard is actually overly tight, as the runtime
   // helper can handle lhs or rhs being a string, so long
   // as the other is an object.
   if (lhs_.isString()) {
@@ -6593,17 +6580,17 @@ bool BinaryArithIRGenerator::tryAttachSt
     writer.guardIsObject(lhsId);
     writer.guardIsString(rhsId);
   }
 
   writer.callStringObjectConcatResult(lhsId, rhsId);
 
   writer.returnFromIC();
   trackAttached("BinaryArith.StringObjectConcat");
-  return true;
+  return AttachDecision::Attach;
 }
 
 NewObjectIRGenerator::NewObjectIRGenerator(JSContext* cx, HandleScript script,
                                            jsbytecode* pc, ICState::Mode mode,
                                            JSOp op, HandleObject templateObj)
     : IRGenerator(cx, script, pc, CacheKind::NewObject, mode),
 #ifdef JS_CACHEIR_SPEW
       op_(op),
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -2476,30 +2476,30 @@ class MOZ_RAII UnaryArithIRGenerator : p
 class MOZ_RAII BinaryArithIRGenerator : public IRGenerator {
   JSOp op_;
   HandleValue lhs_;
   HandleValue rhs_;
   HandleValue res_;
 
   void trackAttached(const char* name);
 
-  bool tryAttachInt32();
-  bool tryAttachDouble();
-  bool tryAttachBitwise();
-  bool tryAttachStringConcat();
-  bool tryAttachStringObjectConcat();
-  bool tryAttachStringNumberConcat();
-  bool tryAttachStringBooleanConcat();
+  AttachDecision tryAttachInt32();
+  AttachDecision tryAttachDouble();
+  AttachDecision tryAttachBitwise();
+  AttachDecision tryAttachStringConcat();
+  AttachDecision tryAttachStringObjectConcat();
+  AttachDecision tryAttachStringNumberConcat();
+  AttachDecision tryAttachStringBooleanConcat();
 
  public:
   BinaryArithIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc,
                          ICState::Mode, JSOp op, HandleValue lhs,
                          HandleValue rhs, HandleValue res);
 
-  bool tryAttachStub();
+  AttachDecision tryAttachStub();
 };
 
 class MOZ_RAII NewObjectIRGenerator : public IRGenerator {
 #ifdef JS_CACHEIR_SPEW
   JSOp op_;
 #endif
   HandleObject templateObject_;
 
--- a/js/src/jit/IonIC.cpp
+++ b/js/src/jit/IonIC.cpp
@@ -611,18 +611,18 @@ bool IonBinaryArithIC::update(JSContext*
         return false;
       }
       break;
     }
     default:
       MOZ_CRASH("Unhandled binary arith op");
   }
 
-  TryAttachIonStubOld<BinaryArithIRGenerator, IonBinaryArithIC>(
-      cx, ic, ionScript, op, lhs, rhs, ret);
+  TryAttachIonStub<BinaryArithIRGenerator, IonBinaryArithIC>(cx, ic, ionScript,
+                                                             op, lhs, rhs, ret);
 
   return true;
 }
 
 /* static */
 bool IonCompareIC::update(JSContext* cx, HandleScript outerScript,
                           IonCompareIC* ic, HandleValue lhs, HandleValue rhs,
                           bool* res) {