Bug 1322724: IonMonkey - Add the hit count information on the extra false branch blocks, r=jandem
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -1500,16 +1500,21 @@ IonBuilder::visitBlock(const CFGBlock* c
mblock->setLoopDepth(loopDepth_);
cfgCurrent = cfgblock;
pc = cfgblock->startPc();
if (mblock->pc() && script()->hasScriptCounts())
mblock->setHitCount(script()->getHitCount(mblock->pc()));
+ // Optimization to move a predecessor that only has this block as successor
+ // just before this block.
+ if (mblock->numPredecessors() == 1 && mblock->getPredecessor(0)->numSuccessors() == 1)
+ graph().moveBlockToEnd(mblock->getPredecessor(0));
+
if (!setCurrentAndSpecializePhis(mblock))
return false;
graph().addBlock(mblock);
while (pc < cfgblock->stopPc()) {
if (!alloc().ensureBallast()) {
abortReason_ = AbortReason_Alloc;
return false;
@@ -2841,16 +2846,19 @@ IonBuilder::visitTest(CFGTest* test)
if (!improveTypesAtTest(mir->getOperand(0), /* trueBranch = */ false, mir))
return false;
ifFalse = newBlock(filterBlock, test->falseBranch()->startPc());
if (!ifFalse)
return false;
filterBlock->end(MGoto::New(alloc(), ifFalse));
+ if (filterBlock->pc() && script()->hasScriptCounts())
+ filterBlock->setHitCount(script()->getHitCount(filterBlock->pc()));
+
blockWorklist[test->falseBranch()->id()] = ifFalse;
current = nullptr;
return true;
}
bool
@@ -3074,16 +3082,19 @@ IonBuilder::visitTableSwitch(CFGTableSwi
if (ins != caseBlock->getSlot(j))
continue;
constant->setDependency(ins);
caseBlock->setSlot(j, constant);
}
graph().addBlock(caseBlock);
+ if (caseBlock->pc() && script()->hasScriptCounts())
+ caseBlock->setHitCount(script()->getHitCount(caseBlock->pc()));
+
MBasicBlock* merge = newBlock(caseBlock, cfgblock->startPc());
if (!merge)
return false;
caseBlock->end(MGoto::New(alloc(), merge));
blockWorklist[cfgblock->id()] = merge;
}