Changeset 190749 in webkit


Ignore:
Timestamp:
Oct 8, 2015 3:18:49 PM (9 years ago)
Author:
fpizlo@apple.com
Message:

DFG SSA should remove unreachable code
https://bugs.webkit.org/show_bug.cgi?id=149931

Reviewed by Geoffrey Garen.

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::run): Remove unreachable code.

  • dfg/DFGObjectAllocationSinkingPhase.cpp: Deal with the CFG changing.
  • dfg/DFGPutStackSinkingPhase.cpp: Deal with the CFG changing.
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r190743 r190749  
     12015-10-08  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG SSA should remove unreachable code
     4        https://bugs.webkit.org/show_bug.cgi?id=149931
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * dfg/DFGConstantFoldingPhase.cpp:
     9        (JSC::DFG::ConstantFoldingPhase::run): Remove unreachable code.
     10        * dfg/DFGObjectAllocationSinkingPhase.cpp: Deal with the CFG changing.
     11        * dfg/DFGPutStackSinkingPhase.cpp: Deal with the CFG changing.
     12
    1132015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp

    r190076 r190749  
    3131#include "DFGAbstractInterpreterInlines.h"
    3232#include "DFGArgumentsUtilities.h"
    33 #include "DFGBasicBlock.h"
     33#include "DFGBasicBlockInlines.h"
    3434#include "DFGGraph.h"
    3535#include "DFGInPlaceAbstractState.h"
     
    5656    {
    5757        bool changed = false;
    58        
    59         for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
    60             BasicBlock* block = m_graph.block(blockIndex);
    61             if (!block)
    62                 continue;
     58
     59        for (BasicBlock* block : m_graph.blocksInNaturalOrder()) {
    6360            if (block->cfaFoundConstants)
    6461                changed |= foldConstants(block);
     
    6764        if (changed && m_graph.m_form == SSA) {
    6865            // It's now possible that we have Upsilons pointed at JSConstants. Fix that.
    69             for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
    70                 BasicBlock* block = m_graph.block(blockIndex);
    71                 if (!block)
    72                     continue;
     66            for (BasicBlock* block : m_graph.blocksInNaturalOrder())
    7367                fixUpsilons(block);
     68        }
     69
     70        if (m_graph.m_form == SSA) {
     71            // It's now possible to simplify basic blocks by placing an Unreachable terminator right
     72            // after anything that invalidates AI.
     73            bool didClipBlock = false;
     74            for (BasicBlock* block : m_graph.blocksInNaturalOrder()) {
     75                m_state.beginBasicBlock(block);
     76                for (unsigned nodeIndex = 0; nodeIndex < block->size(); ++nodeIndex) {
     77                    if (block->at(nodeIndex)->isTerminal()) {
     78                        // It's possible that we have something after the terminal. It could be a
     79                        // no-op Check node, for example. We don't want the logic below to turn that
     80                        // node into Unreachable, since then we'd have two terminators.
     81                        break;
     82                    }
     83                    if (!m_state.isValid()) {
     84                        NodeOrigin origin = block->at(nodeIndex)->origin;
     85                        for (unsigned killIndex = nodeIndex; killIndex < block->size(); ++killIndex)
     86                            m_graph.m_allocator.free(block->at(killIndex));
     87                        block->resize(nodeIndex);
     88                        block->appendNode(m_graph, SpecNone, Unreachable, origin);
     89                        didClipBlock = true;
     90                        break;
     91                    }
     92                    m_interpreter.execute(nodeIndex);
     93                }
     94            }
     95
     96            if (didClipBlock) {
     97                changed = true;
     98                m_graph.invalidateCFG();
     99                m_graph.resetReachability();
     100                m_graph.killUnreachableBlocks();
    74101            }
    75102        }
  • trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp

    r190076 r190749  
    728728        m_graph.computeRefCounts();
    729729        m_graph.initializeNodeOwners();
     730        m_graph.m_dominators.computeIfNecessary(m_graph);
    730731        performLivenessAnalysis(m_graph);
    731732        performOSRAvailabilityAnalysis(m_graph);
  • trunk/Source/JavaScriptCore/dfg/DFGPutStackSinkingPhase.cpp

    r189013 r190749  
    7676            m_graph.dump();
    7777        }
     78
     79        m_graph.m_dominators.computeIfNecessary(m_graph);
    7880       
    7981        SSACalculator ssaCalculator(m_graph);
Note: See TracChangeset for help on using the changeset viewer.