<!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>[167416] 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/167416">167416</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-04-16 21:57:29 -0700 (Wed, 16 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Sink NaN sanitization to uses and remove it when it's unnecessary
https://bugs.webkit.org/show_bug.cgi?id=131419

Reviewed by Oliver Hunt.
        
This moves NaN purification to stores that could see an impure NaN.
        
5% speed-up on AsmBench, 50% speed-up on AsmBench/n-body. It is a regression on FloatMM
though, because of the other bug that causes that benchmark to box doubles in a loop.

* bytecode/SpeculatedType.h:
(JSC::isInt32SpeculationForArithmetic):
(JSC::isMachineIntSpeculationForArithmetic):
(JSC::isDoubleSpeculation):
(JSC::isDoubleSpeculationForArithmetic):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
* dfg/DFGAbstractValue.cpp:
(JSC::DFG::AbstractValue::fixTypeForRepresentation):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::injectTypeConversionsForEdge):
* dfg/DFGInPlaceAbstractState.cpp:
(JSC::DFG::InPlaceAbstractState::mergeStateAtTail):
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileValueRep):
(JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray):
* dfg/DFGUseKind.h:
(JSC::DFG::typeFilterFor):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileValueRep):
(JSC::FTL::LowerDFGToLLVM::compileGetByVal):
* runtime/PureNaN.h:
* tests/stress/float32-array-nan-inlined.js: Added.
(foo):
(test):
* tests/stress/float32-array-nan.js: Added.
(foo):
(test):
* tests/stress/float64-array-nan-inlined.js: Added.
(foo):
(isBigEndian):
(test):
* tests/stress/float64-array-nan.js: Added.
(foo):
(isBigEndian):
(test):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeSpeculatedTypeh">trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh">trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGAbstractValuecpp">trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGFixupPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGInPlaceAbstractStatecpp">trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGPredictionPropagationPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGUseKindh">trunk/Source/JavaScriptCore/dfg/DFGUseKind.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimePureNaNh">trunk/Source/JavaScriptCore/runtime/PureNaN.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressfloat32arraynaninlinedjs">trunk/Source/JavaScriptCore/tests/stress/float32-array-nan-inlined.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressfloat32arraynanjs">trunk/Source/JavaScriptCore/tests/stress/float32-array-nan.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressfloat64arraynaninlinedjs">trunk/Source/JavaScriptCore/tests/stress/float64-array-nan-inlined.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressfloat64arraynanjs">trunk/Source/JavaScriptCore/tests/stress/float64-array-nan.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2014-04-16  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        Sink NaN sanitization to uses and remove it when it's unnecessary
+        https://bugs.webkit.org/show_bug.cgi?id=131419
+
+        Reviewed by Oliver Hunt.
+        
+        This moves NaN purification to stores that could see an impure NaN.
+        
+        5% speed-up on AsmBench, 50% speed-up on AsmBench/n-body. It is a regression on FloatMM
+        though, because of the other bug that causes that benchmark to box doubles in a loop.
+
+        * bytecode/SpeculatedType.h:
+        (JSC::isInt32SpeculationForArithmetic):
+        (JSC::isMachineIntSpeculationForArithmetic):
+        (JSC::isDoubleSpeculation):
+        (JSC::isDoubleSpeculationForArithmetic):
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
+        * dfg/DFGAbstractValue.cpp:
+        (JSC::DFG::AbstractValue::fixTypeForRepresentation):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        (JSC::DFG::FixupPhase::injectTypeConversionsForEdge):
+        * dfg/DFGInPlaceAbstractState.cpp:
+        (JSC::DFG::InPlaceAbstractState::mergeStateAtTail):
+        * dfg/DFGPredictionPropagationPhase.cpp:
+        (JSC::DFG::PredictionPropagationPhase::propagate):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileValueRep):
+        (JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray):
+        * dfg/DFGUseKind.h:
+        (JSC::DFG::typeFilterFor):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileValueRep):
+        (JSC::FTL::LowerDFGToLLVM::compileGetByVal):
+        * runtime/PureNaN.h:
+        * tests/stress/float32-array-nan-inlined.js: Added.
+        (foo):
+        (test):
+        * tests/stress/float32-array-nan.js: Added.
+        (foo):
+        (test):
+        * tests/stress/float64-array-nan-inlined.js: Added.
+        (foo):
+        (isBigEndian):
+        (test):
+        * tests/stress/float64-array-nan.js: Added.
+        (foo):
+        (isBigEndian):
+        (test):
+
</ins><span class="cx"> 2014-04-16  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Unreviewed Windows gardening. Restrict our new 'isinf' check
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeSpeculatedTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> static const SpeculatedType SpecDoubleImpureNaN    = 0x04000000; // It's definitely a NaN that is unsafe to tag (i.e. impure).
</span><span class="cx"> static const SpeculatedType SpecDoubleNaN          = 0x06000000; // It's definitely some kind of NaN.
</span><span class="cx"> static const SpeculatedType SpecBytecodeDouble     = 0x03800000; // It's either a non-NaN or a NaN double, but it's definitely not impure NaN.
</span><del>-static const SpeculatedType SpecDouble             = 0x07800000; // It's either a non-NaN or a NaN double.
</del><ins>+static const SpeculatedType SpecFullDouble         = 0x07800000; // It's either a non-NaN or a NaN double.
</ins><span class="cx"> static const SpeculatedType SpecBytecodeRealNumber = 0x01a00000; // It's either an Int32 or a DoubleReal.
</span><span class="cx"> static const SpeculatedType SpecFullRealNumber     = 0x01e00000; // It's either an Int32 or a DoubleReal, or a Int52.
</span><span class="cx"> static const SpeculatedType SpecBytecodeNumber     = 0x03a00000; // It's either an Int32 or a Double, and the Double cannot be an impure NaN.
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool isInt32SpeculationForArithmetic(SpeculatedType value)
</span><span class="cx"> {
</span><del>-    return !(value &amp; (SpecDouble | SpecInt52));
</del><ins>+    return !(value &amp; (SpecFullDouble | SpecInt52));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool isInt32SpeculationExpectingDefined(SpeculatedType value)
</span><span class="lines">@@ -276,7 +276,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool isMachineIntSpeculationForArithmetic(SpeculatedType value)
</span><span class="cx"> {
</span><del>-    return !(value &amp; SpecDouble);
</del><ins>+    return !(value &amp; SpecFullDouble);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool isInt52AsDoubleSpeculation(SpeculatedType value)
</span><span class="lines">@@ -296,12 +296,12 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool isDoubleSpeculation(SpeculatedType value)
</span><span class="cx"> {
</span><del>-    return !!value &amp;&amp; (value &amp; SpecDouble) == value;
</del><ins>+    return !!value &amp;&amp; (value &amp; SpecFullDouble) == value;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool isDoubleSpeculationForArithmetic(SpeculatedType value)
</span><span class="cx"> {
</span><del>-    return !!(value &amp; SpecDouble);
</del><ins>+    return !!(value &amp; SpecFullDouble);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool isBytecodeRealNumberSpeculation(SpeculatedType value)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -340,7 +340,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        forNode(node).setType(forNode(node-&gt;child1()).m_type);
</del><ins>+        forNode(node).setType(forNode(node-&gt;child1()).m_type &amp; ~SpecDoubleImpureNaN);
</ins><span class="cx">         forNode(node).fixTypeForRepresentation(node);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -1092,10 +1092,10 @@
</span><span class="cx">                 forNode(node).setType(SpecInt52AsDouble);
</span><span class="cx">             break;
</span><span class="cx">         case Array::Float32Array:
</span><del>-            forNode(node).setType(SpecBytecodeDouble);
</del><ins>+            forNode(node).setType(SpecFullDouble);
</ins><span class="cx">             break;
</span><span class="cx">         case Array::Float64Array:
</span><del>-            forNode(node).setType(SpecBytecodeDouble);
</del><ins>+            forNode(node).setType(SpecFullDouble);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             RELEASE_ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx">             m_type &amp;= ~SpecMachineInt;
</span><span class="cx">             m_type |= SpecInt52AsDouble;
</span><span class="cx">         }
</span><del>-        RELEASE_ASSERT(!(m_type &amp; ~SpecDouble));
</del><ins>+        RELEASE_ASSERT(!(m_type &amp; ~SpecFullDouble));
</ins><span class="cx">     } else if (representation == NodeResultInt52) {
</span><span class="cx">         if (m_type &amp; SpecInt52AsDouble) {
</span><span class="cx">             m_type &amp;= ~SpecInt52AsDouble;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx">                 // We don't need to do ref'ing on the children because we're stealing them from
</span><span class="cx">                 // the original division.
</span><span class="cx">                 Node* newDivision = m_insertionSet.insertNode(
</span><del>-                    m_indexInBlock, SpecDouble, *node);
</del><ins>+                    m_indexInBlock, SpecBytecodeDouble, *node);
</ins><span class="cx">                 newDivision-&gt;setResult(NodeResultDouble);
</span><span class="cx">                 
</span><span class="cx">                 node-&gt;setOp(DoubleAsInt32);
</span><span class="lines">@@ -1881,7 +1881,7 @@
</span><span class="cx">                     Edge(edge.node(), Int52RepUse));
</span><span class="cx">             } else {
</span><span class="cx">                 result = m_insertionSet.insertNode(
</span><del>-                    m_indexInBlock, SpecDouble, DoubleRep, node-&gt;origin,
</del><ins>+                    m_indexInBlock, SpecBytecodeDouble, DoubleRep, node-&gt;origin,
</ins><span class="cx">                     Edge(edge.node(), NumberUse));
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -1924,7 +1924,7 @@
</span><span class="cx">             Node* result;
</span><span class="cx">             if (edge-&gt;hasDoubleResult()) {
</span><span class="cx">                 result = m_insertionSet.insertNode(
</span><del>-                    m_indexInBlock, SpecDouble, ValueRep, node-&gt;origin,
</del><ins>+                    m_indexInBlock, SpecBytecodeDouble, ValueRep, node-&gt;origin,
</ins><span class="cx">                     Edge(edge.node(), DoubleRepUse));
</span><span class="cx">             } else {
</span><span class="cx">                 result = m_insertionSet.insertNode(
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGInPlaceAbstractStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -287,7 +287,7 @@
</span><span class="cx">             // before and after setting it.
</span><span class="cx">             source = forNode(node-&gt;child1());
</span><span class="cx">             if (node-&gt;variableAccessData()-&gt;flushFormat() == FlushedDouble)
</span><del>-                RELEASE_ASSERT(!(source.m_type &amp; ~SpecDouble));
</del><ins>+                RELEASE_ASSERT(!(source.m_type &amp; ~SpecFullDouble));
</ins><span class="cx">             break;
</span><span class="cx">         
</span><span class="cx">         default:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGPredictionPropagationPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -373,7 +373,7 @@
</span><span class="cx">             
</span><span class="cx">             if (node-&gt;child1()-&gt;shouldSpeculateFloat32Array()
</span><span class="cx">                 || node-&gt;child1()-&gt;shouldSpeculateFloat64Array())
</span><del>-                changed |= mergePrediction(SpecDouble);
</del><ins>+                changed |= mergePrediction(SpecFullDouble);
</ins><span class="cx">             else if (node-&gt;child1()-&gt;shouldSpeculateUint32Array()) {
</span><span class="cx">                 if (isInt32Speculation(node-&gt;getHeapPrediction()))
</span><span class="cx">                     changed |= mergePrediction(SpecInt32);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -2163,6 +2163,13 @@
</span><span class="cx">         
</span><span class="cx">         FPRReg valueFPR = value.fpr();
</span><span class="cx">         JSValueRegs resultRegs = result.regs();
</span><ins>+        
+        // It's very tempting to in-place filter the value to indicate that it's not impure NaN
+        // anymore. Unfortunately, this would be unsound. If it's a GetLocal or if the value was
+        // subject to a prior SetLocal, filtering the value would imply that the corresponding
+        // local was purified.
+        if (needsTypeCheck(node-&gt;child1(), ~SpecDoubleImpureNaN))
+            m_jit.purifyNaN(valueFPR);
</ins><span class="cx"> 
</span><span class="cx"> #if CPU(X86)
</span><span class="cx">         // boxDouble() on X86 clobbers the source, so we need to copy.
</span><span class="lines">@@ -2507,8 +2514,6 @@
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    m_jit.purifyNaN(resultReg);
-    
</del><span class="cx">     doubleResult(resultReg, node);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGUseKindh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGUseKind.h (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGUseKind.h        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/dfg/DFGUseKind.h        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     case NumberUse:
</span><span class="cx">         return SpecBytecodeNumber;
</span><span class="cx">     case DoubleRepUse:
</span><del>-        return SpecDouble;
</del><ins>+        return SpecFullDouble;
</ins><span class="cx">     case DoubleRepRealUse:
</span><span class="cx">         return SpecDoubleReal;
</span><span class="cx">     case BooleanUse:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -743,7 +743,14 @@
</span><span class="cx">     {
</span><span class="cx">         switch (m_node-&gt;child1().useKind()) {
</span><span class="cx">         case DoubleRepUse: {
</span><del>-            setJSValue(boxDouble(lowDouble(m_node-&gt;child1())));
</del><ins>+            LValue value = lowDouble(m_node-&gt;child1());
+            
+            if (m_interpreter.needsTypeCheck(m_node-&gt;child1(), ~SpecDoubleImpureNaN)) {
+                value = m_out.select(
+                    m_out.doubleEqual(value, value), value, m_out.constDouble(PNaN));
+            }
+            
+            setJSValue(boxDouble(value));
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">             
</span><span class="lines">@@ -2127,8 +2134,6 @@
</span><span class="cx">                     RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">                 }
</span><span class="cx">                 
</span><del>-                result = m_out.select(
-                    m_out.doubleEqual(result, result), result, m_out.constDouble(PNaN));
</del><span class="cx">                 setDouble(result);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimePureNaNh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/PureNaN.h (167415 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/PureNaN.h        2014-04-17 03:54:11 UTC (rev 167415)
+++ trunk/Source/JavaScriptCore/runtime/PureNaN.h        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> // having to call purifyNaN() in surprising places.
</span><span class="cx"> //
</span><span class="cx"> // For naming purposes, we say that a NaN is &quot;pure&quot; if it is safe to tag, in the sense
</span><del>-// that doing so would result in a tagged value that would base the &quot;are you a double&quot;
</del><ins>+// that doing so would result in a tagged value that would pass the &quot;are you a double&quot;
</ins><span class="cx"> // test. We say that a NaN is &quot;impure&quot; if attempting to tag it would result in a value
</span><span class="cx"> // that would look like something other than a double.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressfloat32arraynaninlinedjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/float32-array-nan-inlined.js (0 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/float32-array-nan-inlined.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/float32-array-nan-inlined.js        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+function foo(o) {
+    return o[0];
+}
+
+function test(a, x) {
+    var intArray = new Int32Array(1);
+    intArray[0] = a;
+    var floatArray = new Float32Array(intArray.buffer);
+    var element = foo(floatArray);
+    var result = element + 1;
+    if ((&quot;&quot; + result) != (&quot;&quot; + x))
+        throw &quot;Error: bad result for &quot; + a + &quot;: &quot; + result + &quot;, but expected: &quot; + x + &quot;; loaded &quot; + element + &quot; from the array&quot;;
+}
+
+noInline(test);
+
+for (var i = 0; i &lt; 100000; ++i)
+    test(0, 1);
+
+test(0xFFFF0000, 0/0);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressfloat32arraynanjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/float32-array-nan.js (0 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/float32-array-nan.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/float32-array-nan.js        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+function foo(o) {
+    return o[0];
+}
+
+noInline(foo);
+
+function test(a, x) {
+    var intArray = new Int32Array(1);
+    intArray[0] = a;
+    var floatArray = new Float32Array(intArray.buffer);
+    var element = foo(floatArray);
+    var result = element + 1;
+    if ((&quot;&quot; + result) != (&quot;&quot; + x))
+        throw &quot;Error: bad result for &quot; + a + &quot;: &quot; + result + &quot;, but expected: &quot; + x + &quot;; loaded &quot; + element + &quot; from the array&quot;;
+}
+
+for (var i = 0; i &lt; 100000; ++i)
+    test(0, 1);
+
+test(0xFFFF0000, 0/0);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressfloat64arraynaninlinedjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/float64-array-nan-inlined.js (0 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/float64-array-nan-inlined.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/float64-array-nan-inlined.js        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+function foo(o) {
+    return o[0];
+}
+
+function isBigEndian() {
+    var word = new Int16Array(1);
+    word[0] = 1;
+    var bytes = new Int8Array(word.buffer);
+    return !bytes[0];
+}
+
+function test(a, b, x) {
+    var intArray = new Int32Array(2);
+    intArray[0] = a;
+    intArray[1] = b;
+    var floatArray = new Float64Array(intArray.buffer);
+    var element = foo(floatArray);
+    var result = element + 1;
+    if ((&quot;&quot; + result) != (&quot;&quot; + x))
+        throw &quot;Error: bad result for &quot; + a + &quot;, &quot; + b + &quot;: &quot; + result + &quot;, but expected: &quot; + x + &quot;; loaded &quot; + element + &quot; from the array&quot;;
+}
+
+noInline(test);
+
+for (var i = 0; i &lt; 100000; ++i)
+    test(0, 0, 1);
+
+if (isBigEndian()) {
+    test(0xFFFF0000, 0, 0/0);
+    test(0, 0xFFFF0000, 1);
+} else {
+    test(0xFFFF0000, 0, 1);
+    test(0, 0xFFFF0000, 0/0);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressfloat64arraynanjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/float64-array-nan.js (0 => 167416)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/float64-array-nan.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/float64-array-nan.js        2014-04-17 04:57:29 UTC (rev 167416)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+function foo(o) {
+    return o[0];
+}
+
+noInline(foo);
+
+function isBigEndian() {
+    var word = new Int16Array(1);
+    word[0] = 1;
+    var bytes = new Int8Array(word.buffer);
+    return !bytes[0];
+}
+
+function test(a, b, x) {
+    var intArray = new Int32Array(2);
+    intArray[0] = a;
+    intArray[1] = b;
+    var floatArray = new Float64Array(intArray.buffer);
+    var element = foo(floatArray);
+    var result = element + 1;
+    if ((&quot;&quot; + result) != (&quot;&quot; + x))
+        throw &quot;Error: bad result for &quot; + a + &quot;, &quot; + b + &quot;: &quot; + result + &quot;, but expected: &quot; + x + &quot;; loaded &quot; + element + &quot; from the array&quot;;
+}
+
+for (var i = 0; i &lt; 100000; ++i)
+    test(0, 0, 1);
+
+if (isBigEndian()) {
+    test(0xFFFF0000, 0, 0/0);
+    test(0, 0xFFFF0000, 1);
+} else {
+    test(0xFFFF0000, 0, 1);
+    test(0, 0xFFFF0000, 0/0);
+}
</ins></span></pre>
</div>
</div>

</body>
</html>