<!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>[186819] 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/186819">186819</a></dd>
<dt>Author</dt> <dd>mmirman@apple.com</dd>
<dt>Date</dt> <dd>2015-07-14 14:56:14 -0700 (Tue, 14 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Repatch. Makes compileArithSub in the DFG ensure that the constant is an int32.
https://bugs.webkit.org/show_bug.cgi?id=146910
rdar://problem/21729083
Reviewed by Filip Pizlo.
Also fixes the debug build problem where all edges are assumed to
have UntypedUse before the fixup phase.
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithSub):
* dfg/DFGValidate.cpp:
(JSC::DFG::Validate::validateEdgeWithDoubleResultIfNecessary):
* tests/stress/arith-add-with-constants.js: Added some tests for this case.
(arithAdd42WrittenAsInteger):
(testArithAdd42WrittenAsInteger):
(arithSub42WrittenAsDouble):
(testArithSub42WrittenAsDouble):
(doubleConstant):
(testDoubleConstant): Added test for the case of +0.0 and Math.min(0.0)
(arithAdd42WrittenAsDouble): Deleted.
(testArithAdd42WrittenAsDouble): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGValidatecpp">trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressarithaddwithconstantsjs">trunk/Source/JavaScriptCore/tests/stress/arith-add-with-constants.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (186818 => 186819)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-07-14 21:46:47 UTC (rev 186818)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-07-14 21:56:14 UTC (rev 186819)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2015-07-14 Matthew Mirman <mmirman@apple.com>
</span><span class="cx">
</span><ins>+ Repatch. Makes compileArithSub in the DFG ensure that the constant is an int32.
+ https://bugs.webkit.org/show_bug.cgi?id=146910
+ rdar://problem/21729083
+
+ Reviewed by Filip Pizlo.
+
+ Also fixes the debug build problem where all edges are assumed to
+ have UntypedUse before the fixup phase.
+
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileArithSub):
+ * dfg/DFGValidate.cpp:
+ (JSC::DFG::Validate::validateEdgeWithDoubleResultIfNecessary):
+ * tests/stress/arith-add-with-constants.js: Added some tests for this case.
+ (arithAdd42WrittenAsInteger):
+ (testArithAdd42WrittenAsInteger):
+ (arithSub42WrittenAsDouble):
+ (testArithSub42WrittenAsDouble):
+ (doubleConstant):
+ (testDoubleConstant): Added test for the case of +0.0 and Math.min(0.0)
+ (arithAdd42WrittenAsDouble): Deleted.
+ (testArithAdd42WrittenAsDouble): Deleted.
+
+2015-07-14 Matthew Mirman <mmirman@apple.com>
+
</ins><span class="cx"> Unreviewed, rolling out r186805.
</span><span class="cx">
</span><span class="cx"> Made raytracer on octane 80% slower
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (186818 => 186819)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-07-14 21:46:47 UTC (rev 186818)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-07-14 21:56:14 UTC (rev 186819)
</span><span class="lines">@@ -2989,7 +2989,7 @@
</span><span class="cx"> case Int32Use: {
</span><span class="cx"> ASSERT(!shouldCheckNegativeZero(node->arithMode()));
</span><span class="cx">
</span><del>- if (node->child2()->isNumberConstant()) {
</del><ins>+ if (node->child2()->isInt32Constant()) {
</ins><span class="cx"> SpeculateInt32Operand op1(this, node->child1());
</span><span class="cx"> int32_t imm2 = node->child2()->asInt32();
</span><span class="cx"> GPRTemporary result(this);
</span><span class="lines">@@ -3006,7 +3006,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (node->child1()->isNumberConstant()) {
</del><ins>+ if (node->child1()->isInt32Constant()) {
</ins><span class="cx"> int32_t imm1 = node->child1()->asInt32();
</span><span class="cx"> SpeculateInt32Operand op2(this, node->child2());
</span><span class="cx"> GPRTemporary result(this);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGValidatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp (186818 => 186819)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp        2015-07-14 21:46:47 UTC (rev 186818)
+++ trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp        2015-07-14 21:56:14 UTC (rev 186819)
</span><span class="lines">@@ -574,9 +574,9 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> if (m_graph.m_planStage < PlanStage::AfterFixup)
</span><del>- VALIDATE((node, edge), edge.useKind() == UntypedUse);
- else
- VALIDATE((node, edge), edge.useKind() == DoubleRepUse || edge.useKind() == DoubleRepRealUse || edge.useKind() == DoubleRepMachineIntUse);
</del><ins>+ return;
+
+ VALIDATE((node, edge), edge.useKind() == DoubleRepUse || edge.useKind() == DoubleRepRealUse || edge.useKind() == DoubleRepMachineIntUse);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void checkOperand(
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarithaddwithconstantsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/arith-add-with-constants.js (186818 => 186819)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arith-add-with-constants.js        2015-07-14 21:46:47 UTC (rev 186818)
+++ trunk/Source/JavaScriptCore/tests/stress/arith-add-with-constants.js        2015-07-14 21:56:14 UTC (rev 186819)
</span><span class="lines">@@ -167,56 +167,105 @@
</span><span class="cx"> testArithAdd42WrittenAsInteger();
</span><span class="cx">
</span><span class="cx">
</span><del>-function arithAdd42WrittenAsDouble(x) {
- var a = x + 42.0;
- var b = 42. + x;
</del><ins>+
+
+// Test "value + 42".
+function arithAdd42WrittenAsInteger(x) {
+ var a = x + 42;
+ var b = 42 + x;
</ins><span class="cx"> if (!(isNaN(x) && isNaN(a) && isNaN(b)) && a !== b)
</span><del>- throw "Internal error on arithAdd42WrittenAsDouble, a = " + a + " b = " + b;
</del><ins>+ throw "Internal error on arithAdd42WrittenAsInteger, a = " + a + " b = " + b;
</ins><span class="cx"> return a;
</span><span class="cx"> }
</span><del>-noInline(arithAdd42WrittenAsDouble);
</del><ins>+noInline(arithAdd42WrittenAsInteger);
</ins><span class="cx">
</span><del>-function testArithAdd42WrittenAsDouble() {
</del><ins>+function testArithAdd42WrittenAsInteger() {
</ins><span class="cx"> for (var i = 0; i < 1e4; ++i) {
</span><del>- var result = arithAdd42WrittenAsDouble(13);
</del><ins>+ var result = arithAdd42WrittenAsInteger(13);
</ins><span class="cx"> if (result !== 55) {
</span><del>- throw "arithAdd42WrittenAsDouble(i) = " + result + ", expected 55";
</del><ins>+ throw "arithAdd42WrittenAsInteger(13) = " + result + ", expected 55";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (var i = 0; i < 1e4; ++i) {
</span><del>- var result = arithAdd42WrittenAsDouble(-0);
</del><ins>+ var result = arithAdd42WrittenAsInteger(-0);
</ins><span class="cx"> if (result !== 42) {
</span><del>- throw "arithAdd42WrittenAsDouble(-0) = " + result + ", expected 42";
</del><ins>+ throw "arithAdd42WrittenAsInteger(-0) = " + result + ", expected 42";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (var i = 0; i < 1e4; ++i) {
</span><del>- var result = arithAdd42WrittenAsDouble(13.3);
</del><ins>+ var result = arithAdd42WrittenAsInteger(13.3);
</ins><span class="cx"> if (result !== 55.3) {
</span><del>- throw "arithAdd42WrittenAsDouble(13.3) = " + result + ", expected 55.3";
</del><ins>+ throw "arithAdd42WrittenAsInteger(13.3) = " + result + ", expected 55.3";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (var i = 0; i < 1e4; ++i) {;
</span><del>- var result = arithAdd42WrittenAsDouble(NaN);
</del><ins>+ var result = arithAdd42WrittenAsInteger(NaN);
</ins><span class="cx"> if (!isNaN(result)) {
</span><del>- throw "arithAdd42WrittenAsDouble(NaN) = " + result + ", expected NaN";
</del><ins>+ throw "arithAdd42WrittenAsInteger(NaN) = " + result + ", expected NaN";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (var i = 0; i < 1e4; ++i) {;
</span><del>- var result = arithAdd42WrittenAsDouble(Infinity);
</del><ins>+ var result = arithAdd42WrittenAsInteger(Infinity);
</ins><span class="cx"> if (isFinite(result)) {
</span><del>- throw "arithAdd42WrittenAsDouble(Infinity) = " + result + ", expected Infinity";
</del><ins>+ throw "arithAdd42WrittenAsInteger(Infinity) = " + result + ", expected Infinity";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (var i = 0; i < 1e4; ++i) {;
</span><del>- var result = arithAdd42WrittenAsDouble(-Infinity);
</del><ins>+ var result = arithAdd42WrittenAsInteger(-Infinity);
</ins><span class="cx"> if (isFinite(result) || result >= 0) {
</span><del>- throw "arithAdd42WrittenAsDouble(-Infinity) = " + result + ", expected -Infinity";
</del><ins>+ throw "arithAdd42WrittenAsInteger(-Infinity) = " + result + ", expected -Infinity";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-testArithAdd42WrittenAsDouble();
</del><span class="cx">\ No newline at end of file
</span><ins>+testArithAdd42WrittenAsInteger();
+
+function arithSub42WrittenAsDouble(x) {
+ var a = (x|0) - 42.0;
+ var b = -42. + (x|0);
+ if (!(isNaN(x) && isNaN(a) && isNaN(b)) && a !== b)
+ throw "Internal error on arithSub42WrittenAsDouble, a = " + a + " b = " + b;
+ return a;
+}
+noInline(arithSub42WrittenAsDouble);
+
+function testArithSub42WrittenAsDouble() {
+ for (var i = 0; i < 1e4; ++i) {
+ var result = arithSub42WrittenAsDouble(13);
+ if (result !== -29) {
+ throw "arithSub42WrittenAsDouble(13) = " + result + ", expected -29";
+ }
+ }
+
+ for (var i = 0; i < 1e4; ++i) {
+ var result = arithSub42WrittenAsDouble(-0);
+ if (result !== -42) {
+ throw "arithSub42WrittenAsDouble(-0) = " + result + ", expected -42";
+ }
+ }
+
+ for (var i = 0; i < 1e4; ++i) {
+ var result = arithSub42WrittenAsDouble(13.3);
+ if (result !== -29) {
+ throw "arithSub42WrittenAsDouble(13.3) = " + result + ", expected -29";
+ }
+ }
+}
+testArithSub42WrittenAsDouble();
+
+
+function doubleConstant(){
+ Math.min(0.0);
+ +0.0;
+} noInline(doubleConstant);
+
+function testDoubleConstant(){
+ for (var i = 0; i < 1e4; ++i) {
+ doubleConstant();
+ }
+}
+testDoubleConstant();
</ins></span></pre>
</div>
</div>
</body>
</html>