Bug 1125734 - IonMonkey: Completely disable the MakeLoopsContiguous optimization for loops made unnatural by OSR r=jandem
--- 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;
}