Changeset 260803 in webkit


Ignore:
Timestamp:
Apr 27, 2020 5:51:50 PM (4 years ago)
Author:
keith_miller@apple.com
Message:

OSR Exit compiler should know and print the exiting DFG node's index
https://bugs.webkit.org/show_bug.cgi?id=210998

Reviewed by Mark Lam.

The only interesting thing here is that we set the node to index 0 if there is no node.
AFAICT, we only don't have a node when we are checking arguments.

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::OSRExit):
(JSC::DFG::operationCompileOSRExit):

  • dfg/DFGOSRExitBase.h:

(JSC::DFG::OSRExitBase::OSRExitBase):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileInvalidationPoint):
(JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass):
(JSC::FTL::DFG::LowerDFGToB3::blessSpeculation):

  • ftl/FTLOSRExit.cpp:

(JSC::FTL::OSRExitDescriptor::emitOSRExit):
(JSC::FTL::OSRExitDescriptor::emitOSRExitLater):
(JSC::FTL::OSRExitDescriptor::prepareOSRExitHandle):
(JSC::FTL::OSRExit::OSRExit):

  • ftl/FTLOSRExit.h:
  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r260802 r260803  
     12020-04-27  Keith Miller  <keith_miller@apple.com>
     2
     3        OSR Exit compiler should know and print the exiting DFG node's index
     4        https://bugs.webkit.org/show_bug.cgi?id=210998
     5
     6        Reviewed by Mark Lam.
     7
     8        The only interesting thing here is that we set the node to index 0 if there is no node.
     9        AFAICT, we only don't have a node when we are checking arguments.
     10
     11        * dfg/DFGOSRExit.cpp:
     12        (JSC::DFG::OSRExit::OSRExit):
     13        (JSC::DFG::operationCompileOSRExit):
     14        * dfg/DFGOSRExitBase.h:
     15        (JSC::DFG::OSRExitBase::OSRExitBase):
     16        * ftl/FTLLowerDFGToB3.cpp:
     17        (JSC::FTL::DFG::LowerDFGToB3::compileInvalidationPoint):
     18        (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass):
     19        (JSC::FTL::DFG::LowerDFGToB3::blessSpeculation):
     20        * ftl/FTLOSRExit.cpp:
     21        (JSC::FTL::OSRExitDescriptor::emitOSRExit):
     22        (JSC::FTL::OSRExitDescriptor::emitOSRExitLater):
     23        (JSC::FTL::OSRExitDescriptor::prepareOSRExitHandle):
     24        (JSC::FTL::OSRExit::OSRExit):
     25        * ftl/FTLOSRExit.h:
     26        * ftl/FTLOSRExitCompiler.cpp:
     27        (JSC::FTL::compileStub):
     28
    1292020-04-27  Saam Barati  <sbarati@apple.com>
    230
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp

    r260799 r260803  
    5050
    5151OSRExit::OSRExit(ExitKind kind, JSValueSource jsValueSource, MethodOfGettingAValueProfile valueProfile, SpeculativeJIT* jit, unsigned streamIndex, unsigned recoveryIndex)
    52     : OSRExitBase(kind, jit->m_origin.forExit, jit->m_origin.semantic, jit->m_origin.wasHoisted)
     52    : OSRExitBase(kind, jit->m_origin.forExit, jit->m_origin.semantic, jit->m_origin.wasHoisted, jit->m_currentNode ? jit->m_currentNode->index() : 0)
    5353    , m_jsValueSource(jsValueSource)
    5454    , m_valueProfile(valueProfile)
     
    210210            shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseDFGOSRExit(),
    211211            patchBuffer, OSRExitPtrTag,
    212             "DFG OSR exit #%u (%s, %s) from %s, with operands = %s",
    213                 exitIndex, toCString(exit.m_codeOrigin).data(),
     212            "DFG OSR exit #%u (D@%u, %s, %s) from %s, with operands = %s",
     213                exitIndex, exit.m_dfgNodeIndex, toCString(exit.m_codeOrigin).data(),
    214214                exitKindToString(exit.m_kind), toCString(*codeBlock).data(),
    215215                toCString(ignoringContext<DumpContext>(operands)).data());
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitBase.h

    r260799 r260803  
    4040
    4141struct OSRExitBase {
    42     OSRExitBase(ExitKind kind, CodeOrigin origin, CodeOrigin originForProfile, bool wasHoisted)
     42    OSRExitBase(ExitKind kind, CodeOrigin origin, CodeOrigin originForProfile, bool wasHoisted, uint32_t dfgNodeIndex)
    4343        : m_kind(kind)
    4444        , m_wasHoisted(wasHoisted)
    4545        , m_codeOrigin(origin)
    4646        , m_codeOriginForExitProfile(originForProfile)
     47        , m_dfgNodeIndex(dfgNodeIndex)
    4748    {
    4849        ASSERT(m_codeOrigin.isSet());
     
    5758    CodeOrigin m_codeOriginForExitProfile;
    5859    CallSiteIndex m_exceptionHandlerCallSiteIndex;
     60    uint32_t m_dfgNodeIndex;
    5961
    6062    ALWAYS_INLINE bool isExceptionHandler() const
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r260799 r260803  
    354354
    355355            m_node = nullptr;
     356            m_nodeIndexInGraph = 0;
    356357            m_origin = NodeOrigin(CodeOrigin(BytecodeIndex(0)), CodeOrigin(BytecodeIndex(0)), true);
    357358
     
    512513        m_state.beginBasicBlock(m_highBlock);
    513514       
    514         for (m_nodeIndex = 0; m_nodeIndex < m_highBlock->size(); ++m_nodeIndex) {
    515             if (!compileNode(m_nodeIndex))
     515        for (unsigned nodeIndex = 0; nodeIndex < m_highBlock->size(); ++nodeIndex) {
     516            if (!compileNode(nodeIndex))
    516517                break;
    517518        }
     
    676677       
    677678        m_node = m_highBlock->at(nodeIndex);
     679        m_nodeIndexInGraph = m_node->index();
    678680        m_origin = m_node->origin;
    679681        m_out.setOrigin(m_node);
     
    1081510817        State* state = &m_ftlState;
    1081610818
     10819        auto nodeIndex = m_nodeIndexInGraph;
    1081710820        patchpoint->setGenerator(
    1081810821            [=] (CCallHelpers& jit, const B3::StackmapGenerationParams& params) {
     
    1082310826
    1082410827                RefPtr<OSRExitHandle> handle = descriptor->emitOSRExitLater(
    10825                     *state, UncountableInvalidation, origin, params);
     10828                    *state, UncountableInvalidation, origin, params, nodeIndex, 0);
    1082610829
    1082710830                RefPtr<JITCode> jitCode = state->jitCode.get();
     
    1388113884        JSValue child1Constant = m_state.forNode(m_node->child1()).value();
    1388213885
     13886        auto nodeIndex = m_nodeIndexInGraph;
    1388313887        patchpoint->setGenerator(
    1388413888            [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
     
    1389713901                    fpScratch.append(params.fpScratch(i));
    1389813902
    13899                 RefPtr<OSRExitHandle> handle = exitDescriptor->emitOSRExitLater(*state, BadType, origin, params, osrExitArgumentOffset);
     13903                RefPtr<OSRExitHandle> handle = exitDescriptor->emitOSRExitLater(*state, BadType, origin, params, nodeIndex, osrExitArgumentOffset);
    1390013904
    1390113905                SnippetParams domJITParams(*state, params, node, nullptr, WTFMove(regs), WTFMove(gpScratch), WTFMove(fpScratch));
     
    1858718591        bool willCatchException = m_graph.willCatchExceptionInMachineFrame(m_origin.forExit, opCatchOrigin, exceptionHandler);
    1858818592        if (!willCatchException)
    18589             return PatchpointExceptionHandle::defaultHandle(m_ftlState);
     18593            return PatchpointExceptionHandle::defaultHandle(m_ftlState, m_nodeIndexInGraph);
    1859018594
    1859118595        dataLogLnIf(verboseCompilationEnabled(), "    Patchpoint exception OSR exit #", m_ftlState.jitCode->osrExitDescriptors.size(), " with availability: ", availabilityMap());
     
    1861018614
    1861118615        return PatchpointExceptionHandle::create(
    18612             m_ftlState, exitDescriptor, origin, offset, *exceptionHandler);
     18616            m_ftlState, exitDescriptor, origin, m_nodeIndexInGraph, offset, *exceptionHandler);
    1861318617    }
    1861418618
     
    1868918693
    1869018694        State* state = &m_ftlState;
     18695        auto nodeIndex = m_nodeIndexInGraph;
    1869118696        value->setGenerator(
    1869218697            [=] (CCallHelpers& jit, const B3::StackmapGenerationParams& params) {
    1869318698                exitDescriptor->emitOSRExit(
    18694                     *state, kind, origin, jit, params, 0);
     18699                    *state, kind, origin, jit, params, nodeIndex, 0);
    1869518700            });
    1869618701    }
     
    1918719192
    1918819193    NodeOrigin m_origin;
    19189     unsigned m_nodeIndex;
     19194    unsigned m_nodeIndexInGraph { 0 };
    1919019195    Node* m_node;
    1919119196
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExit.cpp

    r260799 r260803  
    6666Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExit(
    6767    State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin, CCallHelpers& jit,
    68     const StackmapGenerationParams& params, unsigned offset)
     68    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
    6969{
    7070    Ref<OSRExitHandle> handle =
    71         prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
     71        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, dfgNodeIndex, offset);
    7272    handle->emitExitThunk(state, jit);
    7373    return handle;
     
    7676Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExitLater(
    7777    State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
    78     const StackmapGenerationParams& params, unsigned offset)
     78    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
    7979{
    8080    RefPtr<OSRExitHandle> handle =
    81         prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
     81        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, dfgNodeIndex, offset);
    8282    params.addLatePath(
    8383        [handle, &state] (CCallHelpers& jit) {
     
    8989Ref<OSRExitHandle> OSRExitDescriptor::prepareOSRExitHandle(
    9090    State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
    91     const StackmapGenerationParams& params, unsigned offset)
     91    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
    9292{
    9393    unsigned index = state.jitCode->osrExit.size();
    9494    OSRExit& exit = state.jitCode->osrExit.alloc(
    95         this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted);
     95        this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted, dfgNodeIndex);
    9696    Ref<OSRExitHandle> handle = adoptRef(*new OSRExitHandle(index, exit));
    9797    for (unsigned i = offset; i < params.size(); ++i)
     
    103103OSRExit::OSRExit(
    104104    OSRExitDescriptor* descriptor, ExitKind exitKind, CodeOrigin codeOrigin,
    105     CodeOrigin codeOriginForExitProfile, bool wasHoisted)
    106     : OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted)
     105    CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex)
     106    : OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted, dfgNodeIndex)
    107107    , m_descriptor(descriptor)
    108108{
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExit.h

    r260799 r260803  
    9393    Ref<OSRExitHandle> emitOSRExit(
    9494        State&, ExitKind, const DFG::NodeOrigin&, CCallHelpers&, const B3::StackmapGenerationParams&,
    95         unsigned offset = 0);
     95        uint32_t dfgNodeIndex, unsigned offset);
    9696
    9797    // In some cases you want an OSRExit to come into existence, but you don't want to emit it right now.
     
    105105    Ref<OSRExitHandle> emitOSRExitLater(
    106106        State&, ExitKind, const DFG::NodeOrigin&, const B3::StackmapGenerationParams&,
    107         unsigned offset = 0);
     107        uint32_t dfgNodeIndex, unsigned offset);
    108108
    109109private:
     
    113113    Ref<OSRExitHandle> prepareOSRExitHandle(
    114114        State&, ExitKind, const DFG::NodeOrigin&, const B3::StackmapGenerationParams&,
    115         unsigned offset = 0);
     115        uint32_t dfgNodeIndex, unsigned offset);
    116116};
    117117
    118118struct OSRExit : public DFG::OSRExitBase {
    119     OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted);
     119    OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex);
    120120
    121121    OSRExitDescriptor* m_descriptor;
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp

    r260799 r260803  
    533533        shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseFTLOSRExit(),
    534534        patchBuffer, OSRExitPtrTag,
    535         "FTL OSR exit #%u (%s, %s) from %s, with operands = %s",
    536             exitID, toCString(exit.m_codeOrigin).data(),
     535        "FTL OSR exit #%u (D@%u, %s, %s) from %s, with operands = %s",
     536            exitID, exit.m_dfgNodeIndex, toCString(exit.m_codeOrigin).data(),
    537537            exitKindToString(exit.m_kind), toCString(*codeBlock).data(),
    538538            toCString(ignoringContext<DumpContext>(exit.m_descriptor->m_values)).data()
  • trunk/Source/JavaScriptCore/ftl/FTLPatchpointExceptionHandle.cpp

    r260799 r260803  
    4040
    4141Ref<PatchpointExceptionHandle> PatchpointExceptionHandle::create(
    42     State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned offset,
     42    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned dfgNodeIndex, unsigned offset,
    4343    const HandlerInfo& handler)
    4444{
    45     return adoptRef(*new PatchpointExceptionHandle(state, descriptor, origin, offset, handler));
     45    return adoptRef(*new PatchpointExceptionHandle(state, descriptor, origin, dfgNodeIndex, offset, handler));
    4646}
    4747
    48 RefPtr<PatchpointExceptionHandle> PatchpointExceptionHandle::defaultHandle(State& state)
     48RefPtr<PatchpointExceptionHandle> PatchpointExceptionHandle::defaultHandle(State& state, unsigned dfgNodeIndex)
    4949{
    5050    if (!state.defaultExceptionHandle) {
    5151        state.defaultExceptionHandle = adoptRef(
    52             new PatchpointExceptionHandle(state, nullptr, NodeOrigin(), 0, HandlerInfo()));
     52            new PatchpointExceptionHandle(state, nullptr, NodeOrigin(), dfgNodeIndex, 0, HandlerInfo()));
    5353    }
    5454    return state.defaultExceptionHandle;
     
    9999
    100100PatchpointExceptionHandle::PatchpointExceptionHandle(
    101     State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned offset,
     101    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned dfgNodeIndex, unsigned offset,
    102102    const HandlerInfo& handler)
    103103    : m_state(state)
    104104    , m_descriptor(descriptor)
    105105    , m_origin(origin)
     106    , m_dfgNodeIndex(dfgNodeIndex)
    106107    , m_offset(offset)
    107108    , m_handler(handler)
     
    113114{
    114115    return m_descriptor->emitOSRExitLater(
    115         m_state, kind, m_origin, params, m_offset);
     116        m_state, kind, m_origin, params, m_dfgNodeIndex, m_offset);
    116117}
    117118
  • trunk/Source/JavaScriptCore/ftl/FTLPatchpointExceptionHandle.h

    r260799 r260803  
    5353public:
    5454    static Ref<PatchpointExceptionHandle> create(
    55         State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned offset, const HandlerInfo&);
     55        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned dfgNodeIndex, unsigned offset, const HandlerInfo&);
    5656
    57     static RefPtr<PatchpointExceptionHandle> defaultHandle(State&);
     57    static RefPtr<PatchpointExceptionHandle> defaultHandle(State&, unsigned dfgNodeIndex);
    5858   
    5959    ~PatchpointExceptionHandle();
     
    8888private:
    8989    PatchpointExceptionHandle(
    90         State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned offset, const HandlerInfo&);
     90        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned dfgNodeIndex, unsigned offset, const HandlerInfo&);
    9191
    9292    Ref<OSRExitHandle> createHandle(ExitKind, const B3::StackmapGenerationParams&);
     
    9595    OSRExitDescriptor* m_descriptor;
    9696    DFG::NodeOrigin m_origin;
     97    unsigned m_dfgNodeIndex;
    9798    unsigned m_offset;
    9899    HandlerInfo m_handler;
Note: See TracChangeset for help on using the changeset viewer.