<!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>[204849] 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/204849">204849</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-23 12:09:50 -0700 (Tue, 23 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] Make Math.cos() and Math.sin() work with any argument type
https://bugs.webkit.org/show_bug.cgi?id=161069
Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-08-23
Reviewed by Geoffrey Garen.
JSTests:
* stress/arith-cos-on-various-types.js: Added.
* stress/arith-sin-on-various-types.js: Added.
Source/JavaScriptCore:
Same as the ArithSqrt patch: add a generic path if the argument
is not a number.
* 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::compileArithCos):
(JSC::DFG::SpeculativeJIT::compileArithSin):
* 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::compileArithSin):
(JSC::FTL::DFG::LowerDFGToB3::compileArithCos):</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="#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="#trunkJSTestsstressarithcosonvarioustypesjs">trunk/JSTests/stress/arith-cos-on-various-types.js</a></li>
<li><a href="#trunkJSTestsstressarithsinonvarioustypesjs">trunk/JSTests/stress/arith-sin-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 (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/JSTests/ChangeLog        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-08-23 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Make Math.cos() and Math.sin() work with any argument type
+ https://bugs.webkit.org/show_bug.cgi?id=161069
+
+ Reviewed by Geoffrey Garen.
+
+ * stress/arith-cos-on-various-types.js: Added.
+ * stress/arith-sin-on-various-types.js: Added.
+
</ins><span class="cx"> 2016-08-23 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> [ES6] Module namespace object's Symbol.iterator method should only accept module namespace objects
</span></span></pre></div>
<a id="trunkJSTestsstressarithcosonvarioustypesjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/arith-cos-on-various-types.js (0 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/arith-cos-on-various-types.js         (rev 0)
+++ trunk/JSTests/stress/arith-cos-on-various-types.js        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -0,0 +1,168 @@
</span><ins>+"use strict";
+
+let cosOfFour = Math.cos(4);
+
+let validInputTestCases = [
+ // input as string, expected result as string.
+ ["undefined", "NaN"],
+ ["null", "1"],
+ ["0", "1"],
+ ["-0.", "1"],
+ ["4", "" + cosOfFour],
+ ["Math.PI", "-1"],
+ ["Infinity", "NaN"],
+ ["-Infinity", "NaN"],
+ ["NaN", "NaN"],
+ ["\"WebKit\"", "NaN"],
+ ["\"4\"", "" + cosOfFour],
+ ["{ valueOf: () => { return 4; } }", "" + cosOfFour],
+];
+
+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.cos() with a very polymorphic input. All test cases are seen at each iteration.
+function opaqueAllTypesCos(argument) {
+ return Math.cos(argument);
+}
+noInline(opaqueAllTypesCos);
+noOSRExitFuzzing(opaqueAllTypesCos);
+
+function testAllTypesCall() {
+ for (let i = 0; i < 1e3; ++i) {
+ for (let testCaseInput of validInputTypedTestCases) {
+ let output = opaqueAllTypesCos(testCaseInput[0]);
+ if (!isIdentical(output, testCaseInput[1]))
+ throw "Failed testAllTypesCall for input " + testCaseInput[0] + " expected " + testCaseInput[1] + " got " + output;
+ }
+ }
+ if (numberOfDFGCompiles(opaqueAllTypesCos) > 2)
+ throw "We should have detected cos() was polymorphic and generated a generic version.";
+}
+testAllTypesCall();
+
+
+// Test Math.cos() on a completely typed input. Every call see only one type.
+function testSingleTypeCall() {
+ for (let testCaseInput of validInputTestCases) {
+ eval(`
+ function opaqueCos(argument) {
+ return Math.cos(argument);
+ }
+ noInline(opaqueCos);
+ noOSRExitFuzzing(opaqueCos);
+
+ for (let i = 0; i < 1e4; ++i) {
+ if (!isIdentical(opaqueCos(${testCaseInput[0]}), ${testCaseInput[1]})) {
+ throw "Failed testSingleTypeCall()";
+ }
+ }
+ if (numberOfDFGCompiles(opaqueCos) > 1)
+ throw "We should have compiled a single cos for the expected type.";
+ `);
+ }
+}
+testSingleTypeCall();
+
+
+// Verify we call valueOf() exactly once per call.
+function opaqueCosForSideEffects(argument) {
+ return Math.cos(argument);
+}
+noInline(opaqueCosForSideEffects);
+noOSRExitFuzzing(opaqueCosForSideEffects);
+
+function testSideEffect() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let cos16 = Math.cos(16);
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueCosForSideEffects(testObject) !== cos16)
+ throw "Incorrect result in testSideEffect()";
+ }
+ if (testObject.counter !== 1e4)
+ throw "Failed testSideEffect()";
+ if (numberOfDFGCompiles(opaqueCosForSideEffects) > 1)
+ throw "opaqueCosForSideEffects() is predictable, it should only be compiled once.";
+}
+testSideEffect();
+
+
+// Verify SQRT is not subject to CSE if the argument has side effects.
+function opaqueCosForCSE(argument) {
+ return Math.cos(argument) + Math.cos(argument) + Math.cos(argument);
+}
+noInline(opaqueCosForCSE);
+noOSRExitFuzzing(opaqueCosForCSE);
+
+function testCSE() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let cos16 = Math.cos(16);
+ let threeCos16 = cos16 + cos16 + cos16;
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueCosForCSE(testObject) !== threeCos16)
+ throw "Incorrect result in testCSE()";
+ }
+ if (testObject.counter !== 3e4)
+ throw "Failed testCSE()";
+ if (numberOfDFGCompiles(opaqueCosForCSE) > 1)
+ throw "opaqueCosForCSE() is predictable, it should only be compiled once.";
+}
+testCSE();
+
+
+// Test exceptions in the argument.
+function testException() {
+ let counter = 0;
+ function opaqueCosWithException(argument) {
+ let result = Math.cos(argument);
+ ++counter;
+ return result;
+ }
+ noInline(opaqueCosWithException);
+
+ let testObject = { valueOf: () => { return 64; } };
+ let cos64 = Math.cos(64);
+
+ // Warm up without exception.
+ for (let i = 0; i < 1e3; ++i) {
+ if (opaqueCosWithException(testObject) !== cos64)
+ throw "Incorrect result in opaqueCosWithException()";
+ }
+
+ let testThrowObject = { valueOf: () => { throw testObject; return 64; } };
+
+ for (let i = 0; i < 1e2; ++i) {
+ try {
+ if (opaqueCosWithException(testThrowObject) !== 8)
+ throw "This code should not be reached!!";
+ } catch (e) {
+ if (e !== testObject) {
+ throw "Wrong object thrown from opaqueCosWithException."
+ }
+ }
+ }
+
+ if (counter !== 1e3) {
+ throw "Invalid count in testException()";
+ }
+}
+testException();
</ins></span></pre></div>
<a id="trunkJSTestsstressarithsinonvarioustypesjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/arith-sin-on-various-types.js (0 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/arith-sin-on-various-types.js         (rev 0)
+++ trunk/JSTests/stress/arith-sin-on-various-types.js        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -0,0 +1,168 @@
</span><ins>+"use strict";
+
+let sinOfFour = Math.sin(4);
+
+let validInputTestCases = [
+ // input as string, expected result as string.
+ ["undefined", "NaN"],
+ ["null", "0"],
+ ["0", "0"],
+ ["-0.", "-0"],
+ ["4", "" + sinOfFour],
+ ["Math.PI", "" + Math.sin(Math.PI)],
+ ["Infinity", "NaN"],
+ ["-Infinity", "NaN"],
+ ["NaN", "NaN"],
+ ["\"WebKit\"", "NaN"],
+ ["\"4\"", "" + sinOfFour],
+ ["{ valueOf: () => { return 4; } }", "" + sinOfFour],
+];
+
+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.sin() with a very polymorphic input. All test cases are seen at each iteration.
+function opaqueAllTypesSin(argument) {
+ return Math.sin(argument);
+}
+noInline(opaqueAllTypesSin);
+noOSRExitFuzzing(opaqueAllTypesSin);
+
+function testAllTypesCall() {
+ for (let i = 0; i < 1e3; ++i) {
+ for (let testCaseInput of validInputTypedTestCases) {
+ let output = opaqueAllTypesSin(testCaseInput[0]);
+ if (!isIdentical(output, testCaseInput[1]))
+ throw "Failed testAllTypesCall for input " + testCaseInput[0] + " expected " + testCaseInput[1] + " got " + output;
+ }
+ }
+ if (numberOfDFGCompiles(opaqueAllTypesSin) > 2)
+ throw "We should have detected sin() was polymorphic and generated a generic version.";
+}
+testAllTypesCall();
+
+
+// Test Math.sin() on a completely typed input. Every call see only one type.
+function testSingleTypeCall() {
+ for (let testCaseInput of validInputTestCases) {
+ eval(`
+ function opaqueSin(argument) {
+ return Math.sin(argument);
+ }
+ noInline(opaqueSin);
+ noOSRExitFuzzing(opaqueSin);
+
+ for (let i = 0; i < 1e4; ++i) {
+ if (!isIdentical(opaqueSin(${testCaseInput[0]}), ${testCaseInput[1]})) {
+ throw "Failed testSingleTypeCall()";
+ }
+ }
+ if (numberOfDFGCompiles(opaqueSin) > 1)
+ throw "We should have compiled a single sin for the expected type.";
+ `);
+ }
+}
+testSingleTypeCall();
+
+
+// Verify we call valueOf() exactly once per call.
+function opaqueSinForSideEffects(argument) {
+ return Math.sin(argument);
+}
+noInline(opaqueSinForSideEffects);
+noOSRExitFuzzing(opaqueSinForSideEffects);
+
+function testSideEffect() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let sin16 = Math.sin(16);
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueSinForSideEffects(testObject) !== sin16)
+ throw "Incorrect result in testSideEffect()";
+ }
+ if (testObject.counter !== 1e4)
+ throw "Failed testSideEffect()";
+ if (numberOfDFGCompiles(opaqueSinForSideEffects) > 1)
+ throw "opaqueSinForSideEffects() is predictable, it should only be compiled once.";
+}
+testSideEffect();
+
+
+// Verify SQRT is not subject to CSE if the argument has side effects.
+function opaqueSinForCSE(argument) {
+ return Math.sin(argument) + Math.sin(argument) + Math.sin(argument);
+}
+noInline(opaqueSinForCSE);
+noOSRExitFuzzing(opaqueSinForCSE);
+
+function testCSE() {
+ let testObject = {
+ counter: 0,
+ valueOf: function() { ++this.counter; return 16; }
+ };
+ let sin16 = Math.sin(16);
+ let threeSin16 = sin16 + sin16 + sin16;
+ for (let i = 0; i < 1e4; ++i) {
+ if (opaqueSinForCSE(testObject) !== threeSin16)
+ throw "Incorrect result in testCSE()";
+ }
+ if (testObject.counter !== 3e4)
+ throw "Failed testCSE()";
+ if (numberOfDFGCompiles(opaqueSinForCSE) > 1)
+ throw "opaqueSinForCSE() is predictable, it should only be compiled once.";
+}
+testCSE();
+
+
+// Test exceptions in the argument.
+function testException() {
+ let counter = 0;
+ function opaqueSinWithException(argument) {
+ let result = Math.sin(argument);
+ ++counter;
+ return result;
+ }
+ noInline(opaqueSinWithException);
+
+ let testObject = { valueOf: () => { return 64; } };
+ let sin64 = Math.sin(64);
+
+ // Warm up without exception.
+ for (let i = 0; i < 1e3; ++i) {
+ if (opaqueSinWithException(testObject) !== sin64)
+ throw "Incorrect result in opaqueSinWithException()";
+ }
+
+ let testThrowObject = { valueOf: () => { throw testObject; return 64; } };
+
+ for (let i = 0; i < 1e2; ++i) {
+ try {
+ if (opaqueSinWithException(testThrowObject) !== 8)
+ throw "This code should not be reached!!";
+ } catch (e) {
+ if (e !== testObject) {
+ throw "Wrong object thrown from opaqueSinWithException."
+ }
+ }
+ }
+
+ 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 (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-08-23 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Make Math.cos() and Math.sin() work with any argument type
+ https://bugs.webkit.org/show_bug.cgi?id=161069
+
+ Reviewed by Geoffrey Garen.
+
+ Same as the ArithSqrt patch: add a generic path if the argument
+ is not a number.
+
+ * 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::compileArithCos):
+ (JSC::DFG::SpeculativeJIT::compileArithSin):
+ * 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::compileArithSin):
+ (JSC::FTL::DFG::LowerDFGToB3::compileArithCos):
+
</ins><span class="cx"> 2016-08-23 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> [ES6] Module namespace object's Symbol.iterator method should only accept module namespace objects
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -984,7 +984,10 @@
</span><span class="cx"> setConstant(node, jsDoubleNumber(sin(child.asNumber())));
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
</del><ins>+ SpeculatedType sinType = SpecFullNumber;
+ if (node->child1().useKind() == DoubleRepUse)
+ sinType = typeOfDoubleUnaryOp(forNode(node->child1()).m_type);
+ forNode(node).setType(sinType);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -994,7 +997,10 @@
</span><span class="cx"> setConstant(node, jsDoubleNumber(cos(child.asNumber())));
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
</del><ins>+ SpeculatedType cosType = SpecFullNumber;
+ if (node->child1().useKind() == DoubleRepUse)
+ cosType = typeOfDoubleUnaryOp(forNode(node->child1()).m_type);
+ forNode(node).setType(cosType);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGClobberizeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGClobberize.h (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -155,8 +155,6 @@
</span><span class="cx"> case ArithMax:
</span><span class="cx"> case ArithPow:
</span><span class="cx"> case ArithFRound:
</span><del>- case ArithSin:
- case ArithCos:
</del><span class="cx"> case ArithLog:
</span><span class="cx"> case GetScope:
</span><span class="cx"> case SkipScope:
</span><span class="lines">@@ -189,6 +187,8 @@
</span><span class="cx"> def(PureValue(node));
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ case ArithCos:
+ case ArithSin:
</ins><span class="cx"> case ArithSqrt:
</span><span class="cx"> if (node->child1().useKind() == DoubleRepUse)
</span><span class="cx"> def(PureValue(node));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -385,7 +385,9 @@
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>-
</del><ins>+
+ case ArithCos:
+ case ArithSin:
</ins><span class="cx"> case ArithSqrt: {
</span><span class="cx"> Edge& child1 = node->child1();
</span><span class="cx"> if (child1->shouldSpeculateNumberOrBoolean())
</span><span class="lines">@@ -395,8 +397,6 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case ArithFRound:
</span><del>- case ArithSin:
- case ArithCos:
</del><span class="cx"> case ArithLog: {
</span><span class="cx"> fixDoubleOrBooleanEdge(node->child1());
</span><span class="cx"> node->setResult(NodeResultDouble);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGNodeTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGNodeType.h (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -160,8 +160,8 @@
</span><span class="cx"> macro(ArithCeil, NodeResultNumber) \
</span><span class="cx"> macro(ArithTrunc, NodeResultNumber) \
</span><span class="cx"> macro(ArithSqrt, NodeResultDouble) \
</span><del>- macro(ArithSin, NodeResultNumber) \
- macro(ArithCos, NodeResultNumber) \
</del><ins>+ macro(ArithSin, NodeResultDouble) \
+ macro(ArithCos, NodeResultDouble) \
</ins><span class="cx"> macro(ArithLog, NodeResultNumber) \
</span><span class="cx"> \
</span><span class="cx"> /* Add of values may either be arithmetic, or result in string concatenation. */\
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -322,6 +322,30 @@
</span><span class="cx"> return JSValue::encode(jsNumber(a / b));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+double JIT_OPERATION operationArithCos(ExecState* exec, EncodedJSValue encodedOp1)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ JSValue op1 = JSValue::decode(encodedOp1);
+ double a = op1.toNumber(exec);
+ if (UNLIKELY(vm->exception()))
+ return JSValue::encode(JSValue());
+ return cos(a);
+}
+
+double JIT_OPERATION operationArithSin(ExecState* exec, EncodedJSValue encodedOp1)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ JSValue op1 = JSValue::decode(encodedOp1);
+ double a = op1.toNumber(exec);
+ if (UNLIKELY(vm->exception()))
+ return JSValue::encode(JSValue());
+ return sin(a);
+}
+
</ins><span class="cx"> double JIT_OPERATION operationArithSqrt(ExecState* exec, EncodedJSValue encodedOp1)
</span><span class="cx"> {
</span><span class="cx"> VM* vm = &exec->vm();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.h (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -53,6 +53,8 @@
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueBitURShift(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
</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><ins>+double JIT_OPERATION operationArithCos(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
+double JIT_OPERATION operationArithSin(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</ins><span class="cx"> double JIT_OPERATION operationArithSqrt(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationGetByVal(ExecState*, EncodedJSValue encodedBase, EncodedJSValue encodedProperty) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationGetByValCell(ExecState*, JSCell*, EncodedJSValue encodedProperty) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -3885,6 +3885,29 @@
</span><span class="cx"> int32Result(resultReg, node);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SpeculativeJIT::compileArithCos(Node* node)
+{
+ if (node->child1().useKind() == DoubleRepUse) {
+ SpeculateDoubleOperand op1(this, node->child1());
+ FPRReg op1FPR = op1.fpr();
+
+ flushRegisters();
+
+ FPRResult result(this);
+ callOperation(cos, result.fpr(), op1FPR);
+ doubleResult(result.fpr(), node);
+ return;
+ }
+
+ JSValueOperand op1(this, node->child1());
+ JSValueRegs op1Regs = op1.jsValueRegs();
+ flushRegisters();
+ FPRResult result(this);
+ callOperation(operationArithCos, result.fpr(), op1Regs);
+ m_jit.exceptionCheck();
+ doubleResult(result.fpr(), node);
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileArithSub(Node* node)
</span><span class="cx"> {
</span><span class="cx"> switch (node->binaryUseKind()) {
</span><span class="lines">@@ -4888,6 +4911,29 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SpeculativeJIT::compileArithSin(Node* node)
+{
+ if (node->child1().useKind() == DoubleRepUse) {
+ SpeculateDoubleOperand op1(this, node->child1());
+ FPRReg op1FPR = op1.fpr();
+
+ flushRegisters();
+
+ FPRResult result(this);
+ callOperation(sin, result.fpr(), op1FPR);
+ doubleResult(result.fpr(), node);
+ return;
+ }
+
+ JSValueOperand op1(this, node->child1());
+ JSValueRegs op1Regs = op1.jsValueRegs();
+ flushRegisters();
+ FPRResult result(this);
+ callOperation(operationArithSin, result.fpr(), op1Regs);
+ m_jit.exceptionCheck();
+ doubleResult(result.fpr(), node);
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileArithSqrt(Node* node)
</span><span class="cx"> {
</span><span class="cx"> if (node->child1().useKind() == DoubleRepUse) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -2469,6 +2469,7 @@
</span><span class="cx"> void compileArithAdd(Node*);
</span><span class="cx"> void compileMakeRope(Node*);
</span><span class="cx"> void compileArithClz32(Node*);
</span><ins>+ void compileArithCos(Node*);
</ins><span class="cx"> void compileArithSub(Node*);
</span><span class="cx"> void compileArithNegate(Node*);
</span><span class="cx"> void compileArithMul(Node*);
</span><span class="lines">@@ -2477,6 +2478,7 @@
</span><span class="cx"> void compileArithPow(Node*);
</span><span class="cx"> void compileArithRounding(Node*);
</span><span class="cx"> void compileArithRandom(Node*);
</span><ins>+ void compileArithSin(Node*);
</ins><span class="cx"> void compileArithSqrt(Node*);
</span><span class="cx"> void compileArithLog(Node*);
</span><span class="cx"> void compileConstantStoragePointer(Node*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -2389,29 +2389,13 @@
</span><span class="cx"> compileArithRounding(node);
</span><span class="cx"> break;
</span><span class="cx">
</span><del>- case ArithSin: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRReg op1FPR = op1.fpr();
-
- flushRegisters();
-
- FPRResult result(this);
- callOperation(sin, result.fpr(), op1FPR);
- doubleResult(result.fpr(), node);
</del><ins>+ case ArithSin:
+ compileArithSin(node);
</ins><span class="cx"> break;
</span><del>- }
</del><span class="cx">
</span><del>- case ArithCos: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRReg op1FPR = op1.fpr();
-
- flushRegisters();
-
- FPRResult result(this);
- callOperation(cos, result.fpr(), op1FPR);
- doubleResult(result.fpr(), node);
</del><ins>+ case ArithCos:
+ compileArithCos(node);
</ins><span class="cx"> break;
</span><del>- }
</del><span class="cx">
</span><span class="cx"> case ArithLog:
</span><span class="cx"> compileArithLog(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -2513,29 +2513,13 @@
</span><span class="cx"> compileArithRounding(node);
</span><span class="cx"> break;
</span><span class="cx">
</span><del>- case ArithSin: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRReg op1FPR = op1.fpr();
-
- flushRegisters();
-
- FPRResult result(this);
- callOperation(sin, result.fpr(), op1FPR);
- doubleResult(result.fpr(), node);
</del><ins>+ case ArithSin:
+ compileArithSin(node);
</ins><span class="cx"> break;
</span><del>- }
</del><span class="cx">
</span><del>- case ArithCos: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRReg op1FPR = op1.fpr();
-
- flushRegisters();
-
- FPRResult result(this);
- callOperation(cos, result.fpr(), op1FPR);
- doubleResult(result.fpr(), node);
</del><ins>+ case ArithCos:
+ compileArithCos(node);
</ins><span class="cx"> break;
</span><del>- }
</del><span class="cx">
</span><span class="cx"> case ArithLog:
</span><span class="cx"> compileArithLog(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (204848 => 204849)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-23 19:07:33 UTC (rev 204848)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-23 19:09:50 UTC (rev 204849)
</span><span class="lines">@@ -2020,9 +2020,27 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void compileArithSin() { setDouble(m_out.doubleSin(lowDouble(m_node->child1()))); }
</del><ins>+ void compileArithSin()
+ {
+ if (m_node->child1().useKind() == DoubleRepUse) {
+ setDouble(m_out.doubleSin(lowDouble(m_node->child1())));
+ return;
+ }
+ LValue argument = lowJSValue(m_node->child1());
+ LValue result = vmCall(Double, m_out.operation(operationArithSin), m_callFrame, argument);
+ setDouble(result);
+ }
</ins><span class="cx">
</span><del>- void compileArithCos() { setDouble(m_out.doubleCos(lowDouble(m_node->child1()))); }
</del><ins>+ void compileArithCos()
+ {
+ if (m_node->child1().useKind() == DoubleRepUse) {
+ setDouble(m_out.doubleCos(lowDouble(m_node->child1())));
+ return;
+ }
+ LValue argument = lowJSValue(m_node->child1());
+ LValue result = vmCall(Double, m_out.operation(operationArithCos), m_callFrame, argument);
+ setDouble(result);
+ }
</ins><span class="cx">
</span><span class="cx"> void compileArithPow()
</span><span class="cx"> {
</span></span></pre>
</div>
</div>
</body>
</html>