<!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>[205511] 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/205511">205511</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-06 14:54:11 -0700 (Tue, 06 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] Make ArithClz32 work with Cell arguments
https://bugs.webkit.org/show_bug.cgi?id=161369
Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-09-06
Reviewed by Geoffrey Garen.
JSTests:
* stress/arith-clz32-on-various-types.js: Added.
Source/JavaScriptCore:
ArithClz32 was already working with all primitive types
thanks to the magic of ValueToInt32.
This patch adds support for cell arguments through a function
call.
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* 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::compileArithClz32):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileArithClz32):</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="#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="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstressarithclz32onvarioustypesjs">trunk/JSTests/stress/arith-clz32-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 (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/JSTests/ChangeLog        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-09-06 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Make ArithClz32 work with Cell arguments
+ https://bugs.webkit.org/show_bug.cgi?id=161369
+
+ Reviewed by Geoffrey Garen.
+
+ * stress/arith-clz32-on-various-types.js: Added.
+
</ins><span class="cx"> 2016-09-06 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r205504.
</span></span></pre></div>
<a id="trunkJSTestsstressarithclz32onvarioustypesjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/arith-clz32-on-various-types.js (0 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/arith-clz32-on-various-types.js         (rev 0)
+++ trunk/JSTests/stress/arith-clz32-on-various-types.js        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -0,0 +1,232 @@
</span><ins>+"use strict";
+
+let validInputTestCases = [
+ // input as string, expected result as string.
+ ["undefined", "32"],
+ ["null", "32"],
+ ["0", "32"],
+ ["-0.", "32"],
+ ["4", "29"],
+ ["Math.PI", "30"],
+ ["Infinity", "32"],
+ ["-Infinity", "32"],
+ ["NaN", "32"],
+ ["\"WebKit\"", "32"],
+ ["\"4\"", "29"],
+ ["{ valueOf: () => { return 4; } }", "29"],
+];
+
+let validInputTypedTestCases = validInputTestCases.map((element) => { return [eval("(" + element[0] + ")"), eval(element[1])] });
+
+function isIdentical(result, expected)
+{
+ if (expected === expected) {
+ if (result !== expected)
+ return false;
+ if (!expected && 1 / expected === -Infinity && 1 / result !== -Infinity)
+ return false;
+
+ return true;
+ }
+ return result !== result;
+}
+
+
+// Test Math.clz32() without arguments.
+function opaqueClz32NoArgument() {
+ return Math.clz32();
+}
+noInline(opaqueClz32NoArgument);
+noOSRExitFuzzing(opaqueClz32NoArgument);
+
+function testNoArgument() {
+ for (let i = 0; i < 1e4; ++i) {
+ let output = opaqueClz32NoArgument();
+ if (output !== 32) {
+ throw "Failed opaqueClz32NoArgument";
+ }
+ }
+ if (numberOfDFGCompiles(opaqueClz32NoArgument) > 1)
+ throw "The call without arguments should never exit.";
+}
+testNoArgument();
+
+
+// Test Math.clz32() with a very polymorphic input. All test cases are seen at each iteration.
+function opaqueAllTypesClz32(argument) {
+ return Math.clz32(argument);
+}
+noInline(opaqueAllTypesClz32);
+noOSRExitFuzzing(opaqueAllTypesClz32);
+
+function testAllTypesCall() {
+ for (let i = 0; i < 1e3; ++i) {
+ for (let testCaseInput of validInputTypedTestCases) {
+ let output = opaqueAllTypesClz32(testCaseInput[0]);
+ if (!isIdentical(output, testCaseInput[1]))
+ throw "Failed testAllTypesCall for input " + testCaseInput[0] + " expected " + testCaseInput[1] + " got " + output;
+ }
+ }
+ if (numberOfDFGCompiles(opaqueAllTypesClz32) > 2)
+ throw "We should have detected clz32() was polymorphic and generated a generic version.";
+}
+testAllTypesCall();
+
+
+// Test Math.clz32() on a completely typed input. Every call see only one type.
+function testSingleTypeCall() {
+ for (let testCaseInput of validInputTestCases) {
+ eval(`
+ function opaqueClz32(argument) {
+ return Math.clz32(argument);
+ }
+ noInline(opaqueClz32);
+ noOSRExitFuzzing(opaqueClz32);
+
+ for (let i = 0; i < 1e4; ++i) {
+ if (!isIdentical(opaqueClz32(${testCaseInput[0]}), ${testCaseInput[1]})) {
+ throw "Failed testSingleTypeCall()";
+ }
+ }
+ if (numberOfDFGCompiles(opaqueClz32) > 1)
+ throw "We should have compiled a single clz32 for the expected type.";
+ `);
+ }
+}
+testSingleTypeCall();
+
+
+// Test Math.clz32() on constants
+function testConstant() {
+ for (let testCaseInput of validInputTestCases) {
+ eval(`
+ function opaqueClz32OnConstant() {
+ return Math.clz32(${testCaseInput[0]});
+ }
+ noInline(opaqueClz32OnConstant);
+ noOSRExitFuzzing(opaqueClz32OnConstant);
+
+ for (let i = 0; i < 1e4; ++i) {
+ if (!isIdentical(opaqueClz32OnConstant(), ${testCaseInput[1]})) {
+ throw "Failed testConstant()";
+ }
+ }
+ if (numberOfDFGCompiles(opaqueClz32OnConstant) > 1)
+ throw "We should have compiled a single clz32 for the expected type.";
+ `);
+ }
+}
+testConstant();
+
+
+// Verify we call valueOf() exactly once per call.
+function opaqueClz32ForSideEffects(argument) {
+ return Math.clz32(argument);
+}
+noInline(opaqueClz32ForSideEffects);
+noOSRExitFuzzing(opaqueClz32ForSideEffects);
+
+function testSideEffect() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let clz3216 = Math.clz32(16);
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueClz32ForSideEffects(testObject) !== clz3216)
+ throw "Incorrect result in testSideEffect()";
+ }
+ if (testObject.counter !== 1e4)
+ throw "Failed testSideEffect()";
+ if (numberOfDFGCompiles(opaqueClz32ForSideEffects) > 1)
+ throw "opaqueClz32ForSideEffects() is predictable, it should only be compiled once.";
+}
+testSideEffect();
+
+
+// Verify clz32() is not subject to CSE if the argument has side effects.
+function opaqueClz32ForCSE(argument) {
+ return Math.clz32(argument) + Math.clz32(argument) + Math.clz32(argument);
+}
+noInline(opaqueClz32ForCSE);
+noOSRExitFuzzing(opaqueClz32ForCSE);
+
+function testCSE() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let clz3216 = Math.clz32(16);
+ let threeClz3216 = clz3216 + clz3216 + clz3216;
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueClz32ForCSE(testObject) !== threeClz3216)
+ throw "Incorrect result in testCSE()";
+ }
+ if (testObject.counter !== 3e4)
+ throw "Failed testCSE()";
+ if (numberOfDFGCompiles(opaqueClz32ForCSE) > 1)
+ throw "opaqueClz32ForCSE() is predictable, it should only be compiled once.";
+}
+testCSE();
+
+
+// Verify clz32() is not subject to DCE if the argument has side effects.
+function opaqueClz32ForDCE(argument) {
+ Math.clz32(argument);
+}
+noInline(opaqueClz32ForDCE);
+noOSRExitFuzzing(opaqueClz32ForDCE);
+
+function testDCE() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ for (let i = 0; i < 1e4; ++i) {
+ opaqueClz32ForDCE(testObject);
+ }
+ if (testObject.counter !== 1e4)
+ throw "Failed testDCE()";
+ if (numberOfDFGCompiles(opaqueClz32ForDCE) > 1)
+ throw "opaqueClz32ForDCE() is predictable, it should only be compiled once.";
+}
+testDCE();
+
+
+// Test exceptions in the argument.
+function testException() {
+ let counter = 0;
+ function opaqueClz32WithException(argument) {
+ let result = Math.clz32(argument);
+ ++counter;
+ return result;
+ }
+ noInline(opaqueClz32WithException);
+
+ let testObject = { valueOf: () => { return 64; } };
+ let clz3264 = Math.clz32(64);
+
+ // Warm up without exception.
+ for (let i = 0; i < 1e3; ++i) {
+ if (opaqueClz32WithException(testObject) !== clz3264)
+ throw "Incorrect result in opaqueClz32WithException()";
+ }
+
+ let testThrowObject = { valueOf: () => { throw testObject; return 64; } };
+
+ for (let i = 0; i < 1e2; ++i) {
+ try {
+ if (opaqueClz32WithException(testThrowObject) !== 8)
+ throw "This code should not be reached!!";
+ } catch (e) {
+ if (e !== testObject) {
+ throw "Wrong object thrown from opaqueClz32WithException."
+ }
+ }
+ }
+
+ if (counter !== 1e3) {
+ throw "Invalid count in testException()";
+ }
+}
+testException();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-09-06 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Make ArithClz32 work with Cell arguments
+ https://bugs.webkit.org/show_bug.cgi?id=161369
+
+ Reviewed by Geoffrey Garen.
+
+ ArithClz32 was already working with all primitive types
+ thanks to the magic of ValueToInt32.
+ This patch adds support for cell arguments through a function
+ call.
+
+ * dfg/DFGAbstractInterpreterInlines.h:
+ (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+ * 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::compileArithClz32):
+ * dfg/DFGSpeculativeJIT.h:
+ (JSC::DFG::SpeculativeJIT::callOperation):
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::compileArithClz32):
+
</ins><span class="cx"> 2016-09-06 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Gardening: change to use old header guard to appease Win EWS.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -547,8 +547,8 @@
</span><span class="cx">
</span><span class="cx"> case ArithClz32: {
</span><span class="cx"> JSValue operand = forNode(node->child1()).value();
</span><del>- if (operand && operand.isNumber()) {
- uint32_t value = toUInt32(operand.asNumber());
</del><ins>+ if (Optional<double> number = operand.toNumberFromPrimitive()) {
+ uint32_t value = toUInt32(*number);
</ins><span class="cx"> setConstant(node, jsNumber(clz32(value)));
</span><span class="cx"> break;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGClobberizeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGClobberize.h (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -149,7 +149,6 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> case ArithIMul:
</span><del>- case ArithClz32:
</del><span class="cx"> case ArithMin:
</span><span class="cx"> case ArithMax:
</span><span class="cx"> case ArithPow:
</span><span class="lines">@@ -206,6 +205,15 @@
</span><span class="cx"> }
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ case ArithClz32:
+ if (node->child1().useKind() == Int32Use || node->child1().useKind() == KnownInt32Use)
+ def(PureValue(node));
+ else {
+ read(World);
+ write(Heap);
+ }
+ return;
+
</ins><span class="cx"> case BitAnd:
</span><span class="cx"> case BitOr:
</span><span class="cx"> case BitXor:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -126,8 +126,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> case ArithClz32: {
</span><del>- fixIntConvertingEdge(node->child1());
- node->setArithMode(Arith::Unchecked);
</del><ins>+ if (node->child1()->shouldSpeculateNotCell()) {
+ fixIntConvertingEdge(node->child1());
+ node->clearFlags(NodeMustGenerate);
+ } else
+ fixEdge<UntypedUse>(node->child1());
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGNodeTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGNodeType.h (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -142,7 +142,7 @@
</span><span class="cx"> /* this is only true if we do the overflow check - hence the need to keep it alive. More */\
</span><span class="cx"> /* generally, we need to keep alive any operation whose checks cause filtration in AI. */\
</span><span class="cx"> macro(ArithAdd, NodeResultNumber | NodeMustGenerate) \
</span><del>- macro(ArithClz32, NodeResultInt32) \
</del><ins>+ macro(ArithClz32, NodeResultInt32 | NodeMustGenerate) \
</ins><span class="cx"> macro(ArithSub, NodeResultNumber | NodeMustGenerate) \
</span><span class="cx"> macro(ArithNegate, NodeResultNumber | NodeMustGenerate) \
</span><span class="cx"> macro(ArithMul, NodeResultNumber | NodeMustGenerate) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -332,10 +332,22 @@
</span><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> if (UNLIKELY(vm->exception()))
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return PNaN;
</ins><span class="cx"> return fabs(a);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+int32_t JIT_OPERATION operationArithClz32(ExecState* exec, EncodedJSValue encodedOp1)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ JSValue op1 = JSValue::decode(encodedOp1);
+ uint32_t value = op1.toUInt32(exec);
+ if (UNLIKELY(vm->exception()))
+ return 0;
+ return clz32(value);
+}
+
</ins><span class="cx"> double JIT_OPERATION operationArithCos(ExecState* exec, EncodedJSValue encodedOp1)
</span><span class="cx"> {
</span><span class="cx"> VM* vm = &exec->vm();
</span><span class="lines">@@ -356,7 +368,7 @@
</span><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> if (UNLIKELY(vm->exception()))
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return PNaN;
</ins><span class="cx"> return static_cast<float>(a);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -368,7 +380,7 @@
</span><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> if (UNLIKELY(vm->exception()))
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return PNaN;
</ins><span class="cx"> return log(a);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -380,7 +392,7 @@
</span><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> if (UNLIKELY(vm->exception()))
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return PNaN;
</ins><span class="cx"> return sin(a);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -392,7 +404,7 @@
</span><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> if (UNLIKELY(vm->exception()))
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return PNaN;
</ins><span class="cx"> return sqrt(a);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.h (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-09-06 21:54:11 UTC (rev 205511)
</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 operationArithAbs(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><ins>+int32_t JIT_OPERATION operationArithClz32(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</ins><span class="cx"> double JIT_OPERATION operationArithCos(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><span class="cx"> double JIT_OPERATION operationArithFRound(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><span class="cx"> double JIT_OPERATION operationArithLog(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -3932,12 +3932,22 @@
</span><span class="cx">
</span><span class="cx"> void SpeculativeJIT::compileArithClz32(Node* node)
</span><span class="cx"> {
</span><del>- ASSERT_WITH_MESSAGE(node->child1().useKind() == Int32Use || node->child1().useKind() == KnownInt32Use, "The Fixup phase should have enforced a Int32 operand.");
- SpeculateInt32Operand value(this, node->child1());
- GPRTemporary result(this, Reuse, value);
- GPRReg valueReg = value.gpr();
</del><ins>+ if (node->child1().useKind() == Int32Use || node->child1().useKind() == KnownInt32Use) {
+ SpeculateInt32Operand value(this, node->child1());
+ GPRTemporary result(this, Reuse, value);
+ GPRReg valueReg = value.gpr();
+ GPRReg resultReg = result.gpr();
+ m_jit.countLeadingZeros32(valueReg, resultReg);
+ int32Result(resultReg, node);
+ return;
+ }
+ JSValueOperand op1(this, node->child1());
+ JSValueRegs op1Regs = op1.jsValueRegs();
+ GPRTemporary result(this);
</ins><span class="cx"> GPRReg resultReg = result.gpr();
</span><del>- m_jit.countLeadingZeros32(valueReg, resultReg);
</del><ins>+ flushRegisters();
+ callOperation(operationArithClz32, resultReg, op1Regs);
+ m_jit.exceptionCheck();
</ins><span class="cx"> int32Result(resultReg, node);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -1691,6 +1691,12 @@
</span><span class="cx"> return appendCall(operation);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ JITCompiler::Call callOperation(Z_JITOperation_EJ operation, GPRReg result, JSValueRegs arg1)
+ {
+ m_jit.setupArgumentsWithExecState(arg1.payloadGPR());
+ return appendCallSetResult(operation, result);
+ }
+
</ins><span class="cx"> JITCompiler::Call callOperation(Z_JITOperation_EJZZ operation, GPRReg result, GPRReg arg1, unsigned arg2, unsigned arg3)
</span><span class="cx"> {
</span><span class="cx"> m_jit.setupArgumentsWithExecState(arg1, TrustedImm32(arg2), TrustedImm32(arg3));
</span><span class="lines">@@ -2132,7 +2138,11 @@
</span><span class="cx"> m_jit.setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), arg2, EABI_32BIT_DUMMY_ARG arg3.payloadGPR(), arg3.tagGPR());
</span><span class="cx"> return appendCallSetResult(operation, result);
</span><span class="cx"> }
</span><del>-
</del><ins>+ JITCompiler::Call callOperation(Z_JITOperation_EJ operation, GPRReg result, JSValueRegs arg1)
+ {
+ m_jit.setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR());
+ return appendCallSetResult(operation, result);
+ }
</ins><span class="cx"> JITCompiler::Call callOperation(Z_JITOperation_EJZZ operation, GPRReg result, JSValueRegs arg1, unsigned arg2, unsigned arg3)
</span><span class="cx"> {
</span><span class="cx"> m_jit.setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), TrustedImm32(arg2), TrustedImm32(arg3));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (205510 => 205511)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-06 21:53:07 UTC (rev 205510)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-06 21:54:11 UTC (rev 205511)
</span><span class="lines">@@ -1726,8 +1726,15 @@
</span><span class="cx">
</span><span class="cx"> void compileArithClz32()
</span><span class="cx"> {
</span><del>- LValue operand = lowInt32(m_node->child1());
- setInt32(m_out.ctlz32(operand));
</del><ins>+ if (m_node->child1().useKind() == Int32Use || m_node->child1().useKind() == KnownInt32Use) {
+ LValue operand = lowInt32(m_node->child1());
+ setInt32(m_out.ctlz32(operand));
+ return;
+ }
+ DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
+ LValue argument = lowJSValue(m_node->child1());
+ LValue result = vmCall(Int32, m_out.operation(operationArithClz32), m_callFrame, argument);
+ setInt32(result);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void compileArithMul()
</span></span></pre>
</div>
</div>
</body>
</html>