<!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>[170907] branches/ftlopt/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/170907">170907</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-07-08 20:00:27 -0700 (Tue, 08 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[ftlopt] Phantom simplification should be in its own phase
https://bugs.webkit.org/show_bug.cgi?id=134742

Reviewed by Geoffrey Garen.
        
This moves Phantom simplification out of CSE, which greatly simplifies CSE and gives it
more focus. Also this finally adds a phase that removes empty Phantoms. We sort of had
this in CPSRethreading, but that phase runs too infrequently and doesn't run at all for
SSA.

* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* dfg/DFGAdjacencyList.h:
* dfg/DFGCSEPhase.cpp:
(JSC::DFG::CSEPhase::run):
(JSC::DFG::CSEPhase::setReplacement):
(JSC::DFG::CSEPhase::eliminate):
(JSC::DFG::CSEPhase::performNodeCSE):
(JSC::DFG::CSEPhase::eliminateIrrelevantPhantomChildren): Deleted.
* dfg/DFGPhantomRemovalPhase.cpp: Added.
(JSC::DFG::PhantomRemovalPhase::PhantomRemovalPhase):
(JSC::DFG::PhantomRemovalPhase::run):
(JSC::DFG::performCleanUp):
* dfg/DFGPhantomRemovalPhase.h: Added.
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::compileInThreadImpl):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesftloptSourceJavaScriptCoreCMakeListstxt">branches/ftlopt/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoreChangeLog">branches/ftlopt/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoredfgDFGAdjacencyListh">branches/ftlopt/Source/JavaScriptCore/dfg/DFGAdjacencyList.h</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoredfgDFGCSEPhasecpp">branches/ftlopt/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoredfgDFGPlancpp">branches/ftlopt/Source/JavaScriptCore/dfg/DFGPlan.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchesftloptSourceJavaScriptCoredfgDFGPhantomRemovalPhasecpp">branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.cpp</a></li>
<li><a href="#branchesftloptSourceJavaScriptCoredfgDFGPhantomRemovalPhaseh">branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesftloptSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/CMakeLists.txt (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/CMakeLists.txt        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/CMakeLists.txt        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx">     dfg/DFGOSRExitJumpPlaceholder.cpp
</span><span class="cx">     dfg/DFGOSRExitPreparation.cpp
</span><span class="cx">     dfg/DFGOperations.cpp
</span><ins>+    dfg/DFGPhantomRemovalPhase.cpp
</ins><span class="cx">     dfg/DFGPhase.cpp
</span><span class="cx">     dfg/DFGPlan.cpp
</span><span class="cx">     dfg/DFGPredictionInjectionPhase.cpp
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/ChangeLog (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/ChangeLog        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/ChangeLog        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2014-07-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [ftlopt] Phantom simplification should be in its own phase
+        https://bugs.webkit.org/show_bug.cgi?id=134742
+
+        Reviewed by Geoffrey Garen.
+        
+        This moves Phantom simplification out of CSE, which greatly simplifies CSE and gives it
+        more focus. Also this finally adds a phase that removes empty Phantoms. We sort of had
+        this in CPSRethreading, but that phase runs too infrequently and doesn't run at all for
+        SSA.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * dfg/DFGAdjacencyList.h:
+        * dfg/DFGCSEPhase.cpp:
+        (JSC::DFG::CSEPhase::run):
+        (JSC::DFG::CSEPhase::setReplacement):
+        (JSC::DFG::CSEPhase::eliminate):
+        (JSC::DFG::CSEPhase::performNodeCSE):
+        (JSC::DFG::CSEPhase::eliminateIrrelevantPhantomChildren): Deleted.
+        * dfg/DFGPhantomRemovalPhase.cpp: Added.
+        (JSC::DFG::PhantomRemovalPhase::PhantomRemovalPhase):
+        (JSC::DFG::PhantomRemovalPhase::run):
+        (JSC::DFG::performCleanUp):
+        * dfg/DFGPhantomRemovalPhase.h: Added.
+        * dfg/DFGPlan.cpp:
+        (JSC::DFG::Plan::compileInThreadImpl):
+
+2014-07-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
</ins><span class="cx">         [ftlopt] Get rid of Node::misc by moving the fields out of the union so that you can use replacement and owner simultaneously
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=134730
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -432,6 +432,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGOSRExitCompilerCommon.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGOSRExitJumpPlaceholder.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGOSRExitPreparation.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\dfg\DFGPhantomRemovalPhase.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGPhase.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGPlan.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGPredictionInjectionPhase.cpp&quot; /&gt;
</span><span class="lines">@@ -1009,6 +1010,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGOSRExitCompilerCommon.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGOSRExitJumpPlaceholder.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGOSRExitPreparation.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\dfg\DFGPhantomRemovalPhase.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGPhase.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGPlan.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGPredictionInjectionPhase.h&quot; /&gt;
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -456,6 +456,8 @@
</span><span class="cx">                 0FBE0F7516C1DB0B0082C5E8 /* DFGPredictionInjectionPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBE0F6E16C1DB010082C5E8 /* DFGPredictionInjectionPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0FBE0F7616C1DB0F0082C5E8 /* DFGUnificationPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBE0F6F16C1DB010082C5E8 /* DFGUnificationPhase.cpp */; };
</span><span class="cx">                 0FBE0F7716C1DB120082C5E8 /* DFGUnificationPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBE0F7016C1DB010082C5E8 /* DFGUnificationPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                0FBFDD04196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */; };
+                0FBFDD05196C92BF007A5BFA /* DFGPhantomRemovalPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC097681468A6EF00CF2442 /* DFGOSRExit.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0FC0977114693AF500CF2442 /* DFGOSRExitCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC0976F14693AEF00CF2442 /* DFGOSRExitCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0FC0977214693AF900CF2442 /* DFGOSRExitCompiler64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC0977014693AEF00CF2442 /* DFGOSRExitCompiler64.cpp */; };
</span><span class="lines">@@ -2641,6 +2643,8 @@
</span><span class="cx">                 0FBE0F6E16C1DB010082C5E8 /* DFGPredictionInjectionPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGPredictionInjectionPhase.h; path = dfg/DFGPredictionInjectionPhase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FBE0F6F16C1DB010082C5E8 /* DFGUnificationPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGUnificationPhase.cpp; path = dfg/DFGUnificationPhase.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FBE0F7016C1DB010082C5E8 /* DFGUnificationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGUnificationPhase.h; path = dfg/DFGUnificationPhase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGPhantomRemovalPhase.cpp; path = dfg/DFGPhantomRemovalPhase.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGPhantomRemovalPhase.h; path = dfg/DFGPhantomRemovalPhase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0FC097681468A6EF00CF2442 /* DFGOSRExit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSRExit.h; path = dfg/DFGOSRExit.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FC0976F14693AEF00CF2442 /* DFGOSRExitCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSRExitCompiler.h; path = dfg/DFGOSRExitCompiler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FC0977014693AEF00CF2442 /* DFGOSRExitCompiler64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGOSRExitCompiler64.cpp; path = dfg/DFGOSRExitCompiler64.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5176,6 +5180,8 @@
</span><span class="cx">                                 0FEFC9A81681A3B000567F53 /* DFGOSRExitJumpPlaceholder.h */,
</span><span class="cx">                                 0F235BE917178E7300690C7F /* DFGOSRExitPreparation.cpp */,
</span><span class="cx">                                 0F235BEA17178E7300690C7F /* DFGOSRExitPreparation.h */,
</span><ins>+                                0FBFDD02196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp */,
+                                0FBFDD03196C92BF007A5BFA /* DFGPhantomRemovalPhase.h */,
</ins><span class="cx">                                 0FFFC94F14EF909500C72532 /* DFGPhase.cpp */,
</span><span class="cx">                                 0FFFC95014EF909500C72532 /* DFGPhase.h */,
</span><span class="cx">                                 A78A9772179738B8009DF744 /* DFGPlan.cpp */,
</span><span class="lines">@@ -6314,6 +6320,7 @@
</span><span class="cx">                                 8606DDEA18DA44AB00A383D0 /* IdentifierInlines.h in Headers */,
</span><span class="cx">                                 A532438C18568335002ED692 /* InspectorJSTypeBuilders.h in Headers */,
</span><span class="cx">                                 A50E4B6218809DD50068A46D /* InspectorRuntimeAgent.h in Headers */,
</span><ins>+                                0FBFDD05196C92BF007A5BFA /* DFGPhantomRemovalPhase.h in Headers */,
</ins><span class="cx">                                 A55D93AC18514F7900400DED /* InspectorTypeBuilder.h in Headers */,
</span><span class="cx">                                 A593CF831840377100BFCE27 /* InspectorValues.h in Headers */,
</span><span class="cx">                                 969A07990ED1D3AE00F1F681 /* Instruction.h in Headers */,
</span><span class="lines">@@ -8067,6 +8074,7 @@
</span><span class="cx">                                 C225494315F7DBAA0065E898 /* SlotVisitor.cpp in Sources */,
</span><span class="cx">                                 9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
</span><span class="cx">                                 0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */,
</span><ins>+                                0FBFDD04196C92BF007A5BFA /* DFGPhantomRemovalPhase.cpp in Sources */,
</ins><span class="cx">                                 0F493AFA16D0CAD30084508B /* SourceProvider.cpp in Sources */,
</span><span class="cx">                                 E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */,
</span><span class="cx">                                 0F0CD4C415F6B6BB0032F1C0 /* SparseArrayValueMap.cpp in Sources */,
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoredfgDFGAdjacencyListh"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/dfg/DFGAdjacencyList.h (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/dfg/DFGAdjacencyList.h        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/dfg/DFGAdjacencyList.h        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx">             setChild(i, child(i + 1));
</span><span class="cx">         setChild(Size - 1, Edge());
</span><span class="cx">     }
</span><del>-
</del><ins>+    
</ins><span class="cx">     unsigned firstChild() const
</span><span class="cx">     {
</span><span class="cx">         return m_words[0].m_encodedWord;
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoredfgDFGCSEPhasecpp"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/dfg/DFGCSEPhase.cpp        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -54,47 +54,6 @@
</span><span class="cx">         
</span><span class="cx">         m_graph.clearReplacements();
</span><span class="cx">         
</span><del>-        for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
-            BasicBlock* block = m_graph.block(blockIndex);
-            if (!block)
-                continue;
-            
-            // All Phis need to already be marked as relevant to OSR.
-            if (!ASSERT_DISABLED) {
-                for (unsigned i = 0; i &lt; block-&gt;phis.size(); ++i)
-                    ASSERT(block-&gt;phis[i]-&gt;flags() &amp; NodeRelevantToOSR);
-            }
-            
-            for (unsigned i = block-&gt;size(); i--;) {
-                Node* node = block-&gt;at(i);
-                
-                switch (node-&gt;op()) {
-                case SetLocal:
-                case GetLocal: // FIXME: The GetLocal case is only necessary until we do https://bugs.webkit.org/show_bug.cgi?id=106707.
-                    node-&gt;mergeFlags(NodeRelevantToOSR);
-                    break;
-                default:
-                    node-&gt;clearFlags(NodeRelevantToOSR);
-                    break;
-                }
-            }
-        }
-        
-        for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
-            BasicBlock* block = m_graph.block(blockIndex);
-            if (!block)
-                continue;
-            
-            for (unsigned i = block-&gt;size(); i--;) {
-                Node* node = block-&gt;at(i);
-                if (!node-&gt;containsMovHint())
-                    continue;
-                
-                ASSERT(node-&gt;op() != ZombieHint);
-                node-&gt;child1()-&gt;mergeFlags(NodeRelevantToOSR);
-            }
-        }
-        
</del><span class="cx">         if (m_graph.m_form == SSA) {
</span><span class="cx">             Vector&lt;BasicBlock*&gt; depthFirst;
</span><span class="cx">             m_graph.getBlocksInDepthFirstOrder(depthFirst);
</span><span class="lines">@@ -831,30 +790,12 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void eliminateIrrelevantPhantomChildren(Node* node)
-    {
-        ASSERT(node-&gt;op() == Phantom);
-        for (unsigned i = 0; i &lt; AdjacencyList::Size; ++i) {
-            Edge edge = node-&gt;children.child(i);
-            if (!edge)
-                continue;
-            if (edge.useKind() != UntypedUse)
-                continue; // Keep the type check.
-            if (edge-&gt;flags() &amp; NodeRelevantToOSR)
-                continue;
-            
-            node-&gt;children.removeEdge(i--);
-            m_changed = true;
-        }
-    }
-    
</del><span class="cx">     bool setReplacement(Node* replacement)
</span><span class="cx">     {
</span><span class="cx">         if (!replacement)
</span><span class="cx">             return false;
</span><span class="cx">         
</span><span class="cx">         m_currentNode-&gt;convertToPhantom();
</span><del>-        eliminateIrrelevantPhantomChildren(m_currentNode);
</del><span class="cx">         
</span><span class="cx">         // At this point we will eliminate all references to this node.
</span><span class="cx">         m_currentNode-&gt;replacement = replacement;
</span><span class="lines">@@ -868,7 +809,6 @@
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_currentNode-&gt;mustGenerate());
</span><span class="cx">         m_currentNode-&gt;convertToPhantom();
</span><del>-        eliminateIrrelevantPhantomChildren(m_currentNode);
</del><span class="cx">         
</span><span class="cx">         m_changed = true;
</span><span class="cx">     }
</span><span class="lines">@@ -879,8 +819,6 @@
</span><span class="cx">             return;
</span><span class="cx">         ASSERT(node-&gt;mustGenerate());
</span><span class="cx">         node-&gt;setOpAndDefaultFlags(phantomType);
</span><del>-        if (phantomType == Phantom)
-            eliminateIrrelevantPhantomChildren(node);
</del><span class="cx">         
</span><span class="cx">         m_changed = true;
</span><span class="cx">     }
</span><span class="lines">@@ -1110,14 +1048,6 @@
</span><span class="cx">                 eliminate();
</span><span class="cx">             break;
</span><span class="cx">             
</span><del>-        case Phantom:
-            // FIXME: we ought to remove Phantom's that have no children.
-            // NB. It would be incorrect to do this for HardPhantom. In fact, the whole point
-            // of HardPhantom is that we *don't* do this for HardPhantoms, since they signify
-            // a more strict kind of liveness than the Phantom bytecode liveness.
-            eliminateIrrelevantPhantomChildren(node);
-            break;
-            
</del><span class="cx">         case Flush:
</span><span class="cx">             // This is needed for arguments simplification to work. We need to eliminate the
</span><span class="cx">             // redundancy between op_enter's undefined-all-the-things and the subsequent
</span></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoredfgDFGPhantomRemovalPhasecpp"></a>
<div class="addfile"><h4>Added: branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.cpp (0 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.cpp                                (rev 0)
+++ branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.cpp        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;config.h&quot;
+#include &quot;DFGPhantomRemovalPhase.h&quot;
+
+#if ENABLE(DFG_JIT)
+
+#include &quot;DFGGraph.h&quot;
+#include &quot;DFGInsertionSet.h&quot;
+#include &quot;DFGPhase.h&quot;
+#include &quot;DFGPredictionPropagationPhase.h&quot;
+#include &quot;DFGVariableAccessDataDump.h&quot;
+#include &quot;JSCInlines.h&quot;
+
+namespace JSC { namespace DFG {
+
+class PhantomRemovalPhase : public Phase {
+public:
+    PhantomRemovalPhase(Graph&amp; graph)
+        : Phase(graph, &quot;phantom removal&quot;)
+    {
+    }
+    
+    bool run()
+    {
+        bool changed = false;
+        
+        for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
+            BasicBlock* block = m_graph.block(blockIndex);
+            if (!block)
+                continue;
+            
+            // All Phis need to already be marked as relevant to OSR.
+            if (!ASSERT_DISABLED) {
+                for (unsigned i = 0; i &lt; block-&gt;phis.size(); ++i)
+                    ASSERT(block-&gt;phis[i]-&gt;flags() &amp; NodeRelevantToOSR);
+            }
+            
+            for (unsigned i = block-&gt;size(); i--;) {
+                Node* node = block-&gt;at(i);
+                
+                switch (node-&gt;op()) {
+                case SetLocal:
+                case GetLocal: // FIXME: The GetLocal case is only necessary until we do https://bugs.webkit.org/show_bug.cgi?id=106707.
+                    node-&gt;mergeFlags(NodeRelevantToOSR);
+                    break;
+                default:
+                    node-&gt;clearFlags(NodeRelevantToOSR);
+                    break;
+                }
+            }
+        }
+        
+        for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
+            BasicBlock* block = m_graph.block(blockIndex);
+            if (!block)
+                continue;
+            
+            for (unsigned i = block-&gt;size(); i--;) {
+                Node* node = block-&gt;at(i);
+                if (node-&gt;op() == MovHint)
+                    node-&gt;child1()-&gt;mergeFlags(NodeRelevantToOSR);
+            }
+        }
+        
+        for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
+            BasicBlock* block = m_graph.block(blockIndex);
+            if (!block)
+                continue;
+            
+            unsigned sourceIndex = 0;
+            unsigned targetIndex = 0;
+            Node* lastNode = nullptr;
+            while (sourceIndex &lt; block-&gt;size()) {
+                Node* node = block-&gt;at(sourceIndex++);
+                if (node-&gt;op() == Phantom) {
+                    if (lastNode &amp;&amp; (lastNode-&gt;origin.forExit != node-&gt;origin.forExit || (lastNode-&gt;flags() &amp; NodeHasVarArgs)))
+                        lastNode = nullptr;
+                    for (unsigned i = 0; i &lt; AdjacencyList::Size; ++i) {
+                        Edge edge = node-&gt;children.child(i);
+                        if (!edge)
+                            break;
+                        if (edge.useKind() != UntypedUse)
+                            continue; // Keep the type check.
+                        if (edge-&gt;flags() &amp; NodeRelevantToOSR) {
+                            bool found = false;
+                            if (lastNode) {
+                                for (unsigned j = 0; j &lt; AdjacencyList::Size; ++j) {
+                                    if (lastNode-&gt;children.child(j).node() == edge.node()) {
+                                        found = true;
+                                        break;
+                                    }
+                                }
+                            }
+                            if (!found)
+                                continue;
+                        }
+                        
+                        node-&gt;children.removeEdge(i--);
+                        changed = true;
+                    }
+                    
+                    if (node-&gt;children.isEmpty())
+                        continue;
+                }
+                lastNode = node;
+                block-&gt;at(targetIndex++) = node;
+            }
+            block-&gt;resize(targetIndex);
+        }
+        
+        return changed;
+    }
+};
+    
+bool performPhantomRemoval(Graph&amp; graph)
+{
+    SamplingRegion samplingRegion(&quot;DFG Phantom Removal Phase&quot;);
+    return runPhase&lt;PhantomRemovalPhase&gt;(graph);
+}
+
+} } // namespace JSC::DFG
+
+#endif // ENABLE(DFG_JIT)
+
</ins></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoredfgDFGPhantomRemovalPhaseh"></a>
<div class="addfile"><h4>Added: branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.h (0 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.h                                (rev 0)
+++ branches/ftlopt/Source/JavaScriptCore/dfg/DFGPhantomRemovalPhase.h        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef DFGPhantomRemovalPhase_h
+#define DFGPhantomRemovalPhase_h
+
+#if ENABLE(DFG_JIT)
+
+namespace JSC { namespace DFG {
+
+class Graph;
+
+// Cleans up unnecessary Phantoms and Phanton children. This reduces live ranges, but also, it
+// eliminates many Phantoms entirely. This invalidates liveness analysis.
+
+bool performPhantomRemoval(Graph&amp;);
+
+} } // namespace JSC::DFG
+
+#endif // ENABLE(DFG_JIT)
+
+#endif // DFGPhantomRemovalPhase_h
</ins></span></pre></div>
<a id="branchesftloptSourceJavaScriptCoredfgDFGPlancpp"></a>
<div class="modfile"><h4>Modified: branches/ftlopt/Source/JavaScriptCore/dfg/DFGPlan.cpp (170906 => 170907)</h4>
<pre class="diff"><span>
<span class="info">--- branches/ftlopt/Source/JavaScriptCore/dfg/DFGPlan.cpp        2014-07-09 00:51:07 UTC (rev 170906)
+++ branches/ftlopt/Source/JavaScriptCore/dfg/DFGPlan.cpp        2014-07-09 03:00:27 UTC (rev 170907)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #include &quot;DFGLoopPreHeaderCreationPhase.h&quot;
</span><span class="cx"> #include &quot;DFGOSRAvailabilityAnalysisPhase.h&quot;
</span><span class="cx"> #include &quot;DFGOSREntrypointCreationPhase.h&quot;
</span><ins>+#include &quot;DFGPhantomRemovalPhase.h&quot;
</ins><span class="cx"> #include &quot;DFGPredictionInjectionPhase.h&quot;
</span><span class="cx"> #include &quot;DFGPredictionPropagationPhase.h&quot;
</span><span class="cx"> #include &quot;DFGResurrectionForValidationPhase.h&quot;
</span><span class="lines">@@ -260,7 +261,7 @@
</span><span class="cx">     
</span><span class="cx">     if (validationEnabled())
</span><span class="cx">         validate(dfg);
</span><del>-
</del><ins>+    
</ins><span class="cx">     performCPSRethreading(dfg);
</span><span class="cx">     if (changed) {
</span><span class="cx">         performCFA(dfg);
</span><span class="lines">@@ -281,6 +282,7 @@
</span><span class="cx">         performTierUpCheckInjection(dfg);
</span><span class="cx"> 
</span><span class="cx">         performStoreBarrierElision(dfg);
</span><ins>+        performPhantomRemoval(dfg);
</ins><span class="cx">         performCPSRethreading(dfg);
</span><span class="cx">         performDCE(dfg);
</span><span class="cx">         performStackLayout(dfg);
</span><span class="lines">@@ -308,6 +310,7 @@
</span><span class="cx">             return FailPath;
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        performPhantomRemoval(dfg);
</ins><span class="cx">         performCriticalEdgeBreaking(dfg);
</span><span class="cx">         performLoopPreHeaderCreation(dfg);
</span><span class="cx">         performCPSRethreading(dfg);
</span><span class="lines">@@ -324,6 +327,7 @@
</span><span class="cx">             performCFA(dfg);
</span><span class="cx">         }
</span><span class="cx">         performLICM(dfg);
</span><ins>+        performPhantomRemoval(dfg);
</ins><span class="cx">         performIntegerCheckCombining(dfg);
</span><span class="cx">         performCSE(dfg);
</span><span class="cx">         
</span><span class="lines">@@ -332,6 +336,7 @@
</span><span class="cx">         dfg.m_fixpointState = FixpointConverged;
</span><span class="cx">         
</span><span class="cx">         performStoreBarrierElision(dfg);
</span><ins>+        performPhantomRemoval(dfg);
</ins><span class="cx">         performLivenessAnalysis(dfg);
</span><span class="cx">         performCFA(dfg);
</span><span class="cx">         if (Options::validateFTLOSRExitLiveness())
</span></span></pre>
</div>
</div>

</body>
</html>