Ignore:
Timestamp:
Apr 28, 2014, 12:01:07 PM (11 years ago)
Author:
[email protected]
Message:

GC should be able to remove things from the DFG worklist and cancel on-going compilations if it knows that the compilation would already be invalidated
https://bugs.webkit.org/show_bug.cgi?id=132166

Reviewed by Oliver Hunt and Mark Hahnenberg.

The GC can aid type inference by removing structures that are dead and jettisoning
code that relies on those structures. This can dramatically accelerate type inference
for some tricky programs.

Unfortunately, we previously pinned any structures that enqueued compilations depended
on. This means that if you're on a machine that only runs a single compilation thread
and where compilations are relatively slow, you have a high chance of large numbers of
structures being pinned during any GC since the compilation queue is likely to be full
of random stuff.

This comprehensively fixes this issue by allowing the GC to remove compilation plans
if the things they depend on are dead, and to even cancel safepointed compilations.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::shouldImmediatelyAssumeLivenessDuringScan):
(JSC::CodeBlock::isKnownToBeLiveDuringGC):
(JSC::CodeBlock::finalizeUnconditionally):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::shouldImmediatelyAssumeLivenessDuringScan): Deleted.

  • dfg/DFGDesiredIdentifiers.cpp:

(JSC::DFG::DesiredIdentifiers::DesiredIdentifiers):

  • dfg/DFGDesiredIdentifiers.h:
  • dfg/DFGDesiredWatchpoints.h:
  • dfg/DFGDesiredWeakReferences.cpp:

(JSC::DFG::DesiredWeakReferences::DesiredWeakReferences):

  • dfg/DFGDesiredWeakReferences.h:
  • dfg/DFGGraphSafepoint.cpp:

(JSC::DFG::GraphSafepoint::GraphSafepoint):

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

(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::compileInThreadImpl):
(JSC::DFG::Plan::notifyCompiling):
(JSC::DFG::Plan::notifyCompiled):
(JSC::DFG::Plan::notifyReady):
(JSC::DFG::Plan::checkLivenessAndVisitChildren):
(JSC::DFG::Plan::isKnownToBeLiveDuringGC):
(JSC::DFG::Plan::cancel):
(JSC::DFG::Plan::visitChildren): Deleted.

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

(JSC::DFG::Safepoint::Result::~Result):
(JSC::DFG::Safepoint::Result::didGetCancelled):
(JSC::DFG::Safepoint::Safepoint):
(JSC::DFG::Safepoint::~Safepoint):
(JSC::DFG::Safepoint::checkLivenessAndVisitChildren):
(JSC::DFG::Safepoint::isKnownToBeLiveDuringGC):
(JSC::DFG::Safepoint::cancel):
(JSC::DFG::Safepoint::visitChildren): Deleted.

  • dfg/DFGSafepoint.h:

(JSC::DFG::Safepoint::Result::Result):

  • dfg/DFGWorklist.cpp:

(JSC::DFG::Worklist::compilationState):
(JSC::DFG::Worklist::waitUntilAllPlansForVMAreReady):
(JSC::DFG::Worklist::removeAllReadyPlansForVM):
(JSC::DFG::Worklist::completeAllReadyPlansForVM):
(JSC::DFG::Worklist::visitWeakReferences):
(JSC::DFG::Worklist::removeDeadPlans):
(JSC::DFG::Worklist::runThread):
(JSC::DFG::Worklist::visitChildren): Deleted.

  • dfg/DFGWorklist.h:
  • ftl/FTLCompile.cpp:

(JSC::FTL::compile):

  • ftl/FTLCompile.h:
  • heap/CodeBlockSet.cpp:

(JSC::CodeBlockSet::rememberCurrentlyExecutingCodeBlocks):

  • heap/Heap.cpp:

(JSC::Heap::markRoots):
(JSC::Heap::visitCompilerWorklistWeakReferences):
(JSC::Heap::removeDeadCompilerWorklistEntries):
(JSC::Heap::visitWeakHandles):
(JSC::Heap::collect):
(JSC::Heap::visitCompilerWorklists): Deleted.

  • heap/Heap.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r167515 r167897  
    948948    NO_RETURN_DUE_TO_CRASH void endValidationDidFail();
    949949
     950    bool isKnownToBeLiveDuringGC(); // Will only return valid results when called during GC. Assumes that you've already established that the owner executable is live.
     951
    950952protected:
    951953    virtual void visitWeakReferences(SlotVisitor&) override;
     
    10021004    void dumpRareCaseProfile(PrintStream&, const char* name, RareCaseProfile*, bool& hasPrintedProfiling);
    10031005       
    1004 #if ENABLE(DFG_JIT)
    1005     bool shouldImmediatelyAssumeLivenessDuringScan()
    1006     {
    1007         // Interpreter and Baseline JIT CodeBlocks don't need to be jettisoned when
    1008         // their weak references go stale. So if a basline JIT CodeBlock gets
    1009         // scanned, we can assume that this means that it's live.
    1010         if (!JITCode::isOptimizingJIT(jitType()))
    1011             return true;
    1012 
    1013         // For simplicity, we don't attempt to jettison code blocks during GC if
    1014         // they are executing. Instead we strongly mark their weak references to
    1015         // allow them to continue to execute soundly.
    1016         if (m_mayBeExecuting)
    1017             return true;
    1018 
    1019         if (Options::forceDFGCodeBlockLiveness())
    1020             return true;
    1021 
    1022         return false;
    1023     }
    1024 #else
    1025     bool shouldImmediatelyAssumeLivenessDuringScan() { return true; }
    1026 #endif
     1006    bool shouldImmediatelyAssumeLivenessDuringScan();
    10271007   
    10281008    void propagateTransitions(SlotVisitor&);
Note: See TracChangeset for help on using the changeset viewer.