Title: [160242] trunk
Revision
160242
Author
[email protected]
Date
2013-12-06 12:59:16 -0800 (Fri, 06 Dec 2013)

Log Message

FTL should support all of ValueToInt32
https://bugs.webkit.org/show_bug.cgi?id=125283

Reviewed by Mark Hahnenberg.

Source/_javascript_Core: 

* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileValueToInt32):
(JSC::FTL::LowerDFGToLLVM::compilePutByVal):
(JSC::FTL::LowerDFGToLLVM::lowCell):
(JSC::FTL::LowerDFGToLLVM::isCell):

LayoutTests: 

* js/regress/put-by-val-machine-int-expected.txt: Added.
* js/regress/put-by-val-machine-int.html: Added.
* js/regress/script-tests/put-by-val-machine-int.js: Added.
(foo):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160241 => 160242)


--- trunk/LayoutTests/ChangeLog	2013-12-06 20:57:09 UTC (rev 160241)
+++ trunk/LayoutTests/ChangeLog	2013-12-06 20:59:16 UTC (rev 160242)
@@ -1,3 +1,15 @@
+2013-12-06  Filip Pizlo  <[email protected]>
+
+        FTL should support all of ValueToInt32
+        https://bugs.webkit.org/show_bug.cgi?id=125283
+
+        Reviewed by Mark Hahnenberg.
+
+        * js/regress/put-by-val-machine-int-expected.txt: Added.
+        * js/regress/put-by-val-machine-int.html: Added.
+        * js/regress/script-tests/put-by-val-machine-int.js: Added.
+        (foo):
+
 2013-12-06  Eric Carlson  <[email protected]>
 
         Unreviewed gardening, correct previous fix.

Added: trunk/LayoutTests/js/regress/put-by-val-machine-int-expected.txt (0 => 160242)


--- trunk/LayoutTests/js/regress/put-by-val-machine-int-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/put-by-val-machine-int-expected.txt	2013-12-06 20:59:16 UTC (rev 160242)
@@ -0,0 +1,10 @@
+JSRegress/put-by-val-machine-int
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/regress/put-by-val-machine-int.html (0 => 160242)


--- trunk/LayoutTests/js/regress/put-by-val-machine-int.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/put-by-val-machine-int.html	2013-12-06 20:59:16 UTC (rev 160242)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/regress/script-tests/put-by-val-machine-int.js (0 => 160242)


--- trunk/LayoutTests/js/regress/script-tests/put-by-val-machine-int.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/put-by-val-machine-int.js	2013-12-06 20:59:16 UTC (rev 160242)
@@ -0,0 +1,12 @@
+function foo(a, v) {
+    a[0] = v + 2000000000;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+    var a = new Int32Array(1);
+    foo(a, 2000000000);
+    if (a[0] != -294967296)
+        throw "Error: bad value: " + a[0];
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (160241 => 160242)


--- trunk/Source/_javascript_Core/ChangeLog	2013-12-06 20:57:09 UTC (rev 160241)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-12-06 20:59:16 UTC (rev 160242)
@@ -1,5 +1,20 @@
 2013-12-06  Filip Pizlo  <[email protected]>
 
+        FTL should support all of ValueToInt32
+        https://bugs.webkit.org/show_bug.cgi?id=125283
+
+        Reviewed by Mark Hahnenberg.
+
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileValueToInt32):
+        (JSC::FTL::LowerDFGToLLVM::compilePutByVal):
+        (JSC::FTL::LowerDFGToLLVM::lowCell):
+        (JSC::FTL::LowerDFGToLLVM::isCell):
+
+2013-12-06  Filip Pizlo  <[email protected]>
+
         FTL shouldn't have a doubleToUInt32 path
         https://bugs.webkit.org/show_bug.cgi?id=125360
 

Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (160241 => 160242)


--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-12-06 20:57:09 UTC (rev 160241)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-12-06 20:59:16 UTC (rev 160242)
@@ -105,6 +105,7 @@
     case FunctionReentryWatchpoint:
     case VariableWatchpoint:
     case NotifyWrite:
+    case ValueToInt32:
         // These are OK.
         break;
     case GetById:
@@ -224,10 +225,6 @@
             return CannotCompile;
         }
         break;
-    case ValueToInt32:
-        if (node->child1().useKind() != BooleanUse)
-            return CannotCompile;
-        break;
     default:
         // Don't know how to handle anything else.
         return CannotCompile;

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (160241 => 160242)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-12-06 20:57:09 UTC (rev 160241)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-12-06 20:59:16 UTC (rev 160242)
@@ -484,8 +484,96 @@
 
     void compileValueToInt32()
     {
-        ASSERT(m_node->child1().useKind() == BooleanUse);
-        setInt32(m_out.zeroExt(lowBoolean(m_node->child1()), m_out.int32));
+        switch (m_node->child1().useKind()) {
+        case Int32Use:
+            setInt32(lowInt32(m_node->child1()));
+            break;
+            
+        case MachineIntUse:
+            setInt32(m_out.castToInt32(lowStrictInt52(m_node->child1())));
+            break;
+            
+        case NumberUse:
+        case NotCellUse: {
+            LoweredNodeValue value = m_int32Values.get(m_node->child1().node());
+            if (isValid(value)) {
+                setInt32(value.value());
+                break;
+            }
+            
+            value = m_jsValueValues.get(m_node->child1().node());
+            if (isValid(value)) {
+                LBasicBlock intCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 int case"));
+                LBasicBlock notIntCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 not int case"));
+                LBasicBlock doubleCase = 0;
+                LBasicBlock notNumberCase = 0;
+                if (m_node->child1().useKind() == NotCellUse) {
+                    doubleCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 double case"));
+                    notNumberCase = FTL_NEW_BLOCK(m_out, ("ValueToInt32 not number case"));
+                }
+                LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ValueToInt32 continuation"));
+                
+                Vector<ValueFromBlock> results;
+                
+                m_out.branch(isNotInt32(value.value()), notIntCase, intCase);
+                
+                LBasicBlock lastNext = m_out.appendTo(intCase, notIntCase);
+                results.append(m_out.anchor(unboxInt32(value.value())));
+                m_out.jump(continuation);
+                
+                if (m_node->child1().useKind() == NumberUse) {
+                    m_out.appendTo(notIntCase, continuation);
+                    FTL_TYPE_CHECK(
+                        jsValueValue(value.value()), m_node->child1(), SpecFullNumber,
+                        isCellOrMisc(value.value()));
+                    results.append(m_out.anchor(doubleToInt32(unboxDouble(value.value()))));
+                    m_out.jump(continuation);
+                } else {
+                    m_out.appendTo(notIntCase, doubleCase);
+                    m_out.branch(isCellOrMisc(value.value()), notNumberCase, doubleCase);
+                    
+                    m_out.appendTo(doubleCase, notNumberCase);
+                    results.append(m_out.anchor(doubleToInt32(unboxDouble(value.value()))));
+                    m_out.jump(continuation);
+                    
+                    m_out.appendTo(notNumberCase, continuation);
+                    
+                    FTL_TYPE_CHECK(
+                        jsValueValue(value.value()), m_node->child1(), ~SpecCell,
+                        isCell(value.value()));
+                    
+                    LValue specialResult = m_out.select(
+                        m_out.equal(
+                            value.value(),
+                            m_out.constInt64(JSValue::encode(jsBoolean(true)))),
+                        m_out.int32One, m_out.int32Zero);
+                    results.append(m_out.anchor(specialResult));
+                    m_out.jump(continuation);
+                }
+                
+                m_out.appendTo(continuation, lastNext);
+                setInt32(m_out.phi(m_out.int32, results));
+                break;
+            }
+            
+            value = m_doubleValues.get(m_node->child1().node());
+            if (isValid(value)) {
+                setInt32(doubleToInt32(value.value()));
+                break;
+            }
+            
+            terminate(Uncountable);
+            break;
+        }
+            
+        case BooleanUse:
+            setInt32(m_out.zeroExt(lowBoolean(m_node->child1()), m_out.int32));
+            break;
+            
+        default:
+            RELEASE_ASSERT_NOT_REACHED();
+            break;
+        }
     }
 
     void compileInt52ToValue()
@@ -1649,7 +1737,7 @@
                         if (child3.useKind() == Int32Use)
                             intValue = lowInt32(child3);
                         else
-                            intValue = m_out.castToInt32(lowInt52(child3));
+                            intValue = m_out.castToInt32(lowStrictInt52(child3));
 
                         if (isClamped(type)) {
                             ASSERT(elementSize(type) == 1);
@@ -3246,7 +3334,7 @@
     
     LValue lowCell(Edge edge, OperandSpeculationMode mode = AutomaticOperandSpeculation)
     {
-        ASSERT_UNUSED(mode, mode == ManualOperandSpeculation || isCell(edge.useKind()));
+        ASSERT_UNUSED(mode, mode == ManualOperandSpeculation || DFG::isCell(edge.useKind()));
         
         if (edge->op() == JSConstant) {
             JSValue value = m_graph.valueOfJSConstant(edge.node());
@@ -3555,6 +3643,11 @@
         return m_out.testNonZero64(jsValue, m_tagMask);
     }
     
+    LValue isCell(LValue jsValue)
+    {
+        return m_out.testIsZero64(jsValue, m_tagMask);
+    }
+    
     LValue isNotBoolean(LValue jsValue)
     {
         return m_out.testNonZero64(
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to