Ignore:
Timestamp:
Aug 11, 2016, 5:22:20 PM (9 years ago)
Author:
[email protected]
Message:

[JSC] Revert most of r203808
https://bugs.webkit.org/show_bug.cgi?id=160784

Patch by Benjamin Poulain <[email protected]> on 2016-08-11
Reviewed by Geoffrey Garen.

Switching to fastMalloc() caused regressions on Jetstream and Octane
on MacBook Air. I was able to get back some of it in the following
patches but the tests that never go to FTL are still regressed.

This patch revert r203808 except of the node index.
Nodes are allocated with the custom allocator like before but they are
now also kept in a table, addressed by the node index.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • b3/B3SparseCollection.h:

(JSC::B3::SparseCollection::packIndices): Deleted.

  • dfg/DFGAllocator.h: Added.

(JSC::DFG::Allocator::Region::size):
(JSC::DFG::Allocator::Region::headerSize):
(JSC::DFG::Allocator::Region::numberOfThingsPerRegion):
(JSC::DFG::Allocator::Region::data):
(JSC::DFG::Allocator::Region::isInThisRegion):
(JSC::DFG::Allocator::Region::regionFor):
(JSC::DFG::Allocator<T>::Allocator):
(JSC::DFG::Allocator<T>::~Allocator):
(JSC::DFG::Allocator<T>::allocate):
(JSC::DFG::Allocator<T>::free):
(JSC::DFG::Allocator<T>::freeAll):
(JSC::DFG::Allocator<T>::reset):
(JSC::DFG::Allocator<T>::indexOf):
(JSC::DFG::Allocator<T>::allocatorOf):
(JSC::DFG::Allocator<T>::bumpAllocate):
(JSC::DFG::Allocator<T>::freeListAllocate):
(JSC::DFG::Allocator<T>::allocateSlow):
(JSC::DFG::Allocator<T>::freeRegionsStartingAt):
(JSC::DFG::Allocator<T>::startBumpingIn):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compileImpl):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):
(JSC::DFG::Graph::~Graph):
(JSC::DFG::Graph::addNodeToMapByIndex):
(JSC::DFG::Graph::deleteNode):
(JSC::DFG::Graph::packNodeIndices):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::addNode):
(JSC::DFG::Graph::maxNodeCount):
(JSC::DFG::Graph::nodeAt):

  • dfg/DFGLongLivedState.cpp: Added.

(JSC::DFG::LongLivedState::LongLivedState):
(JSC::DFG::LongLivedState::~LongLivedState):
(JSC::DFG::LongLivedState::shrinkToFit):

  • dfg/DFGLongLivedState.h: Added.
  • dfg/DFGNode.h:
  • dfg/DFGNodeAllocator.h: Added.

(operator new ):

  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::compileInThreadImpl):

  • dfg/DFGPlan.h:
  • dfg/DFGWorklist.cpp:

(JSC::DFG::Worklist::runThread):

  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:
File:
1 edited

Legend:

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

    r204130 r204393  
    6767};
    6868
    69 Graph::Graph(VM& vm, Plan& plan)
     69Graph::Graph(VM& vm, Plan& plan, LongLivedState& longLivedState)
    7070    : m_vm(vm)
    7171    , m_plan(plan)
    7272    , m_codeBlock(m_plan.codeBlock)
    7373    , m_profiledBlock(m_codeBlock->alternative())
     74    , m_allocator(longLivedState.m_allocator)
    7475    , m_cfg(std::make_unique<CFG>(*this))
    7576    , m_nextMachineLocal(0)
     
    8788Graph::~Graph()
    8889{
     90    for (BlockIndex blockIndex = numBlocks(); blockIndex--;) {
     91        BasicBlock* block = this->block(blockIndex);
     92        if (!block)
     93            continue;
     94
     95        for (unsigned phiIndex = block->phis.size(); phiIndex--;)
     96            m_allocator.free(block->phis[phiIndex]);
     97        for (unsigned nodeIndex = block->size(); nodeIndex--;)
     98            m_allocator.free(block->at(nodeIndex));
     99    }
     100    m_allocator.freeAll();
    89101}
    90102
     
    568580}
    569581
     582void Graph::addNodeToMapByIndex(Node* node)
     583{
     584    if (m_nodeIndexFreeList.isEmpty()) {
     585        node->m_index = m_nodesByIndex.size();
     586        m_nodesByIndex.append(node);
     587        return;
     588    }
     589    unsigned index = m_nodeIndexFreeList.takeLast();
     590    node->m_index = index;
     591    ASSERT(!m_nodesByIndex[index]);
     592    m_nodesByIndex[index] = node;
     593}
     594
    570595void Graph::deleteNode(Node* node)
    571596{
     
    576601        }
    577602    }
    578     m_nodes.remove(node);
     603
     604    RELEASE_ASSERT(m_nodesByIndex[node->m_index] == node);
     605    unsigned nodeIndex = node->m_index;
     606    m_nodesByIndex[nodeIndex] = nullptr;
     607    m_nodeIndexFreeList.append(nodeIndex);
     608
     609    m_allocator.free(node);
    579610}
    580611
    581612void Graph::packNodeIndices()
    582613{
    583     m_nodes.packIndices();
     614    if (m_nodeIndexFreeList.isEmpty())
     615        return;
     616
     617    unsigned holeIndex = 0;
     618    unsigned endIndex = m_nodesByIndex.size();
     619
     620    while (true) {
     621        while (holeIndex < endIndex && m_nodesByIndex[holeIndex])
     622            ++holeIndex;
     623
     624        if (holeIndex == endIndex)
     625            break;
     626        ASSERT(holeIndex < m_nodesByIndex.size());
     627        ASSERT(!m_nodesByIndex[holeIndex]);
     628
     629        do {
     630            --endIndex;
     631        } while (!m_nodesByIndex[endIndex] && endIndex > holeIndex);
     632
     633        if (holeIndex == endIndex)
     634            break;
     635        ASSERT(endIndex > holeIndex);
     636        ASSERT(m_nodesByIndex[endIndex]);
     637
     638        auto& value = m_nodesByIndex[endIndex];
     639        value->m_index = holeIndex;
     640        m_nodesByIndex[holeIndex] = WTFMove(value);
     641        ++holeIndex;
     642    }
     643
     644    m_nodeIndexFreeList.resize(0);
     645    m_nodesByIndex.resize(endIndex);
    584646}
    585647
Note: See TracChangeset for help on using the changeset viewer.