Ignore:
Timestamp:
Apr 22, 2015, 7:29:14 PM (10 years ago)
Author:
[email protected]
Message:

Fix assertion failure and race condition in Options::dumpSourceAtDFGTime().
https://bugs.webkit.org/show_bug.cgi?id=143898

Reviewed by Filip Pizlo.

CodeBlock::dumpSource() will access SourceCode strings in a way that requires
ref'ing of the underlying StringImpls. This is unsafe to do from arbitrary
compilation threads because StringImpls are not thread safe. As a result, we get
an assertion failure when we run with JSC_dumpSourceAtDFGTime=true on a debug
build.

This patch fixes the issue by only collecting the CodeBlock (and associated info)
into a DeferredSourceDump record while compiling, and stashing it away in a
deferredSourceDump list in the DeferredCompilationCallback object to be dumped
later.

When compilation is done, the callback object will be notified that
compilationDidComplete(). We will dump the SourceCode strings from there.
Since compilationDidComplete() is guaranteed to only be called on the thread
doing JS execution, it is safe to access the SourceCode strings there and ref
their underlying StringImpls as needed.

(JSC::DeferredCompilationCallback::compilationDidComplete):
(JSC::DeferredCompilationCallback::sourceDumpInfo):
(JSC::DeferredCompilationCallback::dumpCompiledSources):

  • bytecode/DeferredCompilationCallback.h:
  • bytecode/DeferredSourceDump.cpp: Added.

(JSC::DeferredSourceDump::DeferredSourceDump):
(JSC::DeferredSourceDump::dump):

  • bytecode/DeferredSourceDump.h: Added.
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseCodeBlock):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compileImpl):

File:
1 edited

Legend:

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

    r180956 r183161  
    102102        new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues));
    103103   
     104    plan->callback = callback;
    104105    if (Options::enableConcurrentJIT()) {
    105106        Worklist* worklist = ensureGlobalWorklistFor(mode);
    106         plan->callback = callback;
    107107        if (logCompilationChanges(mode))
    108108            dataLog("Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist->queueLength(), ".\n");
Note: See TracChangeset for help on using the changeset viewer.