Teach Call ICs how to call Wasm
[WebKit-https.git] / Source / JavaScriptCore / wasm / WasmMemoryInformation.cpp
index c3a4041..2bb38d9 100644 (file)
@@ -44,6 +44,11 @@ static Vector<GPRReg> getPinnedRegisters(unsigned remainingPinnedRegisters)
         GPRReg gpr = reg.gpr();
         if (!remainingPinnedRegisters || RegisterSet::stackRegisters().get(reg))
             return;
+        if (RegisterSet::runtimeTagRegisters().get(reg)) {
+            // Since we don't need to, we currently don't pick from the tag registers to allow
+            // JS->Wasm stubs to freely use these registers.
+            return;
+        }
         --remainingPinnedRegisters;
         registers.append(gpr);
     });
@@ -55,35 +60,25 @@ const PinnedRegisterInfo& PinnedRegisterInfo::get()
     static LazyNeverDestroyed<PinnedRegisterInfo> staticPinnedRegisterInfo;
     static std::once_flag staticPinnedRegisterInfoFlag;
     std::call_once(staticPinnedRegisterInfoFlag, [] () {
-        Vector<PinnedSizeRegisterInfo> sizeRegisters;
-        GPRReg baseMemoryPointer = InvalidGPRReg;
-        GPRReg wasmContextInstancePointer = InvalidGPRReg;
-
-        // FIXME: We should support more than one memory size register, and we should allow different
-        //        WebAssembly.Instance to have different pins. Right now we take a vector with only one entry.
-        //        If we have more than one size register, we can have one for each load size class.
-        //        see: https://bugs.webkit.org/show_bug.cgi?id=162952
-        Vector<unsigned> pinnedSizes = { 0 };
-        unsigned numberOfPinnedRegisters = pinnedSizes.size() + 1;
+        unsigned numberOfPinnedRegisters = 2;
         if (!Context::useFastTLS())
             ++numberOfPinnedRegisters;
         Vector<GPRReg> pinnedRegs = getPinnedRegisters(numberOfPinnedRegisters);
 
-        baseMemoryPointer = pinnedRegs.takeLast();
+        GPRReg baseMemoryPointer = pinnedRegs.takeLast();
+        GPRReg sizeRegister = pinnedRegs.takeLast();
+        GPRReg wasmContextInstancePointer = InvalidGPRReg;
         if (!Context::useFastTLS())
             wasmContextInstancePointer = pinnedRegs.takeLast();
 
-        ASSERT(pinnedSizes.size() == pinnedRegs.size());
-        for (unsigned i = 0; i < pinnedSizes.size(); ++i)
-            sizeRegisters.append({ pinnedRegs[i], pinnedSizes[i] });
-        staticPinnedRegisterInfo.construct(WTFMove(sizeRegisters), baseMemoryPointer, wasmContextInstancePointer);
+        staticPinnedRegisterInfo.construct(sizeRegister, baseMemoryPointer, wasmContextInstancePointer);
     });
 
     return staticPinnedRegisterInfo.get();
 }
 
-PinnedRegisterInfo::PinnedRegisterInfo(Vector<PinnedSizeRegisterInfo>&& sizeRegisters, GPRReg baseMemoryPointer, GPRReg wasmContextInstancePointer)
-    : sizeRegisters(WTFMove(sizeRegisters))
+PinnedRegisterInfo::PinnedRegisterInfo(GPRReg sizeRegister, GPRReg baseMemoryPointer, GPRReg wasmContextInstancePointer)
+    : sizeRegister(sizeRegister)
     , baseMemoryPointer(baseMemoryPointer)
     , wasmContextInstancePointer(wasmContextInstancePointer)
 {