Bug 948241 - IonMonkey: Convert plain arrays to mozilla::Array r=luke
☠☠ backed out by 7c17d67dac5b ☠ ☠
authorDan Gohman <sunfish@google.com>
Mon, 09 Dec 2013 19:39:46 -0800
changeset 159966 8e1d913c4436de02bb2b5e743d1f7dc67f5a690f
parent 159965 c39721a052f3605359aab2a0d09e5aab7766cdb4
child 159967 294b27f4a5f5c4986d2100e8e66c8ce270f317aa
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersluke
bugs948241
milestone29.0a1
Bug 948241 - IonMonkey: Convert plain arrays to mozilla::Array r=luke
js/src/jit/BaselineIC.h
js/src/jit/IonFrames.cpp
js/src/jit/LIR-Common.h
js/src/jit/PcScriptCache.h
js/src/jit/Registers.h
js/src/jit/StupidAllocator.h
js/src/jit/VMFunctions.h
js/src/jit/arm/Assembler-arm.h
js/src/jit/arm/Bailouts-arm.cpp
js/src/jit/arm/IonFrames-arm.h
js/src/jit/arm/MacroAssembler-arm.h
js/src/jit/shared/IonAssemblerBuffer.h
js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
js/src/jit/shared/IonFrames-x86-shared.h
js/src/jit/x64/Bailouts-x64.cpp
js/src/jit/x86/Bailouts-x86.cpp
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -3555,17 +3555,17 @@ class ICSetElem_DenseAdd : public ICUpda
 };
 
 template <size_t ProtoChainDepth>
 class ICSetElem_DenseAddImpl : public ICSetElem_DenseAdd
 {
     friend class ICStubSpace;
 
     static const size_t NumShapes = ProtoChainDepth + 1;
-    HeapPtrShape shapes_[NumShapes];
+    mozilla::Array<HeapPtrShape, NumShapes> shapes_;
 
     ICSetElem_DenseAddImpl(IonCode *stubCode, types::TypeObject *type,
                            const AutoShapeVector *shapes)
       : ICSetElem_DenseAdd(stubCode, type, ProtoChainDepth)
     {
         JS_ASSERT(shapes->length() == NumShapes);
         for (size_t i = 0; i < NumShapes; i++)
             shapes_[i].init((*shapes)[i]);
@@ -3812,17 +3812,17 @@ class ICGetName_Global : public ICMonito
 // shape checks are required all along the scope chain.
 template <size_t NumHops>
 class ICGetName_Scope : public ICMonitoredStub
 {
     friend class ICStubSpace;
 
     static const size_t MAX_HOPS = 6;
 
-    HeapPtrShape shapes_[NumHops + 1];
+    mozilla::Array<HeapPtrShape, NumHops + 1> shapes_;
     uint32_t offset_;
 
     ICGetName_Scope(IonCode *stubCode, ICStub *firstMonitorStub,
                     AutoShapeVector *shapes, uint32_t offset);
 
     static Kind GetStubKind() {
         return (Kind) (GetName_Scope0 + NumHops);
     }
@@ -4954,17 +4954,17 @@ class ICSetProp_NativeAdd : public ICUpd
 };
 
 template <size_t ProtoChainDepth>
 class ICSetProp_NativeAddImpl : public ICSetProp_NativeAdd
 {
     friend class ICStubSpace;
 
     static const size_t NumShapes = ProtoChainDepth + 1;
-    HeapPtrShape shapes_[NumShapes];
+    mozilla::Array<HeapPtrShape, NumShapes> shapes_;
 
     ICSetProp_NativeAddImpl(IonCode *stubCode, HandleTypeObject type,
                             const AutoShapeVector *shapes,
                             HandleShape newShape, uint32_t offset);
 
   public:
     static inline ICSetProp_NativeAddImpl *New(
             ICStubSpace *space, IonCode *code, HandleTypeObject type,
--- a/js/src/jit/IonFrames.cpp
+++ b/js/src/jit/IonFrames.cpp
@@ -1458,18 +1458,18 @@ bool
 InlineFrameIteratorMaybeGC<allowGC>::isFunctionFrame() const
 {
     return !!callee_;
 }
 template bool InlineFrameIteratorMaybeGC<NoGC>::isFunctionFrame() const;
 template bool InlineFrameIteratorMaybeGC<CanGC>::isFunctionFrame() const;
 
 MachineState
-MachineState::FromBailout(uintptr_t regs[Registers::Total],
-                          double fpregs[FloatRegisters::Total])
+MachineState::FromBailout(mozilla::Array<uintptr_t, Registers::Total> &regs,
+                          mozilla::Array<double, FloatRegisters::Total> &fpregs)
 {
     MachineState machine;
 
     for (unsigned i = 0; i < Registers::Total; i++)
         machine.setRegisterLocation(Register::FromCode(i), &regs[i]);
     for (unsigned i = 0; i < FloatRegisters::Total; i++)
         machine.setRegisterLocation(FloatRegister::FromCode(i), &fpregs[i]);
 
--- a/js/src/jit/LIR-Common.h
+++ b/js/src/jit/LIR-Common.h
@@ -241,17 +241,17 @@ class LCallee : public LInstructionHelpe
   public:
     LIR_HEADER(Callee)
 };
 
 // Base class for control instructions (goto, branch, etc.)
 template <size_t Succs, size_t Operands, size_t Temps>
 class LControlInstructionHelper : public LInstructionHelper<0, Operands, Temps> {
 
-    MBasicBlock *successors_[Succs];
+    mozilla::Array<MBasicBlock *, Succs> successors_;
 
   public:
     virtual size_t numSuccessors() const MOZ_FINAL MOZ_OVERRIDE { return Succs; }
 
     virtual MBasicBlock *getSuccessor(size_t i) const MOZ_FINAL MOZ_OVERRIDE {
         return successors_[i];
     }
 
--- a/js/src/jit/PcScriptCache.h
+++ b/js/src/jit/PcScriptCache.h
@@ -27,17 +27,17 @@ struct PcScriptCache
     static const uint32_t Length = 73;
 
     // GC number at the time the cache was filled or created.
     // Storing and checking against this number allows us to not bother
     // clearing this cache on every GC -- only when actually necessary.
     uint64_t gcNumber;
 
     // List of cache entries.
-    PcScriptCacheEntry entries[Length];
+    mozilla::Array<PcScriptCacheEntry, Length> entries;
 
     void clear(uint64_t gcNumber) {
         for (uint32_t i = 0; i < Length; i++)
             entries[i].returnAddress = nullptr;
         this->gcNumber = gcNumber;
     }
 
     // Get a value from the cache. May perform lazy allocation.
--- a/js/src/jit/Registers.h
+++ b/js/src/jit/Registers.h
@@ -76,18 +76,18 @@ struct FloatRegister {
     bool volatile_() const {
         return !!((1 << code()) & FloatRegisters::VolatileMask);
     }
 };
 
 class RegisterDump
 {
   protected: // Silence Clang warning.
-    uintptr_t regs_[Registers::Total];
-    double fpregs_[FloatRegisters::Total];
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
+    mozilla::Array<double, FloatRegisters::Total> fpregs_;
 
   public:
     static size_t offsetOfRegister(Register reg) {
         return offsetof(RegisterDump, regs_) + reg.code() * sizeof(uintptr_t);
     }
     static size_t offsetOfRegister(FloatRegister reg) {
         return offsetof(RegisterDump, fpregs_) + reg.code() * sizeof(double);
     }
@@ -95,18 +95,18 @@ class RegisterDump
 
 // Information needed to recover machine register state.
 class MachineState
 {
     mozilla::Array<uintptr_t *, Registers::Total> regs_;
     mozilla::Array<double *, FloatRegisters::Total> fpregs_;
 
   public:
-    static MachineState FromBailout(uintptr_t regs[Registers::Total],
-                                    double fpregs[FloatRegisters::Total]);
+    static MachineState FromBailout(mozilla::Array<uintptr_t, Registers::Total> &regs,
+                                    mozilla::Array<double, FloatRegisters::Total> &fpregs);
 
     void setRegisterLocation(Register reg, uintptr_t *up) {
         regs_[reg.code()] = up;
     }
     void setRegisterLocation(FloatRegister reg, double *dp) {
         fpregs_[reg.code()] = dp;
     }
 
--- a/js/src/jit/StupidAllocator.h
+++ b/js/src/jit/StupidAllocator.h
@@ -34,17 +34,17 @@ class StupidAllocator : public RegisterA
         void set(uint32_t vreg, LInstruction *ins = nullptr, bool dirty = false) {
             this->vreg = vreg;
             this->age = ins ? ins->id() : 0;
             this->dirty = dirty;
         }
     };
 
     // Active allocation for the current code position.
-    AllocatedRegister registers[MAX_REGISTERS];
+    mozilla::Array<AllocatedRegister, MAX_REGISTERS> registers;
     uint32_t registerCount;
 
     // Type indicating an index into registers.
     typedef uint32_t RegisterIndex;
 
     // Information about each virtual register.
     Vector<LDefinition*, 0, SystemAllocPolicy> virtualRegisters;
 
--- a/js/src/jit/VMFunctions.h
+++ b/js/src/jit/VMFunctions.h
@@ -255,17 +255,17 @@ struct VMFunctionsModal
     }
 
   private:
     void add(const VMFunction &info) {
         JS_ASSERT((unsigned)info.executionMode < NumExecutionModes);
         funs_[info.executionMode].init(info);
     }
 
-    VMFunction funs_[NumExecutionModes];
+    mozilla::Array<VMFunction, NumExecutionModes> funs_;
 };
 
 template <class> struct TypeToDataType { /* Unexpected return type for a VMFunction. */ };
 template <> struct TypeToDataType<bool> { static const DataType result = Type_Bool; };
 template <> struct TypeToDataType<JSObject *> { static const DataType result = Type_Object; };
 template <> struct TypeToDataType<DeclEnvObject *> { static const DataType result = Type_Object; };
 template <> struct TypeToDataType<JSString *> { static const DataType result = Type_Object; };
 template <> struct TypeToDataType<JSFlatString *> { static const DataType result = Type_Object; };
--- a/js/src/jit/arm/Assembler-arm.h
+++ b/js/src/jit/arm/Assembler-arm.h
@@ -1273,17 +1273,17 @@ class Assembler
     // being written into, but later, we may wish to modify instructions
     // that have already been created.  In order to do this, we call the
     // same assembly function, but pass it a destination address, which
     // will be overwritten with a new instruction. In order to do this very
     // after assembly buffers no longer exist, when calling with a third
     // dest parameter, a this object is still needed.  dummy always happens
     // to be null, but we shouldn't be looking at it in any case.
     static Assembler *dummy;
-    Pool pools_[4];
+    mozilla::Array<Pool, 4> pools_;
     Pool *int32Pool;
     Pool *doublePool;
 
   public:
     Assembler()
       : enoughMemory_(true),
         m_buffer(4, 4, 0, &pools_[0], 8),
         int32Pool(m_buffer.getPool(1)),
@@ -2242,17 +2242,17 @@ class DoubleEncoder {
         DoubleEntry()
           : dblTop(-1)
         { }
         DoubleEntry(uint32_t dblTop_, datastore::Imm8VFPImmData data_)
           : dblTop(dblTop_), data(data_)
         { }
     };
 
-    DoubleEntry table[256];
+    mozilla::Array<DoubleEntry, 256> table;
 
   public:
     DoubleEncoder()
     {
         for (int i = 0; i < 256; i++) {
             table[i] = DoubleEntry(encode(i), datastore::Imm8VFPImmData(i));
         }
     }
--- a/js/src/jit/arm/Bailouts-arm.cpp
+++ b/js/src/jit/arm/Bailouts-arm.cpp
@@ -72,18 +72,18 @@ class BailoutStack
     // with frameClassId_ above.  This should be migrated to ip.
   public:
     union {
         uintptr_t frameSize_;
         uintptr_t tableOffset_;
     };
 
   private:
-    double    fpregs_[FloatRegisters::Total];
-    uintptr_t regs_[Registers::Total];
+    mozilla::Array<double, FloatRegisters::Total fpregs_;
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
 
     uintptr_t snapshotOffset_;
 
   public:
     FrameSizeClass frameClass() const {
         return FrameSizeClass::FromClass(frameClassId_);
     }
     uintptr_t tableOffset() const {
--- a/js/src/jit/arm/IonFrames-arm.h
+++ b/js/src/jit/arm/IonFrames-arm.h
@@ -512,18 +512,18 @@ struct IonDOMMethodExitFrameLayoutTraits
     static const size_t offsetOfArgcFromArgv =
         offsetof(IonDOMMethodExitFrameLayout, argc_) -
         offsetof(IonDOMMethodExitFrameLayout, argv_);
 };
 
 // An invalidation bailout stack is at the stack pointer for the callee frame.
 class InvalidationBailoutStack
 {
-    double      fpregs_[FloatRegisters::Total];
-    uintptr_t   regs_[Registers::Total];
+    mozilla::Array<double, FloatRegisters::Total> fpregs_;
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
     IonScript   *ionScript_;
     uint8_t       *osiPointReturnAddress_;
 
   public:
     uint8_t *sp() const {
         return (uint8_t *) this + sizeof(InvalidationBailoutStack);
     }
     IonJSFrameLayout *fp() const;
--- a/js/src/jit/arm/MacroAssembler-arm.h
+++ b/js/src/jit/arm/MacroAssembler-arm.h
@@ -456,18 +456,18 @@ class MacroAssemblerARMCompat : public M
     uint32_t usedSlots_;
 #endif
     bool dynamicAlignment_;
 
     bool enoughMemory_;
 
     // Used to work around the move resolver's lack of support for
     // moving into register pairs, which the softfp ABI needs.
-    MoveResolver::MoveOperand floatArgsInGPR[2];
-    bool floatArgsInGPRValid[2];
+    mozilla::Array<MoveResolver::MoveOperand, 2> floatArgsInGPR;
+    mozilla::Array<bool, 2> floatArgsInGPRValid;
 
     // Compute space needed for the function call and set the properties of the
     // callee.  It returns the space which has to be allocated for calling the
     // function.
     //
     // arg            Number of arguments of the function.
     void setupABICall(uint32_t arg);
 
--- a/js/src/jit/shared/IonAssemblerBuffer.h
+++ b/js/src/jit/shared/IonAssemblerBuffer.h
@@ -63,17 +63,17 @@ struct BufferSlice {
     BufferSlice *getPrev() { return this->prev; }
     void setNext(BufferSlice<SliceSize> *next_) {
         JS_ASSERT(this->next == nullptr);
         JS_ASSERT(next_->prev == nullptr);
         this->next = next_;
         next_->prev = this;
     }
 
-    uint8_t instructions [SliceSize];
+    mozilla::Array<uint8_t, SliceSize> instructions;
     unsigned int size() {
         return nodeSize;
     }
     BufferSlice() : prev(nullptr), next(nullptr), nodeSize(0) {}
     void putBlob(uint32_t instSize, uint8_t* inst) {
         if (inst != nullptr)
             memcpy(&instructions[size()], inst, instSize);
         nodeSize += instSize;
--- a/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
+++ b/js/src/jit/shared/IonAssemblerBufferWithConstantPools.h
@@ -202,17 +202,17 @@ struct Pool
         return immSize * numEntries;
     }
 };
 
 
 template <int SliceSize, int InstBaseSize>
 struct BufferSliceTail : public BufferSlice<SliceSize> {
     Pool *data;
-    uint8_t isBranch[(SliceSize + (InstBaseSize * 8 - 1)) / (InstBaseSize * 8)];
+    mozilla::Array<uint8_t, (SliceSize + (InstBaseSize * 8 - 1)) / (InstBaseSize * 8)> isBranch;
     bool isNatural : 1;
     BufferSliceTail *getNext() {
         return (BufferSliceTail *)this->next;
     }
     BufferSliceTail() : data(nullptr), isNatural(true) {
         memset(isBranch, 0, sizeof(isBranch));
     }
     void markNextAsBranch() {
@@ -277,17 +277,17 @@ static void spewEntry(uint8_t *ptr, int 
 // Each time a pool entry is added, one of these is generated.
 // This can be supplied to read and write that entry after the fact.
 // And it can be used to get the address of the entry once the buffer
 // has been finalized, and an executable copy allocated.
 
 template <int SliceSize, int InstBaseSize, class Inst, class Asm, int poolKindBits>
 struct AssemblerBufferWithConstantPool : public AssemblerBuffer<SliceSize, Inst> {
   private:
-    int entryCount[1 << poolKindBits];
+    mozilla::Array<int, 1 << poolKindBits> entryCount;
     static const int offsetBits = 32 - poolKindBits;
   public:
 
     class PoolEntry {
         template <int ss, int ibs, class i, class a, int pkb>
         friend struct AssemblerBufferWithConstantPool;
         uint32_t offset_ : offsetBits;
         uint32_t kind_ : poolKindBits;
@@ -400,17 +400,17 @@ struct AssemblerBufferWithConstantPool :
     void executableCopy(uint8_t *dest_) {
         if (this->oom())
             return;
         // TODO: only do this when the pool actually has a value in it
         flushPool();
         for (int idx = 0; idx < numPoolKinds; idx++) {
             JS_ASSERT(pools[idx].numEntries == 0 && pools[idx].other->numEntries == 0);
         }
-        typedef uint8_t Chunk[InstBaseSize];
+        typedef mozilla::Array<uint8_t, InstBaseSize> Chunk;
         mozilla::DebugOnly<Chunk *> start = (Chunk*)dest_;
         Chunk *dest = (Chunk*)(((uint32_t)dest_ + instBufferAlign - 1) & ~(instBufferAlign -1));
         int curIndex = 0;
         int curInstOffset = 0;
         JS_ASSERT(start == dest);
         for (BufferSlice * cur = *getHead(); cur != nullptr; cur = cur->getNext()) {
             Chunk *src = (Chunk*)cur->instructions;
             for (unsigned int idx = 0; idx <cur->size()/InstBaseSize;
@@ -700,18 +700,18 @@ struct AssemblerBufferWithConstantPool :
         int poolOffset = perforation.getOffset();
         int magicAlign = getInfo(numDumps-1).finalPos - getInfo(numDumps-1).offset;
         poolOffset += magicAlign;
         poolOffset += headerSize;
         for (int poolIdx = 0; poolIdx < numPoolKinds; poolIdx++) {
             poolOffset=pools[poolIdx].align(poolOffset);
             poolOffset+=pools[poolIdx].numEntries * pools[poolIdx].immSize;
         }
-        LoadOffsets outcasts[1 << poolKindBits];
-        uint8_t *outcastEntries[1 << poolKindBits];
+        mozilla::Array<LoadOffsets, 1 << poolKindBits> outcasts;
+        mozilla::Array<uint8_t *, 1 << poolKindBits> outcastEntries;
         // All of the pool loads referred to by this code are going to
         // need fixing up here.
         int skippedBytes = 0;
         for (int poolIdx = numPoolKinds-1; poolIdx >= 0; poolIdx--) {
             Pool *p =  pools[poolIdx].other;
             JS_ASSERT(p != nullptr);
             unsigned int idx = p->numEntries-1;
             // Allocate space for tracking information that needs to be propagated to the next pool
--- a/js/src/jit/shared/IonFrames-x86-shared.h
+++ b/js/src/jit/shared/IonFrames-x86-shared.h
@@ -509,18 +509,18 @@ class IonBaselineStubFrameLayout : publi
         uint8_t *fp = reinterpret_cast<uint8_t *>(this);
         return *reinterpret_cast<ICStub **>(fp + reverseOffsetOfStubPtr());
     }
 };
 
 // An invalidation bailout stack is at the stack pointer for the callee frame.
 class InvalidationBailoutStack
 {
-    double      fpregs_[FloatRegisters::Total];
-    uintptr_t   regs_[Registers::Total];
+    mozilla::Array<double, FloatRegisters::Total> fpregs_;
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
     IonScript   *ionScript_;
     uint8_t       *osiPointReturnAddress_;
 
   public:
     uint8_t *sp() const {
         return (uint8_t *) this + sizeof(InvalidationBailoutStack);
     }
     IonJSFrameLayout *fp() const;
--- a/js/src/jit/x64/Bailouts-x64.cpp
+++ b/js/src/jit/x64/Bailouts-x64.cpp
@@ -13,18 +13,18 @@ using namespace js::jit;
 # pragma pack(push, 1)
 #endif
 
 namespace js {
 namespace jit {
 
 class BailoutStack
 {
-    double    fpregs_[FloatRegisters::Total];
-    uintptr_t regs_[Registers::Total];
+    mozilla::Array<double, FloatRegisters::Total> fpregs_;
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
     uintptr_t frameSize_;
     uintptr_t snapshotOffset_;
 
   public:
     MachineState machineState() {
         return MachineState::FromBailout(regs_, fpregs_);
     }
     uint32_t snapshotOffset() const {
--- a/js/src/jit/x86/Bailouts-x86.cpp
+++ b/js/src/jit/x86/Bailouts-x86.cpp
@@ -18,18 +18,18 @@ using namespace js::jit;
 #endif
 
 namespace js {
 namespace jit {
 
 class BailoutStack
 {
     uintptr_t frameClassId_;
-    double    fpregs_[FloatRegisters::Total];
-    uintptr_t regs_[Registers::Total];
+    mozilla::Array<double, FloatRegisters::Total> fpregs_;
+    mozilla::Array<uintptr_t, Registers::Total> regs_;
     union {
         uintptr_t frameSize_;
         uintptr_t tableOffset_;
     };
     uintptr_t snapshotOffset_;
 
   public:
     FrameSizeClass frameClass() const {