Modified: trunk/Source/_javascript_Core/ChangeLog (192528 => 192529)
--- trunk/Source/_javascript_Core/ChangeLog 2015-11-17 21:31:57 UTC (rev 192528)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-11-17 21:41:43 UTC (rev 192529)
@@ -1,3 +1,22 @@
+2015-11-17 Filip Pizlo <fpi...@apple.com>
+
+ It's best for the DFG to always have some guess of basic block frequency
+ https://bugs.webkit.org/show_bug.cgi?id=151350
+
+ Reviewed by Geoffrey Garen.
+
+ It'll simplify things for B3 if we always have some estimate of block frequency, even if it's not
+ a great estimate. Using NaN as an estimate is probably worse than using any non-NaN number.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::inlineCall):
+ (JSC::DFG::ByteCodeParser::handleInlining):
+ (JSC::DFG::ByteCodeParser::parseCodeBlock):
+ * dfg/DFGCriticalEdgeBreakingPhase.cpp:
+ (JSC::DFG::CriticalEdgeBreakingPhase::breakCriticalEdge):
+ * dfg/DFGLoopPreHeaderCreationPhase.cpp:
+ (JSC::DFG::createPreHeader):
+
2015-11-17 Michael Saboff <msab...@apple.com>
Reserved VM pool established in r187125 is likely too conservative
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (192528 => 192529)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-11-17 21:31:57 UTC (rev 192528)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-11-17 21:41:43 UTC (rev 192529)
@@ -1505,7 +1505,7 @@
ASSERT(lastBlock->terminal());
// Need to create a new basic block for the continuation at the caller.
- RefPtr<BasicBlock> block = adoptRef(new BasicBlock(nextOffset, m_numArguments, m_numLocals, PNaN));
+ RefPtr<BasicBlock> block = adoptRef(new BasicBlock(nextOffset, m_numArguments, m_numLocals, 1));
// Link the early returns to the basic block we're about to create.
for (size_t i = 0; i < inlineStackEntry.m_unlinkedBlocks.size(); ++i) {
@@ -1848,7 +1848,7 @@
for (unsigned i = 0; i < callLinkStatus.size(); ++i) {
m_currentIndex = oldOffset;
- RefPtr<BasicBlock> block = adoptRef(new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, PNaN));
+ RefPtr<BasicBlock> block = adoptRef(new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, 1));
m_currentBlock = block.get();
m_graph.appendBlock(block);
prepareToParseBlock();
@@ -1899,7 +1899,7 @@
}
RefPtr<BasicBlock> slowPathBlock = adoptRef(
- new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, PNaN));
+ new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, 1));
m_currentIndex = oldOffset;
m_exitOK = true;
data.fallThrough = BranchTarget(slowPathBlock.get());
@@ -1933,7 +1933,7 @@
}
RefPtr<BasicBlock> continuationBlock = adoptRef(
- new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, PNaN));
+ new BasicBlock(UINT_MAX, m_numArguments, m_numLocals, 1));
m_graph.appendBlock(continuationBlock);
if (verbose)
dataLog("Adding unlinked block ", RawPointer(continuationBlock.get()), " (continuation)\n");
@@ -4895,7 +4895,7 @@
m_currentBlock = m_graph.lastBlock();
m_currentBlock->bytecodeBegin = m_currentIndex;
} else {
- RefPtr<BasicBlock> block = adoptRef(new BasicBlock(m_currentIndex, m_numArguments, m_numLocals, PNaN));
+ RefPtr<BasicBlock> block = adoptRef(new BasicBlock(m_currentIndex, m_numArguments, m_numLocals, 1));
m_currentBlock = block.get();
// This assertion checks two things:
// 1) If the bytecodeBegin is greater than currentIndex, then something has gone
Modified: trunk/Source/_javascript_Core/dfg/DFGCriticalEdgeBreakingPhase.cpp (192528 => 192529)
--- trunk/Source/_javascript_Core/dfg/DFGCriticalEdgeBreakingPhase.cpp 2015-11-17 21:31:57 UTC (rev 192528)
+++ trunk/Source/_javascript_Core/dfg/DFGCriticalEdgeBreakingPhase.cpp 2015-11-17 21:41:43 UTC (rev 192529)
@@ -73,9 +73,7 @@
private:
void breakCriticalEdge(BasicBlock* predecessor, BasicBlock** successor)
{
- // Note that we pass NaN for the count of the critical edge block, because we honestly
- // don't know its execution frequency.
- BasicBlock* pad = m_insertionSet.insertBefore(*successor, PNaN);
+ BasicBlock* pad = m_insertionSet.insertBefore(*successor, (*successor)->executionCount);
pad->appendNode(
m_graph, SpecNone, Jump, (*successor)->at(0)->origin, OpInfo(*successor));
pad->predecessors.append(predecessor);
Modified: trunk/Source/_javascript_Core/dfg/DFGLoopPreHeaderCreationPhase.cpp (192528 => 192529)
--- trunk/Source/_javascript_Core/dfg/DFGLoopPreHeaderCreationPhase.cpp 2015-11-17 21:31:57 UTC (rev 192528)
+++ trunk/Source/_javascript_Core/dfg/DFGLoopPreHeaderCreationPhase.cpp 2015-11-17 21:41:43 UTC (rev 192529)
@@ -64,10 +64,17 @@
// SSACalculator and treating the Upsilons as Defs and rebuilding the Phis from scratch.
//
// https://bugs.webkit.org/show_bug.cgi?id=148587
-
- // Don't bother to preserve execution frequencies for now.
- BasicBlock* preHeader = insertionSet.insertBefore(block, PNaN);
+ // Determine a good frequency for the pre-header. It's definitely not the frequency of the loop body.
+ // Instead, we use the max of the frequencies of the loop body's non-loop predecessors.
+ float frequency = 0;
+ for (BasicBlock* predecessor : block->predecessors) {
+ if (graph.m_dominators->dominates(block, predecessor))
+ continue;
+ frequency = std::max(frequency, predecessor->executionCount);
+ }
+ BasicBlock* preHeader = insertionSet.insertBefore(block, frequency);
+
// FIXME: It would be great if we put some effort into enabling exitOK at this origin, if it
// happens to be unset. It might not be set because the loop header (i.e. "block") has Phis in it.
// Phis have to have exitOK=false. There are a few ways to try to set exitOK: