Title: [286930] trunk/Source/_javascript_Core
Revision
286930
Author
ysuz...@apple.com
Date
2021-12-12 17:09:22 -0800 (Sun, 12 Dec 2021)

Log Message

[JSC] Use FixedVector to shrink some of Wasm data structures
https://bugs.webkit.org/show_bug.cgi?id=234206

Reviewed by Saam Barati.

We can use FixedVector to shrink some of Wasm data structures including Wasm::Callee.

* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::PatchpointExceptionHandle::generate const):
(JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck):
* wasm/WasmCallee.cpp:
(JSC::Wasm::LLIntCallee::linkExceptionHandlers):
(JSC::Wasm::OptimizingJITCallee::linkExceptionHandlers):
(JSC::Wasm::OptimizingJITCallee::stackmap const):
* wasm/WasmCallee.h:
(JSC::Wasm::Callee::hasExceptionHandlers const):
(JSC::Wasm::JITCallee::wasmToWasmCallsites):
(JSC::Wasm::OptimizingJITCallee::OptimizingJITCallee):
* wasm/WasmCodeBlock.cpp:
(JSC::Wasm::CodeBlock::CodeBlock):
* wasm/WasmCodeBlock.h:
* wasm/WasmHandlerInfo.cpp:
(JSC::Wasm::HandlerInfo::handlerForIndex):
* wasm/WasmHandlerInfo.h:
* wasm/WasmOSREntryData.h:
(JSC::Wasm::OSREntryData::OSREntryData):
(JSC::Wasm::OSREntryData::values):
(JSC::Wasm::OSREntryValue::OSREntryValue): Deleted.
(JSC::Wasm::OSREntryValue::type const): Deleted.
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::updateCallSitesToCallUs):
* wasm/WasmTierUpCount.cpp:
(JSC::Wasm::TierUpCount::addOSREntryData):
* wasm/WasmTierUpCount.h:
* wasm/js/JSWebAssemblyCodeBlock.cpp:
(JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock):
* wasm/js/JSWebAssemblyCodeBlock.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (286929 => 286930)


--- trunk/Source/_javascript_Core/ChangeLog	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-12-13 01:09:22 UTC (rev 286930)
@@ -1,3 +1,45 @@
+2021-12-12  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Use FixedVector to shrink some of Wasm data structures
+        https://bugs.webkit.org/show_bug.cgi?id=234206
+
+        Reviewed by Saam Barati.
+
+        We can use FixedVector to shrink some of Wasm data structures including Wasm::Callee.
+
+        * wasm/WasmAirIRGenerator.cpp:
+        (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck):
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::PatchpointExceptionHandle::generate const):
+        (JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck):
+        * wasm/WasmCallee.cpp:
+        (JSC::Wasm::LLIntCallee::linkExceptionHandlers):
+        (JSC::Wasm::OptimizingJITCallee::linkExceptionHandlers):
+        (JSC::Wasm::OptimizingJITCallee::stackmap const):
+        * wasm/WasmCallee.h:
+        (JSC::Wasm::Callee::hasExceptionHandlers const):
+        (JSC::Wasm::JITCallee::wasmToWasmCallsites):
+        (JSC::Wasm::OptimizingJITCallee::OptimizingJITCallee):
+        * wasm/WasmCodeBlock.cpp:
+        (JSC::Wasm::CodeBlock::CodeBlock):
+        * wasm/WasmCodeBlock.h:
+        * wasm/WasmHandlerInfo.cpp:
+        (JSC::Wasm::HandlerInfo::handlerForIndex):
+        * wasm/WasmHandlerInfo.h:
+        * wasm/WasmOSREntryData.h:
+        (JSC::Wasm::OSREntryData::OSREntryData):
+        (JSC::Wasm::OSREntryData::values):
+        (JSC::Wasm::OSREntryValue::OSREntryValue): Deleted.
+        (JSC::Wasm::OSREntryValue::type const): Deleted.
+        * wasm/WasmPlan.cpp:
+        (JSC::Wasm::Plan::updateCallSitesToCallUs):
+        * wasm/WasmTierUpCount.cpp:
+        (JSC::Wasm::TierUpCount::addOSREntryData):
+        * wasm/WasmTierUpCount.h:
+        * wasm/js/JSWebAssemblyCodeBlock.cpp:
+        (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock):
+        * wasm/js/JSWebAssemblyCodeBlock.h:
+
 2021-12-11  Saam Barati  <sbar...@apple.com>
 
         Teach the sampling profiler how to display origin data for B3 Wasm

Modified: trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -2924,10 +2924,13 @@
         CCallHelpers::Jump tierUp = jit.branchAdd32(CCallHelpers::PositiveOrZero, CCallHelpers::TrustedImm32(TierUpCount::loopIncrement()), CCallHelpers::Address(params[0].gpr()));
         MacroAssembler::Label tierUpResume = jit.label();
 
-        OSREntryData& osrEntryData = m_tierUp->addOSREntryData(m_functionIndex, loopIndex);
         // First argument is the countdown location.
-        for (unsigned index = 1; index < params.value()->numChildren(); ++index)
-            osrEntryData.values().constructAndAppend(params[index], params.value()->child(index)->type());
+        ASSERT(params.value()->numChildren() >= 1);
+        StackMap values(params.value()->numChildren() - 1);
+        for (unsigned i = 1; i < params.value()->numChildren(); ++i)
+            values[i - 1] = OSREntryValue(params[i], params.value()->child(i)->type());
+
+        OSREntryData& osrEntryData = m_tierUp->addOSREntryData(m_functionIndex, loopIndex, WTFMove(values));
         OSREntryData* osrEntryDataPtr = &osrEntryData;
 
         params.addLatePath([=] (CCallHelpers& jit) {

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -583,8 +583,11 @@
         return;
 
     StackMap values;
-    for (unsigned i = m_offset; i < params.value()->numChildren(); ++i)
-        values.constructAndAppend(params[i], params.value()->child(i)->type());
+    if (params.value()->numChildren() >= m_offset) {
+        values = StackMap(params.value()->numChildren() - m_offset);
+        for (unsigned i = m_offset; i < params.value()->numChildren(); ++i)
+            values[i - m_offset] = OSREntryValue(params[i], params.value()->child(i)->type());
+    }
     generator->addStackMap(m_callSiteIndex, WTFMove(values));
     jit.store32(CCallHelpers::TrustedImm32(m_callSiteIndex), CCallHelpers::tagFor(CallFrameSlot::argumentCountIncludingThis));
 }
@@ -2426,10 +2429,13 @@
         CCallHelpers::Jump tierUp = jit.branchAdd32(CCallHelpers::PositiveOrZero, CCallHelpers::TrustedImm32(TierUpCount::loopIncrement()), CCallHelpers::Address(params[0].gpr()));
         MacroAssembler::Label tierUpResume = jit.label();
 
-        OSREntryData& osrEntryData = m_tierUp->addOSREntryData(m_functionIndex, loopIndex);
         // First argument is the countdown location.
+        ASSERT(params.value()->numChildren() >= 1);
+        StackMap values(params.value()->numChildren() - 1);
         for (unsigned i = 1; i < params.value()->numChildren(); ++i)
-            osrEntryData.values().constructAndAppend(params[i], params.value()->child(i)->type());
+            values[i - 1] = OSREntryValue(params[i], params.value()->child(i)->type());
+
+        OSREntryData& osrEntryData = m_tierUp->addOSREntryData(m_functionIndex, loopIndex, WTFMove(values));
         OSREntryData* osrEntryDataPtr = &osrEntryData;
 
         params.addLatePath([=] (CCallHelpers& jit) {

Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmCallee.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -86,7 +86,7 @@
 void LLIntCallee::linkExceptionHandlers()
 {
     if (size_t count = m_codeBlock->numberOfExceptionHandlers()) {
-        m_exceptionHandlers.resizeToFit(count);
+        m_exceptionHandlers = FixedVector<HandlerInfo>(count);
         for (size_t i = 0; i < count; i++) {
             const UnlinkedHandlerInfo& unlinkedHandler = m_codeBlock->exceptionHandler(i);
             HandlerInfo& handler = m_exceptionHandlers[i];
@@ -137,21 +137,19 @@
     return { nullptr, nullptr };
 }
 
-void OptimizingJITCallee::linkExceptionHandlers()
+void OptimizingJITCallee::linkExceptionHandlers(Vector<UnlinkedHandlerInfo> unlinkedExceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>> exceptionHandlerLocations)
 {
-    size_t count = m_unlinkedExceptionHandlers.size();
-    m_exceptionHandlers.resizeToFit(count);
+    size_t count = unlinkedExceptionHandlers.size();
+    m_exceptionHandlers = FixedVector<HandlerInfo>(count);
     for (size_t i = 0; i < count; i++) {
         HandlerInfo& handler = m_exceptionHandlers[i];
-        const UnlinkedHandlerInfo& unlinkedHandler = m_unlinkedExceptionHandlers[i];
-        CodeLocationLabel<ExceptionHandlerPtrTag> location = m_exceptionHandlerLocations[i];
+        const UnlinkedHandlerInfo& unlinkedHandler = unlinkedExceptionHandlers[i];
+        CodeLocationLabel<ExceptionHandlerPtrTag> location = exceptionHandlerLocations[i];
         handler.initialize(unlinkedHandler, location);
     }
-    m_unlinkedExceptionHandlers.clear();
-    m_exceptionHandlerLocations.clear();
 }
 
-const Vector<OSREntryValue>& OptimizingJITCallee::stackmap(CallSiteIndex callSiteIndex) const
+const StackMap& OptimizingJITCallee::stackmap(CallSiteIndex callSiteIndex) const
 {
     auto iter = m_stackmaps.find(callSiteIndex);
     if (iter == m_stackmaps.end()) {

Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmCallee.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -36,6 +36,7 @@
 #include "WasmIndexOrName.h"
 #include "WasmLLIntTierUpCounter.h"
 #include "WasmTierUpCount.h"
+#include <wtf/FixedVector.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
 namespace JSC {
@@ -63,7 +64,7 @@
 
     const HandlerInfo* handlerForIndex(Instance&, unsigned, const Tag*);
 
-    bool hasExceptionHandlers() const { return !!m_exceptionHandlers.size(); }
+    bool hasExceptionHandlers() const { return !m_exceptionHandlers.isEmpty(); }
 
 #if ENABLE(WEBASSEMBLY_B3JIT)
     virtual void setOSREntryCallee(Ref<OMGForOSREntryCallee>&&, MemoryMode)
@@ -85,7 +86,7 @@
     IndexOrName m_indexOrName;
 
 protected:
-    Vector<HandlerInfo> m_exceptionHandlers;
+    FixedVector<HandlerInfo> m_exceptionHandlers;
 };
 
 class JITCallee : public Callee {
@@ -92,7 +93,7 @@
 public:
     MacroAssemblerCodePtr<WasmEntryPtrTag> entrypoint() const override { return m_entrypoint.compilation->code().retagged<WasmEntryPtrTag>(); }
     RegisterAtOffsetList* calleeSaveRegisters() override { return &m_entrypoint.calleeSaveRegisters; }
-    Vector<UnlinkedWasmToWasmCall>& wasmToWasmCallsites() { return m_wasmToWasmCallsites; }
+    FixedVector<UnlinkedWasmToWasmCall>& wasmToWasmCallsites() { return m_wasmToWasmCallsites; }
 
 protected:
     JS_EXPORT_PRIVATE JITCallee(Wasm::CompilationMode, Wasm::Entrypoint&&);
@@ -106,7 +107,7 @@
     }
 
 private:
-    Vector<UnlinkedWasmToWasmCall> m_wasmToWasmCallsites;
+    FixedVector<UnlinkedWasmToWasmCall> m_wasmToWasmCallsites;
     Wasm::Entrypoint m_entrypoint;
 };
 
@@ -128,36 +129,32 @@
 #if ENABLE(WEBASSEMBLY_B3JIT)
 class OptimizingJITCallee : public JITCallee {
 public:
-    const Vector<OSREntryValue>& stackmap(CallSiteIndex) const;
+    const StackMap& stackmap(CallSiteIndex) const;
 
 protected:
-    OptimizingJITCallee(Wasm::CompilationMode mode, Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    OptimizingJITCallee(Wasm::CompilationMode mode, Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& unlinkedExceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
         : JITCallee(mode, WTFMove(entrypoint), index, WTFMove(name), WTFMove(unlinkedCalls))
         , m_stackmaps(WTFMove(stackmaps))
-        , m_unlinkedExceptionHandlers(WTFMove(exceptionHandlers))
-        , m_exceptionHandlerLocations(WTFMove(exceptionHandlerLocations))
     {
-        RELEASE_ASSERT(m_unlinkedExceptionHandlers.size() == m_exceptionHandlerLocations.size());
-        linkExceptionHandlers();
+        RELEASE_ASSERT(unlinkedExceptionHandlers.size() == exceptionHandlerLocations.size());
+        linkExceptionHandlers(WTFMove(unlinkedExceptionHandlers), WTFMove(exceptionHandlerLocations));
     }
 
 private:
-    void linkExceptionHandlers();
+    void linkExceptionHandlers(Vector<UnlinkedHandlerInfo>, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>);
 
-    HashMap<CallSiteIndex, Vector<OSREntryValue>> m_stackmaps;
-    Vector<UnlinkedHandlerInfo> m_unlinkedExceptionHandlers;
-    Vector<CodeLocationLabel<ExceptionHandlerPtrTag>> m_exceptionHandlerLocations;
+    StackMaps m_stackmaps;
 };
 
 class OMGCallee final : public OptimizingJITCallee {
 public:
-    static Ref<OMGCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    static Ref<OMGCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
     {
         return adoptRef(*new OMGCallee(WTFMove(entrypoint), index, WTFMove(name), WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations)));
     }
 
 private:
-    OMGCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    OMGCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
         : OptimizingJITCallee(Wasm::CompilationMode::OMGMode, WTFMove(entrypoint), index, WTFMove(name), WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations))
     {
     }
@@ -165,7 +162,7 @@
 
 class OMGForOSREntryCallee final : public OptimizingJITCallee {
 public:
-    static Ref<OMGForOSREntryCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, unsigned osrEntryScratchBufferSize, uint32_t loopIndex, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    static Ref<OMGForOSREntryCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, unsigned osrEntryScratchBufferSize, uint32_t loopIndex, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
     {
         return adoptRef(*new OMGForOSREntryCallee(WTFMove(entrypoint), index, WTFMove(name), osrEntryScratchBufferSize, loopIndex, WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations)));
     }
@@ -174,7 +171,7 @@
     uint32_t loopIndex() const { return m_loopIndex; }
 
 private:
-    OMGForOSREntryCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, unsigned osrEntryScratchBufferSize, uint32_t loopIndex, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    OMGForOSREntryCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, unsigned osrEntryScratchBufferSize, uint32_t loopIndex, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
         : OptimizingJITCallee(Wasm::CompilationMode::OMGForOSREntryMode, WTFMove(entrypoint), index, WTFMove(name), WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations))
         , m_osrEntryScratchBufferSize(osrEntryScratchBufferSize)
         , m_loopIndex(loopIndex)
@@ -187,7 +184,7 @@
 
 class BBQCallee final : public OptimizingJITCallee {
 public:
-    static Ref<BBQCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, std::unique_ptr<TierUpCount>&& tierUpCount, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    static Ref<BBQCallee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, std::unique_ptr<TierUpCount>&& tierUpCount, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
     {
         return adoptRef(*new BBQCallee(WTFMove(entrypoint), index, WTFMove(name), WTFMove(tierUpCount), WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations)));
     }
@@ -210,7 +207,7 @@
     TierUpCount* tierUpCount() { return m_tierUpCount.get(); }
 
 private:
-    BBQCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, std::unique_ptr<TierUpCount>&& tierUpCount, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, HashMap<CallSiteIndex, Vector<OSREntryValue>>&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
+    BBQCallee(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name, std::unique_ptr<TierUpCount>&& tierUpCount, Vector<UnlinkedWasmToWasmCall>&& unlinkedCalls, StackMaps&& stackmaps, Vector<UnlinkedHandlerInfo>&& exceptionHandlers, Vector<CodeLocationLabel<ExceptionHandlerPtrTag>>&& exceptionHandlerLocations)
         : OptimizingJITCallee(Wasm::CompilationMode::BBQMode, WTFMove(entrypoint), index, WTFMove(name), WTFMove(unlinkedCalls), WTFMove(stackmaps), WTFMove(exceptionHandlers), WTFMove(exceptionHandlerLocations))
         , m_tierUpCount(WTFMove(tierUpCount))
     {
@@ -290,7 +287,7 @@
     {
     }
 
-    Vector<Ref<LLIntCallee>> m_llintCallees;
+    FixedVector<Ref<LLIntCallee>> m_llintCallees;
 };
 
 } } // namespace JSC::Wasm

Modified: trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -48,6 +48,10 @@
 CodeBlock::CodeBlock(MemoryMode mode, const CodeBlock& other)
     : m_calleeCount(other.m_calleeCount)
     , m_mode(mode)
+#if ENABLE(WEBASSEMBLY_B3JIT)
+    , m_omgCallees(m_calleeCount)
+    , m_bbqCallees(m_calleeCount)
+#endif
     , m_llintCallees(other.m_llintCallees)
     , m_embedderCallees(other.m_embedderCallees)
     , m_wasmIndirectCallEntryPoints(other.m_wasmIndirectCallEntryPoints)
@@ -54,10 +58,6 @@
     , m_wasmToWasmCallsites(other.m_wasmToWasmCallsites)
     , m_wasmToWasmExitStubs(other.m_wasmToWasmExitStubs)
 {
-#if ENABLE(WEBASSEMBLY_B3JIT)
-    m_bbqCallees.resize(m_calleeCount);
-    m_omgCallees.resize(m_calleeCount);
-#endif
     setCompilationFinished();
 }
 
@@ -79,10 +79,10 @@
 
 #if ENABLE(WEBASSEMBLY_B3JIT)
             // FIXME: we should eventually collect the BBQ code.
-            m_bbqCallees.resize(m_calleeCount);
-            m_omgCallees.resize(m_calleeCount);
+            m_bbqCallees = FixedVector<RefPtr<BBQCallee>>(m_calleeCount);
+            m_omgCallees = FixedVector<RefPtr<OMGCallee>>(m_calleeCount);
 #endif
-            m_wasmIndirectCallEntryPoints.resize(m_calleeCount);
+            m_wasmIndirectCallEntryPoints = FixedVector<MacroAssemblerCodePtr<WasmEntryPtrTag>>(m_calleeCount);
 
             for (unsigned i = 0; i < m_calleeCount; ++i)
                 m_wasmIndirectCallEntryPoints[i] = m_llintCallees->at(i)->entrypoint();
@@ -105,9 +105,9 @@
             }
 
             // FIXME: we should eventually collect the BBQ code.
-            m_bbqCallees.resize(m_calleeCount);
-            m_omgCallees.resize(m_calleeCount);
-            m_wasmIndirectCallEntryPoints.resize(m_calleeCount);
+            m_bbqCallees = FixedVector<RefPtr<BBQCallee>>(m_calleeCount);
+            m_omgCallees = FixedVector<RefPtr<OMGCallee>>(m_calleeCount);
+            m_wasmIndirectCallEntryPoints = FixedVector<MacroAssemblerCodePtr<WasmEntryPtrTag>>(m_calleeCount);
 
             BBQPlan* bbqPlan = static_cast<BBQPlan*>(m_plan.get());
             bbqPlan->initializeCallees([&] (unsigned calleeIndex, RefPtr<EmbedderEntrypointCallee>&& embedderEntrypointCallee, RefPtr<BBQCallee>&& wasmEntrypoint) {

Modified: trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -31,6 +31,7 @@
 #include "WasmCallee.h"
 #include "WasmEmbedder.h"
 #include <wtf/CrossThreadCopier.h>
+#include <wtf/FixedVector.h>
 #include <wtf/Lock.h>
 #include <wtf/RefPtr.h>
 #include <wtf/SharedTask.h>
@@ -143,14 +144,14 @@
     unsigned m_calleeCount;
     MemoryMode m_mode;
 #if ENABLE(WEBASSEMBLY_B3JIT)
-    Vector<RefPtr<OMGCallee>> m_omgCallees;
-    Vector<RefPtr<BBQCallee>> m_bbqCallees;
+    FixedVector<RefPtr<OMGCallee>> m_omgCallees;
+    FixedVector<RefPtr<BBQCallee>> m_bbqCallees;
 #endif
     RefPtr<LLIntCallees> m_llintCallees;
     HashMap<uint32_t, RefPtr<EmbedderEntrypointCallee>, DefaultHash<uint32_t>, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> m_embedderCallees;
-    Vector<MacroAssemblerCodePtr<WasmEntryPtrTag>> m_wasmIndirectCallEntryPoints;
-    Vector<Vector<UnlinkedWasmToWasmCall>> m_wasmToWasmCallsites;
-    Vector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToWasmExitStubs;
+    FixedVector<MacroAssemblerCodePtr<WasmEntryPtrTag>> m_wasmIndirectCallEntryPoints;
+    FixedVector<Vector<UnlinkedWasmToWasmCall>> m_wasmToWasmCallsites;
+    FixedVector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToWasmExitStubs;
     RefPtr<EntryPlan> m_plan;
     std::atomic<bool> m_compilationFinished { false };
     String m_errorMessage;

Modified: trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -57,7 +57,7 @@
     }
 }
 
-const HandlerInfo* HandlerInfo::handlerForIndex(Instance& instance, const Vector<HandlerInfo>& exeptionHandlers, unsigned index, const Wasm::Tag* exceptionTag)
+const HandlerInfo* HandlerInfo::handlerForIndex(Instance& instance, const FixedVector<HandlerInfo>& exeptionHandlers, unsigned index, const Wasm::Tag* exceptionTag)
 {
     bool delegating = false;
     unsigned delegateTarget = 0;

Modified: trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmHandlerInfo.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -68,7 +68,7 @@
 };
 
 struct HandlerInfo : public HandlerInfoBase {
-    static const HandlerInfo* handlerForIndex(Instance&, const Vector<HandlerInfo>& exeptionHandlers, unsigned index, const Wasm::Tag* exceptionTag);
+    static const HandlerInfo* handlerForIndex(Instance&, const FixedVector<HandlerInfo>& exeptionHandlers, unsigned index, const Wasm::Tag* exceptionTag);
 
     void initialize(const UnlinkedHandlerInfo&, MacroAssemblerCodePtr<ExceptionHandlerPtrTag>);
 

Modified: trunk/Source/_javascript_Core/wasm/WasmOSREntryData.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmOSREntryData.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmOSREntryData.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -33,8 +33,9 @@
 
 namespace JSC { namespace Wasm {
 
-class OSREntryValue : public B3::ValueRep {
+class OSREntryValue final : public B3::ValueRep {
 public:
+    OSREntryValue() = default;
     OSREntryValue(const B3::ValueRep& valueRep, B3::Type type)
         : B3::ValueRep(valueRep)
         , m_type(type)
@@ -44,10 +45,10 @@
     B3::Type type() const { return m_type; }
 
 private:
-    B3::Type m_type;
+    B3::Type m_type { };
 };
 
-using StackMap = Vector<OSREntryValue>;
+using StackMap = FixedVector<OSREntryValue>;
 using StackMaps = HashMap<CallSiteIndex, StackMap>;
 
 class OSREntryData {
@@ -54,15 +55,16 @@
     WTF_MAKE_NONCOPYABLE(OSREntryData);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    OSREntryData(uint32_t functionIndex, uint32_t loopIndex)
+    OSREntryData(uint32_t functionIndex, uint32_t loopIndex, StackMap&& stackMap)
         : m_functionIndex(functionIndex)
         , m_loopIndex(loopIndex)
+        , m_values(WTFMove(stackMap))
     {
     }
 
     uint32_t functionIndex() const { return m_functionIndex; }
     uint32_t loopIndex() const { return m_loopIndex; }
-    StackMap& values() { return m_values; }
+    const StackMap& values() { return m_values; }
 
 private:
     uint32_t m_functionIndex;

Modified: trunk/Source/_javascript_Core/wasm/WasmPlan.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmPlan.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmPlan.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -127,7 +127,7 @@
 void Plan::updateCallSitesToCallUs(CodeBlock& codeBlock, CodeLocationLabel<WasmEntryPtrTag> entrypoint, uint32_t functionIndex, uint32_t functionIndexSpace)
 {
     HashMap<void*, CodeLocationLabel<WasmEntryPtrTag>> stagedCalls;
-    auto stageRepatch = [&] (const Vector<UnlinkedWasmToWasmCall>& callsites) {
+    auto stageRepatch = [&] (const auto& callsites) {
         for (auto& call : callsites) {
             if (call.functionIndexSpace == functionIndexSpace) {
                 CodeLocationLabel<WasmEntryPtrTag> target = MacroAssembler::prepareForAtomicRepatchNearCallConcurrently(call.callLocation, entrypoint);
@@ -160,7 +160,7 @@
 
     codeBlock.m_wasmIndirectCallEntryPoints[functionIndex] = entrypoint;
 
-    auto repatchCalls = [&] (const Vector<UnlinkedWasmToWasmCall>& callsites) {
+    auto repatchCalls = [&] (const auto& callsites) {
         for (auto& call : callsites) {
             dataLogLnIf(WasmPlanInternal::verbose, "Considering repatching call at: ", RawPointer(call.callLocation.dataLocation()), " that targets ", call.functionIndexSpace);
             if (call.functionIndexSpace == functionIndexSpace) {

Modified: trunk/Source/_javascript_Core/wasm/WasmTierUpCount.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmTierUpCount.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmTierUpCount.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -39,9 +39,9 @@
 
 TierUpCount::~TierUpCount() = default;
 
-OSREntryData& TierUpCount::addOSREntryData(uint32_t functionIndex, uint32_t loopIndex)
+OSREntryData& TierUpCount::addOSREntryData(uint32_t functionIndex, uint32_t loopIndex, StackMap&& stackMap)
 {
-    m_osrEntryData.append(makeUnique<OSREntryData>(functionIndex, loopIndex));
+    m_osrEntryData.append(makeUnique<OSREntryData>(functionIndex, loopIndex, WTFMove(stackMap)));
     return *m_osrEntryData.last().get();
 }
 

Modified: trunk/Source/_javascript_Core/wasm/WasmTierUpCount.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/WasmTierUpCount.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/WasmTierUpCount.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -68,7 +68,7 @@
     Vector<uint32_t>& outerLoops() { return m_outerLoops; }
     Lock& getLock() { return m_lock; }
 
-    OSREntryData& addOSREntryData(uint32_t functionIndex, uint32_t loopIndex);
+    OSREntryData& addOSREntryData(uint32_t functionIndex, uint32_t loopIndex, StackMap&&);
 
     void optimizeAfterWarmUp(uint32_t functionIndex)
     {

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.cpp (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.cpp	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.cpp	2021-12-13 01:09:22 UTC (rev 286930)
@@ -47,10 +47,10 @@
 JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock(VM& vm, Ref<Wasm::CodeBlock>&& codeBlock, const Wasm::ModuleInformation& moduleInformation)
     : Base(vm, vm.webAssemblyCodeBlockStructure.get())
     , m_codeBlock(WTFMove(codeBlock))
+    , m_wasmToJSExitStubs(m_codeBlock->functionImportCount())
 {
     // FIXME: We should not need to do this synchronously.
     // https://bugs.webkit.org/show_bug.cgi?id=170567
-    m_wasmToJSExitStubs.reserveCapacity(m_codeBlock->functionImportCount());
     for (unsigned importIndex = 0; importIndex < m_codeBlock->functionImportCount(); ++importIndex) {
         Wasm::SignatureIndex signatureIndex = moduleInformation.importFunctionSignatureIndices.at(importIndex);
         auto binding = Wasm::wasmToJS(vm, m_callLinkInfos, signatureIndex, importIndex);
@@ -62,7 +62,7 @@
             }
             RELEASE_ASSERT_NOT_REACHED();
         }
-        m_wasmToJSExitStubs.uncheckedAppend(binding.value());
+        m_wasmToJSExitStubs[importIndex] = binding.value();
     }
 }
 

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h (286929 => 286930)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h	2021-12-12 23:49:39 UTC (rev 286929)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h	2021-12-13 01:09:22 UTC (rev 286930)
@@ -89,7 +89,7 @@
     DECLARE_VISIT_CHILDREN;
 
     Ref<Wasm::CodeBlock> m_codeBlock;
-    Vector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToJSExitStubs;
+    FixedVector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToJSExitStubs;
     Bag<OptimizingCallLinkInfo> m_callLinkInfos;
     String m_errorMessage;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to