Bug 937540 part 4 - Use placement new for MBasicBlock. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 16 Nov 2013 10:15:35 +0100
changeset 154955 fc55a33f6b3f6c4588ecc15aa906b62e777a4853
parent 154954 4d4d4d111dfd630a0ddf3ea76c31547810c66600
child 154956 5dd82c64f4b7d165e479a39882404a85612994d3
push id25657
push userMs2ger@gmail.com
push dateSun, 17 Nov 2013 13:24:50 +0000
treeherdermozilla-central@0e88f511e067 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs937540
milestone28.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 937540 part 4 - Use placement new for MBasicBlock. r=djvj
js/src/jit/MIR.h
js/src/jit/MIRGraph.cpp
js/src/jit/MIRGraph.h
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -100,20 +100,16 @@ class MUse : public TempObject, public I
     { }
 
   public:
     // Default constructor for use in vectors.
     MUse()
       : producer_(nullptr), consumer_(nullptr), index_(0)
     { }
 
-    static inline MUse *New(MDefinition *producer, MNode *consumer, uint32_t index) {
-        return new MUse(producer, consumer, index);
-    }
-
     // Set data inside the MUse.
     void set(MDefinition *producer, MNode *consumer, uint32_t index) {
         producer_ = producer;
         consumer_ = consumer;
         index_ = index;
     }
 
     MDefinition *producer() const {
--- a/js/src/jit/MIRGraph.cpp
+++ b/js/src/jit/MIRGraph.cpp
@@ -155,46 +155,46 @@ MIRGraph::forkJoinSlice()
 }
 
 MBasicBlock *
 MBasicBlock::New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info,
                  MBasicBlock *pred, jsbytecode *entryPc, Kind kind)
 {
     JS_ASSERT(entryPc != nullptr);
 
-    MBasicBlock *block = new MBasicBlock(graph, info, entryPc, kind);
+    MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, entryPc, kind);
     if (!block->init())
         return nullptr;
 
     if (!block->inherit(analysis, pred, 0))
         return nullptr;
 
     return block;
 }
 
 MBasicBlock *
 MBasicBlock::NewPopN(MIRGraph &graph, CompileInfo &info,
                      MBasicBlock *pred, jsbytecode *entryPc, Kind kind, uint32_t popped)
 {
-    MBasicBlock *block = new MBasicBlock(graph, info, entryPc, kind);
+    MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, entryPc, kind);
     if (!block->init())
         return nullptr;
 
     if (!block->inherit(nullptr, pred, popped))
         return nullptr;
 
     return block;
 }
 
 MBasicBlock *
 MBasicBlock::NewWithResumePoint(MIRGraph &graph, CompileInfo &info,
                                 MBasicBlock *pred, jsbytecode *entryPc,
                                 MResumePoint *resumePoint)
 {
-    MBasicBlock *block = new MBasicBlock(graph, info, entryPc, NORMAL);
+    MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, entryPc, NORMAL);
 
     resumePoint->block_ = block;
     block->entryResumePoint_ = resumePoint;
 
     if (!block->init())
         return nullptr;
 
     if (!block->inheritResumePoint(pred))
@@ -218,17 +218,17 @@ MBasicBlock::NewSplitEdge(MIRGraph &grap
            : MBasicBlock::NewAsmJS(graph, info, pred, SPLIT_EDGE);
 }
 
 MBasicBlock *
 MBasicBlock::NewAbortPar(MIRGraph &graph, CompileInfo &info,
                          MBasicBlock *pred, jsbytecode *entryPc,
                          MResumePoint *resumePoint)
 {
-    MBasicBlock *block = new MBasicBlock(graph, info, entryPc, NORMAL);
+    MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, entryPc, NORMAL);
 
     resumePoint->block_ = block;
     block->entryResumePoint_ = resumePoint;
 
     if (!block->init())
         return nullptr;
 
     if (!block->addPredecessorWithoutPhis(pred))
@@ -236,17 +236,17 @@ MBasicBlock::NewAbortPar(MIRGraph &graph
 
     block->end(new MAbortPar());
     return block;
 }
 
 MBasicBlock *
 MBasicBlock::NewAsmJS(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, Kind kind)
 {
-    MBasicBlock *block = new MBasicBlock(graph, info, /* entryPC = */ nullptr, kind);
+    MBasicBlock *block = new(graph.alloc()) MBasicBlock(graph, info, /* entryPC = */ nullptr, kind);
     if (!block->init())
         return nullptr;
 
     if (pred) {
         block->stackPosition_ = pred->stackPosition_;
 
         if (block->kind_ == PENDING_LOOP_HEADER) {
             for (size_t i = 0; i < block->stackPosition_; i++) {
--- a/js/src/jit/MIRGraph.h
+++ b/js/src/jit/MIRGraph.h
@@ -554,16 +554,20 @@ class MIRGraph
         blockIdGen_(0),
         idGen_(0),
         osrBlock_(nullptr),
         osrStart_(nullptr),
         numBlocks_(0),
         hasTryBlock_(false)
     { }
 
+    TempAllocator &alloc() const {
+        return *alloc_;
+    }
+
     template <typename T>
     T * allocate(size_t count = 1) {
         return reinterpret_cast<T *>(alloc_->allocate(sizeof(T) * count));
     }
 
     void addBlock(MBasicBlock *block);
     void insertBlockAfter(MBasicBlock *at, MBasicBlock *block);