Bug 1425580 part 19 - Remove LNode::numSuccessors_. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 08 Mar 2018 11:10:51 +0100
changeset 462186 8b23d0fe66d9543df55619bd48d1a1d0704df95f
parent 462185 75d18bb967e0ec0892baeecdd3ae9107483d62c5
child 462205 b6252f86f57b84394ff5db138634982304851091
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1425580
milestone60.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 1425580 part 19 - Remove LNode::numSuccessors_. r=nbp
js/src/jit/LIR.cpp
js/src/jit/LIR.h
js/src/jit/shared/CodeGenerator-shared.h
js/src/jit/shared/LIR-shared.h
--- a/js/src/jit/LIR.cpp
+++ b/js/src/jit/LIR.cpp
@@ -522,33 +522,57 @@ LInstruction::assignSnapshot(LSnapshot* 
                    (void*)snapshot, (void*)this);
         printName(out);
         out.printf(")\n");
     }
 #endif
 }
 
 #ifdef JS_JITSPEW
+static size_t
+NumSuccessorsHelper(const LNode* ins)
+{
+    return 0;
+}
+
+template <size_t Succs, size_t Operands, size_t Temps>
+static size_t
+NumSuccessorsHelper(const LControlInstructionHelper<Succs, Operands, Temps>* ins)
+{
+    return Succs;
+}
+
+static size_t
+NumSuccessors(const LInstruction* ins)
+{
+    switch (ins->op()) {
+      default: MOZ_CRASH("Unexpected LIR op");
+# define LIROP(x) case LNode::LOp_##x: return NumSuccessorsHelper(ins->to##x());
+    LIR_OPCODE_LIST(LIROP)
+# undef LIROP
+    }
+}
+
 static MBasicBlock*
 GetSuccessorHelper(const LNode* ins, size_t i)
 {
     MOZ_CRASH("Unexpected instruction with successors");
 }
 
 template <size_t Succs, size_t Operands, size_t Temps>
 static MBasicBlock*
 GetSuccessorHelper(const LControlInstructionHelper<Succs, Operands, Temps>* ins, size_t i)
 {
     return ins->getSuccessor(i);
 }
 
 static MBasicBlock*
 GetSuccessor(const LInstruction* ins, size_t i)
 {
-    MOZ_ASSERT(i < ins->numSuccessors());
+    MOZ_ASSERT(i < NumSuccessors(ins));
 
     switch (ins->op()) {
       default: MOZ_CRASH("Unexpected LIR op");
 # define LIROP(x) case LNode::LOp_##x: return GetSuccessorHelper(ins->to##x(), i);
     LIR_OPCODE_LIST(LIROP)
 # undef LIROP
     }
 }
@@ -579,31 +603,29 @@ LNode::dump(GenericPrinter& out)
             for (size_t i = 0; i < numTemps; i++) {
                 out.printf("%s", ins->getTemp(i)->toString().get());
                 if (i != numTemps - 1)
                     out.printf(", ");
             }
             out.printf(")");
         }
 
-        size_t numSuccessors = ins->numSuccessors();
+#ifdef JS_JITSPEW
+        size_t numSuccessors = NumSuccessors(ins);
         if (numSuccessors > 0) {
             out.printf(" s=(");
             for (size_t i = 0; i < numSuccessors; i++) {
-#ifdef JS_JITSPEW
                 MBasicBlock* succ = GetSuccessor(ins, i);
                 out.printf("block%u", succ->id());
-#else
-                out.put("block<unknown>");
-#endif
                 if (i != numSuccessors - 1)
                     out.printf(", ");
             }
             out.printf(")");
         }
+#endif
     }
 }
 
 void
 LNode::dump()
 {
     Fprinter out(stderr);
     dump(out);
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -670,17 +670,16 @@ class LNode
     // LPhi::numOperands() may not fit in this bitfield, so we only use this
     // field for LInstruction.
     uint32_t nonPhiNumOperands_ : 6;
     // For LInstruction, the first operand is stored at offset
     // sizeof(LInstruction) + nonPhiOperandsOffset_ * sizeof(uintptr_t).
     uint32_t nonPhiOperandsOffset_ : 5;
     uint32_t numDefs_ : 4;
     uint32_t numTemps_ : 4;
-    uint32_t numSuccessors_ : 2;
 
   public:
     enum Opcode {
 #define LIROP(name) LOp_##name,
         LIR_OPCODE_LIST(LIROP)
 #undef LIROP
         LOp_Invalid
     };
@@ -689,18 +688,17 @@ class LNode
       : mir_(nullptr),
         block_(nullptr),
         id_(0),
         op_(op),
         isCall_(false),
         nonPhiNumOperands_(nonPhiNumOperands),
         nonPhiOperandsOffset_(0),
         numDefs_(numDefs),
-        numTemps_(numTemps),
-        numSuccessors_(0)
+        numTemps_(numTemps)
     {
         MOZ_ASSERT(op_ < LOp_Invalid);
         MOZ_ASSERT(op_ == op, "opcode must fit in bitfield");
         MOZ_ASSERT(nonPhiNumOperands_ == nonPhiNumOperands,
                    "nonPhiNumOperands must fit in bitfield");
         MOZ_ASSERT(numDefs_ == numDefs, "numDefs must fit in bitfield");
         MOZ_ASSERT(numTemps_ == numTemps, "numTemps must fit in bitfield");
     }
@@ -858,26 +856,16 @@ class LInstruction
     // Returns information about temporary registers needed. Each temporary
     // register is an LDefinition with a fixed or virtual register and
     // either GENERAL, FLOAT32, or DOUBLE type.
     size_t numTemps() const {
         return numTemps_;
     }
     inline LDefinition* getTemp(size_t index);
 
-    // Returns the number of successors of this instruction, if it is a control
-    // transfer instruction, or zero otherwise.
-    size_t numSuccessors() const {
-        return numSuccessors_;
-    }
-    void setNumSuccessors(size_t succ) {
-        numSuccessors_ = succ;
-        MOZ_ASSERT(numSuccessors_ == succ, "Number of successors must fit in bitfield");
-    }
-
     LSnapshot* snapshot() const {
         return snapshot_;
     }
     LSafepoint* safepoint() const {
         return safepoint_;
     }
     LMoveGroup* inputMoves() const {
         return inputMoves_;
--- a/js/src/jit/shared/CodeGenerator-shared.h
+++ b/js/src/jit/shared/CodeGenerator-shared.h
@@ -367,18 +367,19 @@ class CodeGeneratorShared : public LElem
     void emitPreBarrier(Register base, const LAllocation* index, int32_t offsetAdjustment);
     void emitPreBarrier(Address address);
 
     // We don't emit code for trivial blocks, so if we want to branch to the
     // given block, and it's trivial, return the ultimate block we should
     // actually branch directly to.
     MBasicBlock* skipTrivialBlocks(MBasicBlock* block) {
         while (block->lir()->isTrivial()) {
-            MOZ_ASSERT(block->lir()->rbegin()->numSuccessors() == 1);
-            block = block->lir()->rbegin()->toGoto()->getSuccessor(0);
+            LGoto* ins = block->lir()->rbegin()->toGoto();
+            MOZ_ASSERT(ins->numSuccessors() == 1);
+            block = ins->getSuccessor(0);
         }
         return block;
     }
 
     // Test whether the given block can be reached via fallthrough from the
     // current block.
     inline bool isNextBlock(LBlock* block) {
         uint32_t target = skipTrivialBlocks(block->mir())->id();
--- a/js/src/jit/shared/LIR-shared.h
+++ b/js/src/jit/shared/LIR-shared.h
@@ -1039,21 +1039,22 @@ class LIsConstructing : public LInstruct
 template <size_t Succs, size_t Operands, size_t Temps>
 class LControlInstructionHelper : public LInstructionHelper<0, Operands, Temps> {
 
     mozilla::Array<MBasicBlock*, Succs> successors_;
 
   protected:
     explicit LControlInstructionHelper(LNode::Opcode opcode)
       : LInstructionHelper<0, Operands, Temps>(opcode)
-    {
-        this->setNumSuccessors(Succs);
-    }
-
-  public:
+    {}
+
+  public:
+    size_t numSuccessors() const {
+        return Succs;
+    }
     MBasicBlock* getSuccessor(size_t i) const {
         return successors_[i];
     }
 
     void setSuccessor(size_t i, MBasicBlock* successor) {
         successors_[i] = successor;
     }
 };