<!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>[185920] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185920">185920</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-24 12:13:54 -0700 (Wed, 24 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Strict Equality on objects should only check that one of the two sides is an object.
https://bugs.webkit.org/show_bug.cgi?id=145992

Source/JavaScriptCore:

This patch adds a new optimization for checking strict equality on objects.
If we speculate that a strict equality comparison has an object on one side
we only need to type check that side. Equality is then determined by a pointer
comparison between the two values (although in the 32-bit case we must also check
that the other side is a cell). Once LICM hoists type checks out of a loop we
can be cleverer about how we choose the operand we type check if both are
speculated to be objects.

For testing I added the addressOf function, which returns the address
of a Cell to the runtime.

Patch by Keith Miller &lt;keith_miller@apple.com&gt; on 2015-06-24
Reviewed by Mark Lam.

* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileStrictEq):
* dfg/DFGSpeculativeJIT.h:
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compileObjectStrictEquality):
(JSC::DFG::SpeculativeJIT::compilePeepHoleObjectStrictEquality):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compileObjectStrictEquality):
(JSC::DFG::SpeculativeJIT::compilePeepHoleObjectStrictEquality):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::compileCompareStrictEq):
* jsc.cpp:
(GlobalObject::finishCreation):
(functionAddressOf):
* tests/stress/equality-type-checking.js: Added.
(Foo):
(checkStrictEq):
(checkStrictEqOther):

LayoutTests:

Patch by Keith Miller &lt;keith_miller@apple.com&gt; on 2015-06-24
Reviewed by Mark Lam.

Adds a test that checks if strict equality checks with objects properly exit out of DFG code when
dealing with document.all, which is an object that masquerades as undefined.

* js/dom/document-all-strict-eq-expected.txt: Added.
* js/dom/document-all-strict-eq.html: Added.
* js/dom/script-tests/document-all-strict-eq.js: Added.
(f):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGFixupPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLCapabilitiescpp">trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsdomdocumentallstricteqexpectedtxt">trunk/LayoutTests/js/dom/document-all-strict-eq-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomdocumentallstricteqhtml">trunk/LayoutTests/js/dom/document-all-strict-eq.html</a></li>
<li><a href="#trunkLayoutTestsjsdomscripttestsdocumentallstricteqjs">trunk/LayoutTests/js/dom/script-tests/document-all-strict-eq.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressequalitytypecheckingjs">trunk/Source/JavaScriptCore/tests/stress/equality-type-checking.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/LayoutTests/ChangeLog        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-06-24  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Strict Equality on objects should only check that one of the two sides is an object.
+        https://bugs.webkit.org/show_bug.cgi?id=145992
+
+        Reviewed by Mark Lam.
+
+        Adds a test that checks if strict equality checks with objects properly exit out of DFG code when
+        dealing with document.all, which is an object that masquerades as undefined.
+
+        * js/dom/document-all-strict-eq-expected.txt: Added.
+        * js/dom/document-all-strict-eq.html: Added.
+        * js/dom/script-tests/document-all-strict-eq.js: Added.
+        (f):
+
</ins><span class="cx"> 2015-06-24  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Test gardening for fast/text/font-weight{,-zh}.html
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomdocumentallstricteqexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/dom/document-all-strict-eq-expected.txt (0 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/document-all-strict-eq-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/dom/document-all-strict-eq-expected.txt        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test to make sure that document.all works properly with strict eq in the DFG
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+document.all was undefined
+PASS f(testObj, document.all) is false
+PASS f(document.all, document.all) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsdomdocumentallstricteqhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/dom/document-all-strict-eq.html (0 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/document-all-strict-eq.html                                (rev 0)
+++ trunk/LayoutTests/js/dom/document-all-strict-eq.html        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;script-tests/document-all-strict-eq.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsdomscripttestsdocumentallstricteqjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/dom/script-tests/document-all-strict-eq.js (0 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/script-tests/document-all-strict-eq.js                                (rev 0)
+++ trunk/LayoutTests/js/dom/script-tests/document-all-strict-eq.js        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+description(&quot;Test to make sure that document.all works properly with strict eq in the DFG&quot;);
+
+var f = function(a, b) {
+    return a === b
+
+}
+noInline(f);
+
+var testObj = {};
+
+// Warm up f to dfg the code before the masqueradesAsUndefined watchpoint fires
+for (var i = 0; i &lt; 1000; i++) {
+    if (!f(testObj,testObj))
+        testFailed(&quot;f(testObj,testObj) should have been true but got false&quot;);}
+
+
+
+if (undefined == document.all) {
+    debug(&quot;document.all was undefined&quot;);
+    shouldBe(&quot;f(testObj, document.all)&quot;, &quot;false&quot;);
+
+    // Get JIT to recompile the jettisoned code after watchpoint fired
+    for (var i = 0; i &lt; 1000; i++) {
+        if (!f(testObj,testObj))
+            testFailed(&quot;f(testObj,testObj) should have been true but got false&quot;);
+    }
+
+    shouldBe(&quot;f(document.all, document.all)&quot;, &quot;true&quot;);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2015-06-24  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Strict Equality on objects should only check that one of the two sides is an object.
+        https://bugs.webkit.org/show_bug.cgi?id=145992
+
+        This patch adds a new optimization for checking strict equality on objects.
+        If we speculate that a strict equality comparison has an object on one side
+        we only need to type check that side. Equality is then determined by a pointer
+        comparison between the two values (although in the 32-bit case we must also check
+        that the other side is a cell). Once LICM hoists type checks out of a loop we
+        can be cleverer about how we choose the operand we type check if both are
+        speculated to be objects.
+
+        For testing I added the addressOf function, which returns the address
+        of a Cell to the runtime.
+
+        Reviewed by Mark Lam.
+
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileStrictEq):
+        * dfg/DFGSpeculativeJIT.h:
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compileObjectStrictEquality):
+        (JSC::DFG::SpeculativeJIT::compilePeepHoleObjectStrictEquality):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compileObjectStrictEquality):
+        (JSC::DFG::SpeculativeJIT::compilePeepHoleObjectStrictEquality):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileCompareStrictEq):
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionAddressOf):
+        * tests/stress/equality-type-checking.js: Added.
+        (Foo):
+        (checkStrictEq):
+        (checkStrictEqOther):
+
</ins><span class="cx"> 2015-06-24  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fixed assertion in JSStringJoiner::join() (regression from r185899).
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -471,7 +471,21 @@
</span><span class="cx">                 fixEdge&lt;StringUse&gt;(node-&gt;child2());
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><del>-            if (node-&gt;child1()-&gt;shouldSpeculateObject() &amp;&amp; node-&gt;child2()-&gt;shouldSpeculateObject()) {
</del><ins>+            WatchpointSet* masqueradesAsUndefinedWatchpoint = m_graph.globalObjectFor(node-&gt;origin.semantic)-&gt;masqueradesAsUndefinedWatchpoint();
+            if (masqueradesAsUndefinedWatchpoint-&gt;isStillValid()) {
+                
+                if (node-&gt;child1()-&gt;shouldSpeculateObject()) {
+                    m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
+                    fixEdge&lt;ObjectUse&gt;(node-&gt;child1());
+                    break;
+                }
+                if (node-&gt;child2()-&gt;shouldSpeculateObject()) {
+                    m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
+                    fixEdge&lt;ObjectUse&gt;(node-&gt;child2());
+                    break;
+                }
+                
+            } else if (node-&gt;child1()-&gt;shouldSpeculateObject() &amp;&amp; node-&gt;child2()-&gt;shouldSpeculateObject()) {
</ins><span class="cx">                 fixEdge&lt;ObjectUse&gt;(node-&gt;child1());
</span><span class="cx">                 fixEdge&lt;ObjectUse&gt;(node-&gt;child2());
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -3915,6 +3915,36 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (node-&gt;isBinaryUseKind(ObjectUse, UntypedUse)) {
+        unsigned branchIndexInBlock = detectPeepHoleBranch();
+        if (branchIndexInBlock != UINT_MAX) {
+            Node* branchNode = m_block-&gt;at(branchIndexInBlock);
+            compilePeepHoleObjectStrictEquality(node-&gt;child1(), node-&gt;child2(), branchNode);
+            use(node-&gt;child1());
+            use(node-&gt;child2());
+            m_indexInBlock = branchIndexInBlock;
+            m_currentNode = branchNode;
+            return true;
+        }
+        compileObjectStrictEquality(node-&gt;child1(), node-&gt;child2());
+        return false;
+    }
+    
+    if (node-&gt;isBinaryUseKind(UntypedUse, ObjectUse)) {
+        unsigned branchIndexInBlock = detectPeepHoleBranch();
+        if (branchIndexInBlock != UINT_MAX) {
+            Node* branchNode = m_block-&gt;at(branchIndexInBlock);
+            compilePeepHoleObjectStrictEquality(node-&gt;child2(), node-&gt;child1(), branchNode);
+            use(node-&gt;child1());
+            use(node-&gt;child2());
+            m_indexInBlock = branchIndexInBlock;
+            m_currentNode = branchNode;
+            return true;
+        }
+        compileObjectStrictEquality(node-&gt;child2(), node-&gt;child1());
+        return false;
+    }
+
</ins><span class="cx">     if (node-&gt;isBinaryUseKind(ObjectUse)) {
</span><span class="cx">         unsigned branchIndexInBlock = detectPeepHoleBranch();
</span><span class="cx">         if (branchIndexInBlock != UINT_MAX) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -2088,8 +2088,10 @@
</span><span class="cx">     void compilePeepHoleBooleanBranch(Node*, Node* branchNode, JITCompiler::RelationalCondition);
</span><span class="cx">     void compilePeepHoleDoubleBranch(Node*, Node* branchNode, JITCompiler::DoubleCondition);
</span><span class="cx">     void compilePeepHoleObjectEquality(Node*, Node* branchNode);
</span><ins>+    void compilePeepHoleObjectStrictEquality(Edge objectChild, Edge otherChild, Node* branchNode);
</ins><span class="cx">     void compilePeepHoleObjectToObjectOrOtherEquality(Edge leftChild, Edge rightChild, Node* branchNode);
</span><span class="cx">     void compileObjectEquality(Node*);
</span><ins>+    void compileObjectStrictEquality(Edge objectChild, Edge otherChild);
</ins><span class="cx">     void compileObjectToObjectOrOtherEquality(Edge leftChild, Edge rightChild);
</span><span class="cx">     void compileObjectOrOtherLogicalNot(Edge value);
</span><span class="cx">     void compileLogicalNot(Node*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -1184,6 +1184,57 @@
</span><span class="cx">     booleanResult(resultPayloadGPR, node);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::compileObjectStrictEquality(Edge objectChild, Edge otherChild)
+{
+    SpeculateCellOperand op1(this, objectChild);
+    JSValueOperand op2(this, otherChild);
+
+    GPRReg op1GPR = op1.gpr();
+    GPRReg op2GPR = op2.payloadGPR();
+
+    DFG_TYPE_CHECK(JSValueSource::unboxedCell(op1GPR), objectChild, SpecObject, m_jit.branchIfNotObject(op1GPR));
+
+    GPRTemporary resultPayload(this, Reuse, op1);
+    GPRReg resultPayloadGPR = resultPayload.gpr();
+    
+    MacroAssembler::Jump op2CellJump = m_jit.branchIfCell(op2.jsValueRegs());
+    
+    m_jit.move(TrustedImm32(0), resultPayloadGPR);
+    MacroAssembler::Jump op2NotCellJump = m_jit.jump();
+    
+    // At this point we know that we can perform a straight-forward equality comparison on pointer
+    // values because we are doing strict equality.
+    op2CellJump.link(&amp;m_jit);
+    m_jit.compare32(MacroAssembler::Equal, op1GPR, op2GPR, resultPayloadGPR);
+    
+    op2NotCellJump.link(&amp;m_jit);
+    booleanResult(resultPayloadGPR, m_currentNode);
+}
+    
+void SpeculativeJIT::compilePeepHoleObjectStrictEquality(Edge objectChild, Edge otherChild, Node* branchNode)
+{
+    BasicBlock* taken = branchNode-&gt;branchData()-&gt;taken.block;
+    BasicBlock* notTaken = branchNode-&gt;branchData()-&gt;notTaken.block;
+
+    SpeculateCellOperand op1(this, objectChild);
+    JSValueOperand op2(this, otherChild);
+    
+    GPRReg op1GPR = op1.gpr();
+    GPRReg op2GPR = op2.payloadGPR();
+
+    DFG_TYPE_CHECK(JSValueSource::unboxedCell(op1GPR), objectChild, SpecObject, m_jit.branchIfNotObject(op1GPR));
+
+    branch32(MacroAssembler::NotEqual, op2.tagGPR(), TrustedImm32(JSValue::CellTag), notTaken);
+    
+    if (taken == nextBlock()) {
+        branch32(MacroAssembler::NotEqual, op1GPR, op2GPR, notTaken);
+        jump(taken);
+    } else {
+        branch32(MacroAssembler::Equal, op1GPR, op2GPR, taken);
+        jump(notTaken);
+    }
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileObjectToObjectOrOtherEquality(Edge leftChild, Edge rightChild)
</span><span class="cx"> {
</span><span class="cx">     SpeculateCellOperand op1(this, leftChild);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -1296,6 +1296,47 @@
</span><span class="cx">     jsValueResult(resultGPR, m_currentNode, DataFormatJSBoolean);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::compileObjectStrictEquality(Edge objectChild, Edge otherChild)
+{
+    SpeculateCellOperand op1(this, objectChild);
+    JSValueOperand op2(this, otherChild);
+    GPRTemporary result(this);
+
+    GPRReg op1GPR = op1.gpr();
+    GPRReg op2GPR = op2.gpr();
+    GPRReg resultGPR = result.gpr();
+
+    DFG_TYPE_CHECK(JSValueSource::unboxedCell(op1GPR), objectChild, SpecObject, m_jit.branchIfNotObject(op1GPR));
+
+    // At this point we know that we can perform a straight-forward equality comparison on pointer
+    // values because we are doing strict equality.
+    m_jit.compare64(MacroAssembler::Equal, op1GPR, op2GPR, resultGPR);
+    m_jit.or32(TrustedImm32(ValueFalse), resultGPR);
+    jsValueResult(resultGPR, m_currentNode, DataFormatJSBoolean);
+}
+    
+void SpeculativeJIT::compilePeepHoleObjectStrictEquality(Edge objectChild, Edge otherChild, Node* branchNode)
+{
+    BasicBlock* taken = branchNode-&gt;branchData()-&gt;taken.block;
+    BasicBlock* notTaken = branchNode-&gt;branchData()-&gt;notTaken.block;
+    
+    SpeculateCellOperand op1(this, objectChild);
+    JSValueOperand op2(this, otherChild);
+    
+    GPRReg op1GPR = op1.gpr();
+    GPRReg op2GPR = op2.gpr();
+    
+    DFG_TYPE_CHECK(JSValueSource::unboxedCell(op1GPR), objectChild, SpecObject, m_jit.branchIfNotObject(op1GPR));
+
+    if (taken == nextBlock()) {
+        branchPtr(MacroAssembler::NotEqual, op1GPR, op2GPR, notTaken);
+        jump(taken);
+    } else {
+        branchPtr(MacroAssembler::Equal, op1GPR, op2GPR, taken);
+        jump(notTaken);
+    }
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileObjectToObjectOrOtherEquality(Edge leftChild, Edge rightChild)
</span><span class="cx"> {
</span><span class="cx">     SpeculateCellOperand op1(this, leftChild);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -329,6 +329,10 @@
</span><span class="cx">             break;
</span><span class="cx">         if (node-&gt;isBinaryUseKind(StringIdentUse))
</span><span class="cx">             break;
</span><ins>+        if (node-&gt;isBinaryUseKind(ObjectUse, UntypedUse))
+            break;
+        if (node-&gt;isBinaryUseKind(UntypedUse, ObjectUse))
+            break;
</ins><span class="cx">         if (node-&gt;isBinaryUseKind(ObjectUse))
</span><span class="cx">             break;
</span><span class="cx">         if (node-&gt;isBinaryUseKind(BooleanUse))
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -4157,7 +4157,23 @@
</span><span class="cx">                 m_out.equal(lowStringIdent(m_node-&gt;child1()), lowStringIdent(m_node-&gt;child2())));
</span><span class="cx">             return;
</span><span class="cx">         }
</span><ins>+
+        if (m_node-&gt;isBinaryUseKind(ObjectUse, UntypedUse)) {
+            setBoolean(
+                m_out.equal(
+                    lowNonNullObject(m_node-&gt;child1()),
+                    lowJSValue(m_node-&gt;child2())));
+            return;
+        }
</ins><span class="cx">         
</span><ins>+        if (m_node-&gt;isBinaryUseKind(UntypedUse, ObjectUse)) {
+            setBoolean(
+                m_out.equal(
+                    lowNonNullObject(m_node-&gt;child2()),
+                    lowJSValue(m_node-&gt;child1())));
+            return;
+        }
+
</ins><span class="cx">         if (m_node-&gt;isBinaryUseKind(ObjectUse)) {
</span><span class="cx">             setBoolean(
</span><span class="cx">                 m_out.equal(
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (185919 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2015-06-24 19:08:09 UTC (rev 185919)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -458,6 +458,7 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionEdenGC(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionHeapSize(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionDeleteAllCompiledCode(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL functionAddressOf(ExecState*);
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionReleaseExecutableMemory(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionDumpCallFrame(ExecState*);
</span><span class="lines">@@ -599,6 +600,7 @@
</span><span class="cx">         addFunction(vm, &quot;edenGC&quot;, functionEdenGC, 0);
</span><span class="cx">         addFunction(vm, &quot;gcHeapSize&quot;, functionHeapSize, 0);
</span><span class="cx">         addFunction(vm, &quot;deleteAllCompiledCode&quot;, functionDeleteAllCompiledCode, 0);
</span><ins>+        addFunction(vm, &quot;addressOf&quot;, functionAddressOf, 1);
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx">         addFunction(vm, &quot;dumpCallFrame&quot;, functionDumpCallFrame, 0);
</span><span class="cx">         addFunction(vm, &quot;releaseExecutableMemory&quot;, functionReleaseExecutableMemory, 0);
</span><span class="lines">@@ -877,6 +879,21 @@
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// This function is not generally very helpful in 64-bit code as the tag and payload
+// share a register. But in 32-bit JITed code the tag may not be checked if an
+// optimization removes type checking requirements, such as in ===.
+EncodedJSValue JSC_HOST_CALL functionAddressOf(ExecState* exec)
+{
+    JSValue value = exec-&gt;argument(0);
+    if (!value.isCell())
+        return JSValue::encode(jsUndefined());
+    // Need to cast to uint64_t so bitwise_cast will play along.
+    uint64_t asNumber = reinterpret_cast&lt;uint64_t&gt;(value.asCell());
+    EncodedJSValue returnValue = JSValue::encode(jsNumber(bitwise_cast&lt;double&gt;(asNumber)));
+    return returnValue;
+}
+
+
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL functionReleaseExecutableMemory(ExecState* exec)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressequalitytypecheckingjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/equality-type-checking.js (0 => 185920)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/equality-type-checking.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/equality-type-checking.js        2015-06-24 19:13:54 UTC (rev 185920)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+/***
+ * There was a bug on 32-bit builds where === with objects would not check the tag
+ * when determining equality via pointer comparison.
+ */
+
+&quot;use strict&quot;;
+
+function Foo() {}
+
+function checkStrictEq(a, b) {
+    return a === b;
+}
+noInline(checkStrictEq);
+
+function checkStrictEqOther(a, b) {
+    return a === b;
+}
+noInline(checkStrictEqOther);
+
+var foo = new Foo();
+var address = addressOf(foo);
+
+if (address === undefined)
+    throw &quot;Error: address should not be undefined&quot;;
+
+if (foo === address || address === foo)
+    throw &quot;Error: an address should not be equal to it's object&quot;;
+
+for (var i = 0; i &lt; 10000000; i++) {
+    if (checkStrictEq(foo, address))
+        throw &quot;Error: an address should not be equal to it's object&quot;;
+    if (checkStrictEqOther(address,foo))
+        throw &quot;Error: an address should not be equal to it's object&quot;;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>