Bug 1245171 - Ensure enough ballast space in js::jit::AddKeepAliveInstructions. r=jandem
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Wed, 17 Feb 2016 18:12:14 +0000
changeset 320941 4ec66e6db2d2df54f1fa61b093c11e385f5c2860
parent 320940 93e0395f69fbe1242899b5e54610f4ad2d80ad27
child 320942 cfa9883c56b6e8654afd47d5f6f158bda7cbb096
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1245171
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 1245171 - Ensure enough ballast space in js::jit::AddKeepAliveInstructions. r=jandem
js/src/jit/Ion.cpp
js/src/jit/IonAnalysis.cpp
js/src/jit/IonAnalysis.h
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -1864,17 +1864,18 @@ OptimizeMIR(MIRGenerator* mir)
         if (!EliminateRedundantChecks(graph))
             return false;
         gs.spewPass("Bounds Check Elimination");
         AssertGraphCoherency(graph);
     }
 
     if (!mir->compilingAsmJS()) {
         AutoTraceLog log(logger, TraceLogger_AddKeepAliveInstructions);
-        AddKeepAliveInstructions(graph);
+        if (!AddKeepAliveInstructions(graph))
+            return false;
         gs.spewPass("Add KeepAlive Instructions");
         AssertGraphCoherency(graph);
     }
 
     return true;
 }
 
 LIRGraph*
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -3179,17 +3179,17 @@ NeedsKeepAlive(MInstruction* slotsOrElem
           default:
             return true;
         }
     }
 
     MOZ_CRASH("Unreachable");
 }
 
-void
+bool
 jit::AddKeepAliveInstructions(MIRGraph& graph)
 {
     for (MBasicBlockIterator i(graph.begin()); i != graph.end(); i++) {
         MBasicBlock* block = *i;
 
         for (MInstructionIterator insIter(block->begin()); insIter != block->end(); insIter++) {
             MInstruction* ins = *insIter;
             if (ins->type() != MIRType_Elements && ins->type() != MIRType_Slots)
@@ -3241,21 +3241,25 @@ jit::AddKeepAliveInstructions(MIRGraph& 
                     MOZ_ASSERT_IF(!use->toInArray()->object()->isUnbox() && !ownerObject->isUnbox(),
                                   use->toInArray()->object() == ownerObject);
                     continue;
                 }
 
                 if (!NeedsKeepAlive(ins, use))
                     continue;
 
+                if (!graph.alloc().ensureBallast())
+                    return false;
                 MKeepAliveObject* keepAlive = MKeepAliveObject::New(graph.alloc(), ownerObject);
                 use->block()->insertAfter(use, keepAlive);
             }
         }
     }
+
+    return true;
 }
 
 bool
 LinearSum::multiply(int32_t scale)
 {
     for (size_t i = 0; i < terms_.length(); i++) {
         if (!SafeMul(scale, terms_[i].scale, &terms_[i].scale))
             return false;
--- a/js/src/jit/IonAnalysis.h
+++ b/js/src/jit/IonAnalysis.h
@@ -81,17 +81,17 @@ void
 AssertGraphCoherency(MIRGraph& graph);
 
 void
 AssertExtendedGraphCoherency(MIRGraph& graph);
 
 bool
 EliminateRedundantChecks(MIRGraph& graph);
 
-void
+bool
 AddKeepAliveInstructions(MIRGraph& graph);
 
 class MDefinition;
 
 // Simple linear sum of the form 'n' or 'x + n'.
 struct SimpleLinearSum
 {
     MDefinition* term;