• fpizlo@apple.com's avatar
    OSR exit profiling should be robust against all code being cleared · 501e606b
    fpizlo@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=123629
    <rdar://problem/15365476>
    
    Reviewed by Michael Saboff.
            
    The problem here is two-fold:
    
    1) A watchpoint (i.e. ProfiledCodeBlockJettisoningWatchpoint) may be fired after we
    have cleared the CodeBlock for all or some Executables.  This means that doing
    codeBlock->baselineVersion() would either crash or return a bogus CodeBlock, since
    there wasn't a baseline code block reachable from the Executable anymore.  The
    solution is that we shouldn't be asking for the baseline code block reachable from
    the owning executable (what baselineVersion did), but instead we should be asking
    for the baseline version reachable from the code block being watchpointed (basically
    what CodeBlock::alternative() did).
    
    2) If dealing with inlined code, baselienCodeBlockForOriginAndBaselineCodeBlock()
    may return null, for the same reason as above - we might have cleared the baseline
    codeblock for the executable that was inlined.  The solution is to just not do
    profiling if there isn't a baseline code block anymore.
    
    * bytecode/CodeBlock.cpp:
    (JSC::CodeBlock::baselineAlternative):
    (JSC::CodeBlock::baselineVersion):
    (JSC::CodeBlock::jettison):
    * bytecode/CodeBlock.h:
    * bytecode/CodeBlockJettisoningWatchpoint.cpp:
    (JSC::CodeBlockJettisoningWatchpoint::fireInternal):
    * bytecode/ProfiledCodeBlockJettisoningWatchpoint.cpp:
    (JSC::ProfiledCodeBlockJettisoningWatchpoint::fireInternal):
    * dfg/DFGOSRExitBase.cpp:
    (JSC::DFG::OSRExitBase::considerAddingAsFrequentExitSiteSlow):
    * jit/AssemblyHelpers.h:
    (JSC::AssemblyHelpers::AssemblyHelpers):
    * runtime/Executable.cpp:
    (JSC::FunctionExecutable::baselineCodeBlockFor):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    501e606b
CodeBlockJettisoningWatchpoint.cpp 1.71 KB