Ignore:
Timestamp:
Apr 4, 2017, 5:25:02 PM (8 years ago)
Author:
[email protected]
Message:

B3::fixSSA() needs a tune-up
https://bugs.webkit.org/show_bug.cgi?id=170485

Reviewed by Saam Barati.

Source/JavaScriptCore:

After the various optimizations to liveness, register allocation, and other phases, the
fixSSA() phase now looks like one of the top offenders. This includes a bunch of
changes to make this phase run faster. This is a ~7% wasm -O1 compile time progression.

Here's what I did:

  • We now use IndexSparseSet instead of IndexMap for tracking variable values. This makes it cheaper to chew through small blocks while there is a non-trivial number of total variables.


  • We now do a "local SSA conversion" pass before anything else. This eliminates obvious Get's. If we were using temporary Variables, it would eliminate many of those. That's useful for when we use demoteValues() and duplciateTails(). For wasm -O1, we mainly care about the fact that it makes a bunch of Set's dead.


  • We now do a Set DCE pass after the local SSA but before SSA conversion. This ensures that any block-local live intervals of Variables disappear and don't need further consideration.


  • We now cache the reaching defs calculation.


  • We now perform the reaching defs calculation lazily.
  • b3/B3FixSSA.cpp:

(JSC::B3::demoteValues):
(JSC::B3::fixSSA):

  • b3/B3SSACalculator.cpp:

(JSC::B3::SSACalculator::reachingDefAtTail):

  • b3/B3VariableLiveness.cpp:

(JSC::B3::VariableLiveness::VariableLiveness):

  • b3/air/AirLiveness.h:

(JSC::B3::Air::Liveness::Liveness):

  • dfg/DFGLivenessAnalysisPhase.cpp:

(JSC::DFG::LivenessAnalysisPhase::LivenessAnalysisPhase): Deleted.
(JSC::DFG::LivenessAnalysisPhase::run): Deleted.
(JSC::DFG::LivenessAnalysisPhase::processBlock): Deleted.

Source/WTF:

This makes IndexSparseSet capable of being used as a map if you instantiate it with
KeyValuePair<unsigned, ValueType>.

  • wtf/HashTraits.h:
  • wtf/IndexSparseSet.h:

(WTF::DefaultIndexSparseSetTraits::create):
(WTF::DefaultIndexSparseSetTraits::key):
(WTF::OverflowHandler>::IndexSparseSet):
(WTF::OverflowHandler>::add):
(WTF::OverflowHandler>::set):
(WTF::OverflowHandler>::remove):
(WTF::OverflowHandler>::clear):
(WTF::OverflowHandler>::size):
(WTF::OverflowHandler>::isEmpty):
(WTF::OverflowHandler>::contains):
(WTF::OverflowHandler>::sort):
(WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::add): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::remove): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::clear): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::size): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::isEmpty): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::contains): Deleted.
(WTF::IndexSparseSet<OverflowHandler>::sort): Deleted.

  • wtf/Liveness.h:

(WTF::Liveness::LocalCalc::Iterable::iterator::iterator):
(WTF::Liveness::workset):

File:
1 edited

Legend:

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

    r213939 r214917  
    4242namespace JSC { namespace DFG {
    4343
     44namespace {
     45
    4446// Uncomment this to log hashtable operations.
    4547// static const char templateString[] = "unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>";
     
    4749
    4850typedef HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> LiveSet;
     51
     52typedef IndexSparseSet<unsigned, DefaultIndexSparseSetTraits<unsigned>, UnsafeVectorOverflow> Workset;
    4953
    5054class LivenessAnalysisPhase : public Phase {
     
    5862    {
    5963        m_graph.m_indexingCache->recompute();
    60         m_workset = std::make_unique<IndexSparseSet<UnsafeVectorOverflow>>(m_graph.m_indexingCache->numIndices());
     64        m_workset = std::make_unique<Workset>(m_graph.m_indexingCache->numIndices());
    6165    }
    6266
     
    186190
    187191    // Single sparse set allocated once and used by every basic block.
    188     std::unique_ptr<IndexSparseSet<UnsafeVectorOverflow>> m_workset;
     192    std::unique_ptr<Workset> m_workset;
    189193};
     194
     195} // anonymous namespace
    190196
    191197bool performLivenessAnalysis(Graph& graph)
Note: See TracChangeset for help on using the changeset viewer.