Title: [265297] trunk/Source/_javascript_Core
Revision
265297
Author
[email protected]
Date
2020-08-05 12:12:00 -0700 (Wed, 05 Aug 2020)

Log Message

Add assertions / inline capacity to checkpoint side state stacks
https://bugs.webkit.org/show_bug.cgi?id=215175

Reviewed by Saam Barati.

The inline capacity should hopefully avoid unneeded mallocs close to 100% of the time during our OSR exit ramp.

* dfg/DFGOSRExit.cpp:
(JSC::DFG::OSRExit::compileExit):
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* runtime/VM.cpp:
(JSC::VM::pushCheckpointOSRSideState):
* runtime/VM.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (265296 => 265297)


--- trunk/Source/_javascript_Core/ChangeLog	2020-08-05 18:53:08 UTC (rev 265296)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-08-05 19:12:00 UTC (rev 265297)
@@ -1,3 +1,20 @@
+2020-08-05  Keith Miller  <[email protected]>
+
+        Add assertions / inline capacity to checkpoint side state stacks
+        https://bugs.webkit.org/show_bug.cgi?id=215175
+
+        Reviewed by Saam Barati.
+
+        The inline capacity should hopefully avoid unneeded mallocs close to 100% of the time during our OSR exit ramp.
+
+        * dfg/DFGOSRExit.cpp:
+        (JSC::DFG::OSRExit::compileExit):
+        * ftl/FTLOSRExitCompiler.cpp:
+        (JSC::FTL::compileStub):
+        * runtime/VM.cpp:
+        (JSC::VM::pushCheckpointOSRSideState):
+        * runtime/VM.h:
+
 2020-08-04  Yusuke Suzuki  <[email protected]>
 
         [JSC] Use LazyNeverDestroyed & std::call_once for complex singletons

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp (265296 => 265297)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2020-08-05 18:53:08 UTC (rev 265296)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2020-08-05 19:12:00 UTC (rev 265297)
@@ -593,7 +593,7 @@
         VM* vmPtr = &vm;
         auto* tmpScratch = scratch + operands.tmpIndex(0);
         jit.probe([=, values = WTFMove(values)] (Probe::Context& context) {
-            Vector<std::unique_ptr<CheckpointOSRExitSideState>> sideStates;
+            Vector<std::unique_ptr<CheckpointOSRExitSideState>, VM::expectedMaxActiveSideStateCount> sideStates;
             sideStates.reserveInitialCapacity(exit.m_codeOrigin.inlineDepth());
             auto sideStateCommitter = makeScopeExit([&] {
                 for (size_t i = sideStates.size(); i--;)

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp (265296 => 265297)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2020-08-05 18:53:08 UTC (rev 265296)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2020-08-05 19:12:00 UTC (rev 265297)
@@ -483,7 +483,7 @@
         JSValue* tmpScratch = reinterpret_cast<JSValue*>(scratch + exit.m_descriptor->m_values.tmpIndex(0));
         VM* vmPtr = &vm;
         jit.probe([=] (Probe::Context& context) {
-            Vector<std::unique_ptr<CheckpointOSRExitSideState>> sideStates;
+            Vector<std::unique_ptr<CheckpointOSRExitSideState>, VM::expectedMaxActiveSideStateCount> sideStates;
             sideStates.reserveInitialCapacity(exit.m_codeOrigin.inlineDepth());
             auto sideStateCommitter = makeScopeExit([&] {
                 for (size_t i = sideStates.size(); i--;)

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (265296 => 265297)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2020-08-05 18:53:08 UTC (rev 265296)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2020-08-05 19:12:00 UTC (rev 265297)
@@ -1094,6 +1094,18 @@
         ASSERT(sideState->associatedCallFrame != payload->associatedCallFrame);
 #endif
     m_checkpointSideState.append(WTFMove(payload));
+
+#if ASSERT_ENABLED
+    auto bounds = StackBounds::currentThreadStackBounds();
+    void* previousCallFrame = bounds.end();
+    for (size_t i = m_checkpointSideState.size(); i--;) {
+        auto* callFrame = m_checkpointSideState[i]->associatedCallFrame;
+        if (!bounds.contains(callFrame))
+            break;
+        ASSERT(previousCallFrame < callFrame);
+        previousCallFrame = callFrame;
+    }
+#endif
 }
 
 std::unique_ptr<CheckpointOSRExitSideState> VM::popCheckpointOSRSideState(CallFrame* expectedCallFrame)

Modified: trunk/Source/_javascript_Core/runtime/VM.h (265296 => 265297)


--- trunk/Source/_javascript_Core/runtime/VM.h	2020-08-05 18:53:08 UTC (rev 265296)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2020-08-05 19:12:00 UTC (rev 265297)
@@ -944,6 +944,7 @@
 
     void gatherScratchBufferRoots(ConservativeRoots&);
 
+    static constexpr unsigned expectedMaxActiveSideStateCount = 4;
     void pushCheckpointOSRSideState(std::unique_ptr<CheckpointOSRExitSideState>&&);
     std::unique_ptr<CheckpointOSRExitSideState> popCheckpointOSRSideState(CallFrame* expectedFrame);
     void popAllCheckpointOSRSideStateUntil(CallFrame* targetFrame);
@@ -1207,7 +1208,7 @@
     Lock m_scratchBufferLock;
     Vector<ScratchBuffer*> m_scratchBuffers;
     size_t m_sizeOfLastScratchBuffer { 0 };
-    Vector<std::unique_ptr<CheckpointOSRExitSideState>, 4> m_checkpointSideState;
+    Vector<std::unique_ptr<CheckpointOSRExitSideState>, expectedMaxActiveSideStateCount> m_checkpointSideState;
     InlineWatchpointSet m_primitiveGigacageEnabled;
     FunctionHasExecutedCache m_functionHasExecutedCache;
     std::unique_ptr<ControlFlowProfiler> m_controlFlowProfiler;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to