<!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>[179223] 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/179223">179223</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-01-27 14:56:00 -0800 (Tue, 27 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move DFGBinarySwitch out of the DFG so that all of the JITs can use it
https://bugs.webkit.org/show_bug.cgi?id=140959

Rubber stamped by Geoffrey Garen.
        
I want to use this for polymorphic stubs for https://bugs.webkit.org/show_bug.cgi?id=140660.
This code no longer has DFG dependencies so this is a very clean move.

* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* dfg/DFGBinarySwitch.cpp: Removed.
* dfg/DFGBinarySwitch.h: Removed.
* dfg/DFGSpeculativeJIT.cpp:
* jit/BinarySwitch.cpp: Copied from Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp.
* jit/BinarySwitch.h: Copied from Source/JavaScriptCore/dfg/DFGBinarySwitch.h.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorejitBinarySwitchcpp">trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitBinarySwitchh">trunk/Source/JavaScriptCore/jit/BinarySwitch.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoredfgDFGBinarySwitchcpp">trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGBinarySwitchh">trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -125,7 +125,6 @@
</span><span class="cx">     dfg/DFGAvailabilityMap.cpp
</span><span class="cx">     dfg/DFGBackwardsPropagationPhase.cpp
</span><span class="cx">     dfg/DFGBasicBlock.cpp
</span><del>-    dfg/DFGBinarySwitch.cpp
</del><span class="cx">     dfg/DFGBlockInsertionSet.cpp
</span><span class="cx">     dfg/DFGBlockSet.cpp
</span><span class="cx">     dfg/DFGBlockWorklist.cpp
</span><span class="lines">@@ -327,6 +326,7 @@
</span><span class="cx">     jit/AccessorCallJITStubRoutine.cpp
</span><span class="cx">     jit/AssemblyHelpers.cpp
</span><span class="cx">     jit/ArityCheckFailReturnThunks.cpp
</span><ins>+    jit/BinarySwitch.cpp
</ins><span class="cx">     jit/ClosureCallStubRoutine.cpp
</span><span class="cx">     jit/ExecutableAllocator.cpp
</span><span class="cx">     jit/ExecutableAllocatorFixedVMPool.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-01-27  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        Move DFGBinarySwitch out of the DFG so that all of the JITs can use it
+        https://bugs.webkit.org/show_bug.cgi?id=140959
+
+        Rubber stamped by Geoffrey Garen.
+        
+        I want to use this for polymorphic stubs for https://bugs.webkit.org/show_bug.cgi?id=140660.
+        This code no longer has DFG dependencies so this is a very clean move.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * dfg/DFGBinarySwitch.cpp: Removed.
+        * dfg/DFGBinarySwitch.h: Removed.
+        * dfg/DFGSpeculativeJIT.cpp:
+        * jit/BinarySwitch.cpp: Copied from Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp.
+        * jit/BinarySwitch.h: Copied from Source/JavaScriptCore/dfg/DFGBinarySwitch.h.
+
</ins><span class="cx"> 2015-01-27  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r179192.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -370,7 +370,6 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGAvailabilityMap.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGBackwardsPropagationPhase.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGBasicBlock.cpp&quot; /&gt;
</span><del>-    &lt;ClCompile Include=&quot;..\dfg\DFGBinarySwitch.cpp&quot; /&gt;
</del><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGBlockInsertionSet.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGBlockSet.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\dfg\DFGBlockWorklist.cpp&quot; /&gt;
</span><span class="lines">@@ -598,6 +597,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\AccessorCallJITStubRoutine.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\ArityCheckFailReturnThunks.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\AssemblyHelpers.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\jit\BinarySwitch.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\jit\ClosureCallStubRoutine.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\ExecutableAllocator.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\jit\GCAwareJITStubRoutine.cpp&quot; /&gt;
</span><span class="lines">@@ -1015,7 +1015,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBackwardsPropagationPhase.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBasicBlock.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBasicBlockInlines.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\dfg\DFGBinarySwitch.h&quot; /&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBlockInsertionSet.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBlockMap.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dfg\DFGBlockMapInlines.h&quot; /&gt;
</span><span class="lines">@@ -1332,6 +1331,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\AccessorCallJITStubRoutine.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\ArityCheckFailReturnThunks.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\AssemblyHelpers.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\jit\BinarySwitch.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\jit\CCallHelpers.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\ClosureCallStubRoutine.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\jit\CompactJITCodeMap.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -353,6 +353,8 @@
</span><span class="cx">                 0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63948115E48114006A597C /* DFGArrayMode.cpp */; };
</span><span class="cx">                 0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63948215E48114006A597C /* DFGArrayMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                0F64B2711A784BAF006E4E66 /* BinarySwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */; };
+                0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F64B2701A784BAF006E4E66 /* BinarySwitch.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 0F666EC0183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0F666EC1183566F900D017F1 /* FullBytecodeLiveness.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0F666EC61835672B00D017F1 /* DFGAvailability.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F666EC21835672B00D017F1 /* DFGAvailability.cpp */; };
</span><span class="lines">@@ -1244,8 +1246,6 @@
</span><span class="cx">                 A704D90717A0BAA8006BA554 /* DFGMergeMode.h in Headers */ = {isa = PBXBuildFile; fileRef = A704D90217A0BAA8006BA554 /* DFGMergeMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A709F2F017A0AC0400512E98 /* SlowPathCall.h in Headers */ = {isa = PBXBuildFile; fileRef = A709F2EF17A0AC0400512E98 /* SlowPathCall.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A709F2F217A0AC2A00512E98 /* CommonSlowPaths.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A709F2F117A0AC2A00512E98 /* CommonSlowPaths.cpp */; };
</span><del>-                A70B083217A0B79B00DAF14B /* DFGBinarySwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */; };
-                A70B083317A0B79B00DAF14B /* DFGBinarySwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */; };
</del><span class="cx">                 A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */; };
</span><span class="cx">                 A72028B61797601E0098028C /* JSCTestRunnerUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A72028B41797601E0098028C /* JSCTestRunnerUtils.cpp */; };
</span><span class="cx">                 A72028B81797601E0098028C /* JSCTestRunnerUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = A72028B51797601E0098028C /* JSCTestRunnerUtils.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2023,6 +2023,8 @@
</span><span class="cx">                 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F63948115E48114006A597C /* DFGArrayMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGArrayMode.cpp; path = dfg/DFGArrayMode.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F63948215E48114006A597C /* DFGArrayMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGArrayMode.h; path = dfg/DFGArrayMode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySwitch.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                0F64B2701A784BAF006E4E66 /* BinarySwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySwitch.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeLivenessAnalysisInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullBytecodeLiveness.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F666EC21835672B00D017F1 /* DFGAvailability.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAvailability.cpp; path = dfg/DFGAvailability.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2935,8 +2937,6 @@
</span><span class="cx">                 A704D90217A0BAA8006BA554 /* DFGMergeMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGMergeMode.h; path = dfg/DFGMergeMode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A709F2EF17A0AC0400512E98 /* SlowPathCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlowPathCall.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A709F2F117A0AC2A00512E98 /* CommonSlowPaths.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonSlowPaths.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGBinarySwitch.cpp; path = dfg/DFGBinarySwitch.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBinarySwitch.h; path = dfg/DFGBinarySwitch.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITOpcodes32_64.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A718F61A11754A21002465A7 /* RegExpJitTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpJitTables.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A718F8211178EB4B002465A7 /* create_regex_tables */ = {isa = PBXFileReference; explicitFileType = text.script.python; fileEncoding = 4; path = create_regex_tables; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -3744,6 +3744,8 @@
</span><span class="cx">                                 0F6B1CC818641DF800845D97 /* ArityCheckFailReturnThunks.h */,
</span><span class="cx">                                 0F24E53B17EA9F5900ABB217 /* AssemblyHelpers.cpp */,
</span><span class="cx">                                 0F24E53C17EA9F5900ABB217 /* AssemblyHelpers.h */,
</span><ins>+                                0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */,
+                                0F64B2701A784BAF006E4E66 /* BinarySwitch.h */,
</ins><span class="cx">                                 0F24E53D17EA9F5900ABB217 /* CCallHelpers.h */,
</span><span class="cx">                                 0F73D7AB165A142A00ACAB71 /* ClosureCallStubRoutine.cpp */,
</span><span class="cx">                                 0F73D7AC165A142A00ACAB71 /* ClosureCallStubRoutine.h */,
</span><span class="lines">@@ -3785,8 +3787,8 @@
</span><span class="cx">                                 14A6581A0F4E36F4000150FD /* JITStubs.h */,
</span><span class="cx">                                 FEF6835A174343CC00A32E25 /* JITStubsARM.h */,
</span><span class="cx">                                 FEF6835B174343CC00A32E25 /* JITStubsARMv7.h */,
</span><ins>+                                FEF6835C174343CC00A32E25 /* JITStubsX86_64.h */,
</ins><span class="cx">                                 FEF6835D174343CC00A32E25 /* JITStubsX86.h */,
</span><del>-                                FEF6835C174343CC00A32E25 /* JITStubsX86_64.h */,
</del><span class="cx">                                 A7A4AE0C17973B4D005612B1 /* JITStubsX86Common.h */,
</span><span class="cx">                                 0F5EF91B16878F78003E5C25 /* JITThunks.cpp */,
</span><span class="cx">                                 0F5EF91C16878F78003E5C25 /* JITThunks.h */,
</span><span class="lines">@@ -4655,8 +4657,6 @@
</span><span class="cx">                                 A7D89CE317A0B8CC00773AD8 /* DFGBasicBlock.cpp */,
</span><span class="cx">                                 0F620170143FCD2F0068B77C /* DFGBasicBlock.h */,
</span><span class="cx">                                 0FD5652216AB780A00197653 /* DFGBasicBlockInlines.h */,
</span><del>-                                A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */,
-                                A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */,
</del><span class="cx">                                 A7D89CE417A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp */,
</span><span class="cx">                                 A7D89CE517A0B8CC00773AD8 /* DFGBlockInsertionSet.h */,
</span><span class="cx">                                 0FC3CCF519ADA410006AC72A /* DFGBlockMap.h */,
</span><span class="lines">@@ -5555,7 +5555,6 @@
</span><span class="cx">                                 0F714CA516EA92F200F3EBEB /* DFGBackwardsPropagationPhase.h in Headers */,
</span><span class="cx">                                 0F620176143FCD3B0068B77C /* DFGBasicBlock.h in Headers */,
</span><span class="cx">                                 0FFB921A16D02EC50055A5DB /* DFGBasicBlockInlines.h in Headers */,
</span><del>-                                A70B083317A0B79B00DAF14B /* DFGBinarySwitch.h in Headers */,
</del><span class="cx">                                 A7D89CF417A0B8CC00773AD8 /* DFGBlockInsertionSet.h in Headers */,
</span><span class="cx">                                 0F8364B7164B0C110053329A /* DFGBranchDirection.h in Headers */,
</span><span class="cx">                                 86EC9DC51328DF82002B2AD7 /* DFGByteCodeParser.h in Headers */,
</span><span class="lines">@@ -5891,6 +5890,7 @@
</span><span class="cx">                                 0F9749711687ADE400A4FF6A /* JSCellInlines.h in Headers */,
</span><span class="cx">                                 0F1DD84A18A945BE0026F3FA /* JSCInlines.h in Headers */,
</span><span class="cx">                                 BC18C42B0E16F5CD00B34460 /* JSCJSValue.h in Headers */,
</span><ins>+                                0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */,
</ins><span class="cx">                                 865A30F1135007E100CDB49E /* JSCJSValueInlines.h in Headers */,
</span><span class="cx">                                 BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */,
</span><span class="cx">                                 86E3C613167BABD7006D760A /* JSContext.h in Headers */,
</span><span class="lines">@@ -6820,7 +6820,6 @@
</span><span class="cx">                                 0F714CA416EA92F000F3EBEB /* DFGBackwardsPropagationPhase.cpp in Sources */,
</span><span class="cx">                                 0F2B9CEC19D0BA7D00B1D1B5 /* DFGPromotedHeapLocation.cpp in Sources */,
</span><span class="cx">                                 A7D89CF217A0B8CC00773AD8 /* DFGBasicBlock.cpp in Sources */,
</span><del>-                                A70B083217A0B79B00DAF14B /* DFGBinarySwitch.cpp in Sources */,
</del><span class="cx">                                 2A88067819107D5500CB0BBB /* DFGFunctionWhitelist.cpp in Sources */,
</span><span class="cx">                                 A7D89CF317A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp in Sources */,
</span><span class="cx">                                 86EC9DC41328DF82002B2AD7 /* DFGByteCodeParser.cpp in Sources */,
</span><span class="lines">@@ -6995,6 +6994,7 @@
</span><span class="cx">                                 0FF0F19F16B72A17005DF95B /* FunctionExecutableDump.cpp in Sources */,
</span><span class="cx">                                 52B310FD1974AE870080857C /* FunctionHasExecutedCache.cpp in Sources */,
</span><span class="cx">                                 147F39CC107EC37600427A48 /* FunctionPrototype.cpp in Sources */,
</span><ins>+                                0F64B2711A784BAF006E4E66 /* BinarySwitch.cpp in Sources */,
</ins><span class="cx">                                 0F766D2F15A8DCE0008F363E /* GCAwareJITStubRoutine.cpp in Sources */,
</span><span class="cx">                                 C2239D1A16262BDD005AC5FD /* GCThread.cpp in Sources */,
</span><span class="cx">                                 C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGBinarySwitchcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -1,198 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 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;DFGBinarySwitch.h&quot;
-
-#if ENABLE(DFG_JIT)
-
-#include &quot;JSCInlines.h&quot;
-
-namespace JSC { namespace DFG {
-
-BinarySwitch::BinarySwitch(GPRReg value, const Vector&lt;int64_t&gt;&amp; cases, Type type)
-    : m_value(value)
-    , m_index(0)
-    , m_caseIndex(UINT_MAX)
-    , m_medianBias(0)
-    , m_type(type)
-{
-    if (cases.isEmpty())
-        return;
-    
-    for (unsigned i = 0; i &lt; cases.size(); ++i)
-        m_cases.append(Case(cases[i], i));
-    std::sort(m_cases.begin(), m_cases.end());
-    build(0, m_cases.size());
-}
-
-bool BinarySwitch::advance(MacroAssembler&amp; jit)
-{
-    if (m_cases.isEmpty()) {
-        m_fallThrough.append(jit.jump());
-        return false;
-    }
-    
-    if (m_index == m_branches.size()) {
-        RELEASE_ASSERT(m_jumpStack.isEmpty());
-        return false;
-    }
-    
-    for (;;) {
-        const BranchCode&amp; code = m_branches[m_index++];
-        switch (code.kind) {
-        case NotEqualToFallThrough:
-            switch (m_type) {
-            case Int32:
-                m_fallThrough.append(jit.branch32(
-                    MacroAssembler::NotEqual, m_value,
-                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
-                break;
-            case IntPtr:
-                m_fallThrough.append(jit.branchPtr(
-                    MacroAssembler::NotEqual, m_value,
-                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
-                break;
-            }
-            break;
-        case NotEqualToPush:
-            switch (m_type) {
-            case Int32:
-                m_jumpStack.append(jit.branch32(
-                    MacroAssembler::NotEqual, m_value,
-                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
-                break;
-            case IntPtr:
-                m_jumpStack.append(jit.branchPtr(
-                    MacroAssembler::NotEqual, m_value,
-                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
-                break;
-            }
-            break;
-        case LessThanToPush:
-            switch (m_type) {
-            case Int32:
-                m_jumpStack.append(jit.branch32(
-                    MacroAssembler::LessThan, m_value,
-                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
-                break;
-            case IntPtr:
-                m_jumpStack.append(jit.branchPtr(
-                    MacroAssembler::LessThan, m_value,
-                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
-                break;
-            }
-            break;
-        case Pop:
-            m_jumpStack.takeLast().link(&amp;jit);
-            break;
-        case ExecuteCase:
-            m_caseIndex = code.index;
-            return true;
-        }
-    }
-}
-
-void BinarySwitch::build(unsigned start, unsigned end)
-{
-    unsigned size = end - start;
-    
-    switch (size) {
-    case 0: {
-        RELEASE_ASSERT_NOT_REACHED();
-        break;
-    }
-        
-    case 1: {
-        if (start
-            &amp;&amp; m_cases[start - 1].value == m_cases[start].value - 1
-            &amp;&amp; start + 1 &lt; m_cases.size()
-            &amp;&amp; m_cases[start + 1].value == m_cases[start].value + 1) {
-            m_branches.append(BranchCode(ExecuteCase, start));
-            break;
-        }
-        
-        m_branches.append(BranchCode(NotEqualToFallThrough, start));
-        m_branches.append(BranchCode(ExecuteCase, start));
-        break;
-    }
-        
-    case 2: {
-        if (m_cases[start].value + 1 == m_cases[start + 1].value
-            &amp;&amp; start
-            &amp;&amp; m_cases[start - 1].value == m_cases[start].value - 1
-            &amp;&amp; start + 2 &lt; m_cases.size()
-            &amp;&amp; m_cases[start + 2].value == m_cases[start + 1].value + 1) {
-            m_branches.append(BranchCode(NotEqualToPush, start));
-            m_branches.append(BranchCode(ExecuteCase, start));
-            m_branches.append(BranchCode(Pop));
-            m_branches.append(BranchCode(ExecuteCase, start + 1));
-            break;
-        }
-        
-        unsigned firstCase = start;
-        unsigned secondCase = start + 1;
-        if (m_medianBias)
-            std::swap(firstCase, secondCase);
-        m_medianBias ^= 1;
-        
-        m_branches.append(BranchCode(NotEqualToPush, firstCase));
-        m_branches.append(BranchCode(ExecuteCase, firstCase));
-        m_branches.append(BranchCode(Pop));
-        m_branches.append(BranchCode(NotEqualToFallThrough, secondCase));
-        m_branches.append(BranchCode(ExecuteCase, secondCase));
-        break;
-    }
-        
-    default: {
-        unsigned medianIndex = (start + end) / 2;
-        if (!(size &amp; 1)) {
-            // Because end is exclusive, in the even case, this rounds up by
-            // default. Hence median bias sometimes flips to subtracing one
-            // in order to get round-down behavior.
-            medianIndex -= m_medianBias;
-            m_medianBias ^= 1;
-        }
-        
-        RELEASE_ASSERT(medianIndex &gt; start);
-        RELEASE_ASSERT(medianIndex + 1 &lt; end);
-        
-        m_branches.append(BranchCode(LessThanToPush, medianIndex));
-        m_branches.append(BranchCode(NotEqualToPush, medianIndex));
-        m_branches.append(BranchCode(ExecuteCase, medianIndex));
-        
-        m_branches.append(BranchCode(Pop));
-        build(medianIndex + 1, end);
-        
-        m_branches.append(BranchCode(Pop));
-        build(start, medianIndex);
-        break;
-    } }
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGBinarySwitchh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.h (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.h        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.h        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -1,140 +0,0 @@
</span><del>-/*
- * Copyright (C) 2013 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 DFGBinarySwitch_h
-#define DFGBinarySwitch_h
-
-#if ENABLE(DFG_JIT)
-
-#include &quot;GPRInfo.h&quot;
-#include &quot;MacroAssembler.h&quot;
-
-namespace JSC { namespace DFG {
-
-// The BinarySwitch class makes it easy to emit a switch statement over either
-// 32-bit integers or pointers, where the switch uses a tree of branches
-// rather than a jump table. This makes it particularly useful if the case
-// values are too far apart to make a jump table practical, or if there are
-// sufficiently few cases that the total cost of log(numCases) branches is
-// less than the cost of an indirected jump.
-//
-// In an effort to simplify the logic of emitting code for each case, this
-// uses an iterator style, rather than a functor callback style. This makes
-// sense because even the iterator implementation found herein is relatively
-// simple, whereas the code it's used from is usually quite complex - one
-// example being the trie-of-trees string switch implementation, where the
-// code emitted for each case involves recursing to emit code for a sub-trie.
-//
-// Use this like so:
-//
-// BinarySwitch switch(valueReg, casesVector, BinarySwitch::Int32);
-// while (switch.advance(jit)) {
-//     int value = switch.caseValue();
-//     unsigned index = switch.caseIndex(); // index into casesVector, above
-//     ... // generate code for this case
-// }
-// switch.fallThrough().link(&amp;jit);
-
-class BinarySwitch {
-public:
-    enum Type {
-        Int32,
-        IntPtr
-    };
-    
-    BinarySwitch(GPRReg value, const Vector&lt;int64_t&gt;&amp; cases, Type);
-    
-    unsigned caseIndex() const { return m_cases[m_caseIndex].index; }
-    int64_t caseValue() const { return m_cases[m_caseIndex].value; }
-    
-    bool advance(MacroAssembler&amp;);
-    
-    MacroAssembler::JumpList&amp; fallThrough() { return m_fallThrough; }
-    
-private:
-    void build(unsigned start, unsigned end);
-    
-    GPRReg m_value;
-    
-    struct Case {
-        Case() { }
-
-        Case(int64_t value, unsigned index)
-            : value(value)
-            , index(index)
-        {
-        }
-        
-        bool operator&lt;(const Case&amp; other) const
-        {
-            return value &lt; other.value;
-        }
-        
-        int64_t value;
-        unsigned index;
-    };
-    
-    Vector&lt;Case&gt; m_cases;
-    
-    enum BranchKind {
-        NotEqualToFallThrough,
-        NotEqualToPush,
-        LessThanToPush,
-        Pop,
-        ExecuteCase
-    };
-        
-    struct BranchCode {
-        BranchCode() { }
-        
-        BranchCode(BranchKind kind, unsigned index = UINT_MAX)
-            : kind(kind)
-            , index(index)
-        {
-        }
-        
-        BranchKind kind;
-        unsigned index;
-    };
-    
-    Vector&lt;BranchCode&gt; m_branches;
-
-    unsigned m_index;
-    unsigned m_caseIndex;
-    Vector&lt;MacroAssembler::Jump&gt; m_jumpStack;
-    
-    MacroAssembler::JumpList m_fallThrough;
-    
-    unsigned m_medianBias;
-    
-    Type m_type;
-};
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
-#endif // DFGBinarySwitch_h
-
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (179222 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -29,9 +29,9 @@
</span><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Arguments.h&quot;
</span><ins>+#include &quot;BinarySwitch.h&quot;
</ins><span class="cx"> #include &quot;DFGAbstractInterpreterInlines.h&quot;
</span><span class="cx"> #include &quot;DFGArrayifySlowPathGenerator.h&quot;
</span><del>-#include &quot;DFGBinarySwitch.h&quot;
</del><span class="cx"> #include &quot;DFGCallArrayAllocatorSlowPathGenerator.h&quot;
</span><span class="cx"> #include &quot;DFGMayExit.h&quot;
</span><span class="cx"> #include &quot;DFGSaneStringGetByValSlowPathGenerator.h&quot;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitBinarySwitchcppfromrev179136trunkSourceJavaScriptCoredfgDFGBinarySwitchcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp (from rev 179136, trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.cpp) (0 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -0,0 +1,198 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2015 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;BinarySwitch.h&quot;
+
+#if ENABLE(JIT)
+
+#include &quot;JSCInlines.h&quot;
+
+namespace JSC {
+
+BinarySwitch::BinarySwitch(GPRReg value, const Vector&lt;int64_t&gt;&amp; cases, Type type)
+    : m_value(value)
+    , m_index(0)
+    , m_caseIndex(UINT_MAX)
+    , m_medianBias(0)
+    , m_type(type)
+{
+    if (cases.isEmpty())
+        return;
+    
+    for (unsigned i = 0; i &lt; cases.size(); ++i)
+        m_cases.append(Case(cases[i], i));
+    std::sort(m_cases.begin(), m_cases.end());
+    build(0, m_cases.size());
+}
+
+bool BinarySwitch::advance(MacroAssembler&amp; jit)
+{
+    if (m_cases.isEmpty()) {
+        m_fallThrough.append(jit.jump());
+        return false;
+    }
+    
+    if (m_index == m_branches.size()) {
+        RELEASE_ASSERT(m_jumpStack.isEmpty());
+        return false;
+    }
+    
+    for (;;) {
+        const BranchCode&amp; code = m_branches[m_index++];
+        switch (code.kind) {
+        case NotEqualToFallThrough:
+            switch (m_type) {
+            case Int32:
+                m_fallThrough.append(jit.branch32(
+                    MacroAssembler::NotEqual, m_value,
+                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
+                break;
+            case IntPtr:
+                m_fallThrough.append(jit.branchPtr(
+                    MacroAssembler::NotEqual, m_value,
+                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
+                break;
+            }
+            break;
+        case NotEqualToPush:
+            switch (m_type) {
+            case Int32:
+                m_jumpStack.append(jit.branch32(
+                    MacroAssembler::NotEqual, m_value,
+                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
+                break;
+            case IntPtr:
+                m_jumpStack.append(jit.branchPtr(
+                    MacroAssembler::NotEqual, m_value,
+                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
+                break;
+            }
+            break;
+        case LessThanToPush:
+            switch (m_type) {
+            case Int32:
+                m_jumpStack.append(jit.branch32(
+                    MacroAssembler::LessThan, m_value,
+                    MacroAssembler::Imm32(static_cast&lt;int32_t&gt;(m_cases[code.index].value))));
+                break;
+            case IntPtr:
+                m_jumpStack.append(jit.branchPtr(
+                    MacroAssembler::LessThan, m_value,
+                    MacroAssembler::ImmPtr(bitwise_cast&lt;const void*&gt;(static_cast&lt;intptr_t&gt;(m_cases[code.index].value)))));
+                break;
+            }
+            break;
+        case Pop:
+            m_jumpStack.takeLast().link(&amp;jit);
+            break;
+        case ExecuteCase:
+            m_caseIndex = code.index;
+            return true;
+        }
+    }
+}
+
+void BinarySwitch::build(unsigned start, unsigned end)
+{
+    unsigned size = end - start;
+    
+    switch (size) {
+    case 0: {
+        RELEASE_ASSERT_NOT_REACHED();
+        break;
+    }
+        
+    case 1: {
+        if (start
+            &amp;&amp; m_cases[start - 1].value == m_cases[start].value - 1
+            &amp;&amp; start + 1 &lt; m_cases.size()
+            &amp;&amp; m_cases[start + 1].value == m_cases[start].value + 1) {
+            m_branches.append(BranchCode(ExecuteCase, start));
+            break;
+        }
+        
+        m_branches.append(BranchCode(NotEqualToFallThrough, start));
+        m_branches.append(BranchCode(ExecuteCase, start));
+        break;
+    }
+        
+    case 2: {
+        if (m_cases[start].value + 1 == m_cases[start + 1].value
+            &amp;&amp; start
+            &amp;&amp; m_cases[start - 1].value == m_cases[start].value - 1
+            &amp;&amp; start + 2 &lt; m_cases.size()
+            &amp;&amp; m_cases[start + 2].value == m_cases[start + 1].value + 1) {
+            m_branches.append(BranchCode(NotEqualToPush, start));
+            m_branches.append(BranchCode(ExecuteCase, start));
+            m_branches.append(BranchCode(Pop));
+            m_branches.append(BranchCode(ExecuteCase, start + 1));
+            break;
+        }
+        
+        unsigned firstCase = start;
+        unsigned secondCase = start + 1;
+        if (m_medianBias)
+            std::swap(firstCase, secondCase);
+        m_medianBias ^= 1;
+        
+        m_branches.append(BranchCode(NotEqualToPush, firstCase));
+        m_branches.append(BranchCode(ExecuteCase, firstCase));
+        m_branches.append(BranchCode(Pop));
+        m_branches.append(BranchCode(NotEqualToFallThrough, secondCase));
+        m_branches.append(BranchCode(ExecuteCase, secondCase));
+        break;
+    }
+        
+    default: {
+        unsigned medianIndex = (start + end) / 2;
+        if (!(size &amp; 1)) {
+            // Because end is exclusive, in the even case, this rounds up by
+            // default. Hence median bias sometimes flips to subtracing one
+            // in order to get round-down behavior.
+            medianIndex -= m_medianBias;
+            m_medianBias ^= 1;
+        }
+        
+        RELEASE_ASSERT(medianIndex &gt; start);
+        RELEASE_ASSERT(medianIndex + 1 &lt; end);
+        
+        m_branches.append(BranchCode(LessThanToPush, medianIndex));
+        m_branches.append(BranchCode(NotEqualToPush, medianIndex));
+        m_branches.append(BranchCode(ExecuteCase, medianIndex));
+        
+        m_branches.append(BranchCode(Pop));
+        build(medianIndex + 1, end);
+        
+        m_branches.append(BranchCode(Pop));
+        build(start, medianIndex);
+        break;
+    } }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorejitBinarySwitchhfromrev179136trunkSourceJavaScriptCoredfgDFGBinarySwitchh"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/jit/BinarySwitch.h (from rev 179136, trunk/Source/JavaScriptCore/dfg/DFGBinarySwitch.h) (0 => 179223)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/BinarySwitch.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/jit/BinarySwitch.h        2015-01-27 22:56:00 UTC (rev 179223)
</span><span class="lines">@@ -0,0 +1,140 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2015 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 BinarySwitch_h
+#define BinarySwitch_h
+
+#if ENABLE(JIT)
+
+#include &quot;GPRInfo.h&quot;
+#include &quot;MacroAssembler.h&quot;
+
+namespace JSC {
+
+// The BinarySwitch class makes it easy to emit a switch statement over either
+// 32-bit integers or pointers, where the switch uses a tree of branches
+// rather than a jump table. This makes it particularly useful if the case
+// values are too far apart to make a jump table practical, or if there are
+// sufficiently few cases that the total cost of log(numCases) branches is
+// less than the cost of an indirected jump.
+//
+// In an effort to simplify the logic of emitting code for each case, this
+// uses an iterator style, rather than a functor callback style. This makes
+// sense because even the iterator implementation found herein is relatively
+// simple, whereas the code it's used from is usually quite complex - one
+// example being the trie-of-trees string switch implementation, where the
+// code emitted for each case involves recursing to emit code for a sub-trie.
+//
+// Use this like so:
+//
+// BinarySwitch switch(valueReg, casesVector, BinarySwitch::Int32);
+// while (switch.advance(jit)) {
+//     int value = switch.caseValue();
+//     unsigned index = switch.caseIndex(); // index into casesVector, above
+//     ... // generate code for this case
+// }
+// switch.fallThrough().link(&amp;jit);
+
+class BinarySwitch {
+public:
+    enum Type {
+        Int32,
+        IntPtr
+    };
+    
+    BinarySwitch(GPRReg value, const Vector&lt;int64_t&gt;&amp; cases, Type);
+    
+    unsigned caseIndex() const { return m_cases[m_caseIndex].index; }
+    int64_t caseValue() const { return m_cases[m_caseIndex].value; }
+    
+    bool advance(MacroAssembler&amp;);
+    
+    MacroAssembler::JumpList&amp; fallThrough() { return m_fallThrough; }
+    
+private:
+    void build(unsigned start, unsigned end);
+    
+    GPRReg m_value;
+    
+    struct Case {
+        Case() { }
+
+        Case(int64_t value, unsigned index)
+            : value(value)
+            , index(index)
+        {
+        }
+        
+        bool operator&lt;(const Case&amp; other) const
+        {
+            return value &lt; other.value;
+        }
+        
+        int64_t value;
+        unsigned index;
+    };
+    
+    Vector&lt;Case&gt; m_cases;
+    
+    enum BranchKind {
+        NotEqualToFallThrough,
+        NotEqualToPush,
+        LessThanToPush,
+        Pop,
+        ExecuteCase
+    };
+        
+    struct BranchCode {
+        BranchCode() { }
+        
+        BranchCode(BranchKind kind, unsigned index = UINT_MAX)
+            : kind(kind)
+            , index(index)
+        {
+        }
+        
+        BranchKind kind;
+        unsigned index;
+    };
+    
+    Vector&lt;BranchCode&gt; m_branches;
+
+    unsigned m_index;
+    unsigned m_caseIndex;
+    Vector&lt;MacroAssembler::Jump&gt; m_jumpStack;
+    
+    MacroAssembler::JumpList m_fallThrough;
+    
+    unsigned m_medianBias;
+    
+    Type m_type;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // BinarySwitch_h
+
</ins></span></pre>
</div>
</div>

</body>
</html>