Ignore:
Timestamp:
Nov 16, 2011, 7:58:48 PM (14 years ago)
Author:
[email protected]
Message:

Code block jettisoning should be part of the GC's transitive closure
https://bugs.webkit.org/show_bug.cgi?id=72467

Reviewed by Geoff Garen.

Replaced JettisonedCodeBlocks with DFGCodeBlocks. The latter knows about all
DFG code blocks (i.e. those that may be jettisoned, and may have inlined weak
references) and helps track what state each of those code blocks is in during
GC. The state consists of two flags; mayBeExecuting, which tells if the code block
is live from call frames; and isJettisoned, which tells if the code block is
not owned by any executable and thus should be deleted as soon as it is not
mayBeExecuting.

  • Not executing, Not jettisoned: The code block may or may not be reachable from any executables, but it is owned by an executable, and hence should be kept alive if its executable is live and if all of its weak references are live. Otherwise it should be deleted during the current GC cycle, and its outgoing references should not be scanned.


  • Not executing but jettisoned: The code block should be deleted as soon as possible and none of its outgoing references should be scanned.


  • Executing but not jettisoned: The code block should be kept alive during this GC cycle, and all of its outgoing references (including the weak ones) should be scanned and marked strongly. The mayBeExecuting bit will be cleared at the end of the GC cycle.


  • Executing and jettisoned: The code block should be kept alive during this GC cycle, and all of its outgoing references (including the weak ones) should be scanned and marked strongly. However, on the next GC cycle, it will have its mayBeExecuting bit cleared and hence it will become a candidate for immediate deletion provided it is not executing again.

This is performance-neutral.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::~CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::setJITCode):
(JSC::CodeBlock::DFGData::DFGData):
(JSC::DFGCodeBlocks::mark):

  • heap/ConservativeRoots.cpp:

(JSC::ConservativeRoots::add):

  • heap/ConservativeRoots.h:
  • heap/DFGCodeBlocks.cpp: Added.

(JSC::DFGCodeBlocks::DFGCodeBlocks):
(JSC::DFGCodeBlocks::~DFGCodeBlocks):
(JSC::DFGCodeBlocks::jettison):
(JSC::DFGCodeBlocks::clearMarks):
(JSC::DFGCodeBlocks::deleteUnmarkedJettisonedCodeBlocks):
(JSC::DFGCodeBlocks::traceMarkedCodeBlocks):

  • heap/DFGCodeBlocks.h: Added.
  • heap/Heap.cpp:

(JSC::Heap::jettisonDFGCodeBlock):
(JSC::Heap::markRoots):
(JSC::Heap::collect):

  • heap/Heap.h:
  • heap/JettisonedCodeBlocks.cpp: Removed.
  • heap/JettisonedCodeBlocks.h: Removed.
  • interpreter/RegisterFile.cpp:

(JSC::RegisterFile::gatherConservativeRoots):

  • interpreter/RegisterFile.h:
  • runtime/Executable.cpp:

(JSC::jettisonCodeBlock):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r100242 r100556  
    487487}
    488488
     489void Heap::jettisonDFGCodeBlock(PassOwnPtr<CodeBlock> codeBlock)
     490{
     491    m_dfgCodeBlocks.jettison(codeBlock);
     492}
     493
    489494void Heap::markProtectedObjects(HeapRootVisitor& heapRootVisitor)
    490495{
     
    492497    for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it)
    493498        heapRootVisitor.visit(&it->first);
    494 }
    495 
    496 void Heap::addJettisonedCodeBlock(PassOwnPtr<CodeBlock> codeBlock)
    497 {
    498     m_jettisonedCodeBlocks.addCodeBlock(codeBlock);
    499499}
    500500
     
    580580
    581581    ConservativeRoots registerFileRoots(&m_objectSpace.blocks());
    582     m_jettisonedCodeBlocks.clearMarks();
     582    m_dfgCodeBlocks.clearMarks();
    583583    {
    584584        GCPHASE(GatherRegisterFileRoots);
    585         registerFile().gatherConservativeRoots(registerFileRoots, m_jettisonedCodeBlocks);
    586     }
    587     m_jettisonedCodeBlocks.deleteUnmarkedCodeBlocks();
     585        registerFile().gatherConservativeRoots(registerFileRoots, m_dfgCodeBlocks);
     586    }
    588587#if ENABLE(GGC)
    589588    MarkedBlock::DirtyCellVector dirtyCells;
     
    669668        {
    670669            GCPHASE(TraceCodeBlocks);
    671             m_jettisonedCodeBlocks.traceCodeBlocks(visitor);
     670            m_dfgCodeBlocks.traceMarkedCodeBlocks(visitor);
    672671            visitor.donateAndDrain();
    673672        }
     
    806805        resetAllocator();
    807806    }
     807   
     808    {
     809        GCPHASE(DeleteCodeBlocks);
     810        m_dfgCodeBlocks.deleteUnmarkedJettisonedCodeBlocks();
     811    }
    808812
    809813    if (sweepToggle == DoSweep) {
Note: See TracChangeset for help on using the changeset viewer.