From 7077033e4af72666bf461b74c83174dfcedfa034 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Sat, 16 Nov 2013 10:15:30 +0100 Subject: [PATCH] Bug 937540 part 2 - Use placement new for BitSet and LoopAliasInfo. r=sstangl --- js/src/jit/AliasAnalysis.cpp | 2 +- js/src/jit/AliasAnalysis.h | 3 ++- js/src/jit/BitSet.cpp | 11 +++++------ js/src/jit/BitSet.h | 4 ++-- js/src/jit/CodeGenerator.cpp | 2 +- js/src/jit/LiveRangeAllocator.cpp | 4 ++-- js/src/jit/Safepoints.cpp | 4 ++-- js/src/jit/Safepoints.h | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/js/src/jit/AliasAnalysis.cpp b/js/src/jit/AliasAnalysis.cpp index 3d2123c4fed..1ee52ea862b 100644 --- a/js/src/jit/AliasAnalysis.cpp +++ b/js/src/jit/AliasAnalysis.cpp @@ -148,7 +148,7 @@ AliasAnalysis::analyze() if (block->isLoopHeader()) { IonSpew(IonSpew_Alias, "Processing loop header %d", block->id()); - loop_ = new LoopAliasInfo(loop_, *block); + loop_ = new(mir->temp()) LoopAliasInfo(loop_, *block); } for (MDefinitionIterator def(*block); def; def++) { diff --git a/js/src/jit/AliasAnalysis.h b/js/src/jit/AliasAnalysis.h index 12da273848a..bff9b669a46 100644 --- a/js/src/jit/AliasAnalysis.h +++ b/js/src/jit/AliasAnalysis.h @@ -17,7 +17,8 @@ class MIRGraph; typedef Vector InstructionVector; -class LoopAliasInfo : public TempObject { +class LoopAliasInfo : public TempObject +{ private: LoopAliasInfo *outer_; MBasicBlock *loopHeader_; diff --git a/js/src/jit/BitSet.cpp b/js/src/jit/BitSet.cpp index 48b56e9f089..c320ac8574e 100644 --- a/js/src/jit/BitSet.cpp +++ b/js/src/jit/BitSet.cpp @@ -10,21 +10,20 @@ using namespace js; using namespace js::jit; BitSet * -BitSet::New(unsigned int max) +BitSet::New(TempAllocator &alloc, unsigned int max) { - BitSet *result = new BitSet(max); - if (!result->init()) + BitSet *result = new(alloc) BitSet(max); + if (!result->init(alloc)) return nullptr; return result; } bool -BitSet::init() +BitSet::init(TempAllocator &alloc) { size_t sizeRequired = numWords() * sizeof(*bits_); - TempAllocator *alloc = GetIonContext()->temp; - bits_ = (uint32_t *)alloc->allocate(sizeRequired); + bits_ = (uint32_t *)alloc.allocate(sizeRequired); if (!bits_) return false; diff --git a/js/src/jit/BitSet.h b/js/src/jit/BitSet.h index 5bce72390db..730557be1ef 100644 --- a/js/src/jit/BitSet.h +++ b/js/src/jit/BitSet.h @@ -44,12 +44,12 @@ class BitSet : private TempObject return RawLengthForBits(max_); } - bool init(); + bool init(TempAllocator &alloc); public: class Iterator; - static BitSet *New(unsigned int max); + static BitSet *New(TempAllocator &alloc, unsigned int max); unsigned int getMax() const { return max_; diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index be0bf7e4f90..b86761644fa 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -5700,7 +5700,7 @@ CodeGenerator::generate() gen->info().script()->filename(), gen->info().script()->lineno); - if (!safepoints_.init(graph.totalSlotCount())) + if (!safepoints_.init(gen->temp(), graph.totalSlotCount())) return false; #if JS_TRACE_LOGGING diff --git a/js/src/jit/LiveRangeAllocator.cpp b/js/src/jit/LiveRangeAllocator.cpp index e4e7e56b6df..d556e479590 100644 --- a/js/src/jit/LiveRangeAllocator.cpp +++ b/js/src/jit/LiveRangeAllocator.cpp @@ -491,7 +491,7 @@ LiveRangeAllocator::buildLivenessInfo() return false; Vector loopWorkList; - BitSet *loopDone = BitSet::New(graph.numBlockIds()); + BitSet *loopDone = BitSet::New(alloc(), graph.numBlockIds()); if (!loopDone) return false; @@ -502,7 +502,7 @@ LiveRangeAllocator::buildLivenessInfo() LBlock *block = graph.getBlock(i - 1); MBasicBlock *mblock = block->mir(); - BitSet *live = BitSet::New(graph.numVirtualRegisters()); + BitSet *live = BitSet::New(alloc(), graph.numVirtualRegisters()); if (!live) return false; liveIn[mblock->id()] = live; diff --git a/js/src/jit/Safepoints.cpp b/js/src/jit/Safepoints.cpp index ef0039aa871..125d35acb01 100644 --- a/js/src/jit/Safepoints.cpp +++ b/js/src/jit/Safepoints.cpp @@ -18,9 +18,9 @@ using namespace jit; using mozilla::FloorLog2; bool -SafepointWriter::init(uint32_t slotCount) +SafepointWriter::init(TempAllocator &alloc, uint32_t slotCount) { - frameSlots_ = BitSet::New(slotCount); + frameSlots_ = BitSet::New(alloc, slotCount); if (!frameSlots_) return false; diff --git a/js/src/jit/Safepoints.h b/js/src/jit/Safepoints.h index d8d488a07d0..c151634452a 100644 --- a/js/src/jit/Safepoints.h +++ b/js/src/jit/Safepoints.h @@ -26,7 +26,7 @@ class SafepointWriter BitSet *frameSlots_; public: - bool init(uint32_t slotCount); + bool init(TempAllocator &alloc, uint32_t slotCount); private: // A safepoint entry is written in the order these functions appear.