Ignore:
Timestamp:
Mar 7, 2013, 3:11:22 PM (12 years ago)
Author:
[email protected]
Message:

The DFG fixpoint is not strictly profitable, and should be straight-lined
https://bugs.webkit.org/show_bug.cgi?id=111764

Reviewed by Oliver Hunt and Geoffrey Garen.

The DFG previously ran optimizations to fixpoint because there exists a circular dependency:

CSE depends on CFG simplification: CFG simplification merges blocks, and CSE is block-local.

CFG simplification depends on CFA and constant folding: constant folding reveals branches on
constants.

CFA depends on CSE: CSE reveals must-alias relationships by proving that two operations
always produce identical values.

Arguments simplification also depends on CSE, but it ought not depend on anything else.

Hence we get a cycle like: CFA -> folding -> CFG -> CSE -> CFA.

Note that before we had sparse conditional CFA, we also had CFA depending on CFG. This ought
not be the case anymore: CFG simplification should not by itself lead to better CFA results.

My guess is that the weakest link in this cycle is CFG -> CSE. CSE cuts both ways: if you
CSE too much then you increase register pressure. Hence it's not clear that you always want
to CSE after simplifying control flow. This leads to an order of optimization as follows:

CSE -> arguments -> CFA -> folding -> CFG

This is a 2.5% speed-up on SunSpider, a 4% speed-up on V8Spider, a possible 0.3% slow-down
on V8v7, nothing on Kraken, and 1.2% speed-up in the JSRegress geomean. I'll take a 2.5%
speed-up over a 0.3% V8v7 speed-up.

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp

    r144973 r145143  
    127127    performStructureCheckHoisting(dfg);
    128128   
    129     unsigned cnt = 1;
    130129    dfg.m_fixpointState = FixpointNotConverged;
    131     for (;; ++cnt) {
    132         if (logCompilationChanges())
    133             dataLogF("DFG beginning optimization fixpoint iteration #%u.\n", cnt);
    134         bool changed = false;
    135        
    136         if (validationEnabled())
    137             validate(dfg);
    138        
    139         performCFA(dfg);
    140         changed |= performConstantFolding(dfg);
    141         changed |= performArgumentsSimplification(dfg);
    142         changed |= performCFGSimplification(dfg);
    143         changed |= performCSE(dfg);
    144        
    145         if (!changed)
    146             break;
    147        
    148         performCPSRethreading(dfg);
    149     }
    150    
    151     if (logCompilationChanges())
    152         dataLogF("DFG optimization fixpoint converged in %u iterations.\n", cnt);
     130
     131    performCSE(dfg);
     132    performArgumentsSimplification(dfg);
     133    performCPSRethreading(dfg); // This should usually be a no-op since CSE rarely dethreads, and arguments simplification rarely does anything.
     134    performCFA(dfg);
     135    performConstantFolding(dfg);
     136    performCFGSimplification(dfg);
    153137
    154138    dfg.m_fixpointState = FixpointConverged;
     139
    155140    performStoreElimination(dfg);
    156     performCPSRethreading(dfg); // This should usually be a no-op since store elimination rarely dethreads the graph.
     141    performCPSRethreading(dfg);
    157142    performDCE(dfg);
    158143    performVirtualRegisterAllocation(dfg);
Note: See TracChangeset for help on using the changeset viewer.