Ignore:
Timestamp:
Jul 24, 2013, 8:59:31 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: Profiler should be thread-safe
https://bugs.webkit.org/show_bug.cgi?id=115445

Reviewed by Geoffrey Garen.

Change the Profiler::Database API for Compilation creation so that we don't add
it to the Database until it's completely constructed. This prevents the Database
from seeing Compilations that are being concurrently constructed.

Change the Profiler::Database itself to do locking for creation of Bytecodes and
for modifying the map. This map may be consulted by both the main thread and the
concurrent thread.

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::linkFunction):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • profiler/ProfilerBytecodes.h:
  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::ensureBytecodesFor):
(JSC::Profiler::Database::notifyDestruction):
(JSC::Profiler::Database::addCompilation):

  • profiler/ProfilerDatabase.h:

(Database):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp

    r148696 r153143  
    6161Bytecodes* Database::ensureBytecodesFor(CodeBlock* codeBlock)
    6262{
     63    Locker locker(m_lock);
     64   
    6365    codeBlock = codeBlock->baselineVersion();
    6466   
     
    7779void Database::notifyDestruction(CodeBlock* codeBlock)
    7880{
     81    Locker locker(m_lock);
     82   
    7983    m_bytecodesMap.remove(codeBlock);
    8084}
    8185
    82 PassRefPtr<Compilation> Database::newCompilation(Bytecodes* bytecodes, CompilationKind kind)
     86void Database::addCompilation(PassRefPtr<Compilation> compilation)
    8387{
    84     RefPtr<Compilation> compilation = adoptRef(new Compilation(bytecodes, kind));
     88    ASSERT(!isCompilationThread());
     89   
    8590    m_compilations.append(compilation);
    86     return compilation.release();
    87 }
    88 
    89 PassRefPtr<Compilation> Database::newCompilation(CodeBlock* codeBlock, CompilationKind kind)
    90 {
    91     return newCompilation(ensureBytecodesFor(codeBlock), kind);
    9291}
    9392
Note: See TracChangeset for help on using the changeset viewer.