<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204947] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204947">204947</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-24 18:21:43 -0700 (Wed, 24 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Make FRound work with any type
https://bugs.webkit.org/show_bug.cgi?id=161129

Reviewed by Geoffrey Garen.

JSTests:

* stress/arith-fround-on-various-types.js: Added.

Source/JavaScriptCore:

Math.fround() does nothing with arguments past the first one
(https://tc39.github.io/ecma262/#sec-math.fround).
We can unify ArithFRound with the other single-input intrinsics.

Everything else is same old: if the input type is not a number,
be pessimistic about everything and do a C call.

* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGNodeType.h:
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithFRound):
* dfg/DFGSpeculativeJIT.h:
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileArithFRound):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh">trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp">trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGClobberizeh">trunk/Source/JavaScriptCore/dfg/DFGClobberize.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGFixupPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGNodeTypeh">trunk/Source/JavaScriptCore/dfg/DFGNodeType.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGOperationscpp">trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGOperationsh">trunk/Source/JavaScriptCore/dfg/DFGOperations.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstressarithfroundonvarioustypesjs">trunk/JSTests/stress/arith-fround-on-various-types.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/JSTests/ChangeLog        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-08-24  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        [JSC] Make FRound work with any type
+        https://bugs.webkit.org/show_bug.cgi?id=161129
+
+        Reviewed by Geoffrey Garen.
+
+        * stress/arith-fround-on-various-types.js: Added.
+
</ins><span class="cx"> 2016-08-24  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, roll out r204901, r204897, r204866, r204856, r204854.
</span></span></pre></div>
<a id="trunkJSTestsstressarithfroundonvarioustypesjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/arith-fround-on-various-types.js (0 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/arith-fround-on-various-types.js                                (rev 0)
+++ trunk/JSTests/stress/arith-fround-on-various-types.js        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -0,0 +1,190 @@
</span><ins>+&quot;use strict&quot;;
+
+let froundOfPi = Math.fround(Math.PI);
+let froundOfE = Math.fround(Math.E);
+
+let validInputTestCases = [
+    // input as string, expected result as string.
+    [&quot;undefined&quot;, &quot;NaN&quot;],
+    [&quot;null&quot;, &quot;0&quot;],
+    [&quot;0&quot;, &quot;0&quot;],
+    [&quot;-0.&quot;, &quot;-0&quot;],
+    [&quot;1.&quot;, &quot;1&quot;],
+    [&quot;Math.PI&quot;, &quot;&quot; + froundOfPi],
+    [&quot;Math.E&quot;, &quot;&quot; + froundOfE],
+    [&quot;Infinity&quot;, &quot;Infinity&quot;],
+    [&quot;-Infinity&quot;, &quot;-Infinity&quot;],
+    [&quot;NaN&quot;, &quot;NaN&quot;],
+    [&quot;\&quot;WebKit\&quot;&quot;, &quot;NaN&quot;],
+    [&quot;\&quot;&quot; + Math.PI + &quot;\&quot;&quot;, &quot;&quot; + froundOfPi],
+    [&quot;{ valueOf: () =&gt; { return Math.E; } }&quot;, &quot;&quot; + froundOfE],
+    [&quot;{ valueOf: () =&gt; { return 1; } }&quot;, &quot;1&quot;],
+    [&quot;{ valueOf: () =&gt; { return Math.PI; } }&quot;, &quot;&quot; + froundOfPi],
+];
+
+let validInputTypedTestCases = validInputTestCases.map((element) =&gt; { return [eval(&quot;(&quot; + element[0] + &quot;)&quot;), eval(element[1])] });
+
+function isIdentical(result, expected)
+{
+    if (expected === expected) {
+        if (result !== expected)
+            return false;
+        if (!expected &amp;&amp; 1 / expected === -Infinity &amp;&amp; 1 / result !== -Infinity)
+            return false;
+
+        return true;
+    }
+    return result !== result;
+}
+
+// Test Math.fround() without arguments.
+function opaqueFRoundNoArgument() {
+    return Math.fround();
+}
+noInline(opaqueFRoundNoArgument);
+noOSRExitFuzzing(opaqueFRoundNoArgument);
+
+function testNoArgument() {
+    for (let i = 0; i &lt; 1e4; ++i) {
+        let output = opaqueFRoundNoArgument();
+        if (output === output) {
+            throw &quot;Failed opaqueFRoundNoArgument&quot;;
+        }
+    }
+    if (numberOfDFGCompiles(opaqueFRoundNoArgument) &gt; 1)
+        throw &quot;The call without arguments should never exit.&quot;;
+}
+testNoArgument();
+
+// Test Math.fround() with a very polymorphic input. All test cases are seen at each iteration.
+function opaqueAllTypesFround(argument) {
+    return Math.fround(argument);
+}
+noInline(opaqueAllTypesFround);
+noOSRExitFuzzing(opaqueAllTypesFround);
+
+function testAllTypesCall() {
+    for (let i = 0; i &lt; 1e3; ++i) {
+        for (let testCaseInput of validInputTypedTestCases) {
+            let output = opaqueAllTypesFround(testCaseInput[0]);
+            if (!isIdentical(output, testCaseInput[1]))
+                throw &quot;Failed testAllTypesCall for input &quot; + testCaseInput[0] + &quot; expected &quot; + testCaseInput[1] + &quot; got &quot; + output;
+        }
+    }
+    if (numberOfDFGCompiles(opaqueAllTypesFround) &gt; 2)
+        throw &quot;We should have detected fround() was polymorphic and generated a generic version.&quot;;
+}
+testAllTypesCall();
+
+
+// Test Math.fround() on a completely typed input. Every call see only one type.
+function testSingleTypeCall() {
+    for (let testCaseInput of validInputTestCases) {
+        eval(`
+            function opaqueFround(argument) {
+                return Math.fround(argument);
+            }
+            noInline(opaqueFround);
+            noOSRExitFuzzing(opaqueFround);
+
+            for (let i = 0; i &lt; 1e4; ++i) {
+                if (!isIdentical(opaqueFround(${testCaseInput[0]}), ${testCaseInput[1]})) {
+                    throw &quot;Failed testSingleTypeCall()&quot;;
+                }
+            }
+            if (numberOfDFGCompiles(opaqueFround) &gt; 1)
+                throw &quot;We should have compiled a single fround for the expected type.&quot;;
+        `);
+    }
+}
+testSingleTypeCall();
+
+
+// Verify we call valueOf() exactly once per call.
+function opaqueFroundForSideEffects(argument) {
+    return Math.fround(argument);
+}
+noInline(opaqueFroundForSideEffects);
+noOSRExitFuzzing(opaqueFroundForSideEffects);
+
+function testSideEffect() {
+    let testObject = {
+        counter: 0,
+        valueOf: function() { ++this.counter; return 16; }
+    };
+    let fround16 = Math.fround(16);
+    for (let i = 0; i &lt; 1e4; ++i) {
+        if (opaqueFroundForSideEffects(testObject) !== fround16)
+            throw &quot;Incorrect result in testSideEffect()&quot;;
+    }
+    if (testObject.counter !== 1e4)
+        throw &quot;Failed testSideEffect()&quot;;
+    if (numberOfDFGCompiles(opaqueFroundForSideEffects) &gt; 1)
+        throw &quot;opaqueFroundForSideEffects() is predictable, it should only be compiled once.&quot;;
+}
+testSideEffect();
+
+
+// Verify SQRT is not subject to CSE if the argument has side effects.
+function opaqueFroundForCSE(argument) {
+    return Math.fround(argument) + Math.fround(argument) + Math.fround(argument);
+}
+noInline(opaqueFroundForCSE);
+noOSRExitFuzzing(opaqueFroundForCSE);
+
+function testCSE() {
+    let testObject = {
+        counter: 0,
+        valueOf: function() { ++this.counter; return 16; }
+    };
+    let fround16 = Math.fround(16);
+    let threeFround16 = fround16 + fround16 + fround16;
+    for (let i = 0; i &lt; 1e4; ++i) {
+        if (opaqueFroundForCSE(testObject) !== threeFround16)
+            throw &quot;Incorrect result in testCSE()&quot;;
+    }
+    if (testObject.counter !== 3e4)
+        throw &quot;Failed testCSE()&quot;;
+    if (numberOfDFGCompiles(opaqueFroundForCSE) &gt; 1)
+        throw &quot;opaqueFroundForCSE() is predictable, it should only be compiled once.&quot;;
+}
+testCSE();
+
+
+// Test exceptions in the argument.
+function testException() {
+    let counter = 0;
+    function opaqueFroundWithException(argument) {
+        let result = Math.fround(argument);
+        ++counter;
+        return result;
+    }
+    noInline(opaqueFroundWithException);
+
+    let testObject = { valueOf: () =&gt; {  return 64; } };
+    let fround64 = Math.fround(64);
+
+    // Warm up without exception.
+    for (let i = 0; i &lt; 1e3; ++i) {
+        if (opaqueFroundWithException(testObject) !== fround64)
+            throw &quot;Incorrect result in opaqueFroundWithException()&quot;;
+    }
+
+    let testThrowObject = { valueOf: () =&gt; { throw testObject; return 64; } };
+
+    for (let i = 0; i &lt; 1e2; ++i) {
+        try {
+            if (opaqueFroundWithException(testThrowObject) !== 8)
+                throw &quot;This code should not be reached!!&quot;;
+        } catch (e) {
+            if (e !== testObject) {
+                throw &quot;Wrong object thrown from opaqueFroundWithException.&quot;
+            }
+        }
+    }
+
+    if (counter !== 1e3) {
+        throw &quot;Invalid count in testException()&quot;;
+    }
+}
+testException();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-08-24  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        [JSC] Make FRound work with any type
+        https://bugs.webkit.org/show_bug.cgi?id=161129
+
+        Reviewed by Geoffrey Garen.
+
+        Math.fround() does nothing with arguments past the first one
+        (https://tc39.github.io/ecma262/#sec-math.fround).
+        We can unify ArithFRound with the other single-input intrinsics.
+
+        Everything else is same old: if the input type is not a number,
+        be pessimistic about everything and do a C call.
+
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleIntrinsicCall):
+        * dfg/DFGClobberize.h:
+        (JSC::DFG::clobberize):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        * dfg/DFGNodeType.h:
+        * dfg/DFGOperations.cpp:
+        * dfg/DFGOperations.h:
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileArithFRound):
+        * dfg/DFGSpeculativeJIT.h:
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileArithFRound):
+
</ins><span class="cx"> 2016-08-24  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Shrink DFG::OSRExit a bit.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -974,7 +974,10 @@
</span><span class="cx">             setConstant(node, jsDoubleNumber(static_cast&lt;float&gt;(child.asNumber())));
</span><span class="cx">             break;
</span><span class="cx">         }
</span><del>-        forNode(node).setType(typeOfDoubleRounding(forNode(node-&gt;child1()).m_type));
</del><ins>+        SpeculatedType froundType = SpecFullNumber;
+        if (node-&gt;child1().useKind() == DoubleRepUse)
+            froundType = typeOfDoubleUnaryOp(forNode(node-&gt;child1()).m_type);
+        forNode(node).setType(froundType);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -2140,41 +2140,40 @@
</span><span class="cx">     case MaxIntrinsic:
</span><span class="cx">         return handleMinMax(resultOperand, ArithMax, registerOffset, argumentCountIncludingThis, insertChecks);
</span><span class="cx"> 
</span><del>-    case SqrtIntrinsic:
</del><span class="cx">     case CosIntrinsic:
</span><ins>+    case FRoundIntrinsic:
+    case LogIntrinsic:
</ins><span class="cx">     case SinIntrinsic:
</span><del>-    case LogIntrinsic: {
</del><ins>+    case SqrtIntrinsic: {
</ins><span class="cx">         if (argumentCountIncludingThis == 1) {
</span><span class="cx">             insertChecks();
</span><span class="cx">             set(VirtualRegister(resultOperand), addToGraph(JSConstant, OpInfo(m_constantNaN)));
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
+        NodeType nodeType = Unreachable;
</ins><span class="cx">         switch (intrinsic) {
</span><del>-        case SqrtIntrinsic:
-            insertChecks();
-            set(VirtualRegister(resultOperand), addToGraph(ArithSqrt, get(virtualRegisterForArgument(1, registerOffset))));
-            return true;
-            
</del><span class="cx">         case CosIntrinsic:
</span><del>-            insertChecks();
-            set(VirtualRegister(resultOperand), addToGraph(ArithCos, get(virtualRegisterForArgument(1, registerOffset))));
-            return true;
-            
</del><ins>+            nodeType = ArithCos;
+            break;
+        case FRoundIntrinsic:
+            nodeType = ArithFRound;
+            break;
+        case LogIntrinsic:
+            nodeType = ArithLog;
+            break;
</ins><span class="cx">         case SinIntrinsic:
</span><del>-            insertChecks();
-            set(VirtualRegister(resultOperand), addToGraph(ArithSin, get(virtualRegisterForArgument(1, registerOffset))));
-            return true;
-
-        case LogIntrinsic:
-            insertChecks();
-            set(VirtualRegister(resultOperand), addToGraph(ArithLog, get(virtualRegisterForArgument(1, registerOffset))));
-            return true;
-            
</del><ins>+            nodeType = ArithSin;
+            break;
+        case SqrtIntrinsic:
+            nodeType = ArithSqrt;
+            break;
</ins><span class="cx">         default:
</span><span class="cx">             RELEASE_ASSERT_NOT_REACHED();
</span><del>-            return false;
</del><span class="cx">         }
</span><ins>+        insertChecks();
+        set(VirtualRegister(resultOperand), addToGraph(nodeType, get(virtualRegisterForArgument(1, registerOffset))));
+        return true;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     case PowIntrinsic: {
</span><span class="lines">@@ -2476,15 +2475,6 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">         
</span><del>-    case FRoundIntrinsic: {
-        if (argumentCountIncludingThis != 2)
-            return false;
-        insertChecks();
-        VirtualRegister operand = virtualRegisterForArgument(1, registerOffset);
-        set(VirtualRegister(resultOperand), addToGraph(ArithFRound, get(operand)));
-        return true;
-    }
-        
</del><span class="cx">     case DFGTrueIntrinsic: {
</span><span class="cx">         insertChecks();
</span><span class="cx">         set(VirtualRegister(resultOperand), jsConstant(jsBoolean(true)));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGClobberizeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGClobberize.h (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -154,7 +154,6 @@
</span><span class="cx">     case ArithMin:
</span><span class="cx">     case ArithMax:
</span><span class="cx">     case ArithPow:
</span><del>-    case ArithFRound:
</del><span class="cx">     case GetScope:
</span><span class="cx">     case SkipScope:
</span><span class="cx">     case GetGlobalObject:
</span><span class="lines">@@ -187,6 +186,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     case ArithCos:
</span><ins>+    case ArithFRound:
</ins><span class="cx">     case ArithLog:
</span><span class="cx">     case ArithSin:
</span><span class="cx">     case ArithSqrt:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -387,6 +387,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         case ArithCos:
</span><ins>+        case ArithFRound:
</ins><span class="cx">         case ArithLog:
</span><span class="cx">         case ArithSin:
</span><span class="cx">         case ArithSqrt: {
</span><span class="lines">@@ -397,11 +398,6 @@
</span><span class="cx">                 fixEdge&lt;UntypedUse&gt;(child1);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><del>-        case ArithFRound: {
-            fixDoubleOrBooleanEdge(node-&gt;child1());
-            node-&gt;setResult(NodeResultDouble);
-            break;
-        }
</del><span class="cx">             
</span><span class="cx">         case LogicalNot: {
</span><span class="cx">             if (node-&gt;child1()-&gt;shouldSpeculateBoolean()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGNodeTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGNodeType.h (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">     macro(ArithAbs, NodeResultNumber | NodeMustGenerate) \
</span><span class="cx">     macro(ArithMin, NodeResultNumber) \
</span><span class="cx">     macro(ArithMax, NodeResultNumber) \
</span><del>-    macro(ArithFRound, NodeResultNumber) \
</del><ins>+    macro(ArithFRound, NodeResultDouble) \
</ins><span class="cx">     macro(ArithPow, NodeResultDouble) \
</span><span class="cx">     macro(ArithRandom, NodeResultDouble | NodeMustGenerate) \
</span><span class="cx">     macro(ArithRound, NodeResultNumber) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -334,6 +334,18 @@
</span><span class="cx">     return cos(a);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+double JIT_OPERATION operationArithFRound(ExecState* exec, EncodedJSValue encodedOp1)
+{
+    VM* vm = &amp;exec-&gt;vm();
+    NativeCallFrameTracer tracer(vm, exec);
+
+    JSValue op1 = JSValue::decode(encodedOp1);
+    double a = op1.toNumber(exec);
+    if (UNLIKELY(vm-&gt;exception()))
+        return JSValue::encode(JSValue());
+    return static_cast&lt;float&gt;(a);
+}
+
</ins><span class="cx"> double JIT_OPERATION operationArithLog(ExecState* exec, EncodedJSValue encodedOp1)
</span><span class="cx"> {
</span><span class="cx">     VM* vm = &amp;exec-&gt;vm();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.h (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueAddNotNumber(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueDiv(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
</span><span class="cx"> double JIT_OPERATION operationArithCos(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><ins>+double JIT_OPERATION operationArithFRound(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</ins><span class="cx"> double JIT_OPERATION operationArithLog(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><span class="cx"> double JIT_OPERATION operationArithSin(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><span class="cx"> double JIT_OPERATION operationArithSqrt(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -4538,6 +4538,26 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::compileArithFRound(Node* node)
+{
+    if (node-&gt;child1().useKind() == DoubleRepUse) {
+        SpeculateDoubleOperand op1(this, node-&gt;child1());
+        FPRTemporary result(this, op1);
+        m_jit.convertDoubleToFloat(op1.fpr(), result.fpr());
+        m_jit.convertFloatToDouble(result.fpr(), result.fpr());
+        doubleResult(result.fpr(), node);
+        return;
+    }
+
+    JSValueOperand op1(this, node-&gt;child1());
+    JSValueRegs op1Regs = op1.jsValueRegs();
+    flushRegisters();
+    FPRResult result(this);
+    callOperation(operationArithFRound, result.fpr(), op1Regs);
+    m_jit.exceptionCheck();
+    doubleResult(result.fpr(), node);
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileArithMod(Node* node)
</span><span class="cx"> {
</span><span class="cx">     switch (node-&gt;binaryUseKind()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -2474,6 +2474,7 @@
</span><span class="cx">     void compileArithNegate(Node*);
</span><span class="cx">     void compileArithMul(Node*);
</span><span class="cx">     void compileArithDiv(Node*);
</span><ins>+    void compileArithFRound(Node*);
</ins><span class="cx">     void compileArithMod(Node*);
</span><span class="cx">     void compileArithPow(Node*);
</span><span class="cx">     void compileArithRounding(Node*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -2367,16 +2367,9 @@
</span><span class="cx">         compileArithSqrt(node);
</span><span class="cx">         break;
</span><span class="cx"> 
</span><del>-    case ArithFRound: {
-        SpeculateDoubleOperand op1(this, node-&gt;child1());
-        FPRTemporary result(this, op1);
-        
-        m_jit.convertDoubleToFloat(op1.fpr(), result.fpr());
-        m_jit.convertFloatToDouble(result.fpr(), result.fpr());
-        
-        doubleResult(result.fpr(), node);
</del><ins>+    case ArithFRound:
+        compileArithFRound(node);
</ins><span class="cx">         break;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     case ArithRandom:
</span><span class="cx">         compileArithRandom(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -2491,16 +2491,9 @@
</span><span class="cx">         compileArithSqrt(node);
</span><span class="cx">         break;
</span><span class="cx"> 
</span><del>-    case ArithFRound: {
-        SpeculateDoubleOperand op1(this, node-&gt;child1());
-        FPRTemporary result(this, op1);
-        
-        m_jit.convertDoubleToFloat(op1.fpr(), result.fpr());
-        m_jit.convertFloatToDouble(result.fpr(), result.fpr());
-        
-        doubleResult(result.fpr(), node);
</del><ins>+    case ArithFRound:
+        compileArithFRound(node);
</ins><span class="cx">         break;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     case ArithRandom:
</span><span class="cx">         compileArithRandom(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (204946 => 204947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-25 00:46:43 UTC (rev 204946)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-25 01:21:43 UTC (rev 204947)
</span><span class="lines">@@ -2315,7 +2315,13 @@
</span><span class="cx">     
</span><span class="cx">     void compileArithFRound()
</span><span class="cx">     {
</span><del>-        setDouble(m_out.fround(lowDouble(m_node-&gt;child1())));
</del><ins>+        if (m_node-&gt;child1().useKind() == DoubleRepUse) {
+            setDouble(m_out.fround(lowDouble(m_node-&gt;child1())));
+            return;
+        }
+        LValue argument = lowJSValue(m_node-&gt;child1());
+        LValue result = vmCall(Double, m_out.operation(operationArithFRound), m_callFrame, argument);
+        setDouble(result);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void compileArithNegate()
</span></span></pre>
</div>
</div>

</body>
</html>