Bug 1125734 - IonMonkey: Completely disable the MakeLoopsContiguous optimization for loops made unnatural by OSR r=jandem
authorDan Gohman <sunfish@mozilla.com>
Tue, 27 Jan 2015 16:28:07 -0800
changeset 239527 ec859a233c28e28e1f7144fdd9b17a4a22fcbb4f
parent 239526 b4eb1cc07186dbf7e029103d74b476bf552ca3e1
child 239528 fe0a5e20d1f46a7529418d3a8c10a1a25bd751f9
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewersjandem
bugs1125734
milestone38.0a1
Bug 1125734 - IonMonkey: Completely disable the MakeLoopsContiguous optimization for loops made unnatural by OSR r=jandem
js/src/jit/IonAnalysis.cpp
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -3477,52 +3477,38 @@ MakeLoopContiguous(MIRGraph &graph, MBas
     ReversePostorderIterator insertIter = graph.rpoBegin(backedge);
     insertIter++;
     MBasicBlock *insertPt = *insertIter;
 
     // Visit all the blocks from the loop header to the loop backedge.
     size_t headerId = header->id();
     size_t inLoopId = headerId;
     size_t notInLoopId = inLoopId + numMarked;
-    size_t numOSRDominated = 0;
     ReversePostorderIterator i = graph.rpoBegin(header);
-    MBasicBlock *osrBlock = graph.osrBlock();
     for (;;) {
         MBasicBlock *block = *i++;
         MOZ_ASSERT(block->id() >= header->id() && block->id() <= backedge->id(),
                    "Loop backedge should be last block in loop");
 
         if (block->isMarked()) {
             // This block is in the loop.
             block->unmark();
             block->setId(inLoopId++);
             // If we've reached the loop backedge, we're done!
             if (block == backedge)
                 break;
-        } else if (osrBlock && osrBlock->dominates(block)) {
-            // This block is not in the loop, but since it's dominated by the
-            // OSR entry, the block was probably in the loop before some
-            // folding. This probably means that the block has outgoing paths
-            // which re-enter the loop in the middle. And that, finally, means
-            // that we can't move this block to the end, since it could create a
-            // backwards branch to a block which is not the loop header.
-            block->setId(inLoopId++);
-            ++numOSRDominated;
         } else {
             // This block is not in the loop. Move it to the end.
             graph.moveBlockBefore(insertPt, block);
             block->setId(notInLoopId++);
         }
     }
     MOZ_ASSERT(header->id() == headerId, "Loop header id changed");
-    MOZ_ASSERT(inLoopId == headerId + numMarked + numOSRDominated,
-               "Wrong number of blocks kept in loop");
-    MOZ_ASSERT(notInLoopId == (insertIter != graph.rpoEnd()
-                               ? insertPt->id()
-                               : graph.numBlocks()) - numOSRDominated,
+    MOZ_ASSERT(inLoopId == headerId + numMarked, "Wrong number of blocks kept in loop");
+    MOZ_ASSERT(notInLoopId == (insertIter != graph.rpoEnd() ? insertPt->id() : graph.numBlocks()),
                "Wrong number of blocks moved out of loop");
 }
 
 // Reorder the blocks in the graph so that loops are contiguous.
 bool
 jit::MakeLoopsContiguous(MIRGraph &graph)
 {
     // Visit all loop headers (in any order).
@@ -3534,15 +3520,22 @@ jit::MakeLoopsContiguous(MIRGraph &graph
         // Mark all blocks that are actually part of the loop.
         bool canOsr;
         size_t numMarked = MarkLoopBlocks(graph, header, &canOsr);
 
         // If the loop isn't a loop, don't try to optimize it.
         if (numMarked == 0)
             continue;
 
+        // If there's an OSR block entering the loop in the middle, it's tricky,
+        // so don't try to handle it, for now.
+        if (canOsr) {
+            UnmarkLoopBlocks(graph, header);
+            continue;
+        }
+
         // Move all blocks between header and backedge that aren't marked to
         // the end of the loop, making the loop itself contiguous.
         MakeLoopContiguous(graph, header, numMarked);
     }
 
     return true;
 }