Bug 1027897 - IonMonkey: Use FixedList for a few things. r=bhackett

This commit is contained in:
Dan Gohman 2014-06-23 13:42:07 -07:00
Родитель 7086f3a7bd
Коммит 8a69102407
2 изменённых файлов: 9 добавлений и 22 удалений

Просмотреть файл

@ -505,44 +505,37 @@ 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();
}
};

Просмотреть файл

@ -255,21 +255,17 @@ class InstructionData
// 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;
}
@ -286,11 +282,9 @@ class InstructionDataMap
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];
}
};