Title: [153254] trunk/Source/_javascript_Core
Revision
153254
Author
[email protected]
Date
2013-07-24 21:04:01 -0700 (Wed, 24 Jul 2013)

Log Message

fourthTier: FTL should support hole/OOB PutByVal's
https://bugs.webkit.org/show_bug.cgi?id=118112

Reviewed by Geoffrey Garen.

Added a common code generator for the out-of-bounds case that is reused by
all contiguous-like arrays (Int32, Double, Contiguous).

This is relatively straight-forward, except that it's the first time that
the FTL has to call DFG operations that take more than two arguments.

* ftl/FTLAbbreviations.h:
(JSC::FTL::functionType):
(JSC::FTL::buildCall):
* ftl/FTLAbstractHeapRepository.h:
(FTL):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLIntrinsicRepository.h:
(FTL):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compilePutByVal):
(LowerDFGToLLVM):
(JSC::FTL::LowerDFGToLLVM::contiguousPutByValOutOfBounds):
(JSC::FTL::LowerDFGToLLVM::vmCall):
* ftl/FTLOutput.h:
(JSC::FTL::Output::call):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (153253 => 153254)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:04:01 UTC (rev 153254)
@@ -1,5 +1,50 @@
+2013-06-27  Filip Pizlo  <[email protected]>
+
+        Unreviewed, fix build for LLVM ToT.
+
+        This doesn't affect those using the binary drops, but if you're building from
+        LLVM ToT you'll get link errors. These arise because we expect there to be a
+        libLLVMArchive, but that is no longer built by LLVM ToT. This casues the linker
+        to fall back on the system's libLLVMArchive, which is incompatible with the
+        other LLVM libs we pull in.
+        
+        Also, we didn't need that library anyway and shouldn't have been linking
+        against it.
+
+        * Configurations/_javascript_Core.xcconfig:
+
 2013-06-26  Filip Pizlo  <[email protected]>
 
+        fourthTier: FTL should support hole/OOB PutByVal's
+        https://bugs.webkit.org/show_bug.cgi?id=118112
+
+        Reviewed by Geoffrey Garen.
+        
+        Added a common code generator for the out-of-bounds case that is reused by
+        all contiguous-like arrays (Int32, Double, Contiguous).
+        
+        This is relatively straight-forward, except that it's the first time that
+        the FTL has to call DFG operations that take more than two arguments.
+
+        * ftl/FTLAbbreviations.h:
+        (JSC::FTL::functionType):
+        (JSC::FTL::buildCall):
+        * ftl/FTLAbstractHeapRepository.h:
+        (FTL):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLIntrinsicRepository.h:
+        (FTL):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compilePutByVal):
+        (LowerDFGToLLVM):
+        (JSC::FTL::LowerDFGToLLVM::contiguousPutByValOutOfBounds):
+        (JSC::FTL::LowerDFGToLLVM::vmCall):
+        * ftl/FTLOutput.h:
+        (JSC::FTL::Output::call):
+
+2013-06-26  Filip Pizlo  <[email protected]>
+
         fourthTier: FTL::canCompile(Graph&) should not consider nodes that won't be compiled
         https://bugs.webkit.org/show_bug.cgi?id=118097
 

Modified: trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig (153253 => 153254)


--- trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig	2013-07-25 04:04:01 UTC (rev 153254)
@@ -37,7 +37,7 @@
 
 OTHER_LDFLAGS_LLVM = $(OTHER_LDFLAGS_LLVM_$(ENABLE_FTL_JIT));
 OTHER_LDFLAGS_LLVM_ = ;
-OTHER_LDFLAGS_LLVM_ENABLE_FTL_JIT = -lpthread -lm -lLLVMTableGen -lLLVMDebugInfo -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMIRReader -lLLVMAsmParser -lLLVMMCDisassembler -lLLVMMCParser -lLLVMInstrumentation -lLLVMArchive -lLLVMBitReader -lLLVMInterpreter -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMBitWriter -lLLVMMCJIT -lLLVMJIT -lLLVMCodeGen -lLLVMObjCARCOpts -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport;
+OTHER_LDFLAGS_LLVM_ENABLE_FTL_JIT = -lpthread -lm -lLLVMTableGen -lLLVMDebugInfo -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMIRReader -lLLVMAsmParser -lLLVMMCDisassembler -lLLVMMCParser -lLLVMInstrumentation -lLLVMBitReader -lLLVMInterpreter -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMBitWriter -lLLVMMCJIT -lLLVMJIT -lLLVMCodeGen -lLLVMObjCARCOpts -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport;
 
 
 

Modified: trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLAbbreviations.h	2013-07-25 04:04:01 UTC (rev 153254)
@@ -98,6 +98,16 @@
     LType paramTypes[] = { param1, param2 };
     return functionType(returnType, paramTypes, 2, variadicity);
 }
+static inline LType functionType(LType returnType, LType param1, LType param2, LType param3, Variadicity variadicity = NotVariadic)
+{
+    LType paramTypes[] = { param1, param2, param3 };
+    return functionType(returnType, paramTypes, 3, variadicity);
+}
+static inline LType functionType(LType returnType, LType param1, LType param2, LType param3, LType param4, Variadicity variadicity = NotVariadic)
+{
+    LType paramTypes[] = { param1, param2, param3, param4 };
+    return functionType(returnType, paramTypes, 4, variadicity);
+}
 
 static inline LType typeOf(LValue value) { return LLVMTypeOf(value); }
 
@@ -222,6 +232,16 @@
     LValue args[] = { arg1, arg2 };
     return buildCall(builder, function, args, 2);
 }
+static inline LValue buildCall(LBuilder builder, LValue function, LValue arg1, LValue arg2, LValue arg3)
+{
+    LValue args[] = { arg1, arg2, arg3 };
+    return buildCall(builder, function, args, 3);
+}
+static inline LValue buildCall(LBuilder builder, LValue function, LValue arg1, LValue arg2, LValue arg3, LValue arg4)
+{
+    LValue args[] = { arg1, arg2, arg3, arg4 };
+    return buildCall(builder, function, args, 4);
+}
 enum TailCallMode { IsNotTailCall, IsTailCall };
 static inline void setTailCall(LValue call, TailCallMode mode) { LLVMSetTailCall(call, mode == IsTailCall); }
 static inline LValue buildExtractValue(LBuilder builder, LValue aggVal, unsigned index) { return LLVMBuildExtractValue(builder, aggVal, index, ""); }

Modified: trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLAbstractHeapRepository.h	2013-07-25 04:04:01 UTC (rev 153254)
@@ -40,6 +40,7 @@
 
 #define FOR_EACH_ABSTRACT_FIELD(macro) \
     macro(Butterfly_publicLength, Butterfly::offsetOfPublicLength()) \
+    macro(Butterfly_vectorLength, Butterfly::offsetOfVectorLength()) \
     macro(JSCell_structure, JSCell::structureOffset()) \
     macro(JSObject_butterfly, JSObject::butterflyOffset()) \
     macro(JSString_length, JSString::offsetOfLength()) \

Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-07-25 04:04:01 UTC (rev 153254)
@@ -125,13 +125,6 @@
         default:
             return false;
         }
-        switch (node->arrayMode().speculation()) {
-        case Array::SaneChain:
-        case Array::InBounds:
-            break;
-        default:
-            return false;
-        }
         break;
     case CompareEq:
     case CompareStrictEq:

Modified: trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h	2013-07-25 04:04:01 UTC (rev 153254)
@@ -44,7 +44,9 @@
 
 #define FOR_EACH_FUNCTION_TYPE(macro) \
     macro(I_DFGOperation_EJss, functionType(intPtr, intPtr, intPtr)) \
-    macro(P_DFGOperation_EC, functionType(intPtr, intPtr, intPtr))
+    macro(P_DFGOperation_EC, functionType(intPtr, intPtr, intPtr)) \
+    macro(V_DFGOperation_EOZD, functionType(voidType, intPtr, intPtr, int32, doubleType)) \
+    macro(V_DFGOperation_EOZJ, functionType(voidType, intPtr, intPtr, int32, int64))
 
 class IntrinsicRepository : public CommonValues {
 public:

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-07-25 04:04:01 UTC (rev 153254)
@@ -1311,9 +1311,13 @@
         Edge child3 = m_graph.varArgChild(m_node, 2);
         Edge child4 = m_graph.varArgChild(m_node, 3);
 
+        LValue base = lowCell(child1);
         LValue index = lowInt32(child2);
         LValue storage = lowStorage(child4);
         
+        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("PutByVal continuation"));
+        LBasicBlock outerLastNext = m_out.appendTo(m_out.m_block, continuation);
+            
         switch (m_node->arrayMode().type()) {
         case Array::Int32:
         case Array::Contiguous: {
@@ -1330,22 +1334,17 @@
             
             if (m_node->op() == PutByValAlias) {
                 m_out.store64(value, elementPointer);
-                return;
+                break;
             }
             
-            if (m_node->arrayMode().isInBounds()) {
-                speculate(
-                    StoreToHoleOrOutOfBounds, noValue(), 0,
-                    m_out.aboveOrEqual(
-                        index, m_out.load32(storage, m_heaps.Butterfly_publicLength)));
-            } else {
-                // FIXME: Implement hole/OOB stores in the FTL.
-                // https://bugs.webkit.org/show_bug.cgi?id=118077
-                RELEASE_ASSERT_NOT_REACHED();
-            }
+            contiguousPutByValOutOfBounds(
+                codeBlock()->isStrictMode()
+                    ? operationPutByValBeyondArrayBoundsStrict
+                    : operationPutByValBeyondArrayBoundsNonStrict,
+                base, storage, index, value, continuation);
             
             m_out.store64(value, elementPointer);
-            return;
+            break;
         }
             
         case Array::Double: {
@@ -1362,28 +1361,26 @@
 
             if (m_node->op() == PutByValAlias) {
                 m_out.storeDouble(value, elementPointer);
-                return;
+                break;
             }
             
-            if (m_node->arrayMode().isInBounds()) {
-                speculate(
-                    StoreToHoleOrOutOfBounds, noValue(), 0,
-                    m_out.aboveOrEqual(
-                        index, m_out.load32(storage, m_heaps.Butterfly_publicLength)));
-            } else {
-                // FIXME: Implement hole/OOB stores in the FTL.
-                // https://bugs.webkit.org/show_bug.cgi?id=118077
-                RELEASE_ASSERT_NOT_REACHED();
-            }
+            contiguousPutByValOutOfBounds(
+                codeBlock()->isStrictMode()
+                    ? operationPutDoubleByValBeyondArrayBoundsStrict
+                    : operationPutDoubleByValBeyondArrayBoundsNonStrict,
+                base, storage, index, value, continuation);
             
             m_out.storeDouble(value, elementPointer);
-            return;
+            break;
         }
             
         default:
             RELEASE_ASSERT_NOT_REACHED();
-            return;
+            break;
         }
+
+        m_out.jump(continuation);
+        m_out.appendTo(continuation, outerLastNext);
     }
     
     void compileGetByOffset()
@@ -1868,6 +1865,59 @@
         return m_out.phi(m_out.boolean, results);
     }
     
+    template<typename FunctionType>
+    void contiguousPutByValOutOfBounds(
+        FunctionType slowPathFunction,
+        LValue base, LValue storage, LValue index, LValue value,
+        LBasicBlock continuation)
+    {
+        LValue isNotInBounds = m_out.aboveOrEqual(
+            index, m_out.load32(storage, m_heaps.Butterfly_publicLength));
+        if (m_node->arrayMode().isInBounds())
+            speculate(StoreToHoleOrOutOfBounds, noValue(), 0, isNotInBounds);
+        else {
+            LBasicBlock notInBoundsCase =
+                FTL_NEW_BLOCK(m_out, ("PutByVal not in bounds"));
+            LBasicBlock performStore =
+                FTL_NEW_BLOCK(m_out, ("PutByVal perform store"));
+                
+            m_out.branch(isNotInBounds, notInBoundsCase, performStore);
+                
+            LBasicBlock lastNext = m_out.appendTo(notInBoundsCase, performStore);
+                
+            LValue isOutOfBounds = m_out.aboveOrEqual(
+                index, m_out.load32(storage, m_heaps.Butterfly_vectorLength));
+                
+            if (!m_node->arrayMode().isOutOfBounds())
+                speculate(OutOfBounds, noValue(), 0, isOutOfBounds);
+            else {
+                LBasicBlock outOfBoundsCase =
+                    FTL_NEW_BLOCK(m_out, ("PutByVal out of bounds"));
+                LBasicBlock holeCase =
+                    FTL_NEW_BLOCK(m_out, ("PutByVal hole case"));
+                    
+                m_out.branch(isOutOfBounds, outOfBoundsCase, holeCase);
+                    
+                LBasicBlock innerLastNext = m_out.appendTo(outOfBoundsCase, holeCase);
+                    
+                vmCall(
+                    m_out.operation(slowPathFunction),
+                    m_callFrame, base, index, value);
+                    
+                m_out.jump(continuation);
+                    
+                m_out.appendTo(holeCase, innerLastNext);
+            }
+            
+            m_out.store32(
+                m_out.add(index, m_out.int32One),
+                storage, m_heaps.Butterfly_publicLength);
+                
+            m_out.jump(performStore);
+            m_out.appendTo(performStore, lastNext);
+        }
+    }
+    
     void buildSwitch(SwitchData* data, LType type, LValue switchValue)
     {
         Vector<SwitchCase> cases;
@@ -2331,6 +2381,20 @@
         callCheck(mode);
         return result;
     }
+    LValue vmCall(LValue function, LValue arg1, LValue arg2, LValue arg3, ExceptionCheckMode mode = CheckExceptions)
+    {
+        callPreflight();
+        LValue result = m_out.call(function, arg1, arg2, arg3);
+        callCheck(mode);
+        return result;
+    }
+    LValue vmCall(LValue function, LValue arg1, LValue arg2, LValue arg3, LValue arg4, ExceptionCheckMode mode = CheckExceptions)
+    {
+        callPreflight();
+        LValue result = m_out.call(function, arg1, arg2, arg3, arg4);
+        callCheck(mode);
+        return result;
+    }
     
     void callPreflight(CodeOrigin codeOrigin)
     {

Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.h (153253 => 153254)


--- trunk/Source/_javascript_Core/ftl/FTLOutput.h	2013-07-25 04:03:59 UTC (rev 153253)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.h	2013-07-25 04:04:01 UTC (rev 153254)
@@ -324,6 +324,8 @@
     LValue call(LValue function) { return buildCall(m_builder, function); }
     LValue call(LValue function, LValue arg1) { return buildCall(m_builder, function, arg1); }
     LValue call(LValue function, LValue arg1, LValue arg2) { return buildCall(m_builder, function, arg1, arg2); }
+    LValue call(LValue function, LValue arg1, LValue arg2, LValue arg3) { return buildCall(m_builder, function, arg1, arg2, arg3); }
+    LValue call(LValue function, LValue arg1, LValue arg2, LValue arg3, LValue arg4) { return buildCall(m_builder, function, arg1, arg2, arg3, arg4); }
     
     template<typename FunctionType>
     LValue operation(FunctionType function)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to