Bug 1027897 - IonMonkey: Use FixedList for a few things. r=bhackett
authorDan Gohman <sunfish@mozilla.com>
Mon, 23 Jun 2014 13:42:07 -0700
changeset 190341 47e90dfb0c31ea60372c7a188400c67b25265005
parent 190340 cfaf432d687722853d8c40f374fd3601bdc3ab66
child 190342 3f65f6f5b322ad8ee5ca29654246d4a3367e5efb
push id27004
push useremorley@mozilla.com
push dateTue, 24 Jun 2014 15:52:34 +0000
treeherdermozilla-central@7b174d47f3cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1027897
milestone33.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 1027897 - IonMonkey: Use FixedList for a few things. r=bhackett
js/src/jit/LiveRangeAllocator.h
js/src/jit/RegisterAllocator.h
--- a/js/src/jit/LiveRangeAllocator.h
+++ b/js/src/jit/LiveRangeAllocator.h
@@ -500,54 +500,47 @@ class VirtualRegister
 };
 
 // Index of the virtual registers in a graph. VREG is a subclass of
 // VirtualRegister extended with any allocator specific state for the vreg.
 template <typename VREG>
 class VirtualRegisterMap
 {
   private:
-    VREG *vregs_;
-    uint32_t numVregs_;
+    FixedList<VREG> vregs_;
 
     void operator=(const VirtualRegisterMap &) MOZ_DELETE;
     VirtualRegisterMap(const VirtualRegisterMap &) MOZ_DELETE;
 
   public:
     VirtualRegisterMap()
-      : vregs_(nullptr),
-        numVregs_(0)
+      : vregs_()
     { }
 
     bool init(MIRGenerator *gen, uint32_t numVregs) {
-        vregs_ = gen->allocate<VREG>(numVregs);
-        numVregs_ = numVregs;
-        if (!vregs_)
+        if (!vregs_.init(gen->alloc(), numVregs))
             return false;
-        memset(vregs_, 0, sizeof(VREG) * numVregs);
+        memset(&vregs_[0], 0, sizeof(VREG) * numVregs);
         TempAllocator &alloc = gen->alloc();
         for (uint32_t i = 0; i < numVregs; i++)
             new(&vregs_[i]) VREG(alloc);
         return true;
     }
     VREG &operator[](unsigned int index) {
-        JS_ASSERT(index < numVregs_);
         return vregs_[index];
     }
     VREG &operator[](const LAllocation *alloc) {
         JS_ASSERT(alloc->isUse());
-        JS_ASSERT(alloc->toUse()->virtualRegister() < numVregs_);
         return vregs_[alloc->toUse()->virtualRegister()];
     }
     VREG &operator[](const LDefinition *def) {
-        JS_ASSERT(def->virtualRegister() < numVregs_);
         return vregs_[def->virtualRegister()];
     }
     uint32_t numVirtualRegisters() const {
-        return numVregs_;
+        return vregs_.length();
     }
 };
 
 static inline bool
 IsNunbox(VirtualRegister *vreg)
 {
 #ifdef JS_NUNBOX32
     return (vreg->type() == LDefinition::TYPE ||
--- a/js/src/jit/RegisterAllocator.h
+++ b/js/src/jit/RegisterAllocator.h
@@ -250,52 +250,46 @@ class InstructionData
     LMoveGroup *movesAfter() const {
         return movesAfter_;
     }
 };
 
 // Structure to track all moves inserted next to instructions in a graph.
 class InstructionDataMap
 {
-    InstructionData *insData_;
-    uint32_t numIns_;
+    FixedList<InstructionData> insData_;
 
   public:
     InstructionDataMap()
-      : insData_(nullptr),
-        numIns_(0)
+      : insData_()
     { }
 
     bool init(MIRGenerator *gen, uint32_t numInstructions) {
-        insData_ = gen->allocate<InstructionData>(numInstructions);
-        numIns_ = numInstructions;
-        if (!insData_)
+        if (!insData_.init(gen->alloc(), numInstructions))
             return false;
-        memset(insData_, 0, sizeof(InstructionData) * numInstructions);
+        memset(&insData_[0], 0, sizeof(InstructionData) * numInstructions);
         return true;
     }
 
     InstructionData &operator[](CodePosition pos) {
         return operator[](pos.ins());
     }
     const InstructionData &operator[](CodePosition pos) const {
         return operator[](pos.ins());
     }
     InstructionData &operator[](LInstruction *ins) {
         return operator[](ins->id());
     }
     const InstructionData &operator[](LInstruction *ins) const {
         return operator[](ins->id());
     }
     InstructionData &operator[](uint32_t ins) {
-        JS_ASSERT(ins < numIns_);
         return insData_[ins];
     }
     const InstructionData &operator[](uint32_t ins) const {
-        JS_ASSERT(ins < numIns_);
         return insData_[ins];
     }
 };
 
 // Common superclass for register allocators.
 class RegisterAllocator
 {
     void operator=(const RegisterAllocator &) MOZ_DELETE;