<!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>[180360] trunk/Source/JavaScriptCore</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/180360">180360</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-19 13:08:21 -0800 (Thu, 19 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Refine the FTL part of ArithPow
https://bugs.webkit.org/show_bug.cgi?id=141792
Patch by Benjamin Poulain <bpoulain@apple.com> on 2015-02-19
Reviewed by Filip Pizlo.
This patch refines the FTL lowering of ArithPow. This was left out
of the original patch to keep it simpler.
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileArithPow):
Two improvements here:
1) Do not generate the NaN check unless we know the exponent might be a NaN.
2) Use one BasicBlock per check with the appropriate weight. Now that we have
one branch per test, move the Infinity check before the check for 1 since
it is the less common case.
* tests/stress/math-pow-becomes-custom-function.js: Added.
Test for changing the Math.pow() function after it has been optimized.
* tests/stress/math-pow-nan-behaviors.js:
The previous tests were only going as far as the DFGAbstractInterpreter
were the operations were replaced by the equivalent constant.
I duplicated the test functions to also test the dynamic behavior of DFG
and FTL.
* tests/stress/math-pow-with-constants.js:
Add cases covering exponent constants. LLVM removes many value
checks for those.
* tests/stress/math-pow-with-never-NaN-exponent.js: Added.
Test for the new optimization removing the NaN check.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressmathpownanbehaviorsjs">trunk/Source/JavaScriptCore/tests/stress/math-pow-nan-behaviors.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressmathpowwithconstantsjs">trunk/Source/JavaScriptCore/tests/stress/math-pow-with-constants.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressmathpowbecomescustomfunctionjs">trunk/Source/JavaScriptCore/tests/stress/math-pow-becomes-custom-function.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressmathpowwithneverNaNexponentjs">trunk/Source/JavaScriptCore/tests/stress/math-pow-with-never-NaN-exponent.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (180359 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-02-19 20:42:52 UTC (rev 180359)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2015-02-19 Benjamin Poulain <bpoulain@apple.com>
+
+ Refine the FTL part of ArithPow
+ https://bugs.webkit.org/show_bug.cgi?id=141792
+
+ Reviewed by Filip Pizlo.
+
+ This patch refines the FTL lowering of ArithPow. This was left out
+ of the original patch to keep it simpler.
+
+ * ftl/FTLLowerDFGToLLVM.cpp:
+ (JSC::FTL::LowerDFGToLLVM::compileArithPow):
+ Two improvements here:
+ 1) Do not generate the NaN check unless we know the exponent might be a NaN.
+ 2) Use one BasicBlock per check with the appropriate weight. Now that we have
+ one branch per test, move the Infinity check before the check for 1 since
+ it is the less common case.
+
+ * tests/stress/math-pow-becomes-custom-function.js: Added.
+ Test for changing the Math.pow() function after it has been optimized.
+
+ * tests/stress/math-pow-nan-behaviors.js:
+ The previous tests were only going as far as the DFGAbstractInterpreter
+ were the operations were replaced by the equivalent constant.
+
+ I duplicated the test functions to also test the dynamic behavior of DFG
+ and FTL.
+
+ * tests/stress/math-pow-with-constants.js:
+ Add cases covering exponent constants. LLVM removes many value
+ checks for those.
+
+ * tests/stress/math-pow-with-never-NaN-exponent.js: Added.
+ Test for the new optimization removing the NaN check.
+
</ins><span class="cx"> 2015-02-19 Csaba Osztrogonác <ossy@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r180279): It broke 20 tests on ARM Linux
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (180359 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-02-19 20:42:52 UTC (rev 180359)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -1659,44 +1659,52 @@
</span><span class="cx">
</span><span class="cx"> LBasicBlock integerExponentIsSmallBlock = FTL_NEW_BLOCK(m_out, ("ArithPow test integer exponent is small."));
</span><span class="cx"> LBasicBlock integerExponentPowBlock = FTL_NEW_BLOCK(m_out, ("ArithPow pow(double, (int)double)."));
</span><del>- LBasicBlock doubleExponentPowBlock = FTL_NEW_BLOCK(m_out, ("ArithPow pow(double, double)."));
</del><ins>+ LBasicBlock doubleExponentPowBlockEntry = FTL_NEW_BLOCK(m_out, ("ArithPow pow(double, double)."));
+ LBasicBlock nanExceptionExponentIsInfinity = FTL_NEW_BLOCK(m_out, ("ArithPow NaN Exception, check exponent is infinity."));
+ LBasicBlock nanExceptionBaseIsOne = FTL_NEW_BLOCK(m_out, ("ArithPow NaN Exception, check base is one."));
</ins><span class="cx"> LBasicBlock powBlock = FTL_NEW_BLOCK(m_out, ("ArithPow regular pow"));
</span><del>- LBasicBlock nanException = FTL_NEW_BLOCK(m_out, ("ArithPow NaN Exception"));
</del><ins>+ LBasicBlock nanExceptionResultIsNaN = FTL_NEW_BLOCK(m_out, ("ArithPow NaN Exception, result is NaN."));
</ins><span class="cx"> LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ArithPow continuation"));
</span><span class="cx">
</span><span class="cx"> LValue integerExponent = m_out.fpToInt32(exponent);
</span><span class="cx"> LValue integerExponentConvertedToDouble = m_out.intToDouble(integerExponent);
</span><span class="cx"> LValue exponentIsInteger = m_out.doubleEqual(exponent, integerExponentConvertedToDouble);
</span><del>- m_out.branch(exponentIsInteger, unsure(integerExponentIsSmallBlock), unsure(doubleExponentPowBlock));
</del><ins>+ m_out.branch(exponentIsInteger, unsure(integerExponentIsSmallBlock), unsure(doubleExponentPowBlockEntry));
</ins><span class="cx">
</span><span class="cx"> LBasicBlock lastNext = m_out.appendTo(integerExponentIsSmallBlock, integerExponentPowBlock);
</span><span class="cx"> LValue integerExponentBelow1000 = m_out.below(integerExponent, m_out.constInt32(1000));
</span><del>- m_out.branch(integerExponentBelow1000, usually(integerExponentPowBlock), rarely(doubleExponentPowBlock));
</del><ins>+ m_out.branch(integerExponentBelow1000, usually(integerExponentPowBlock), rarely(doubleExponentPowBlockEntry));
</ins><span class="cx">
</span><del>- m_out.appendTo(integerExponentPowBlock, doubleExponentPowBlock);
</del><ins>+ m_out.appendTo(integerExponentPowBlock, doubleExponentPowBlockEntry);
</ins><span class="cx"> ValueFromBlock powDoubleIntResult = m_out.anchor(m_out.doublePowi(base, integerExponent));
</span><span class="cx"> m_out.jump(continuation);
</span><span class="cx">
</span><del>- m_out.appendTo(doubleExponentPowBlock, powBlock);
</del><span class="cx"> // If y is NaN, the result is NaN.
</span><del>- // FIXME: shouldn't we only check that if the type of child2() might have NaN?
- LValue exponentIsNaN = m_out.doubleNotEqualOrUnordered(exponent, exponent);
</del><ins>+ m_out.appendTo(doubleExponentPowBlockEntry, nanExceptionExponentIsInfinity);
+ LValue exponentIsNaN;
+ if (m_state.forNode(m_node->child2()).m_type & SpecDoubleNaN)
+ exponentIsNaN = m_out.doubleNotEqualOrUnordered(exponent, exponent);
+ else
+ exponentIsNaN = m_out.booleanFalse;
+ m_out.branch(exponentIsNaN, rarely(nanExceptionResultIsNaN), usually(nanExceptionExponentIsInfinity));
</ins><span class="cx">
</span><span class="cx"> // If abs(x) is 1 and y is +infinity, the result is NaN.
</span><span class="cx"> // If abs(x) is 1 and y is -infinity, the result is NaN.
</span><ins>+ m_out.appendTo(nanExceptionExponentIsInfinity, nanExceptionBaseIsOne);
</ins><span class="cx"> LValue absoluteExponent = m_out.doubleAbs(exponent);
</span><span class="cx"> LValue absoluteExponentIsInfinity = m_out.doubleEqual(absoluteExponent, m_out.constDouble(std::numeric_limits<double>::infinity()));
</span><ins>+ m_out.branch(absoluteExponentIsInfinity, rarely(nanExceptionBaseIsOne), usually(powBlock));
+
+ m_out.appendTo(nanExceptionBaseIsOne, powBlock);
</ins><span class="cx"> LValue absoluteBase = m_out.doubleAbs(base);
</span><span class="cx"> LValue absoluteBaseIsOne = m_out.doubleEqual(absoluteBase, m_out.constDouble(1));
</span><del>- LValue oneBaseInfiniteExponent = m_out.bitAnd(absoluteExponentIsInfinity, absoluteBaseIsOne);
</del><ins>+ m_out.branch(absoluteBaseIsOne, unsure(nanExceptionResultIsNaN), unsure(powBlock));
</ins><span class="cx">
</span><del>- m_out.branch(m_out.bitOr(exponentIsNaN, oneBaseInfiniteExponent), rarely(nanException), usually(powBlock));
-
- m_out.appendTo(powBlock, nanException);
</del><ins>+ m_out.appendTo(powBlock, nanExceptionResultIsNaN);
</ins><span class="cx"> ValueFromBlock powResult = m_out.anchor(m_out.doublePow(base, exponent));
</span><span class="cx"> m_out.jump(continuation);
</span><span class="cx">
</span><del>- m_out.appendTo(nanException, continuation);
</del><ins>+ m_out.appendTo(nanExceptionResultIsNaN, continuation);
</ins><span class="cx"> ValueFromBlock pureNan = m_out.anchor(m_out.constDouble(PNaN));
</span><span class="cx"> m_out.jump(continuation);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressmathpowbecomescustomfunctionjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/math-pow-becomes-custom-function.js (0 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/math-pow-becomes-custom-function.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/math-pow-becomes-custom-function.js        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+function mathPowWrapper(x, y) {
+ return Math.pow(x, y);
+}
+noInline(mathPowWrapper);
+
+function testChangingMathPow() {
+ var result = 0;
+ for (var i = 0; i < 10000; ++i) {
+ result += mathPowWrapper(3, 2);
+ }
+ Math.pow = function(a, b) { return a + b; }
+ for (var i = 0; i < 10000; ++i) {
+ result += mathPowWrapper(3, 2);
+ }
+ if (result !== 140000)
+ throw "Result = " + result + ", expected 140000";
+}
+testChangingMathPow();
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressmathpownanbehaviorsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/math-pow-nan-behaviors.js (180359 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/math-pow-nan-behaviors.js        2015-02-19 20:42:52 UTC (rev 180359)
+++ trunk/Source/JavaScriptCore/tests/stress/math-pow-nan-behaviors.js        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> // If y is NaN, the result is NaN.
</span><del>-function testIntegerBaseWithNaNExponent() {
</del><ins>+function testIntegerBaseWithNaNExponentStatic() {
</ins><span class="cx"> for (var i = 0; i < 10000; ++i) {
</span><span class="cx"> var result = Math.pow(5, NaN);
</span><span class="cx"> if (!isNaN(result))
</span><span class="lines">@@ -11,28 +11,70 @@
</span><span class="cx"> throw "Error: bad result, Math.pow(i, NaN) = " + result + " with i = " + i;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-noInline(testIntegerBaseWithNaNExponent);
-testIntegerBaseWithNaNExponent();
</del><ins>+noInline(testIntegerBaseWithNaNExponentStatic);
+testIntegerBaseWithNaNExponentStatic();
</ins><span class="cx">
</span><del>-function testFloatingPointBaseWithNaNExponent() {
</del><ins>+function mathPowIntegerBaseWithNaNExponentDynamic(x, y) {
+ return Math.pow(x, y);
+}
+noInline(mathPowIntegerBaseWithNaNExponentDynamic);
+function testIntegerBaseWithNaNExponentDynamic() {
+ // Warm up with 2 integers.
</ins><span class="cx"> for (var i = 0; i < 10000; ++i) {
</span><ins>+ var result = mathPowIntegerBaseWithNaNExponentDynamic(2, 5);
+ if (result !== 32)
+ throw "Error: bad result, mathPowIntegerBaseWithNaNExponentDynamic(2, 5) = " + result + ", expected 32."
+ }
+
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowIntegerBaseWithNaNExponentDynamic(i, NaN);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowIntegerBaseWithNaNExponentDynamic(i, NaN) = " + result + " with i = " + i + ", expected NaN";
+ }
+}
+noInline(testIntegerBaseWithNaNExponentDynamic);
+testIntegerBaseWithNaNExponentDynamic();
+
+function testFloatingPointBaseWithNaNExponentStatic() {
+ for (var i = 0; i < 10000; ++i) {
</ins><span class="cx"> var result = Math.pow(5.5, NaN);
</span><span class="cx"> if (!isNaN(result))
</span><span class="cx"> throw "Error: bad result, Math.pow(5.5, NaN) = " + result;
</span><span class="cx"> }
</span><span class="cx"> for (var i = 0; i < 10000; ++i) {
</span><del>- var result = Math.pow(i + 1, NaN);
</del><ins>+ var result = Math.pow(i + 0.5, NaN);
</ins><span class="cx"> if (!isNaN(result))
</span><span class="cx"> throw "Error: bad result, Math.pow(i + 0.5, NaN) = " + result + " with i = " + i;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-noInline(testFloatingPointBaseWithNaNExponent);
-testFloatingPointBaseWithNaNExponent();
</del><ins>+noInline(testFloatingPointBaseWithNaNExponentStatic);
+testFloatingPointBaseWithNaNExponentStatic();
</ins><span class="cx">
</span><ins>+function mathPowFloatingPointBaseWithNaNExponentDynamic(x, y) {
+ return Math.pow(x, y);
+}
+noInline(mathPowFloatingPointBaseWithNaNExponentDynamic);
+function testFloatingPointBaseWithNaNExponentDynamic() {
+ // Warm up with 2 double.
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowFloatingPointBaseWithNaNExponentDynamic(2.5, 5.1);
+ if (result !== 107.02717054543135)
+ throw "Error: bad result, mathPowFloatingPointBaseWithNaNExponentDynamic(2.5, 5.1) = " + result + ", expected 107.02717054543135."
+ }
+
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowFloatingPointBaseWithNaNExponentDynamic(i + 0.5, NaN);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowFloatingPointBaseWithNaNExponentDynamic(i + 0.5, NaN) = " + result + " with i = " + i + ", expected NaN";
+ }
+}
+noInline(testFloatingPointBaseWithNaNExponentDynamic);
+testFloatingPointBaseWithNaNExponentDynamic();
+
</ins><span class="cx"> // If y is +0, the result is 1, even if x is NaN.
</span><span class="cx"> // If y is −0, the result is 1, even if x is NaN.
</span><span class="cx"> // If x is NaN and y is nonzero, the result is NaN.
</span><del>-function testNaNBase() {
</del><ins>+function testNaNBaseStatic() {
</ins><span class="cx"> for (var i = 0; i < 10000; ++i) {
</span><span class="cx"> var result = Math.pow(NaN, i + 1);
</span><span class="cx"> if (!isNaN(result))
</span><span class="lines">@@ -54,12 +96,53 @@
</span><span class="cx"> throw "Error: bad result, Math.pow(NaN, -0) = " + result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-noInline(testNaNBase);
-testNaNBase();
</del><ins>+noInline(testNaNBaseStatic);
+testNaNBaseStatic();
</ins><span class="cx">
</span><ins>+function mathPowNaNBaseDynamic1(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowNaNBaseDynamic2(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowNaNBaseDynamic3(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowNaNBaseDynamic4(x, y) {
+ return Math.pow(x, y);
+}
+noInline(mathPowNaNBaseDynamic1);
+noInline(mathPowNaNBaseDynamic2);
+noInline(mathPowNaNBaseDynamic3);
+noInline(mathPowNaNBaseDynamic4);
+function testNaNBaseDynamic() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowNaNBaseDynamic1(NaN, i + 1);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowNaNBaseDynamic1(NaN, i + 1) = " + result + " with i = " + i;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowNaNBaseDynamic2(NaN, i + 1.5);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowNaNBaseDynamic2(NaN, i + 1.5) = " + result + " with i = " + i;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowNaNBaseDynamic3(NaN, 0);
+ if (result !== 1)
+ throw "Error: bad result, mathPowNaNBaseDynamic3(NaN, 0) = " + result;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowNaNBaseDynamic4(NaN, -0);
+ if (result !== 1)
+ throw "Error: bad result, mathPowNaNBaseDynamic4(NaN, -0) = " + result;
+ }
+}
+noInline(testNaNBaseDynamic);
+testNaNBaseDynamic();
+
</ins><span class="cx"> // If abs(x) is 1 and y is +∞, the result is NaN.
</span><span class="cx"> // If abs(x) is 1 and y is −∞, the result is NaN.
</span><del>-function infiniteExponents() {
</del><ins>+function infiniteExponentsStatic() {
</ins><span class="cx"> for (var i = 0; i < 10000; ++i) {
</span><span class="cx"> var result = Math.pow(1, Number.POSITIVE_INFINITY);
</span><span class="cx"> if (!isNaN(result))
</span><span class="lines">@@ -81,5 +164,46 @@
</span><span class="cx"> throw "Error: bad result, Math.pow(-1, Number.NEGATIVE_INFINITY) = " + result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-noInline(infiniteExponents);
-infiniteExponents();
</del><ins>+noInline(infiniteExponentsStatic);
+infiniteExponentsStatic();
+
+function mathPowInfiniteExponentsDynamic1(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowInfiniteExponentsDynamic2(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowInfiniteExponentsDynamic3(x, y) {
+ return Math.pow(x, y);
+}
+function mathPowInfiniteExponentsDynamic4(x, y) {
+ return Math.pow(x, y);
+}
+noInline(mathPowInfiniteExponentsDynamic1);
+noInline(mathPowInfiniteExponentsDynamic2);
+noInline(mathPowInfiniteExponentsDynamic3);
+noInline(mathPowInfiniteExponentsDynamic4);
+function infiniteExponentsDynamic() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowInfiniteExponentsDynamic1(1, Number.POSITIVE_INFINITY);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowInfiniteExponentsDynamic1(1, Number.POSITIVE_INFINITY) = " + result;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowInfiniteExponentsDynamic2(-1, Number.POSITIVE_INFINITY);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowInfiniteExponentsDynamic2(-1, Number.POSITIVE_INFINITY) = " + result;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowInfiniteExponentsDynamic3(1, Number.NEGATIVE_INFINITY);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowInfiniteExponentsDynamic3(1, Number.NEGATIVE_INFINITY) = " + result;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = mathPowInfiniteExponentsDynamic4(-1, Number.NEGATIVE_INFINITY);
+ if (!isNaN(result))
+ throw "Error: bad result, mathPowInfiniteExponentsDynamic4(-1, Number.NEGATIVE_INFINITY) = " + result;
+ }
+}
+noInline(infiniteExponentsDynamic);
+infiniteExponentsDynamic();
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressmathpowwithconstantsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/math-pow-with-constants.js (180359 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/math-pow-with-constants.js        2015-02-19 20:42:52 UTC (rev 180359)
+++ trunk/Source/JavaScriptCore/tests/stress/math-pow-with-constants.js        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -113,3 +113,103 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> testBaseAndExponentConstantLiterals();
</span><ins>+
+
+function exponentIsIntegerConstant(x) {
+ return Math.pow(x, 42);
+}
+noInline(exponentIsIntegerConstant);
+
+function testExponentIsIntegerConstant() {
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsIntegerConstant(2);
+ if (result !== 4398046511104)
+ throw "Error: exponentIsIntegerConstant(2) should be 4398046511104, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsIntegerConstant(5);
+ if (result !== 2.2737367544323207e+29)
+ throw "Error: exponentIsIntegerConstant(5) should be 2.2737367544323207e+29, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsIntegerConstant(2.1);
+ if (result !== 34135823067412.42)
+ throw "Error: exponentIsIntegerConstant(2.1) should be 34135823067412.42, was = " + result;
+ }
+}
+testExponentIsIntegerConstant();
+
+
+function exponentIsDoubleConstant(x) {
+ return Math.pow(x, 42.5);
+}
+noInline(exponentIsDoubleConstant);
+
+function testExponentIsDoubleConstant() {
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsDoubleConstant(2);
+ if (result !== 6219777023950.95)
+ throw "Error: exponentIsDoubleConstant(2) should be 6219777023950.95, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsDoubleConstant(5);
+ if (result !== 5.084229945850415e+29)
+ throw "Error: exponentIsDoubleConstant(5) should be 5.084229945850415e+29, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsDoubleConstant(2.1);
+ if (result !== 49467507261113.805)
+ throw "Error: exponentIsDoubleConstant(2.1) should be 49467507261113.805, was = " + result;
+ }
+}
+testExponentIsDoubleConstant();
+
+
+function exponentIsInfinityConstant(x) {
+ return Math.pow(x, Infinity);
+}
+noInline(exponentIsInfinityConstant);
+
+function testExponentIsInfinityConstant() {
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsInfinityConstant(2);
+ if (result !== Infinity)
+ throw "Error: exponentIsInfinityConstant(2) should be Infinity, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsInfinityConstant(5);
+ if (result !== Infinity)
+ throw "Error: exponentIsInfinityConstant(5) should be Infinity, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsInfinityConstant(2.1);
+ if (result !== Infinity)
+ throw "Error: exponentIsInfinityConstant(2.1) should be Infinity, was = " + result;
+ }
+}
+testExponentIsInfinityConstant();
+
+
+function exponentIsNegativeInfinityConstant(x) {
+ return Math.pow(x, -Infinity);
+}
+noInline(exponentIsNegativeInfinityConstant);
+
+function testExponentIsNegativeInfinityConstant() {
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsNegativeInfinityConstant(2);
+ if (result !== 0)
+ throw "Error: exponentIsNegativeInfinityConstant(2) should be zero, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsNegativeInfinityConstant(5);
+ if (result !== 0)
+ throw "Error: exponentIsNegativeInfinityConstant(5) should be zero, was = " + result;
+ }
+ for (var i = 0; i < 1000; ++i) {
+ var result = exponentIsNegativeInfinityConstant(2.1);
+ if (result !== 0)
+ throw "Error: exponentIsNegativeInfinityConstant(2.1) should be zero, was = " + result;
+ }
+}
+testExponentIsNegativeInfinityConstant();
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressmathpowwithneverNaNexponentjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/math-pow-with-never-NaN-exponent.js (0 => 180360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/math-pow-with-never-NaN-exponent.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/math-pow-with-never-NaN-exponent.js        2015-02-19 21:08:21 UTC (rev 180360)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+function exponentIsNonNanDouble1(x, doubleArrayIndex) {
+ var doubleArray = [4.4];
+ return Math.pow(x, doubleArray[doubleArrayIndex]);
+}
+noInline(exponentIsNonNanDouble1);
+
+function exponentIsNonNanDouble2(x, doubleArray) {
+ return Math.pow(x, doubleArray[0]);
+}
+noInline(exponentIsNonNanDouble2);
+
+function testExponentIsDoubleConstant() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = exponentIsNonNanDouble1(2, 0);
+ if (result !== 21.112126572366314)
+ throw "Error: exponentIsNonNanDouble1(2, 0) should be 21.112126572366314, was = " + result;
+ }
+ for (var i = 0; i < 10000; ++i) {
+ var result = exponentIsNonNanDouble2(3, [-1.5]);
+ if (result !== 0.19245008972987526)
+ throw "Error: exponentIsNonNanDouble2(3, [-1.5]) should be 0.19245008972987526, was = " + result;
+ }
+}
+testExponentIsDoubleConstant();
</ins></span></pre>
</div>
</div>
</body>
</html>