Title: [260772] trunk/Source/_javascript_Core
Revision
260772
Author
[email protected]
Date
2020-04-27 13:22:31 -0700 (Mon, 27 Apr 2020)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (260771 => 260772)


--- trunk/Source/_javascript_Core/ChangeLog	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-04-27 20:22:31 UTC (rev 260772)
@@ -1,3 +1,31 @@
+2020-04-27  Keith Miller  <[email protected]>
+
+        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):
+
 2020-04-27  Ross Kirsling  <[email protected]>
 
         [JSC] CallData/ConstructData should include CallType/ConstructType

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp (260771 => 260772)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2020-04-27 20:22:31 UTC (rev 260772)
@@ -49,7 +49,7 @@
 namespace JSC { namespace DFG {
 
 OSRExit::OSRExit(ExitKind kind, JSValueSource jsValueSource, MethodOfGettingAValueProfile valueProfile, SpeculativeJIT* jit, unsigned streamIndex, unsigned recoveryIndex)
-    : OSRExitBase(kind, jit->m_origin.forExit, jit->m_origin.semantic, jit->m_origin.wasHoisted)
+    : OSRExitBase(kind, jit->m_origin.forExit, jit->m_origin.semantic, jit->m_origin.wasHoisted, jit->m_currentNode ? jit->m_currentNode->index() : 0)
     , m_jsValueSource(jsValueSource)
     , m_valueProfile(valueProfile)
     , m_recoveryIndex(recoveryIndex)
@@ -209,8 +209,8 @@
         exit.m_code = FINALIZE_CODE_IF(
             shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseDFGOSRExit(),
             patchBuffer, OSRExitPtrTag,
-            "DFG OSR exit #%u (%s, %s) from %s, with operands = %s",
-                exitIndex, toCString(exit.m_codeOrigin).data(),
+            "DFG OSR exit #%u (D@%u, %s, %s) from %s, with operands = %s",
+                exitIndex, exit.m_dfgNodeIndex, toCString(exit.m_codeOrigin).data(),
                 exitKindToString(exit.m_kind), toCString(*codeBlock).data(),
                 toCString(ignoringContext<DumpContext>(operands)).data());
     }

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExitBase.h (260771 => 260772)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExitBase.h	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExitBase.h	2020-04-27 20:22:31 UTC (rev 260772)
@@ -39,11 +39,12 @@
 // and the FTL.
 
 struct OSRExitBase {
-    OSRExitBase(ExitKind kind, CodeOrigin origin, CodeOrigin originForProfile, bool wasHoisted)
+    OSRExitBase(ExitKind kind, CodeOrigin origin, CodeOrigin originForProfile, bool wasHoisted, uint32_t dfgNodeIndex)
         : m_kind(kind)
         , m_wasHoisted(wasHoisted)
         , m_codeOrigin(origin)
         , m_codeOriginForExitProfile(originForProfile)
+        , m_dfgNodeIndex(dfgNodeIndex)
     {
         ASSERT(m_codeOrigin.isSet());
         ASSERT(m_codeOriginForExitProfile.isSet());
@@ -56,6 +57,7 @@
     CodeOrigin m_codeOrigin;
     CodeOrigin m_codeOriginForExitProfile;
     CallSiteIndex m_exceptionHandlerCallSiteIndex;
+    uint32_t m_dfgNodeIndex;
 
     ALWAYS_INLINE bool isExceptionHandler() const
     {

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2020-04-27 20:22:31 UTC (rev 260772)
@@ -353,6 +353,7 @@
             }
 
             m_node = nullptr;
+            m_nodeIndexInGraph = 0;
             m_origin = NodeOrigin(CodeOrigin(BytecodeIndex(0)), CodeOrigin(BytecodeIndex(0)), true);
 
             // Check Arguments.
@@ -511,8 +512,8 @@
         m_state.reset();
         m_state.beginBasicBlock(m_highBlock);
         
-        for (m_nodeIndex = 0; m_nodeIndex < m_highBlock->size(); ++m_nodeIndex) {
-            if (!compileNode(m_nodeIndex))
+        for (unsigned nodeIndex = 0; nodeIndex < m_highBlock->size(); ++nodeIndex) {
+            if (!compileNode(nodeIndex))
                 break;
         }
     }
@@ -675,6 +676,7 @@
         }
         
         m_node = m_highBlock->at(nodeIndex);
+        m_nodeIndexInGraph = m_node->index();
         m_origin = m_node->origin;
         m_out.setOrigin(m_node);
         
@@ -10822,7 +10824,7 @@
                 CCallHelpers::Label label = jit.watchpointLabel();
 
                 RefPtr<OSRExitHandle> handle = descriptor->emitOSRExitLater(
-                    *state, UncountableInvalidation, origin, params);
+                    *state, UncountableInvalidation, origin, params, m_nodeIndexInGraph, 0);
 
                 RefPtr<JITCode> jitCode = state->jitCode.get();
 
@@ -13896,7 +13898,7 @@
                 for (unsigned i = 0; i < domJIT->numFPScratchRegisters; ++i)
                     fpScratch.append(params.fpScratch(i));
 
-                RefPtr<OSRExitHandle> handle = exitDescriptor->emitOSRExitLater(*state, BadType, origin, params, osrExitArgumentOffset);
+                RefPtr<OSRExitHandle> handle = exitDescriptor->emitOSRExitLater(*state, BadType, origin, params, m_nodeIndexInGraph, osrExitArgumentOffset);
 
                 SnippetParams domJITParams(*state, params, node, nullptr, WTFMove(regs), WTFMove(gpScratch), WTFMove(fpScratch));
                 CCallHelpers::JumpList failureCases = domJIT->generator()->run(jit, domJITParams);
@@ -18586,7 +18588,7 @@
         HandlerInfo* exceptionHandler;
         bool willCatchException = m_graph.willCatchExceptionInMachineFrame(m_origin.forExit, opCatchOrigin, exceptionHandler);
         if (!willCatchException)
-            return PatchpointExceptionHandle::defaultHandle(m_ftlState);
+            return PatchpointExceptionHandle::defaultHandle(m_ftlState, m_nodeIndexInGraph);
 
         dataLogLnIf(verboseCompilationEnabled(), "    Patchpoint exception OSR exit #", m_ftlState.jitCode->osrExitDescriptors.size(), " with availability: ", availabilityMap());
 
@@ -18609,7 +18611,7 @@
             ValueRep::LateColdAny);
 
         return PatchpointExceptionHandle::create(
-            m_ftlState, exitDescriptor, origin, offset, *exceptionHandler);
+            m_ftlState, exitDescriptor, origin, m_nodeIndexInGraph, offset, *exceptionHandler);
     }
 
     LBasicBlock lowBlock(DFG::BasicBlock* block)
@@ -18691,7 +18693,7 @@
         value->setGenerator(
             [=] (CCallHelpers& jit, const B3::StackmapGenerationParams& params) {
                 exitDescriptor->emitOSRExit(
-                    *state, kind, origin, jit, params, 0);
+                    *state, kind, origin, jit, params, m_nodeIndexInGraph, 0);
             });
     }
 
@@ -19186,7 +19188,7 @@
     LBasicBlock m_nextLowBlock;
 
     NodeOrigin m_origin;
-    unsigned m_nodeIndex;
+    unsigned m_nodeIndexInGraph { 0 };
     Node* m_node;
 
     // These are used for validating AI state.

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp	2020-04-27 20:22:31 UTC (rev 260772)
@@ -65,10 +65,10 @@
 
 Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExit(
     State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin, CCallHelpers& jit,
-    const StackmapGenerationParams& params, unsigned offset)
+    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
 {
     Ref<OSRExitHandle> handle =
-        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
+        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, dfgNodeIndex, offset);
     handle->emitExitThunk(state, jit);
     return handle;
 }
@@ -75,10 +75,10 @@
 
 Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExitLater(
     State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
-    const StackmapGenerationParams& params, unsigned offset)
+    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
 {
     RefPtr<OSRExitHandle> handle =
-        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
+        prepareOSRExitHandle(state, exitKind, nodeOrigin, params, dfgNodeIndex, offset);
     params.addLatePath(
         [handle, &state] (CCallHelpers& jit) {
             handle->emitExitThunk(state, jit);
@@ -88,11 +88,11 @@
 
 Ref<OSRExitHandle> OSRExitDescriptor::prepareOSRExitHandle(
     State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
-    const StackmapGenerationParams& params, unsigned offset)
+    const StackmapGenerationParams& params, uint32_t dfgNodeIndex, unsigned offset)
 {
     unsigned index = state.jitCode->osrExit.size();
     OSRExit& exit = state.jitCode->osrExit.alloc(
-        this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted);
+        this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted, dfgNodeIndex);
     Ref<OSRExitHandle> handle = adoptRef(*new OSRExitHandle(index, exit));
     for (unsigned i = offset; i < params.size(); ++i)
         exit.m_valueReps.append(params[i]);
@@ -102,8 +102,8 @@
 
 OSRExit::OSRExit(
     OSRExitDescriptor* descriptor, ExitKind exitKind, CodeOrigin codeOrigin,
-    CodeOrigin codeOriginForExitProfile, bool wasHoisted)
-    : OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted)
+    CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex)
+    : OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted, dfgNodeIndex)
     , m_descriptor(descriptor)
 {
 }

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExit.h (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExit.h	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExit.h	2020-04-27 20:22:31 UTC (rev 260772)
@@ -92,7 +92,7 @@
     // this call, the OSRExit is simply ready to go.
     Ref<OSRExitHandle> emitOSRExit(
         State&, ExitKind, const DFG::NodeOrigin&, CCallHelpers&, const B3::StackmapGenerationParams&,
-        unsigned offset = 0);
+        uint32_t dfgNodeIndex, unsigned offset);
 
     // In some cases you want an OSRExit to come into existence, but you don't want to emit it right now.
     // This will emit the OSR exit in a late path. You can't be sure exactly when that will happen, but
@@ -104,7 +104,7 @@
     // eventually gets access to its label.
     Ref<OSRExitHandle> emitOSRExitLater(
         State&, ExitKind, const DFG::NodeOrigin&, const B3::StackmapGenerationParams&,
-        unsigned offset = 0);
+        uint32_t dfgNodeIndex, unsigned offset);
 
 private:
     // This is the low-level interface. It will create a handle representing the desire to emit code for
@@ -112,11 +112,11 @@
     // that the above two APIs are written in terms of this and OSRExitHandle::emitExitThunk().
     Ref<OSRExitHandle> prepareOSRExitHandle(
         State&, ExitKind, const DFG::NodeOrigin&, const B3::StackmapGenerationParams&,
-        unsigned offset = 0);
+        uint32_t dfgNodeIndex, unsigned offset);
 };
 
 struct OSRExit : public DFG::OSRExitBase {
-    OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted);
+    OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex);
 
     OSRExitDescriptor* m_descriptor;
     MacroAssemblerCodeRef<OSRExitPtrTag> m_code;

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2020-04-27 20:22:31 UTC (rev 260772)
@@ -532,8 +532,8 @@
     exit.m_code = FINALIZE_CODE_IF(
         shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseFTLOSRExit(),
         patchBuffer, OSRExitPtrTag,
-        "FTL OSR exit #%u (%s, %s) from %s, with operands = %s",
-            exitID, toCString(exit.m_codeOrigin).data(),
+        "FTL OSR exit #%u (D@%u, %s, %s) from %s, with operands = %s",
+            exitID, exit.m_dfgNodeIndex, toCString(exit.m_codeOrigin).data(),
             exitKindToString(exit.m_kind), toCString(*codeBlock).data(),
             toCString(ignoringContext<DumpContext>(exit.m_descriptor->m_values)).data()
         );

Modified: trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp	2020-04-27 20:22:31 UTC (rev 260772)
@@ -39,17 +39,17 @@
 using namespace DFG;
 
 Ref<PatchpointExceptionHandle> PatchpointExceptionHandle::create(
-    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned offset,
+    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned dfgNodeIndex, unsigned offset,
     const HandlerInfo& handler)
 {
-    return adoptRef(*new PatchpointExceptionHandle(state, descriptor, origin, offset, handler));
+    return adoptRef(*new PatchpointExceptionHandle(state, descriptor, origin, dfgNodeIndex, offset, handler));
 }
 
-RefPtr<PatchpointExceptionHandle> PatchpointExceptionHandle::defaultHandle(State& state)
+RefPtr<PatchpointExceptionHandle> PatchpointExceptionHandle::defaultHandle(State& state, unsigned dfgNodeIndex)
 {
     if (!state.defaultExceptionHandle) {
         state.defaultExceptionHandle = adoptRef(
-            new PatchpointExceptionHandle(state, nullptr, NodeOrigin(), 0, HandlerInfo()));
+            new PatchpointExceptionHandle(state, nullptr, NodeOrigin(), dfgNodeIndex, 0, HandlerInfo()));
     }
     return state.defaultExceptionHandle;
 }
@@ -98,11 +98,12 @@
 }
 
 PatchpointExceptionHandle::PatchpointExceptionHandle(
-    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned offset,
+    State& state, OSRExitDescriptor* descriptor, NodeOrigin origin, unsigned dfgNodeIndex, unsigned offset,
     const HandlerInfo& handler)
     : m_state(state)
     , m_descriptor(descriptor)
     , m_origin(origin)
+    , m_dfgNodeIndex(dfgNodeIndex)
     , m_offset(offset)
     , m_handler(handler)
 {
@@ -112,7 +113,7 @@
     ExitKind kind, const B3::StackmapGenerationParams& params)
 {
     return m_descriptor->emitOSRExitLater(
-        m_state, kind, m_origin, params, m_offset);
+        m_state, kind, m_origin, params, m_dfgNodeIndex, m_offset);
 }
 
 } } // namespace JSC::FTL

Modified: trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.h (260771 => 260772)


--- trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.h	2020-04-27 20:21:17 UTC (rev 260771)
+++ trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.h	2020-04-27 20:22:31 UTC (rev 260772)
@@ -52,9 +52,9 @@
 class PatchpointExceptionHandle : public ThreadSafeRefCounted<PatchpointExceptionHandle> {
 public:
     static Ref<PatchpointExceptionHandle> create(
-        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned offset, const HandlerInfo&);
+        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned dfgNodeIndex, unsigned offset, const HandlerInfo&);
 
-    static RefPtr<PatchpointExceptionHandle> defaultHandle(State&);
+    static RefPtr<PatchpointExceptionHandle> defaultHandle(State&, unsigned dfgNodeIndex);
     
     ~PatchpointExceptionHandle();
 
@@ -87,7 +87,7 @@
 
 private:
     PatchpointExceptionHandle(
-        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned offset, const HandlerInfo&);
+        State&, OSRExitDescriptor*, DFG::NodeOrigin, unsigned dfgNodeIndex, unsigned offset, const HandlerInfo&);
 
     Ref<OSRExitHandle> createHandle(ExitKind, const B3::StackmapGenerationParams&);
 
@@ -94,6 +94,7 @@
     State& m_state;
     OSRExitDescriptor* m_descriptor;
     DFG::NodeOrigin m_origin;
+    unsigned m_dfgNodeIndex;
     unsigned m_offset;
     HandlerInfo m_handler;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to