We should support CreateThis in the FTL
[WebKit-https.git] / Source / JavaScriptCore / ftl / FTLLowerDFGToB3.cpp
index f4e4048..3ba87e1 100644 (file)
@@ -856,6 +856,9 @@ private:
         case NewArrayWithSpread:
             compileNewArrayWithSpread();
             break;
+        case CreateThis:
+            compileCreateThis();
+            break;
         case Spread:
             compileSpread();
             break;
@@ -1298,6 +1301,12 @@ private:
         case CallDOMGetter:
             compileCallDOMGetter();
             break;
+        case FilterCallLinkStatus:
+        case FilterGetByIdStatus:
+        case FilterPutByIdStatus:
+        case FilterInByIdStatus:
+            compileFilterICStatus();
+            break;
 
         case PhantomLocal:
         case LoopHint:
@@ -5698,6 +5707,40 @@ private:
 
         setJSValue(result);
     }
+    
+    void compileCreateThis()
+    {
+        LValue callee = lowCell(m_node->child1());
+
+        LBasicBlock isFunctionBlock = m_out.newBlock();
+        LBasicBlock hasRareData = m_out.newBlock();
+        LBasicBlock slowPath = m_out.newBlock();
+        LBasicBlock continuation = m_out.newBlock();
+
+        m_out.branch(isFunction(callee, provenType(m_node->child1())), usually(isFunctionBlock), rarely(slowPath));
+
+        LBasicBlock lastNext = m_out.appendTo(isFunctionBlock, hasRareData);
+        LValue rareData = m_out.loadPtr(callee, m_heaps.JSFunction_rareData);
+        m_out.branch(m_out.isZero64(rareData), rarely(slowPath), usually(hasRareData));
+
+        m_out.appendTo(hasRareData, slowPath);
+        LValue allocator = m_out.loadPtr(rareData, m_heaps.FunctionRareData_allocator);
+        LValue structure = m_out.loadPtr(rareData, m_heaps.FunctionRareData_structure);
+        LValue butterfly = m_out.constIntPtr(0);
+        ValueFromBlock fastResult = m_out.anchor(allocateObject(allocator, structure, butterfly, slowPath));
+        m_out.jump(continuation);
+
+        m_out.appendTo(slowPath, continuation);
+        ValueFromBlock slowResult = m_out.anchor(vmCall(
+            Int64, m_out.operation(operationCreateThis), m_callFrame, callee, m_out.constInt32(m_node->inlineCapacity())));
+        m_out.jump(continuation);
+
+        m_out.appendTo(continuation, lastNext);
+        LValue result = m_out.phi(Int64, fastResult, slowResult);
+
+        mutatorFence();
+        setJSValue(result);
+    }
 
     void compileSpread()
     {
@@ -12191,6 +12234,11 @@ private:
         setJSValue(patchpoint);
     }
     
+    void compileFilterICStatus()
+    {
+        m_interpreter.filterICStatus(m_node);
+    }
+    
     void emitSwitchForMultiByOffset(LValue base, bool structuresChecked, Vector<SwitchCase, 2>& cases, LBasicBlock exit)
     {
         if (cases.isEmpty()) {