Ignore:
Timestamp:
Sep 3, 2013, 9:39:29 AM (12 years ago)
Author:
[email protected]
Message:

CodeBlock::jettison() should be implicit
https://bugs.webkit.org/show_bug.cgi?id=120567

Reviewed by Oliver Hunt.

This is a risky change from a performance standpoint, but I believe it's
necessary. This makes all CodeBlocks get swept by GC. Nobody but the GC
can delete CodeBlocks because the GC always holds a reference to them.
Once a CodeBlock reaches just one reference (i.e. the one from the GC)
then the GC will free it only if it's not on the stack.

This allows me to get rid of the jettisoning logic. We need this for FTL
tier-up. Well; we don't need it, but it will help prevent a lot of bugs.
Previously, if you wanted to to replace one code block with another, you
had to remember to tell the GC that the previous code block is
"jettisoned". We would need to do this when tiering up from DFG to FTL
and when dealing with DFG-to-FTL OSR entry code blocks. There are a lot
of permutations here - tiering up to the FTL, OSR entering into the FTL,
deciding that an OSR entry code block is not relevant anymore - just to
name a few. In each of these cases we'd have to jettison the previous
code block. It smells like a huge source of future bugs.

So I made jettisoning implicit by making the GC always watch out for a
CodeBlock being owned solely by the GC.

This change is performance neutral.

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

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::~CodeBlock):
(JSC::CodeBlock::visitAggregate):
(JSC::CodeBlock::jettison):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::setJITCode):
(JSC::CodeBlock::shouldImmediatelyAssumeLivenessDuringScan):
(JSC::CodeBlockSet::mark):

  • dfg/DFGCommonData.h:

(JSC::DFG::CommonData::CommonData):

  • heap/CodeBlockSet.cpp: Added.

(JSC::CodeBlockSet::CodeBlockSet):
(JSC::CodeBlockSet::~CodeBlockSet):
(JSC::CodeBlockSet::add):
(JSC::CodeBlockSet::clearMarks):
(JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced):
(JSC::CodeBlockSet::traceMarked):

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

(JSC::ConservativeRoots::add):

  • heap/ConservativeRoots.h:
  • heap/DFGCodeBlocks.cpp: Removed.
  • heap/DFGCodeBlocks.h: Removed.
  • heap/Heap.cpp:

(JSC::Heap::markRoots):
(JSC::Heap::deleteAllCompiledCode):
(JSC::Heap::deleteUnmarkedCompiledCode):

  • heap/Heap.h:
  • interpreter/JSStack.cpp:

(JSC::JSStack::gatherConservativeRoots):

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

(JSC::ScriptExecutable::installCode):

  • runtime/Executable.h:
  • runtime/VM.h:
File:
1 edited

Legend:

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

    r154797 r154986  
    355355}
    356356
    357 void Heap::jettisonDFGCodeBlock(PassRefPtr<CodeBlock> codeBlock)
    358 {
    359     m_dfgCodeBlocks.jettison(codeBlock);
    360 }
    361 
    362357void Heap::addReference(JSCell* cell, ArrayBuffer* buffer)
    363358{
     
    458453
    459454    ConservativeRoots stackRoots(&m_objectSpace.blocks(), &m_storageSpace);
    460     m_dfgCodeBlocks.clearMarks();
     455    m_codeBlocks.clearMarks();
    461456    {
    462457        GCPHASE(GatherStackRoots);
    463         stack().gatherConservativeRoots(
    464             stackRoots, m_jitStubRoutines, m_dfgCodeBlocks);
     458        stack().gatherConservativeRoots(stackRoots, m_jitStubRoutines, m_codeBlocks);
    465459    }
    466460
     
    485479    {
    486480        ParallelModeEnabler enabler(visitor);
    487 
    488         if (m_vm->codeBlocksBeingCompiled.size()) {
    489             GCPHASE(VisitActiveCodeBlock);
    490             for (size_t i = 0; i < m_vm->codeBlocksBeingCompiled.size(); i++)
    491                 m_vm->codeBlocksBeingCompiled[i]->visitAggregate(visitor);
    492         }
    493481
    494482        m_vm->smallStrings.visitStrongReferences(visitor);
     
    559547            GCPHASE(TraceCodeBlocksAndJITStubRoutines);
    560548            MARK_LOG_ROOT(visitor, "Trace Code Blocks and JIT Stub Routines");
    561             m_dfgCodeBlocks.traceMarkedCodeBlocks(visitor);
     549            m_codeBlocks.traceMarked(visitor);
    562550            m_jitStubRoutines.traceMarkedStubRoutines(visitor);
    563551            visitor.donateAndDrain();
     
    684672    }
    685673
    686     m_dfgCodeBlocks.clearMarks();
    687     m_dfgCodeBlocks.deleteUnmarkedJettisonedCodeBlocks();
     674    m_codeBlocks.clearMarks();
     675    m_codeBlocks.deleteUnmarkedAndUnreferenced();
    688676}
    689677
     
    702690    }
    703691
    704     m_dfgCodeBlocks.deleteUnmarkedJettisonedCodeBlocks();
     692    m_codeBlocks.deleteUnmarkedAndUnreferenced();
    705693    m_jitStubRoutines.deleteUnmarkedJettisonedStubRoutines();
    706694}
Note: See TracChangeset for help on using the changeset viewer.