Ignore:
Timestamp:
Jan 30, 2020, 2:32:43 PM (5 years ago)
Author:
[email protected]
Message:

[JSC] Remove unnecessary allocations in BytecodeBasicBlock
https://bugs.webkit.org/show_bug.cgi?id=206986

Reviewed by Mark Lam.

We know that BytecodeBasicBlock itself takes 2MB in Gmail. And each BytecodeBasicBlock has Vector<unsigned>
and Vector<BytecodeBasicBlock*>.

BytecodeBasicBlock holds all the offset per bytecode as unsigned in m_offsets. But this offset is
only used when reverse iterating a bytecode in a BytecodeBasicBlock. We can hold a length of each
bytecode instead, which is much smaller (unsigned v.s. uint8_t).

Since each BytecodeBasicBlock has index, we should hold successors in Vector<unsigned> instead of Vector<BytecodeBasicBlock*>.

We are also allocating BytecodeBasicBlock in makeUnique<> and having them in Vector<std::unique_ptr<BytecodeBasicBlock>>.
But this is not necessary since only BytecodeBasicBlock::compute can modify this vector. We should generate Vector<BytecodeBasicBlock>
from BytecodeBasicBlock::compute.

We are also planning purging BytecodeBasicBlock in UnlinkedCodeBlock if it is not used so much. But this will be done in a separate patch.

  • bytecode/BytecodeBasicBlock.cpp:

(JSC::BytecodeBasicBlock::BytecodeBasicBlock):
(JSC::BytecodeBasicBlock::addLength):
(JSC::BytecodeBasicBlock::shrinkToFit):
(JSC::BytecodeBasicBlock::computeImpl):
(JSC::BytecodeBasicBlock::compute):

  • bytecode/BytecodeBasicBlock.h:

(JSC::BytecodeBasicBlock::delta const):
(JSC::BytecodeBasicBlock::successors const):
(JSC::BytecodeBasicBlock::operator bool const):
(JSC::BytecodeBasicBlock::addSuccessor):
(JSC::BytecodeBasicBlock::offsets const): Deleted.
(JSC::BytecodeBasicBlock:: const): Deleted.
(JSC::BytecodeBasicBlock::BytecodeBasicBlock): Deleted.
(JSC::BytecodeBasicBlock::addLength): Deleted.

  • bytecode/BytecodeGeneratorification.cpp:

(JSC::BytecodeGeneratorification::BytecodeGeneratorification):

  • bytecode/BytecodeGraph.h:

(JSC::BytecodeGraph::blockContainsBytecodeOffset):
(JSC::BytecodeGraph::findBasicBlockForBytecodeOffset):
(JSC::BytecodeGraph::findBasicBlockWithLeaderOffset):
(JSC::BytecodeGraph::at const):
(JSC::BytecodeGraph::operator[] const):
(JSC::BytecodeGraph::begin):
(JSC::BytecodeGraph::end):
(JSC::BytecodeGraph::first):
(JSC::BytecodeGraph::last):
(JSC::BytecodeGraph::BytecodeGraph):
(JSC::BytecodeGraph::begin const): Deleted.
(JSC::BytecodeGraph::end const): Deleted.

  • bytecode/BytecodeLivenessAnalysis.cpp:

(JSC::BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeIndex):
(JSC::BytecodeLivenessAnalysis::computeFullLiveness):
(JSC::BytecodeLivenessAnalysis::computeKills):
(JSC::BytecodeLivenessAnalysis::dumpResults):

  • bytecode/BytecodeLivenessAnalysis.h:
  • bytecode/BytecodeLivenessAnalysisInlines.h:

(JSC::BytecodeLivenessPropagation::computeLocalLivenessForBytecodeIndex):
(JSC::BytecodeLivenessPropagation::computeLocalLivenessForBlock):
(JSC::BytecodeLivenessPropagation::getLivenessInfoAtBytecodeIndex):
(JSC::BytecodeLivenessPropagation::runLivenessFixpoint):

  • bytecode/InstructionStream.h:

(JSC::InstructionStream::MutableRef::operator-> const):
(JSC::InstructionStream::MutableRef::ptr const):
(JSC::InstructionStream::MutableRef::unwrap const):

  • bytecode/Opcode.h:
  • generator/Section.rb:
  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):

  • llint/LLIntData.cpp:

(JSC::LLInt::initialize):

  • llint/LowLevelInterpreter.cpp:

(JSC::CLoop::execute):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r255406 r255459  
    216216            while (BytecodeBasicBlock* block = worklist.pop()) {
    217217                startBytecodeIndex = BytecodeIndex(std::min(startBytecodeIndex.offset(), block->leaderOffset()));
    218                 worklist.pushAll(block->successors());
     218                for (unsigned successorIndex : block->successors())
     219                    worklist.push(&graph[successorIndex]);
    219220
    220221                // Also add catch blocks for bytecodes that throw.
Note: See TracChangeset for help on using the changeset viewer.