Bug 1322724: IonMonkey - Add the hit count information on the extra false branch blocks, r=jandem
authorHannes Verschore <hv1989@gmail.com>
Fri, 09 Dec 2016 14:14:37 -1000
changeset 325622 b877875abb3afc917bef6a2a14d39449eaf53ccd
parent 325621 b1d7f3640ea7b8c7004d50d0001845564c6f71df
child 325623 edb24e0ff1e147e44f042f8d0dccf59eac6f6de0
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjandem
bugs1322724
milestone53.0a1
Bug 1322724: IonMonkey - Add the hit count information on the extra false branch blocks, r=jandem
js/src/jit/IonBuilder.cpp
--- 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;
         }