Bug 1244828 - Ensure enough ballast space in TypeAnalyzer::adjustPhiInputs. r=h4writer
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 11 Feb 2016 17:50:52 +0000
changeset 283966 db1d8b455d542bfea1cbc3242aba1564d693975f
parent 283965 fdbd942a9cac3bd39681d6de46ba5b8f9f8a2ba5
child 283967 ecae2990b06807d8ce7c1d4761f6569f29a6af9f
push id71766
push usernpierron@mozilla.com
push dateThu, 11 Feb 2016 17:51:03 +0000
treeherdermozilla-inbound@26277a6d10fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1244828
milestone47.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 1244828 - Ensure enough ballast space in TypeAnalyzer::adjustPhiInputs. r=h4writer
js/src/jit/IonAnalysis.cpp
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -1188,17 +1188,17 @@ class TypeAnalyzer
         phi->setNotInWorklist();
         return phi;
     }
 
     bool respecialize(MPhi* phi, MIRType type);
     bool propagateSpecialization(MPhi* phi);
     bool specializePhis();
     void replaceRedundantPhi(MPhi* phi);
-    void adjustPhiInputs(MPhi* phi);
+    bool adjustPhiInputs(MPhi* phi);
     bool adjustInputs(MDefinition* def);
     bool insertConversions();
 
     bool checkFloatCoherency();
     bool graphContainsFloat32();
     bool markPhiConsumers();
     bool markPhiProducers();
     bool specializeValidFloatOps();
@@ -1403,32 +1403,35 @@ TypeAnalyzer::specializePhis()
                     return false;
             }
         }
     } while (!phiWorklist_.empty());
 
     return true;
 }
 
-void
+bool
 TypeAnalyzer::adjustPhiInputs(MPhi* phi)
 {
     MIRType phiType = phi->type();
     MOZ_ASSERT(phiType != MIRType_None);
 
     // If we specialized a type that's not Value, there are 3 cases:
     // 1. Every input is of that type.
     // 2. Every observed input is of that type (i.e., some inputs haven't been executed yet).
     // 3. Inputs were doubles and int32s, and was specialized to double.
     if (phiType != MIRType_Value) {
         for (size_t i = 0, e = phi->numOperands(); i < e; i++) {
             MDefinition* in = phi->getOperand(i);
             if (in->type() == phiType)
                 continue;
 
+            if (!alloc().ensureBallast())
+                return false;
+
             if (in->isBox() && in->toBox()->input()->type() == phiType) {
                 phi->replaceOperand(i, in->toBox()->input());
             } else {
                 MInstruction* replacement;
 
                 if (phiType == MIRType_Double && IsFloatType(in->type())) {
                     // Convert int32 operands to double.
                     replacement = MToDouble::New(alloc(), in);
@@ -1462,34 +1465,39 @@ TypeAnalyzer::adjustPhiInputs(MPhi* phi)
                     replacement = MUnbox::New(alloc(), in, phiType, MUnbox::Fallible);
                 }
 
                 in->block()->insertBefore(in->block()->lastIns(), replacement);
                 phi->replaceOperand(i, replacement);
             }
         }
 
-        return;
+        return true;
     }
 
     // Box every typed input.
     for (size_t i = 0, e = phi->numOperands(); i < e; i++) {
         MDefinition* in = phi->getOperand(i);
         if (in->type() == MIRType_Value)
             continue;
 
         if (in->isUnbox() && phi->typeIncludes(in->toUnbox()->input())) {
             // The input is being explicitly unboxed, so sneak past and grab
             // the original box.
             phi->replaceOperand(i, in->toUnbox()->input());
         } else {
+            if (!alloc().ensureBallast())
+                return false;
+
             MDefinition* box = AlwaysBoxAt(alloc(), in->block()->lastIns(), in);
             phi->replaceOperand(i, box);
         }
     }
+
+    return true;
 }
 
 bool
 TypeAnalyzer::adjustInputs(MDefinition* def)
 {
     // Definitions such as MPhi have no type policy.
     if (!def->isInstruction())
         return true;
@@ -1547,17 +1555,18 @@ TypeAnalyzer::insertConversions()
                 phi->type() == MIRType_Null ||
                 phi->type() == MIRType_MagicOptimizedArguments ||
                 phi->type() == MIRType_MagicOptimizedOut ||
                 phi->type() == MIRType_MagicUninitializedLexical)
             {
                 replaceRedundantPhi(phi);
                 block->discardPhi(phi);
             } else {
-                adjustPhiInputs(phi);
+                if (!adjustPhiInputs(phi))
+                    return false;
             }
         }
 
         // AdjustInputs can add/remove/mutate instructions before and after the
         // current instruction. Only increment the iterator after it is finished.
         for (MInstructionIterator iter(block->begin()); iter != block->end(); iter++) {
             if (!alloc().ensureBallast())
                 return false;