Bug 1264948 - MBasicBlock::addPredecessor, check for OOMs when allocating Phi nodes. r=h4writer
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Mon, 20 Jun 2016 13:54:08 +0000
changeset 302089 88336c73abae97f9f122e6ebd8db2e93797b29d3
parent 302088 42b04c4bae8f414001d848aa17cc0290938c3413
child 302090 8b1a20de30f9694f851178a4caeed8c56d3f3903
push id78584
push usernpierron@mozilla.com
push dateMon, 20 Jun 2016 13:54:38 +0000
treeherdermozilla-inbound@ab5f00905c50 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1264948
milestone50.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 1264948 - MBasicBlock::addPredecessor, check for OOMs when allocating Phi nodes. r=h4writer
js/src/jit/MIR.h
js/src/jit/MIRGraph.cpp
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -7151,16 +7151,19 @@ class MPhi final
 #endif
     {
         setResultType(resultType);
     }
 
     static MPhi* New(TempAllocator& alloc, MIRType resultType = MIRType::Value) {
         return new(alloc) MPhi(alloc, resultType);
     }
+    static MPhi* New(TempAllocator::Fallible alloc, MIRType resultType = MIRType::Value) {
+        return new(alloc) MPhi(alloc.alloc, resultType);
+    }
 
     void removeOperand(size_t index);
     void removeAllOperands();
 
     MDefinition* getOperand(size_t index) const override {
         return inputs_[index].producer();
     }
     size_t numOperands() const override {
--- a/js/src/jit/MIRGraph.cpp
+++ b/js/src/jit/MIRGraph.cpp
@@ -1188,19 +1188,21 @@ MBasicBlock::addPredecessorPopN(TempAllo
             if (mine->isPhi() && mine->block() == this) {
                 MOZ_ASSERT(predecessors_.length());
                 if (!mine->toPhi()->addInputSlow(other))
                     return false;
             } else {
                 // Otherwise, create a new phi node.
                 MPhi* phi;
                 if (mine->type() == other->type())
-                    phi = MPhi::New(alloc, mine->type());
+                    phi = MPhi::New(alloc.fallible(), mine->type());
                 else
-                    phi = MPhi::New(alloc);
+                    phi = MPhi::New(alloc.fallible());
+                if (!phi)
+                    return false;
                 addPhi(phi);
 
                 // Prime the phi for each predecessor, so input(x) comes from
                 // predecessor(x).
                 if (!phi->reserveLength(predecessors_.length() + 1))
                     return false;
 
                 for (size_t j = 0, numPreds = predecessors_.length(); j < numPreds; ++j) {