Bug 1425580 part 2 - Devirtualize LNode::numTemps. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 06 Feb 2018 14:37:07 +0100
changeset 402605 44646ddb114772f27ad5081198fc0b2c4be5128b
parent 402604 61d73dd6b95fe42ee537635a9ed4656648c23b22
child 402606 842b589abd9ca0563f14fd2e786f05a34c44e6bb
push id33393
push userrgurzau@mozilla.com
push dateTue, 06 Feb 2018 21:54:26 +0000
treeherdermozilla-central@0790ec12200d [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 2 - Devirtualize LNode::numTemps. r=nbp
js/src/jit/LIR.h
js/src/jit/shared/LIR-shared.h
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -661,24 +661,28 @@ class LNode
 
   private:
     LBlock* block_;
     uint32_t id_;
 
   protected:
     // Bitfields below are all uint32_t to make sure MSVC packs them correctly.
     uint32_t isCall_ : 1;
+    uint32_t numTemps_ : 4;
 
   public:
-    LNode()
+    explicit LNode(uint32_t numTemps)
       : mir_(nullptr),
         block_(nullptr),
         id_(0),
-        isCall_(false)
-    { }
+        isCall_(false),
+        numTemps_(numTemps)
+    {
+        MOZ_ASSERT(numTemps_ == numTemps, "numTemps must fit in bitfield");
+    }
 
     enum Opcode {
 #   define LIROP(name) LOp_##name,
         LIR_OPCODE_LIST(LIROP)
 #   undef LIROP
         LOp_Invalid
     };
 
@@ -716,17 +720,19 @@ class LNode
     // Returns information about operands.
     virtual size_t numOperands() const = 0;
     virtual LAllocation* getOperand(size_t index) = 0;
     virtual void setOperand(size_t index, const LAllocation& a) = 0;
 
     // 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.
-    virtual size_t numTemps() const = 0;
+    size_t numTemps() const {
+        return numTemps_;
+    }
     virtual LDefinition* getTemp(size_t index) = 0;
     virtual void setTemp(size_t index, const LDefinition& a) = 0;
 
     // Returns the number of successors of this instruction, if it is a control
     // transfer instruction, or zero otherwise.
     virtual size_t numSuccessors() const = 0;
     virtual MBasicBlock* getSuccessor(size_t i) const = 0;
     virtual void setSuccessor(size_t i, MBasicBlock* successor) = 0;
@@ -811,18 +817,19 @@ class LInstruction
     // to hold either gcthings or Values.
     LSafepoint* safepoint_;
 
     LMoveGroup* inputMoves_;
     LMoveGroup* fixReuseMoves_;
     LMoveGroup* movesAfter_;
 
   protected:
-    LInstruction()
-      : snapshot_(nullptr),
+    explicit LInstruction(uint32_t numTemps)
+      : LNode(numTemps),
+        snapshot_(nullptr),
         safepoint_(nullptr),
         inputMoves_(nullptr),
         fixReuseMoves_(nullptr),
         movesAfter_(nullptr)
     { }
 
     void setIsCall() {
         isCall_ = true;
@@ -920,17 +927,18 @@ class LPhi final : public LNode
 {
     LAllocation* const inputs_;
     LDefinition def_;
 
   public:
     LIR_HEADER(Phi)
 
     LPhi(MPhi* ins, LAllocation* inputs)
-        : inputs_(inputs)
+      : LNode(/* numTemps = */ 0),
+        inputs_(inputs)
     {
         setMir(ins);
     }
 
     size_t numDefs() const override {
         return 1;
     }
     LDefinition* getDef(size_t index) override {
@@ -947,19 +955,16 @@ class LPhi final : public LNode
     LAllocation* getOperand(size_t index) override {
         MOZ_ASSERT(index < numOperands());
         return &inputs_[index];
     }
     void setOperand(size_t index, const LAllocation& a) override {
         MOZ_ASSERT(index < numOperands());
         inputs_[index] = a;
     }
-    size_t numTemps() const override {
-        return 0;
-    }
     LDefinition* getTemp(size_t index) override {
         MOZ_CRASH("no temps");
     }
     void setTemp(size_t index, const LDefinition& temp) override {
         MOZ_CRASH("no temps");
     }
     size_t numSuccessors() const override {
         return 0;
@@ -1071,26 +1076,28 @@ class LBlock
 
 namespace details {
     template <size_t Defs, size_t Temps>
     class LInstructionFixedDefsTempsHelper : public LInstruction
     {
         mozilla::Array<LDefinition, Defs> defs_;
         mozilla::Array<LDefinition, Temps> temps_;
 
+      protected:
+        LInstructionFixedDefsTempsHelper()
+          : LInstruction(Temps)
+        {}
+
       public:
         size_t numDefs() const final override {
             return Defs;
         }
         LDefinition* getDef(size_t index) final override {
             return &defs_[index];
         }
-        size_t numTemps() const final override {
-            return Temps;
-        }
         LDefinition* getTemp(size_t index) final override {
             return &temps_[index];
         }
 
         void setDef(size_t index, const LDefinition& def) final override {
             defs_[index] = def;
         }
         void setTemp(size_t index, const LDefinition& a) final override {
--- a/js/src/jit/shared/LIR-shared.h
+++ b/js/src/jit/shared/LIR-shared.h
@@ -8990,17 +8990,18 @@ class LWasmCallBase : public LInstructio
 {
     LAllocation* operands_;
     uint32_t numOperands_;
     uint32_t needsBoundsCheck_;
 
   public:
 
     LWasmCallBase(LAllocation* operands, uint32_t numOperands, bool needsBoundsCheck)
-      : operands_(operands),
+      : LInstruction(/* numTemps = */ 0),
+        operands_(operands),
         numOperands_(numOperands),
         needsBoundsCheck_(needsBoundsCheck)
     {
         setIsCall();
     }
 
     MWasmCall* mir() const {
         return mir_->toWasmCall();
@@ -9022,19 +9023,16 @@ class LWasmCallBase : public LInstructio
     LAllocation* getOperand(size_t index) override {
         MOZ_ASSERT(index < numOperands_);
         return &operands_[index];
     }
     void setOperand(size_t index, const LAllocation& a) override {
         MOZ_ASSERT(index < numOperands_);
         operands_[index] = a;
     }
-    size_t numTemps() const override {
-        return 0;
-    }
     LDefinition* getTemp(size_t index) override {
         MOZ_CRASH("no temps");
     }
     void setTemp(size_t index, const LDefinition& a) override {
         MOZ_CRASH("no temps");
     }
     size_t numSuccessors() const override {
         return 0;