Title: [196642] trunk
Revision
196642
Author
fpi...@apple.com
Date
2016-02-16 11:12:36 -0800 (Tue, 16 Feb 2016)

Log Message

FTL should support StringFromCharCode
https://bugs.webkit.org/show_bug.cgi?id=154267
Source/_javascript_Core:

rdar://problem/24192536

Reviewed by Mark Lam.

* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode): Fix a bug preventing the UntypedUse from being effective.
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
(JSC::FTL::DFG::LowerDFGToLLVM::compileStringFromCharCode): Implement the opcode.
* tests/stress/string-from-char-code-slow.js: Added.

LayoutTests:


Reviewed by Mark Lam.

* js/regress/script-tests/string-from-char-code.js: Added.
(result):
* js/regress/script-tests/untyped-string-from-char-code.js: Added.
(result):
* js/regress/string-from-char-code-expected.txt: Added.
* js/regress/string-from-char-code.html: Added.
* js/regress/untyped-string-from-char-code-expected.txt: Added.
* js/regress/untyped-string-from-char-code.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (196641 => 196642)


--- trunk/LayoutTests/ChangeLog	2016-02-16 18:48:36 UTC (rev 196641)
+++ trunk/LayoutTests/ChangeLog	2016-02-16 19:12:36 UTC (rev 196642)
@@ -1,3 +1,19 @@
+2016-02-16  Filip Pizlo  <fpi...@apple.com>
+
+        FTL should support StringFromCharCode
+        https://bugs.webkit.org/show_bug.cgi?id=154267
+
+        Reviewed by Mark Lam.
+
+        * js/regress/script-tests/string-from-char-code.js: Added.
+        (result):
+        * js/regress/script-tests/untyped-string-from-char-code.js: Added.
+        (result):
+        * js/regress/string-from-char-code-expected.txt: Added.
+        * js/regress/string-from-char-code.html: Added.
+        * js/regress/untyped-string-from-char-code-expected.txt: Added.
+        * js/regress/untyped-string-from-char-code.html: Added.
+
 2016-02-16  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] No hover-horizontal scrolling available

Added: trunk/LayoutTests/js/regress/script-tests/string-from-char-code.js (0 => 196642)


--- trunk/LayoutTests/js/regress/script-tests/string-from-char-code.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/string-from-char-code.js	2016-02-16 19:12:36 UTC (rev 196642)
@@ -0,0 +1,10 @@
+var result = (function() {
+    var result;
+    for (var i = 0; i < 10000000; ++i)
+        result = String.fromCharCode(32);
+    return result
+})();
+
+if (result != " ")
+    throw "Error: bad result: " + result;
+

Added: trunk/LayoutTests/js/regress/script-tests/untyped-string-from-char-code.js (0 => 196642)


--- trunk/LayoutTests/js/regress/script-tests/untyped-string-from-char-code.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/untyped-string-from-char-code.js	2016-02-16 19:12:36 UTC (rev 196642)
@@ -0,0 +1,12 @@
+var result = (function(a) {
+    a[0] = 32;
+
+    var result;
+    for (var i = 0; i < 1000000; ++i)
+        result = String.fromCharCode(a[0]);
+    return result
+})(new Float64Array(1));
+
+if (result != " ")
+    throw "Error: bad result: " + result;
+

Added: trunk/LayoutTests/js/regress/string-from-char-code-expected.txt (0 => 196642)


--- trunk/LayoutTests/js/regress/string-from-char-code-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/string-from-char-code-expected.txt	2016-02-16 19:12:36 UTC (rev 196642)
@@ -0,0 +1,10 @@
+JSRegress/string-from-char-code
+
+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/string-from-char-code.html (0 => 196642)


--- trunk/LayoutTests/js/regress/string-from-char-code.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/string-from-char-code.html	2016-02-16 19:12:36 UTC (rev 196642)
@@ -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/untyped-string-from-char-code-expected.txt (0 => 196642)


--- trunk/LayoutTests/js/regress/untyped-string-from-char-code-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/untyped-string-from-char-code-expected.txt	2016-02-16 19:12:36 UTC (rev 196642)
@@ -0,0 +1,10 @@
+JSRegress/untyped-string-from-char-code
+
+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/untyped-string-from-char-code.html (0 => 196642)


--- trunk/LayoutTests/js/regress/untyped-string-from-char-code.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/untyped-string-from-char-code.html	2016-02-16 19:12:36 UTC (rev 196642)
@@ -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>

Modified: trunk/Source/_javascript_Core/ChangeLog (196641 => 196642)


--- trunk/Source/_javascript_Core/ChangeLog	2016-02-16 18:48:36 UTC (rev 196641)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-02-16 19:12:36 UTC (rev 196642)
@@ -1,3 +1,20 @@
+2016-02-16  Filip Pizlo  <fpi...@apple.com>
+
+        FTL should support StringFromCharCode
+        https://bugs.webkit.org/show_bug.cgi?id=154267
+        rdar://problem/24192536
+
+        Reviewed by Mark Lam.
+
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode): Fix a bug preventing the UntypedUse from being effective.
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileStringFromCharCode): Implement the opcode.
+        * tests/stress/string-from-char-code-slow.js: Added.
+
 2016-02-15  Benjamin Poulain  <bpoul...@apple.com>
 
         [JSC] BranchAdd can override arguments of its stackmap

Modified: trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (196641 => 196642)


--- trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2016-02-16 18:48:36 UTC (rev 196641)
+++ trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2016-02-16 19:12:36 UTC (rev 196642)
@@ -602,11 +602,10 @@
         }
 
         case StringFromCharCode:
-            if (node->child1()->shouldSpeculateUntypedForArithmetic()) {
+            if (node->child1()->shouldSpeculateInt32())
+                fixEdge<Int32Use>(node->child1());
+            else
                 fixEdge<UntypedUse>(node->child1());
-                break;
-            }
-            fixEdge<Int32Use>(node->child1());
             break;
 
         case StringCharAt:

Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (196641 => 196642)


--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2016-02-16 18:48:36 UTC (rev 196641)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2016-02-16 19:12:36 UTC (rev 196642)
@@ -127,6 +127,7 @@
     case CheckIdent:
     case CheckWatchdogTimer:
     case StringCharCodeAt:
+    case StringFromCharCode:
     case AllocatePropertyStorage:
     case ReallocatePropertyStorage:
     case GetTypedArrayByteOffset:

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (196641 => 196642)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2016-02-16 18:48:36 UTC (rev 196641)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2016-02-16 19:12:36 UTC (rev 196642)
@@ -870,6 +870,9 @@
         case StringCharCodeAt:
             compileStringCharCodeAt();
             break;
+        case StringFromCharCode:
+            compileStringFromCharCode();
+            break;
         case GetByOffset:
         case GetGetterSetterByOffset:
             compileGetByOffset();
@@ -4521,6 +4524,50 @@
         
         setInt32(m_out.phi(m_out.int32, char8Bit, char16Bit));
     }
+
+    void compileStringFromCharCode()
+    {
+        Edge childEdge = m_node->child1();
+        
+        if (childEdge.useKind() == UntypedUse) {
+            LValue result = vmCall(
+                m_out.int64, m_out.operation(operationStringFromCharCodeUntyped), m_callFrame,
+                lowJSValue(childEdge));
+            setJSValue(result);
+            return;
+        }
+
+        DFG_ASSERT(m_graph, m_node, childEdge.useKind() == Int32Use);
+
+        LValue value = lowInt32(childEdge);
+        
+        LBasicBlock smallIntCase = FTL_NEW_BLOCK(m_out, ("StringFromCharCode small int case"));
+        LBasicBlock slowCase = FTL_NEW_BLOCK(m_out, ("StringFromCharCode slow case"));
+        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("StringFromCharCode continuation"));
+
+        m_out.branch(
+            m_out.aboveOrEqual(value, m_out.constInt32(0xff)),
+            rarely(slowCase), usually(smallIntCase));
+
+        LBasicBlock lastNext = m_out.appendTo(smallIntCase, slowCase);
+
+        LValue smallStrings = m_out.constIntPtr(vm().smallStrings.singleCharacterStrings());
+        LValue fastResultValue = m_out.loadPtr(
+            m_out.baseIndex(m_heaps.singleCharacterStrings, smallStrings, m_out.zeroExtPtr(value)));
+        ValueFromBlock fastResult = m_out.anchor(fastResultValue);
+        m_out.jump(continuation);
+
+        m_out.appendTo(slowCase, continuation);
+
+        LValue slowResultValue = vmCall(
+            m_out.intPtr, m_out.operation(operationStringFromCharCode), m_callFrame, value);
+        ValueFromBlock slowResult = m_out.anchor(slowResultValue);
+        m_out.jump(continuation);
+
+        m_out.appendTo(continuation, lastNext);
+
+        setJSValue(m_out.phi(m_out.int64, fastResult, slowResult));
+    }
     
     void compileGetByOffset()
     {

Added: trunk/Source/_javascript_Core/tests/stress/string-from-char-code-slow.js (0 => 196642)


--- trunk/Source/_javascript_Core/tests/stress/string-from-char-code-slow.js	                        (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/string-from-char-code-slow.js	2016-02-16 19:12:36 UTC (rev 196642)
@@ -0,0 +1,10 @@
+var result = (function() {
+    var result;
+    for (var i = 0; i < 1000000; ++i)
+        result = String.fromCharCode(1000);
+    return result
+})();
+
+if (result != "Ϩ")
+    throw "Error: bad result: " + result;
+
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to