Ignore:
Timestamp:
Oct 4, 2017, 1:00:01 PM (8 years ago)
Author:
[email protected]
Message:

Add support for using Probe DFG OSR Exit behind a runtime flag.
https://bugs.webkit.org/show_bug.cgi?id=177844
<rdar://problem/34801425>

Reviewed by Saam Barati.

Source/JavaScriptCore:

This is based on the code originally posted in https://bugs.webkit.org/show_bug.cgi?id=175144
(in r221774 and r221832) with some optimizations and bug fixes added. The probe
based DFG OSR Exit is only enabled if Options::useProbeOSRExit() is true. We're
landing this behind an option switch to make it easier to tune performance using
the probe based OSR exit.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/MacroAssembler.cpp:

(JSC::stdFunctionCallback):

  • assembler/MacroAssemblerPrinter.cpp:

(JSC::Printer::printCallback):

  • assembler/ProbeContext.cpp:

(JSC::Probe::executeProbe):
(JSC::Probe::flushDirtyStackPages):

  • assembler/ProbeContext.h:

(JSC::Probe::Context::Context):
(JSC::Probe::Context::arg):

  • assembler/ProbeFrame.h: Added.

(JSC::Probe::Frame::Frame):
(JSC::Probe::Frame::argument):
(JSC::Probe::Frame::operand):
(JSC::Probe::Frame::setArgument):
(JSC::Probe::Frame::setOperand):
(JSC::Probe::Frame::get):
(JSC::Probe::Frame::set):

  • assembler/ProbeStack.cpp:

(JSC::Probe::Page::lowWatermarkFromVisitingDirtyChunks):
(JSC::Probe::Stack::Stack):
(JSC::Probe::Stack::lowWatermarkFromVisitingDirtyPages):

  • assembler/ProbeStack.h:

(JSC::Probe::Stack::Stack):
(JSC::Probe::Stack::lowWatermark):
(JSC::Probe::Stack::set):
(JSC::Probe::Stack::savedStackPointer const):
(JSC::Probe::Stack::setSavedStackPointer):
(JSC::Probe::Stack::newStackPointer const): Deleted.
(JSC::Probe::Stack::setNewStackPointer): Deleted.

  • bytecode/ArrayProfile.h:

(JSC::ArrayProfile::observeArrayMode):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::updateOSRExitCounterAndCheckIfNeedToReoptimize):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addressOfOSRExitCounter): Deleted.

  • bytecode/ExecutionCounter.h:

(JSC::ExecutionCounter::hasCrossedThreshold const):
(JSC::ExecutionCounter::setNewThresholdForOSRExit):

  • bytecode/MethodOfGettingAValueProfile.cpp:

(JSC::MethodOfGettingAValueProfile::reportValue):

  • bytecode/MethodOfGettingAValueProfile.h:
  • dfg/DFGDriver.cpp:

(JSC::DFG::compileImpl):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::jsValueFor):
(JSC::DFG::restoreCalleeSavesFor):
(JSC::DFG::saveCalleeSavesFor):
(JSC::DFG::restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer):
(JSC::DFG::copyCalleeSavesToVMEntryFrameCalleeSavesBuffer):
(JSC::DFG::saveOrCopyCalleeSavesFor):
(JSC::DFG::createDirectArgumentsDuringExit):
(JSC::DFG::createClonedArgumentsDuringExit):
(JSC::DFG::emitRestoreArguments):
(JSC::DFG::OSRExit::executeOSRExit):
(JSC::DFG::reifyInlinedCallFrames):
(JSC::DFG::adjustAndJumpToTarget):
(JSC::DFG::printOSRExit):

  • dfg/DFGOSRExit.h:

(JSC::DFG::OSRExitState::OSRExitState):

  • dfg/DFGThunks.cpp:

(JSC::DFG::osrExitThunkGenerator):

  • dfg/DFGThunks.h:
  • dfg/DFGVariableEventStream.cpp:

(JSC::DFG::tryToSetConstantRecovery):
(JSC::DFG::VariableEventStream::reconstruct const):
(JSC::DFG::VariableEventStream::tryToSetConstantRecovery const): Deleted.

  • dfg/DFGVariableEventStream.h:
  • profiler/ProfilerOSRExit.h:

(JSC::Profiler::OSRExit::incCount):

  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:
  • runtime/Options.h:

Tools:

Enable --useProbeOSrExit=true for dfg-eager and ftl-no-cjit-validate-sampling-profiler
test configurations.

  • Scripts/run-jsc-stress-tests:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/ProbeStack.cpp

    r222058 r222871  
    3535namespace Probe {
    3636
     37static void* const maxLowWatermark = reinterpret_cast<void*>(std::numeric_limits<uintptr_t>::max());
     38
    3739#if ASAN_ENABLED
    3840// FIXME: we should consider using the copy function for both ASan and non-ASan builds.
     
    5052}
    5153#else
    52 #define copyStackPage(dst, src, size) std::memcpy(dst, src, size);
     54#define copyStackPage(dst, src, size) std::memcpy(dst, src, size)
    5355#endif
    5456
     
    8587}
    8688
     89void* Page::lowWatermarkFromVisitingDirtyChunks()
     90{
     91    uint64_t dirtyBits = m_dirtyBits;
     92    size_t offset = 0;
     93    while (dirtyBits) {
     94        if (dirtyBits & 1)
     95            return reinterpret_cast<uint8_t*>(m_baseLogicalAddress) + offset;
     96        dirtyBits = dirtyBits >> 1;
     97        offset += s_chunkSize;
     98    }
     99    return maxLowWatermark;
     100}
     101
    87102Stack::Stack(Stack&& other)
    88     : m_newStackPointer(other.m_newStackPointer)
    89     , m_lowWatermark(other.m_lowWatermark)
    90     , m_stackBounds(WTFMove(other.m_stackBounds))
     103    : m_stackBounds(WTFMove(other.m_stackBounds))
    91104    , m_pages(WTFMove(other.m_pages))
    92105{
     106    m_savedStackPointer = other.m_savedStackPointer;
    93107#if !ASSERT_DISABLED
    94108    other.m_isValid = false;
     
    129143}
    130144
     145void* Stack::lowWatermarkFromVisitingDirtyPages()
     146{
     147    void* low = maxLowWatermark;
     148    for (auto it = m_pages.begin(); it != m_pages.end(); ++it) {
     149        Page& page = *it->value;
     150        if (!page.hasWritesToFlush() || low < page.baseAddress())
     151            continue;
     152        low = std::min(low, page.lowWatermarkFromVisitingDirtyChunks());
     153    }
     154    return low;
     155}
     156
    131157} // namespace Probe
    132158} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.