B3 -O1 should not allocateStackByGraphColoring
[WebKit-https.git] / Source / JavaScriptCore / b3 / air / AirCode.cpp
index 0aaa518..7cb8e70 100644 (file)
@@ -102,7 +102,14 @@ BasicBlock* Code::addBlock(double frequency)
 
 StackSlot* Code::addStackSlot(unsigned byteSize, StackSlotKind kind, B3::StackSlot* b3Slot)
 {
-    return m_stackSlots.addNew(byteSize, kind, b3Slot);
+    StackSlot* result = m_stackSlots.addNew(byteSize, kind, b3Slot);
+    if (m_stackIsAllocated) {
+        // FIXME: This is unnecessarily awful. Fortunately, it doesn't run often.
+        unsigned extent = WTF::roundUpToMultipleOf(result->alignment(), frameSize() + byteSize);
+        result->setOffsetFromFP(-static_cast<ptrdiff_t>(extent));
+        setFrameSize(WTF::roundUpToMultipleOf(stackAlignmentBytes(), extent));
+    }
+    return result;
 }
 
 StackSlot* Code::addStackSlot(B3::StackSlot* b3Slot)
@@ -138,6 +145,28 @@ bool Code::isEntrypoint(BasicBlock* block) const
     return false;
 }
 
+void Code::setCalleeSaveRegisterAtOffsetList(RegisterAtOffsetList&& registerAtOffsetList, StackSlot* slot)
+{
+    m_uncorrectedCalleeSaveRegisterAtOffsetList = WTFMove(registerAtOffsetList);
+    for (const RegisterAtOffset& registerAtOffset : m_uncorrectedCalleeSaveRegisterAtOffsetList)
+        m_calleeSaveRegisters.set(registerAtOffset.reg());
+    m_calleeSaveStackSlot = slot;
+}
+
+RegisterAtOffsetList Code::calleeSaveRegisterAtOffsetList() const
+{
+    RegisterAtOffsetList result = m_uncorrectedCalleeSaveRegisterAtOffsetList;
+    if (StackSlot* slot = m_calleeSaveStackSlot) {
+        ptrdiff_t offset = slot->byteSize() + slot->offsetFromFP();
+        for (size_t i = result.size(); i--;) {
+            result.at(i) = RegisterAtOffset(
+                result.at(i).reg(),
+                result.at(i).offset() + offset);
+        }
+    }
+    return result;
+}
+
 void Code::resetReachability()
 {
     clearPredecessors(m_blocks);
@@ -170,12 +199,13 @@ void Code::dump(PrintStream& out) const
         for (Special* special : specials())
             out.print("    ", deepDump(special), "\n");
     }
-    if (m_frameSize)
-        out.print("Frame size: ", m_frameSize, "\n");
+    if (m_frameSize || m_stackIsAllocated)
+        out.print("Frame size: ", m_frameSize, m_stackIsAllocated ? " (Allocated)" : "", "\n");
     if (m_callArgAreaSize)
         out.print("Call arg area size: ", m_callArgAreaSize, "\n");
-    if (m_calleeSaveRegisters.size())
-        out.print("Callee saves: ", m_calleeSaveRegisters, "\n");
+    RegisterAtOffsetList calleeSaveRegisters = this->calleeSaveRegisterAtOffsetList();
+    if (calleeSaveRegisters.size())
+        out.print("Callee saves: ", calleeSaveRegisters, "\n");
 }
 
 unsigned Code::findFirstBlockIndex(unsigned index) const