Title: [276224] trunk/Source/_javascript_Core
Revision
276224
Author
[email protected]
Date
2021-04-18 00:14:07 -0700 (Sun, 18 Apr 2021)

Log Message

[JSC] Make more DFG/FTL data FixedVector/Vector
https://bugs.webkit.org/show_bug.cgi?id=224713

Reviewed by Darin Adler.

1. DFG::JITCode::m_osrEntry / DFG::JITCode::m_osrExit / DFG::JITCode::m_speculationRecovery are changed to FixedVector.
   They are added at compiling time, and after that, these vectors are not modified. So when finalizing, we can easily make it FixedVector.
   We also change OSREntry::{m_reshufflings,m_expectedValues} to FixedVector and FixedOperands.
2. FTL::JITCode::m_osrExit is changed from SegmentedVector to Vector. We are still using Vector since it also involves osrExitDescriptor.
   But later, we should merge m_osrExit to osrExitDescriptor. Vector is still better than SegmentedVector since it wastes several entries
   per segment. SegmentedVector was used to use a direct pointer of OSRExit (this is not possible in Vector since this pointer can be invalidated
   after growing), but usage of that is fairly limited so that we can just replace them with m_index + osrExit vector.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::tallyFrequentExitSites):
* bytecode/Operands.h:
(JSC::Operands::Operands):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::shrinkToFit):
(JSC::DFG::JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite):
(JSC::DFG::JITCode::validateReferences):
(JSC::DFG::JITCode::findPC):
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGJITCode.h:
* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::noticeOSREntry):
(JSC::DFG::JITCompiler::appendExceptionHandlingOSRExit):
* dfg/DFGJITCompiler.h:
(JSC::DFG::JITCompiler::appendOSRExit):
(JSC::DFG::JITCompiler::appendSpeculationRecovery):
* dfg/DFGOSREntry.h:
* dfg/DFGOSRExit.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::speculationCheck):
(JSC::DFG::SpeculativeJIT::emitInvalidationPoint):
(JSC::DFG::SpeculativeJIT::linkOSREntries):
* ftl/FTLJITCode.cpp:
(JSC::FTL::JITCode::shrinkToFit):
(JSC::FTL::JITCode::validateReferences):
(JSC::FTL::JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite):
(JSC::FTL::JITCode::findPC):
* ftl/FTLJITCode.h:
* ftl/FTLOSRExit.cpp:
(JSC::FTL::OSRExitDescriptor::prepareOSRExitHandle):
(JSC::FTL::OSRExit::OSRExit):
* ftl/FTLOSRExit.h:
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::JSC_DEFINE_JIT_OPERATION):
* ftl/FTLOSRExitHandle.cpp:
(JSC::FTL::OSRExitHandle::emitExitThunk):
* ftl/FTLOSRExitHandle.h:
(JSC::FTL::OSRExitHandle::OSRExitHandle):
* ftl/FTLPatchpointExceptionHandle.cpp:
(JSC::FTL::PatchpointExceptionHandle::scheduleExitCreationForUnwind):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (276223 => 276224)


--- trunk/Source/_javascript_Core/ChangeLog	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-04-18 07:14:07 UTC (rev 276224)
@@ -1,3 +1,63 @@
+2021-04-18  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Make more DFG/FTL data FixedVector/Vector
+        https://bugs.webkit.org/show_bug.cgi?id=224713
+
+        Reviewed by Darin Adler.
+
+        1. DFG::JITCode::m_osrEntry / DFG::JITCode::m_osrExit / DFG::JITCode::m_speculationRecovery are changed to FixedVector.
+           They are added at compiling time, and after that, these vectors are not modified. So when finalizing, we can easily make it FixedVector.
+           We also change OSREntry::{m_reshufflings,m_expectedValues} to FixedVector and FixedOperands.
+        2. FTL::JITCode::m_osrExit is changed from SegmentedVector to Vector. We are still using Vector since it also involves osrExitDescriptor.
+           But later, we should merge m_osrExit to osrExitDescriptor. Vector is still better than SegmentedVector since it wastes several entries
+           per segment. SegmentedVector was used to use a direct pointer of OSRExit (this is not possible in Vector since this pointer can be invalidated
+           after growing), but usage of that is fairly limited so that we can just replace them with m_index + osrExit vector.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::tallyFrequentExitSites):
+        * bytecode/Operands.h:
+        (JSC::Operands::Operands):
+        * dfg/DFGJITCode.cpp:
+        (JSC::DFG::JITCode::shrinkToFit):
+        (JSC::DFG::JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite):
+        (JSC::DFG::JITCode::validateReferences):
+        (JSC::DFG::JITCode::findPC):
+        (JSC::DFG::JITCode::finalizeOSREntrypoints):
+        * dfg/DFGJITCode.h:
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::linkOSRExits):
+        (JSC::DFG::JITCompiler::link):
+        (JSC::DFG::JITCompiler::noticeOSREntry):
+        (JSC::DFG::JITCompiler::appendExceptionHandlingOSRExit):
+        * dfg/DFGJITCompiler.h:
+        (JSC::DFG::JITCompiler::appendOSRExit):
+        (JSC::DFG::JITCompiler::appendSpeculationRecovery):
+        * dfg/DFGOSREntry.h:
+        * dfg/DFGOSRExit.cpp:
+        (JSC::DFG::JSC_DEFINE_JIT_OPERATION):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::speculationCheck):
+        (JSC::DFG::SpeculativeJIT::emitInvalidationPoint):
+        (JSC::DFG::SpeculativeJIT::linkOSREntries):
+        * ftl/FTLJITCode.cpp:
+        (JSC::FTL::JITCode::shrinkToFit):
+        (JSC::FTL::JITCode::validateReferences):
+        (JSC::FTL::JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite):
+        (JSC::FTL::JITCode::findPC):
+        * ftl/FTLJITCode.h:
+        * ftl/FTLOSRExit.cpp:
+        (JSC::FTL::OSRExitDescriptor::prepareOSRExitHandle):
+        (JSC::FTL::OSRExit::OSRExit):
+        * ftl/FTLOSRExit.h:
+        * ftl/FTLOSRExitCompiler.cpp:
+        (JSC::FTL::JSC_DEFINE_JIT_OPERATION):
+        * ftl/FTLOSRExitHandle.cpp:
+        (JSC::FTL::OSRExitHandle::emitExitThunk):
+        * ftl/FTLOSRExitHandle.h:
+        (JSC::FTL::OSRExitHandle::OSRExitHandle):
+        * ftl/FTLPatchpointExceptionHandle.cpp:
+        (JSC::FTL::PatchpointExceptionHandle::scheduleExitCreationForUnwind):
+
 2021-04-17  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, suppress warnings

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -2973,7 +2973,7 @@
     switch (jitType()) {
     case JITType::DFGJIT: {
         DFG::JITCode* jitCode = m_jitCode->dfg();
-        for (auto& exit : jitCode->osrExit)
+        for (auto& exit : jitCode->m_osrExit)
             exit.considerAddingAsFrequentExitSite(profiledBlock);
         break;
     }
@@ -2980,14 +2980,12 @@
 
 #if ENABLE(FTL_JIT)
     case JITType::FTLJIT: {
-        // There is no easy way to avoid duplicating this code since the FTL::JITCode::osrExit
+        // There is no easy way to avoid duplicating this code since the FTL::JITCode::m_osrExit
         // vector contains a totally different type, that just so happens to behave like
-        // DFG::JITCode::osrExit.
+        // DFG::JITCode::m_osrExit.
         FTL::JITCode* jitCode = m_jitCode->ftl();
-        for (unsigned i = 0; i < jitCode->osrExit.size(); ++i) {
-            FTL::OSRExit& exit = jitCode->osrExit[i];
+        for (auto& exit : jitCode->m_osrExit)
             exit.considerAddingAsFrequentExitSite(profiledBlock);
-        }
         break;
     }
 #endif

Modified: trunk/Source/_javascript_Core/bytecode/Operands.h (276223 => 276224)


--- trunk/Source/_javascript_Core/bytecode/Operands.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/bytecode/Operands.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -138,6 +138,8 @@
 template<typename T, typename StorageArg = std::conditional_t<std::is_same_v<T, bool>, FastBitVector, Vector<T, 0, UnsafeVectorOverflow>>>
 class Operands {
 public:
+    template<typename, typename> friend class Operands;
+
     using Storage = StorageArg;
     using RefType = std::conditional_t<std::is_same_v<T, bool>, FastBitReference, T&>;
     using ConstRefType = std::conditional_t<std::is_same_v<T, bool>, bool, const T&>;
@@ -170,6 +172,14 @@
         m_values.fill(initialValue);
     }
 
+    template<typename U>
+    explicit Operands(const Operands<T, U>& other)
+        : m_values(other.m_values)
+        , m_numArguments(other.m_numArguments)
+        , m_numLocals(other.m_numLocals)
+    {
+    }
+
     size_t numberOfArguments() const { return m_numArguments; }
     size_t numberOfLocals() const { return m_numLocals; }
     size_t numberOfTmps() const { return m_values.size() - numberOfArguments() - numberOfLocals(); }

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCode.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGJITCode.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCode.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -59,9 +59,6 @@
 void JITCode::shrinkToFit(const ConcurrentJSLocker&)
 {
     common.shrinkToFit();
-    osrEntry.shrinkToFit();
-    osrExit.shrinkToFit();
-    speculationRecovery.shrinkToFit();
     minifiedDFG.prepareAndShrink();
     variableEventStream.shrinkToFit();
 }
@@ -86,7 +83,7 @@
 
 RegisterSet JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock* codeBlock, CallSiteIndex callSiteIndex)
 {
-    for (OSRExit& exit : osrExit) {
+    for (OSRExit& exit : m_osrExit) {
         if (exit.isExceptionHandler() && exit.m_exceptionHandlerCallSiteIndex.bits() == callSiteIndex.bits()) {
             Operands<ValueRecovery> valueRecoveries;
             reconstruct(codeBlock, exit.m_codeOrigin, exit.m_streamIndex, valueRecoveries);
@@ -219,7 +216,7 @@
 {
     common.validateReferences(trackedReferences);
     
-    for (OSREntryData& entry : osrEntry) {
+    for (OSREntryData& entry : m_osrEntry) {
         for (unsigned i = entry.m_expectedValues.size(); i--;)
             entry.m_expectedValues[i].validateReferences(trackedReferences);
     }
@@ -229,7 +226,7 @@
 
 Optional<CodeOrigin> JITCode::findPC(CodeBlock*, void* pc)
 {
-    for (OSRExit& exit : osrExit) {
+    for (OSRExit& exit : m_osrExit) {
         if (ExecutableMemoryHandle* handle = exit.m_code.executableMemory()) {
             if (handle->start().untaggedPtr() <= pc && pc < handle->end().untaggedPtr())
                 return Optional<CodeOrigin>(exit.m_codeOriginForExitProfile);
@@ -239,7 +236,7 @@
     return WTF::nullopt;
 }
 
-void JITCode::finalizeOSREntrypoints()
+void JITCode::finalizeOSREntrypoints(Vector<OSREntryData>&& osrEntry)
 {
     auto comparator = [] (const auto& a, const auto& b) {
         return a.m_bytecodeIndex < b.m_bytecodeIndex;
@@ -253,6 +250,7 @@
     };
     verifyIsSorted(osrEntry);
 #endif
+    m_osrEntry = WTFMove(osrEntry);
 }
 
 } } // namespace JSC::DFG

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCode.h (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGJITCode.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCode.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -54,43 +54,15 @@
     CommonData* dfgCommon() final;
     JITCode* dfg() final;
     
-    OSREntryData* appendOSREntryData(BytecodeIndex bytecodeIndex, CodeLocationLabel<OSREntryPtrTag> machineCode)
-    {
-        DFG::OSREntryData entry;
-        entry.m_bytecodeIndex = bytecodeIndex;
-        entry.m_machineCode = machineCode;
-        osrEntry.append(entry);
-        return &osrEntry.last();
-    }
-    
     OSREntryData* osrEntryDataForBytecodeIndex(BytecodeIndex bytecodeIndex)
     {
         return tryBinarySearch<OSREntryData, BytecodeIndex>(
-            osrEntry, osrEntry.size(), bytecodeIndex,
+            m_osrEntry, m_osrEntry.size(), bytecodeIndex,
             getOSREntryDataBytecodeIndex);
     }
 
-    void finalizeOSREntrypoints();
-
-    unsigned appendOSRExit(const OSRExit& exit)
-    {
-        unsigned result = osrExit.size();
-        osrExit.append(exit);
-        return result;
-    }
+    void finalizeOSREntrypoints(Vector<DFG::OSREntryData>&&);
     
-    OSRExit& lastOSRExit()
-    {
-        return osrExit.last();
-    }
-    
-    unsigned appendSpeculationRecovery(const SpeculationRecovery& recovery)
-    {
-        unsigned result = speculationRecovery.size();
-        speculationRecovery.append(recovery);
-        return result;
-    }
-    
     void reconstruct(
         CodeBlock*, CodeOrigin, unsigned streamIndex, Operands<ValueRecovery>& result);
     
@@ -135,9 +107,9 @@
 
 public:
     CommonData common;
-    Vector<DFG::OSREntryData> osrEntry;
-    SegmentedVector<DFG::OSRExit, 8> osrExit;
-    Vector<DFG::SpeculationRecovery> speculationRecovery;
+    FixedVector<DFG::OSREntryData> m_osrEntry;
+    FixedVector<DFG::OSRExit> m_osrExit;
+    FixedVector<DFG::SpeculationRecovery> m_speculationRecovery;
     DFG::VariableEventStream variableEventStream;
     DFG::MinifiedGraph minifiedDFG;
 

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -66,9 +66,9 @@
 
 void JITCompiler::linkOSRExits()
 {
-    ASSERT(m_jitCode->osrExit.size() == m_exitCompilationInfo.size());
+    ASSERT(m_osrExit.size() == m_exitCompilationInfo.size());
     if (UNLIKELY(m_graph.compilation())) {
-        for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
+        for (unsigned i = 0; i < m_osrExit.size(); ++i) {
             OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
             Vector<Label> labels;
             if (!info.m_failureJumps.empty()) {
@@ -80,7 +80,7 @@
         }
     }
     
-    for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
+    for (unsigned i = 0; i < m_osrExit.size(); ++i) {
         OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
         JumpList& failureJumps = info.m_failureJumps;
         if (!failureJumps.empty())
@@ -278,11 +278,11 @@
     
     MacroAssemblerCodeRef<JITThunkPtrTag> osrExitThunk = vm().getCTIStub(osrExitGenerationThunkGenerator);
     auto target = CodeLocationLabel<JITThunkPtrTag>(osrExitThunk.code());
-    for (unsigned i = 0; i < m_jitCode->osrExit.size(); ++i) {
+    for (unsigned i = 0; i < m_osrExit.size(); ++i) {
         OSRExitCompilationInfo& info = m_exitCompilationInfo[i];
         if (!Options::useProbeOSRExit()) {
             linkBuffer.link(info.m_patchableJump.m_jump, target);
-            OSRExit& exit = m_jitCode->osrExit[i];
+            OSRExit& exit = m_osrExit[i];
             exit.m_patchableJumpLocation = linkBuffer.locationOf<JSInternalPtrTag>(info.m_patchableJump);
         }
         if (info.m_replacementSource.isSet()) {
@@ -293,7 +293,7 @@
     }
     
     if (UNLIKELY(m_graph.compilation())) {
-        ASSERT(m_exitSiteLabels.size() == m_jitCode->osrExit.size());
+        ASSERT(m_exitSiteLabels.size() == m_osrExit.size());
         for (unsigned i = 0; i < m_exitSiteLabels.size(); ++i) {
             Vector<Label>& labels = m_exitSiteLabels[i];
             Vector<MacroAssemblerCodePtr<JSInternalPtrTag>> addresses;
@@ -305,6 +305,8 @@
         ASSERT(!m_exitSiteLabels.size());
 
     m_jitCode->common.compilation = m_graph.compilation();
+    m_jitCode->m_osrExit = WTFMove(m_osrExit);
+    m_jitCode->m_speculationRecovery = WTFMove(m_speculationRecovery);
     
     // Link new DFG exception handlers and remove baseline JIT handlers.
     m_codeBlock->clearExceptionHandlers();
@@ -547,10 +549,13 @@
     if (!basicBlock.intersectionOfCFAHasVisited)
         return;
 
-    OSREntryData* entry = m_jitCode->appendOSREntryData(basicBlock.bytecodeBegin, linkBuffer.locationOf<OSREntryPtrTag>(blockHead));
+    OSREntryData entry;
+    entry.m_bytecodeIndex = basicBlock.bytecodeBegin;
+    entry.m_machineCode = linkBuffer.locationOf<OSREntryPtrTag>(blockHead);
 
-    entry->m_expectedValues = basicBlock.intersectionOfPastValuesAtHead;
-        
+    FixedOperands<AbstractValue> expectedValues(basicBlock.intersectionOfPastValuesAtHead);
+    Vector<OSREntryReshuffling> reshufflings;
+
     // Fix the expected values: in our protocol, a dead variable will have an expected
     // value of (None, []). But the old JIT may stash some values there. So we really
     // need (Top, TOP).
@@ -557,22 +562,22 @@
     for (size_t argument = 0; argument < basicBlock.variablesAtHead.numberOfArguments(); ++argument) {
         Node* node = basicBlock.variablesAtHead.argument(argument);
         if (!node || !node->shouldGenerate())
-            entry->m_expectedValues.argument(argument).makeBytecodeTop();
+            expectedValues.argument(argument).makeBytecodeTop();
     }
     for (size_t local = 0; local < basicBlock.variablesAtHead.numberOfLocals(); ++local) {
         Node* node = basicBlock.variablesAtHead.local(local);
         if (!node || !node->shouldGenerate())
-            entry->m_expectedValues.local(local).makeBytecodeTop();
+            expectedValues.local(local).makeBytecodeTop();
         else {
             VariableAccessData* variable = node->variableAccessData();
-            entry->m_machineStackUsed.set(variable->machineLocal().toLocal());
+            entry.m_machineStackUsed.set(variable->machineLocal().toLocal());
                 
             switch (variable->flushFormat()) {
             case FlushedDouble:
-                entry->m_localsForcedDouble.set(local);
+                entry.m_localsForcedDouble.set(local);
                 break;
             case FlushedInt52:
-                entry->m_localsForcedAnyInt.set(local);
+                entry.m_localsForcedAnyInt.set(local);
                 break;
             default:
                 break;
@@ -580,7 +585,7 @@
 
             ASSERT(!variable->operand().isTmp());
             if (variable->operand().virtualRegister() != variable->machineLocal()) {
-                entry->m_reshufflings.append(
+                reshufflings.append(
                     OSREntryReshuffling(
                         variable->operand().virtualRegister().offset(), variable->machineLocal().offset()));
             }
@@ -587,7 +592,9 @@
         }
     }
         
-    entry->m_reshufflings.shrinkToFit();
+    entry.m_expectedValues = WTFMove(expectedValues);
+    entry.m_reshufflings = WTFMove(reshufflings);
+    m_osrEntry.append(WTFMove(entry));
 }
 
 void JITCompiler::appendExceptionHandlingOSRExit(ExitKind kind, unsigned eventStreamIndex, CodeOrigin opCatchOrigin, HandlerInfo* exceptionHandler, CallSiteIndex callSite, MacroAssembler::JumpList jumpsToFail)
@@ -596,7 +603,7 @@
     exit.m_codeOrigin = opCatchOrigin;
     exit.m_exceptionHandlerCallSiteIndex = callSite;
     OSRExitCompilationInfo& exitInfo = appendExitInfo(jumpsToFail);
-    jitCode()->appendOSRExit(exit);
+    m_osrExit.append(WTFMove(exit));
     m_exceptionHandlerOSRExitCallSites.append(ExceptionHandlingOSRExitInfo { exitInfo, *exceptionHandler, callSite });
 }
 

Modified: trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCompiler.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -86,6 +86,8 @@
 // call to be linked).
 class JITCompiler : public CCallHelpers {
 public:
+    friend class SpeculativeJIT;
+
     JITCompiler(Graph& dfg);
     ~JITCompiler();
     
@@ -265,7 +267,21 @@
 
     void noticeOSREntry(BasicBlock&, JITCompiler::Label blockHead, LinkBuffer&);
     void noticeCatchEntrypoint(BasicBlock&, JITCompiler::Label blockHead, LinkBuffer&, Vector<FlushFormat>&& argumentFormats);
-    
+
+    unsigned appendOSRExit(OSRExit&& exit)
+    {
+        unsigned result = m_osrExit.size();
+        m_osrExit.append(WTFMove(exit));
+        return result;
+    }
+
+    unsigned appendSpeculationRecovery(const SpeculationRecovery& recovery)
+    {
+        unsigned result = m_speculationRecovery.size();
+        m_speculationRecovery.append(recovery);
+        return result;
+    }
+
     RefPtr<JITCode> jitCode() { return m_jitCode; }
     
     Vector<Label>& blockHeads() { return m_blockHeads; }
@@ -373,6 +389,9 @@
     Vector<JSDirectTailCallRecord, 4> m_jsDirectTailCalls;
     SegmentedVector<OSRExitCompilationInfo, 4> m_exitCompilationInfo;
     Vector<Vector<Label>> m_exitSiteLabels;
+    Vector<DFG::OSREntryData> m_osrEntry;
+    Vector<DFG::OSRExit> m_osrExit;
+    Vector<DFG::SpeculationRecovery> m_speculationRecovery;
     
     struct ExceptionHandlingOSRExitInfo {
         OSRExitCompilationInfo& exitInfo;

Modified: trunk/Source/_javascript_Core/dfg/DFGOSREntry.h (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGOSREntry.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGOSREntry.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -56,11 +56,11 @@
 struct OSREntryData {
     BytecodeIndex m_bytecodeIndex;
     CodeLocationLabel<OSREntryPtrTag> m_machineCode;
-    Operands<AbstractValue> m_expectedValues;
+    FixedOperands<AbstractValue> m_expectedValues;
     // Use bitvectors here because they tend to only require one word.
     BitVector m_localsForcedDouble;
     BitVector m_localsForcedAnyInt;
-    Vector<OSREntryReshuffling> m_reshufflings;
+    FixedVector<OSREntryReshuffling> m_reshufflings;
     BitVector m_machineStackUsed;
     
     void dumpInContext(PrintStream&, DumpContext*) const;

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -163,7 +163,7 @@
     DeferGCForAWhile deferGC(vm.heap);
 
     uint32_t exitIndex = vm.osrExitIndex;
-    OSRExit& exit = codeBlock->jitCode()->dfg()->osrExit[exitIndex];
+    OSRExit& exit = codeBlock->jitCode()->dfg()->m_osrExit[exitIndex];
 
     ASSERT(!vm.callFrameForCatch || exit.m_kind == GenericUnwind);
     EXCEPTION_ASSERT_UNUSED(scope, !!scope.exception() || !exit.isExceptionHandler());
@@ -174,7 +174,7 @@
 
     SpeculationRecovery* recovery = nullptr;
     if (exit.m_recoveryIndex != UINT_MAX)
-        recovery = &codeBlock->jitCode()->dfg()->speculationRecovery[exit.m_recoveryIndex];
+        recovery = &codeBlock->jitCode()->dfg()->m_speculationRecovery[exit.m_recoveryIndex];
 
     {
         CCallHelpers jit(codeBlock);

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -268,7 +268,7 @@
         m_jit.appendExitInfo(jumpsToFail);
     } else
         m_jit.appendExitInfo(jumpToFail);
-    m_jit.jitCode()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
+    m_jit.appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
 }
 
 void SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, Node* node, const MacroAssembler::JumpList& jumpsToFail)
@@ -283,7 +283,7 @@
         m_jit.appendExitInfo(myJumpsToFail);
     } else
         m_jit.appendExitInfo(jumpsToFail);
-    m_jit.jitCode()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
+    m_jit.appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
 }
 
 OSRExitJumpPlaceholder SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, Node* node)
@@ -290,9 +290,9 @@
 {
     if (!m_compileOkay)
         return OSRExitJumpPlaceholder();
-    unsigned index = m_jit.jitCode()->osrExit.size();
+    unsigned index = m_jit.m_osrExit.size();
     m_jit.appendExitInfo();
-    m_jit.jitCode()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
+    m_jit.appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size()));
     return OSRExitJumpPlaceholder(index);
 }
 
@@ -315,9 +315,9 @@
 {
     if (!m_compileOkay)
         return;
-    unsigned recoveryIndex = m_jit.jitCode()->appendSpeculationRecovery(recovery);
+    unsigned recoveryIndex = m_jit.appendSpeculationRecovery(recovery);
     m_jit.appendExitInfo(jumpToFail);
-    m_jit.jitCode()->appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size(), recoveryIndex));
+    m_jit.appendOSRExit(OSRExit(kind, jsValueSource, m_jit.graph().methodOfGettingAValueProfileFor(m_currentNode, node), this, m_stream->size(), recoveryIndex));
 }
 
 void SpeculativeJIT::speculationCheck(ExitKind kind, JSValueSource jsValueSource, Edge nodeUse, MacroAssembler::Jump jumpToFail, const SpeculationRecovery& recovery)
@@ -330,7 +330,7 @@
     if (!m_compileOkay)
         return;
     OSRExitCompilationInfo& info = m_jit.appendExitInfo(JITCompiler::JumpList());
-    m_jit.jitCode()->appendOSRExit(OSRExit(
+    m_jit.appendOSRExit(OSRExit(
         UncountableInvalidation, JSValueSource(), MethodOfGettingAValueProfile(),
         this, m_stream->size()));
     info.m_replacementSource = m_jit.watchpointLabel();
@@ -2201,7 +2201,7 @@
         }
     }
 
-    m_jit.jitCode()->finalizeOSREntrypoints();
+    m_jit.jitCode()->finalizeOSREntrypoints(WTFMove(m_jit.m_osrEntry));
     m_jit.jitCode()->common.finalizeCatchEntrypoints(WTFMove(m_jit.graph().m_catchEntrypoints));
 
     ASSERT(osrEntryIndex == m_osrEntryHeads.size());
@@ -2209,7 +2209,7 @@
     if (verboseCompilationEnabled()) {
         DumpContext dumpContext;
         dataLog("OSR Entries:\n");
-        for (OSREntryData& entryData : m_jit.jitCode()->osrEntry)
+        for (OSREntryData& entryData : m_jit.jitCode()->m_osrEntry)
             dataLog("    ", inContext(entryData, &dumpContext), "\n");
         if (!dumpContext.isEmpty())
             dumpContext.dump(WTF::dataFile());

Modified: trunk/Source/_javascript_Core/ftl/FTLJITCode.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLJITCode.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLJITCode.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -138,7 +138,7 @@
 void JITCode::shrinkToFit(const ConcurrentJSLocker&)
 {
     common.shrinkToFit();
-    osrExit.shrinkToFit();
+    m_osrExit.shrinkToFit();
     osrExitDescriptors.shrinkToFit();
     lazySlowPaths.shrinkToFit();
 }
@@ -147,13 +147,13 @@
 {
     common.validateReferences(trackedReferences);
     
-    for (OSRExit& exit : osrExit)
+    for (OSRExit& exit : m_osrExit)
         exit.m_descriptor->validateReferences(trackedReferences);
 }
 
 RegisterSet JITCode::liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex callSiteIndex)
 {
-    for (OSRExit& exit : osrExit) {
+    for (OSRExit& exit : m_osrExit) {
         if (exit.m_exceptionHandlerCallSiteIndex.bits() == callSiteIndex.bits()) {
             RELEASE_ASSERT(exit.isExceptionHandler());
             RELEASE_ASSERT(exit.isGenericUnwindHandler());
@@ -165,7 +165,7 @@
 
 Optional<CodeOrigin> JITCode::findPC(CodeBlock* codeBlock, void* pc)
 {
-    for (OSRExit& exit : osrExit) {
+    for (OSRExit& exit : m_osrExit) {
         if (ExecutableMemoryHandle* handle = exit.m_code.executableMemory()) {
             if (handle->start().untaggedPtr() <= pc && pc < handle->end().untaggedPtr())
                 return Optional<CodeOrigin>(exit.m_codeOriginForExitProfile);

Modified: trunk/Source/_javascript_Core/ftl/FTLJITCode.h (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLJITCode.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLJITCode.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -70,7 +70,7 @@
     void shrinkToFit(const ConcurrentJSLocker&) override;
     
     DFG::CommonData common;
-    SegmentedVector<OSRExit, 8> osrExit;
+    Vector<OSRExit> m_osrExit;
     SegmentedVector<OSRExitDescriptor, 8> osrExitDescriptors;
     Vector<std::unique_ptr<LazySlowPath>> lazySlowPaths;
     

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExit.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -82,21 +82,20 @@
     State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
     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, dfgNodeIndex);
-    Ref<OSRExitHandle> handle = adoptRef(*new OSRExitHandle(index, exit));
-    exit.m_valueReps = FixedVector<B3::ValueRep>(params.size() - offset);
+    FixedVector<B3::ValueRep> valueReps(params.size() - offset);
     for (unsigned i = offset, indexInValueReps = 0; i < params.size(); ++i, ++indexInValueReps)
-        exit.m_valueReps[indexInValueReps] = params[i];
-    return handle;
+        valueReps[indexInValueReps] = params[i];
+    unsigned index = state.jitCode->m_osrExit.size();
+    state.jitCode->m_osrExit.append(OSRExit(this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted, dfgNodeIndex, WTFMove(valueReps)));
+    return adoptRef(*new OSRExitHandle(index, state.jitCode.get()));
 }
 
 OSRExit::OSRExit(
     OSRExitDescriptor* descriptor, ExitKind exitKind, CodeOrigin codeOrigin,
-    CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex)
+    CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex, FixedVector<B3::ValueRep>&& valueReps)
     : OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted, dfgNodeIndex)
     , m_descriptor(descriptor)
+    , m_valueReps(WTFMove(valueReps))
 {
 }
 

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExit.h (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExit.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExit.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -120,7 +120,7 @@
 };
 
 struct OSRExit : public DFG::OSRExitBase {
-    OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex);
+    OSRExit(OSRExitDescriptor*, ExitKind, CodeOrigin, CodeOrigin codeOriginForExitProfile, bool wasHoisted, uint32_t dfgNodeIndex, FixedVector<B3::ValueRep>&&);
 
     OSRExitDescriptor* m_descriptor;
     MacroAssemblerCodeRef<OSRExitPtrTag> m_code;

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitCompiler.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -543,7 +543,7 @@
     DeferGCForAWhile deferGC(vm.heap);
 
     JITCode* jitCode = codeBlock->jitCode()->ftl();
-    OSRExit& exit = jitCode->osrExit[exitID];
+    OSRExit& exit = jitCode->m_osrExit[exitID];
     
     if (shouldDumpDisassembly() || Options::verboseOSR() || Options::verboseFTLOSRExit()) {
         dataLog("    Owning block: ", pointerDump(codeBlock), "\n");

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -41,13 +41,13 @@
     Profiler::Compilation* compilation = state.graph.compilation();
     CCallHelpers::Label myLabel = jit.label();
     label = myLabel;
-    jit.pushToSaveImmediateWithoutTouchingRegisters(CCallHelpers::TrustedImm32(index));
+    jit.pushToSaveImmediateWithoutTouchingRegisters(CCallHelpers::TrustedImm32(m_index));
     CCallHelpers::PatchableJump jump = jit.patchableJump();
     RefPtr<OSRExitHandle> self = this;
     VM& vm = state.vm();
     jit.addLinkTask(
         [self, jump, myLabel, compilation, &vm] (LinkBuffer& linkBuffer) {
-            self->exit.m_patchableJump = CodeLocationJump<JSInternalPtrTag>(linkBuffer.locationOf<JSInternalPtrTag>(jump));
+            self->m_jitCode->m_osrExit[self->m_index].m_patchableJump = CodeLocationJump<JSInternalPtrTag>(linkBuffer.locationOf<JSInternalPtrTag>(jump));
 
             linkBuffer.link(
                 jump.m_jump,

Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.h (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.h	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExitHandle.h	2021-04-18 07:14:07 UTC (rev 276224)
@@ -40,14 +40,14 @@
 // This is an object that stores some interesting data about an OSR exit. It's expected that you will
 // scrape this data from this object by the time compilation finishes.
 struct OSRExitHandle : public ThreadSafeRefCounted<OSRExitHandle> {
-    OSRExitHandle(unsigned index, OSRExit& exit)
-        : index(index)
-        , exit(exit)
+    OSRExitHandle(unsigned index, JITCode* jitCode)
+        : m_index(index)
+        , m_jitCode(jitCode)
     {
     }
 
-    unsigned index;
-    OSRExit& exit;
+    unsigned m_index;
+    JITCode* m_jitCode;
 
     // This is the label at which the OSR exit jump lives. This will get populated once the OSR exit
     // emits its jump. This happens immediately when you call OSRExit::appendOSRExit(). It happens at

Modified: trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp (276223 => 276224)


--- trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp	2021-04-18 07:10:05 UTC (rev 276223)
+++ trunk/Source/_javascript_Core/ftl/FTLPatchpointExceptionHandle.cpp	2021-04-18 07:14:07 UTC (rev 276224)
@@ -80,7 +80,7 @@
     
     RefPtr<OSRExitHandle> handle = createHandle(GenericUnwind, params);
 
-    handle->exit.m_exceptionHandlerCallSiteIndex = callSiteIndex;
+    handle->m_jitCode->m_osrExit[handle->m_index].m_exceptionHandlerCallSiteIndex = callSiteIndex;
 
     HandlerInfo handler = m_handler;
     params.addLatePath(
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to