<!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>[160294] 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/160294">160294</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2013-12-08 17:06:54 -0800 (Sun, 08 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>FTL should support UntypedUse versions of Compare nodes
https://bugs.webkit.org/show_bug.cgi?id=125426

Reviewed by Oliver Hunt.
        
This adds UntypedUse versions of all comparisons except CompareStrictEq, which is
sufficiently different that I thought I'd do it in another patch.
        
This also extends our ability to abstract over comparison kind and removes a bunch of
copy-paste code.

* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLIntrinsicRepository.h:
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileCompareEq):
(JSC::FTL::LowerDFGToLLVM::compileCompareLess):
(JSC::FTL::LowerDFGToLLVM::compileCompareLessEq):
(JSC::FTL::LowerDFGToLLVM::compileCompareGreater):
(JSC::FTL::LowerDFGToLLVM::compileCompareGreaterEq):
(JSC::FTL::LowerDFGToLLVM::compare):
(JSC::FTL::LowerDFGToLLVM::nonSpeculativeCompare):
* ftl/FTLOutput.h:
(JSC::FTL::Output::icmp):
(JSC::FTL::Output::equal):
(JSC::FTL::Output::notEqual):
(JSC::FTL::Output::above):
(JSC::FTL::Output::aboveOrEqual):
(JSC::FTL::Output::below):
(JSC::FTL::Output::belowOrEqual):
(JSC::FTL::Output::greaterThan):
(JSC::FTL::Output::greaterThanOrEqual):
(JSC::FTL::Output::lessThan):
(JSC::FTL::Output::lessThanOrEqual):
(JSC::FTL::Output::fcmp):
(JSC::FTL::Output::doubleEqual):
(JSC::FTL::Output::doubleNotEqualOrUnordered):
(JSC::FTL::Output::doubleLessThan):
(JSC::FTL::Output::doubleLessThanOrEqual):
(JSC::FTL::Output::doubleGreaterThan):
(JSC::FTL::Output::doubleGreaterThanOrEqual):
(JSC::FTL::Output::doubleEqualOrUnordered):
(JSC::FTL::Output::doubleNotEqual):
(JSC::FTL::Output::doubleLessThanOrUnordered):
(JSC::FTL::Output::doubleLessThanOrEqualOrUnordered):
(JSC::FTL::Output::doubleGreaterThanOrUnordered):
(JSC::FTL::Output::doubleGreaterThanOrEqualOrUnordered):
* tests/stress/untyped-equality.js: Added.
(foo):
* tests/stress/untyped-less-than.js: Added.
(foo):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLCapabilitiescpp">trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLIntrinsicRepositoryh">trunk/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLOutputh">trunk/Source/JavaScriptCore/ftl/FTLOutput.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressuntypedequalityjs">trunk/Source/JavaScriptCore/tests/stress/untyped-equality.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressuntypedlessthanjs">trunk/Source/JavaScriptCore/tests/stress/untyped-less-than.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/ChangeLog        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2013-12-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        FTL should support UntypedUse versions of Compare nodes
+        https://bugs.webkit.org/show_bug.cgi?id=125426
+
+        Reviewed by Oliver Hunt.
+        
+        This adds UntypedUse versions of all comparisons except CompareStrictEq, which is
+        sufficiently different that I thought I'd do it in another patch.
+        
+        This also extends our ability to abstract over comparison kind and removes a bunch of
+        copy-paste code.
+
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLIntrinsicRepository.h:
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileCompareEq):
+        (JSC::FTL::LowerDFGToLLVM::compileCompareLess):
+        (JSC::FTL::LowerDFGToLLVM::compileCompareLessEq):
+        (JSC::FTL::LowerDFGToLLVM::compileCompareGreater):
+        (JSC::FTL::LowerDFGToLLVM::compileCompareGreaterEq):
+        (JSC::FTL::LowerDFGToLLVM::compare):
+        (JSC::FTL::LowerDFGToLLVM::nonSpeculativeCompare):
+        * ftl/FTLOutput.h:
+        (JSC::FTL::Output::icmp):
+        (JSC::FTL::Output::equal):
+        (JSC::FTL::Output::notEqual):
+        (JSC::FTL::Output::above):
+        (JSC::FTL::Output::aboveOrEqual):
+        (JSC::FTL::Output::below):
+        (JSC::FTL::Output::belowOrEqual):
+        (JSC::FTL::Output::greaterThan):
+        (JSC::FTL::Output::greaterThanOrEqual):
+        (JSC::FTL::Output::lessThan):
+        (JSC::FTL::Output::lessThanOrEqual):
+        (JSC::FTL::Output::fcmp):
+        (JSC::FTL::Output::doubleEqual):
+        (JSC::FTL::Output::doubleNotEqualOrUnordered):
+        (JSC::FTL::Output::doubleLessThan):
+        (JSC::FTL::Output::doubleLessThanOrEqual):
+        (JSC::FTL::Output::doubleGreaterThan):
+        (JSC::FTL::Output::doubleGreaterThanOrEqual):
+        (JSC::FTL::Output::doubleEqualOrUnordered):
+        (JSC::FTL::Output::doubleNotEqual):
+        (JSC::FTL::Output::doubleLessThanOrUnordered):
+        (JSC::FTL::Output::doubleLessThanOrEqualOrUnordered):
+        (JSC::FTL::Output::doubleGreaterThanOrUnordered):
+        (JSC::FTL::Output::doubleGreaterThanOrEqualOrUnordered):
+        * tests/stress/untyped-equality.js: Added.
+        (foo):
+        * tests/stress/untyped-less-than.js: Added.
+        (foo):
+
</ins><span class="cx"> 2013-12-07  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fold typedArray.length if typedArray is constant
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -486,6 +486,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SpeculativeJIT::nonSpeculativeNonPeepholeCompare(Node* node, MacroAssembler::RelationalCondition cond, S_JITOperation_EJJ helperFunction)
</span><span class="cx"> {
</span><ins>+    ASSERT(node-&gt;isBinaryUseKind(UntypedUse));
</ins><span class="cx">     JSValueOperand arg1(this, node-&gt;child1());
</span><span class="cx">     JSValueOperand arg2(this, node-&gt;child2());
</span><span class="cx">     GPRReg arg1GPR = arg1.gpr();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -179,6 +179,17 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case CompareEq:
</span><ins>+        if (node-&gt;isBinaryUseKind(Int32Use))
+            break;
+        if (node-&gt;isBinaryUseKind(MachineIntUse))
+            break;
+        if (node-&gt;isBinaryUseKind(NumberUse))
+            break;
+        if (node-&gt;isBinaryUseKind(ObjectUse))
+            break;
+        if (node-&gt;isBinaryUseKind(UntypedUse))
+            break;
+        return CannotCompile;
</ins><span class="cx">     case CompareStrictEq:
</span><span class="cx">         if (node-&gt;isBinaryUseKind(Int32Use))
</span><span class="cx">             break;
</span><span class="lines">@@ -199,6 +210,8 @@
</span><span class="cx">             break;
</span><span class="cx">         if (node-&gt;isBinaryUseKind(NumberUse))
</span><span class="cx">             break;
</span><ins>+        if (node-&gt;isBinaryUseKind(UntypedUse))
+            break;
</ins><span class="cx">         return CannotCompile;
</span><span class="cx">     case Switch:
</span><span class="cx">         switch (node-&gt;switchData()-&gt;kind) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLIntrinsicRepositoryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx">     macro(P_JITOperation_EStSS, functionType(intPtr, intPtr, intPtr, intPtr, intPtr)) \
</span><span class="cx">     macro(P_JITOperation_EStZ, functionType(intPtr, intPtr, intPtr, int32)) \
</span><span class="cx">     macro(S_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \
</span><ins>+    macro(S_JITOperation_EJJ, functionType(intPtr, intPtr, int64, int64)) \
</ins><span class="cx">     macro(V_JITOperation_EJJJ, functionType(voidType, intPtr, int64, int64, int64)) \
</span><span class="cx">     macro(V_JITOperation_EOZD, functionType(voidType, intPtr, intPtr, int32, doubleType)) \
</span><span class="cx">     macro(V_JITOperation_EOZJ, functionType(voidType, intPtr, intPtr, int32, int64)) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -2396,6 +2396,11 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        if (m_node-&gt;isBinaryUseKind(UntypedUse)) {
+            nonSpeculativeCompare(LLVMIntEQ, operationCompareEq);
+            return;
+        }
+        
</ins><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -2464,106 +2469,22 @@
</span><span class="cx">     
</span><span class="cx">     void compileCompareLess()
</span><span class="cx">     {
</span><del>-        if (m_node-&gt;isBinaryUseKind(Int32Use)) {
-            setBoolean(
-                m_out.lessThan(lowInt32(m_node-&gt;child1()), lowInt32(m_node-&gt;child2())));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(MachineIntUse)) {
-            Int52Kind kind;
-            LValue left = lowWhicheverInt52(m_node-&gt;child1(), kind);
-            LValue right = lowInt52(m_node-&gt;child2(), kind);
-            setBoolean(m_out.lessThan(left, right));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(NumberUse)) {
-            setBoolean(
-                m_out.doubleLessThan(lowDouble(m_node-&gt;child1()), lowDouble(m_node-&gt;child2())));
-            return;
-        }
-        
-        RELEASE_ASSERT_NOT_REACHED();
</del><ins>+        compare(LLVMIntSLT, LLVMRealOLT, operationCompareLess);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void compileCompareLessEq()
</span><span class="cx">     {
</span><del>-        if (m_node-&gt;isBinaryUseKind(Int32Use)) {
-            setBoolean(
-                m_out.lessThanOrEqual(lowInt32(m_node-&gt;child1()), lowInt32(m_node-&gt;child2())));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(MachineIntUse)) {
-            Int52Kind kind;
-            LValue left = lowWhicheverInt52(m_node-&gt;child1(), kind);
-            LValue right = lowInt52(m_node-&gt;child2(), kind);
-            setBoolean(m_out.lessThanOrEqual(left, right));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(NumberUse)) {
-            setBoolean(
-                m_out.doubleLessThanOrEqual(
-                    lowDouble(m_node-&gt;child1()), lowDouble(m_node-&gt;child2())));
-            return;
-        }
-        
-        RELEASE_ASSERT_NOT_REACHED();
</del><ins>+        compare(LLVMIntSLE, LLVMRealOLE, operationCompareLessEq);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void compileCompareGreater()
</span><span class="cx">     {
</span><del>-        if (m_node-&gt;isBinaryUseKind(Int32Use)) {
-            setBoolean(
-                m_out.greaterThan(lowInt32(m_node-&gt;child1()), lowInt32(m_node-&gt;child2())));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(MachineIntUse)) {
-            Int52Kind kind;
-            LValue left = lowWhicheverInt52(m_node-&gt;child1(), kind);
-            LValue right = lowInt52(m_node-&gt;child2(), kind);
-            setBoolean(m_out.greaterThan(left, right));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(NumberUse)) {
-            setBoolean(
-                m_out.doubleGreaterThan(
-                    lowDouble(m_node-&gt;child1()), lowDouble(m_node-&gt;child2())));
-            return;
-        }
-        
-        RELEASE_ASSERT_NOT_REACHED();
</del><ins>+        compare(LLVMIntSGT, LLVMRealOGT, operationCompareGreater);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void compileCompareGreaterEq()
</span><span class="cx">     {
</span><del>-        if (m_node-&gt;isBinaryUseKind(Int32Use)) {
-            setBoolean(
-                m_out.greaterThanOrEqual(
-                    lowInt32(m_node-&gt;child1()), lowInt32(m_node-&gt;child2())));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(MachineIntUse)) {
-            Int52Kind kind;
-            LValue left = lowWhicheverInt52(m_node-&gt;child1(), kind);
-            LValue right = lowInt52(m_node-&gt;child2(), kind);
-            setBoolean(m_out.greaterThanOrEqual(left, right));
-            return;
-        }
-        
-        if (m_node-&gt;isBinaryUseKind(NumberUse)) {
-            setBoolean(
-                m_out.doubleGreaterThanOrEqual(
-                    lowDouble(m_node-&gt;child1()), lowDouble(m_node-&gt;child2())));
-            return;
-        }
-        
-        RELEASE_ASSERT_NOT_REACHED();
</del><ins>+        compare(LLVMIntSGE, LLVMRealOGE, operationCompareGreaterEq);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void compileLogicalNot()
</span><span class="lines">@@ -2800,6 +2721,69 @@
</span><span class="cx">             m_state.forNode(edge).m_value);
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    void compare(
+        LIntPredicate intCondition, LRealPredicate realCondition,
+        S_JITOperation_EJJ helperFunction)
+    {
+        if (m_node-&gt;isBinaryUseKind(Int32Use)) {
+            LValue left = lowInt32(m_node-&gt;child1());
+            LValue right = lowInt32(m_node-&gt;child2());
+            setBoolean(m_out.icmp(intCondition, left, right));
+            return;
+        }
+        
+        if (m_node-&gt;isBinaryUseKind(MachineIntUse)) {
+            Int52Kind kind;
+            LValue left = lowWhicheverInt52(m_node-&gt;child1(), kind);
+            LValue right = lowInt52(m_node-&gt;child2(), kind);
+            setBoolean(m_out.icmp(intCondition, left, right));
+            return;
+        }
+        
+        if (m_node-&gt;isBinaryUseKind(NumberUse)) {
+            LValue left = lowDouble(m_node-&gt;child1());
+            LValue right = lowDouble(m_node-&gt;child2());
+            setBoolean(m_out.fcmp(realCondition, left, right));
+            return;
+        }
+        
+        if (m_node-&gt;isBinaryUseKind(UntypedUse)) {
+            nonSpeculativeCompare(intCondition, helperFunction);
+            return;
+        }
+        
+        RELEASE_ASSERT_NOT_REACHED();
+    }
+    
+    void nonSpeculativeCompare(LIntPredicate intCondition, S_JITOperation_EJJ helperFunction)
+    {
+        LValue left = lowJSValue(m_node-&gt;child1());
+        LValue right = lowJSValue(m_node-&gt;child2());
+        
+        LBasicBlock leftIsInt = FTL_NEW_BLOCK(m_out, (&quot;CompareEq untyped left is int&quot;));
+        LBasicBlock fastPath = FTL_NEW_BLOCK(m_out, (&quot;CompareEq untyped fast path&quot;));
+        LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, (&quot;CompareEq untyped slow path&quot;));
+        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;CompareEq untyped continuation&quot;));
+        
+        m_out.branch(isNotInt32(left), slowPath, leftIsInt);
+        
+        LBasicBlock lastNext = m_out.appendTo(leftIsInt, fastPath);
+        m_out.branch(isNotInt32(right), slowPath, fastPath);
+        
+        m_out.appendTo(fastPath, slowPath);
+        ValueFromBlock fastResult = m_out.anchor(
+            m_out.icmp(intCondition, unboxInt32(left), unboxInt32(right)));
+        m_out.jump(continuation);
+        
+        m_out.appendTo(slowPath, continuation);
+        ValueFromBlock slowResult = m_out.anchor(m_out.notNull(vmCall(
+            m_out.operation(helperFunction), m_callFrame, left, right)));
+        m_out.jump(continuation);
+        
+        m_out.appendTo(continuation, lastNext);
+        setBoolean(m_out.phi(m_out.boolean, fastResult, slowResult));
+    }
+    
</ins><span class="cx">     LValue allocateCell(LValue allocator, LValue structure, LBasicBlock slowPath)
</span><span class="cx">     {
</span><span class="cx">         LBasicBlock success = FTL_NEW_BLOCK(m_out, (&quot;object allocation success&quot;));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLOutputh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLOutput.h (160293 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLOutput.h        2013-12-08 20:09:09 UTC (rev 160293)
+++ trunk/Source/JavaScriptCore/ftl/FTLOutput.h        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -314,29 +314,31 @@
</span><span class="cx">     void storePtr(LValue value, LValue base, const AbstractField&amp; field) { storePtr(value, address(base, field)); }
</span><span class="cx">     void storeDouble(LValue value, LValue base, const AbstractField&amp; field) { storeDouble(value, address(base, field)); }
</span><span class="cx">     
</span><del>-    LValue equal(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntEQ, left, right); }
-    LValue notEqual(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntNE, left, right); }
-    LValue above(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntUGT, left, right); }
-    LValue aboveOrEqual(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntUGE, left, right); }
-    LValue below(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntULT, left, right); }
-    LValue belowOrEqual(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntULE, left, right); }
-    LValue greaterThan(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntSGT, left, right); }
-    LValue greaterThanOrEqual(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntSGE, left, right); }
-    LValue lessThan(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntSLT, left, right); }
-    LValue lessThanOrEqual(LValue left, LValue right) { return buildICmp(m_builder, LLVMIntSLE, left, right); }
</del><ins>+    LValue icmp(LIntPredicate cond, LValue left, LValue right) { return buildICmp(m_builder, cond, left, right); }
+    LValue equal(LValue left, LValue right) { return icmp(LLVMIntEQ, left, right); }
+    LValue notEqual(LValue left, LValue right) { return icmp(LLVMIntNE, left, right); }
+    LValue above(LValue left, LValue right) { return icmp(LLVMIntUGT, left, right); }
+    LValue aboveOrEqual(LValue left, LValue right) { return icmp(LLVMIntUGE, left, right); }
+    LValue below(LValue left, LValue right) { return icmp(LLVMIntULT, left, right); }
+    LValue belowOrEqual(LValue left, LValue right) { return icmp(LLVMIntULE, left, right); }
+    LValue greaterThan(LValue left, LValue right) { return icmp(LLVMIntSGT, left, right); }
+    LValue greaterThanOrEqual(LValue left, LValue right) { return icmp(LLVMIntSGE, left, right); }
+    LValue lessThan(LValue left, LValue right) { return icmp(LLVMIntSLT, left, right); }
+    LValue lessThanOrEqual(LValue left, LValue right) { return icmp(LLVMIntSLE, left, right); }
</ins><span class="cx">     
</span><del>-    LValue doubleEqual(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealOEQ, left, right); }
-    LValue doubleNotEqualOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealUNE, left, right); }
-    LValue doubleLessThan(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealOLT, left, right); }
-    LValue doubleLessThanOrEqual(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealOLE, left, right); }
-    LValue doubleGreaterThan(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealOGT, left, right); }
-    LValue doubleGreaterThanOrEqual(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealOGE, left, right); }
-    LValue doubleEqualOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealUEQ, left, right); }
-    LValue doubleNotEqual(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealONE, left, right); }
-    LValue doubleLessThanOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealULT, left, right); }
-    LValue doubleLessThanOrEqualOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealULE, left, right); }
-    LValue doubleGreaterThanOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealUGT, left, right); }
-    LValue doubleGreaterThanOrEqualOrUnordered(LValue left, LValue right) { return buildFCmp(m_builder, LLVMRealUGE, left, right); }
</del><ins>+    LValue fcmp(LRealPredicate cond, LValue left, LValue right) { return buildFCmp(m_builder, cond, left, right); }
+    LValue doubleEqual(LValue left, LValue right) { return fcmp(LLVMRealOEQ, left, right); }
+    LValue doubleNotEqualOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealUNE, left, right); }
+    LValue doubleLessThan(LValue left, LValue right) { return fcmp(LLVMRealOLT, left, right); }
+    LValue doubleLessThanOrEqual(LValue left, LValue right) { return fcmp(LLVMRealOLE, left, right); }
+    LValue doubleGreaterThan(LValue left, LValue right) { return fcmp(LLVMRealOGT, left, right); }
+    LValue doubleGreaterThanOrEqual(LValue left, LValue right) { return fcmp(LLVMRealOGE, left, right); }
+    LValue doubleEqualOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealUEQ, left, right); }
+    LValue doubleNotEqual(LValue left, LValue right) { return fcmp(LLVMRealONE, left, right); }
+    LValue doubleLessThanOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealULT, left, right); }
+    LValue doubleLessThanOrEqualOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealULE, left, right); }
+    LValue doubleGreaterThanOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealUGT, left, right); }
+    LValue doubleGreaterThanOrEqualOrUnordered(LValue left, LValue right) { return fcmp(LLVMRealUGE, left, right); }
</ins><span class="cx">     
</span><span class="cx">     LValue isZero8(LValue value) { return equal(value, int8Zero); }
</span><span class="cx">     LValue notZero8(LValue value) { return notEqual(value, int8Zero); }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressuntypedequalityjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/untyped-equality.js (0 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/untyped-equality.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/untyped-equality.js        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+function foo(a, b) {
+    return a == b;
+}
+
+noInline(foo);
+
+var data = [
+    [5, 6.5, false],
+    [&quot;foo&quot;, &quot;bar&quot;, false],
+    [true, false, false],
+    [&quot;42&quot;, 42, true],
+    [1.2, 1.2, true]
+];
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var test = data[i % data.length];
+    var result = foo(test[0], test[1]);
+    if (result != test[2])
+        throw &quot;Error: bad result for &quot; + test + &quot;: &quot; + result;
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressuntypedlessthanjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/untyped-less-than.js (0 => 160294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/untyped-less-than.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/untyped-less-than.js        2013-12-09 01:06:54 UTC (rev 160294)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+function foo(a, b) {
+    return a &lt; b;
+}
+
+noInline(foo);
+
+var data = [
+    [5, 6.5, true],
+    [&quot;foo&quot;, &quot;bar&quot;, false],
+    [true, false, false],
+    [false, true, true],
+    [&quot;42&quot;, 42, false],
+    [1.2, 1.2, false],
+    [&quot;-1&quot;, 1, true],
+    [-1, &quot;1&quot;, true]
+];
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var test = data[i % data.length];
+    var result = foo(test[0], test[1]);
+    if (result != test[2])
+        throw &quot;Error: bad result for &quot; + test + &quot;: &quot; + result;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>