<!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>[212775] 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/212775">212775</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2017-02-21 15:57:03 -0800 (Tue, 21 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Air should have a disassembly mode that dumps IR and assembly intermixed
https://bugs.webkit.org/show_bug.cgi?id=168629

Reviewed by Filip Pizlo.

This will make dumping FTL disassembly dump Air intermixed
with the assembly generated by each Air Inst. This is similar
to how dumpDFGDisassembly dumps the generated assembly for each
Node.
        
Here is what the output will look like:
        
Generated FTL JIT code for foo#CUaFiQ:[0x10b76c960-&gt;0x10b76c2d0-&gt;0x10b7b6da0, FTLFunctionCall, 40 (NeverInline)], instruction count = 40:
BB#0: ; frequency = 1.000000
        0x469004e02e00: push %rbp
        0x469004e02e01: mov %rsp, %rbp
        0x469004e02e04: add $0xffffffffffffffd0, %rsp
    Move $0x10b76c960, %rax, $4487301472(@16)
        0x469004e02e08: mov $0x10b76c960, %rax
    Move %rax, 16(%rbp), @19
        0x469004e02e12: mov %rax, 0x10(%rbp)
    Patch &amp;Patchpoint2, %rbp, %rax, @20
        0x469004e02e16: lea -0x50(%rbp), %rax
        0x469004e02e1a: mov $0x1084081e0, %<a href="http://trac.webkit.org/projects/webkit/changeset/11">r11</a>
        0x469004e02e24: cmp %rax, (%<a href="http://trac.webkit.org/projects/webkit/changeset/11">r11</a>)
        0x469004e02e27: ja 0x469004e02e9a
    Move 56(%rbp), %rdx, @23
        0x469004e02e2d: mov 0x38(%rbp), %rdx
    Move $0xffff000000000002, %rax, $-281474976710654(@15)
        0x469004e02e31: mov $0xffff000000000002, %rax
    Patch &amp;BranchTest64(3,SameAsRep)1, NonZero, %rdx, %rax, %rdx, @26
        0x469004e02e3b: test %rdx, %rax
        0x469004e02e3e: jnz 0x469004e02f08
    Move 48(%rbp), %rax, @29
        0x469004e02e44: mov 0x30(%rbp), %rax
    Move %rax, %rcx, @31
        0x469004e02e48: mov %rax, %rcx
    Xor64 $6, %rcx, @31
        0x469004e02e4b: xor $0x6, %rcx
    Patch &amp;BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35
        0x469004e02e4f: test $0xfffffffffffffffe, %rcx
        0x469004e02e56: jnz 0x469004e02f12
    Patch &amp;Branch32(3,SameAsRep)0, NotEqual, (%rdx), $266, %rdx, @45
        0x469004e02e5c: cmp $0x10a, (%rdx)
        0x469004e02e62: jnz 0x469004e02f1c
    BranchTest32 NonZero, %rax, $1, @49
        0x469004e02e68: test $0x1, %al
        0x469004e02e6a: jnz 0x469004e02e91
  Successors: #3, #1
BB#1: ; frequency = 1.000000
  Predecessors: #0
    Move $0, %rcx, @65
        0x469004e02e70: xor %rcx, %rcx
    Jump @66
  Successors: #2
BB#2: ; frequency = 1.000000
  Predecessors: #1, #3
    Move 24(%rdx), %rax, @58
        0x469004e02e73: mov 0x18(%rdx), %rax
    Patch &amp;BranchAdd32(4,ForceLateUseUnlessRecoverable)3, Overflow, %rcx, %rax, %rcx, %rcx, %rax, @60
        0x469004e02e77: add %eax, %ecx
        0x469004e02e79: jo 0x469004e02f26
    Move $0xffff000000000000, %rax, $-281474976710656(@14)
        0x469004e02e7f: mov $0xffff000000000000, %rax
    Add64 %rcx, %rax, %rax, @62
        0x469004e02e89: add %rcx, %rax
    Ret64 %rax, @63
        0x469004e02e8c: mov %rbp, %rsp
        0x469004e02e8f: pop %rbp
        0x469004e02e90: ret 
BB#3: ; frequency = 1.000000
  Predecessors: #0
    Move 16(%rdx), %rcx, @52
        0x469004e02e91: mov 0x10(%rdx), %rcx
    Jump @55
        0x469004e02e95: jmp 0x469004e02e73
  Successors: #2

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/air/AirCode.h:
(JSC::B3::Air::Code::setDisassembler):
(JSC::B3::Air::Code::disassembler):
* b3/air/AirDisassembler.cpp: Added.
(JSC::B3::Air::Disassembler::startEntrypoint):
(JSC::B3::Air::Disassembler::endEntrypoint):
(JSC::B3::Air::Disassembler::startLatePath):
(JSC::B3::Air::Disassembler::endLatePath):
(JSC::B3::Air::Disassembler::startBlock):
(JSC::B3::Air::Disassembler::addInst):
(JSC::B3::Air::Disassembler::dump):
* b3/air/AirDisassembler.h: Added.
* b3/air/AirGenerate.cpp:
(JSC::B3::Air::generate):
* ftl/FTLCompile.cpp:
(JSC::FTL::compile):</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="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirCodeh">trunk/Source/JavaScriptCore/b3/air/AirCode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirGeneratecpp">trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLCompilecpp">trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreb3airAirDisassemblercpp">trunk/Source/JavaScriptCore/b3/air/AirDisassembler.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3airAirDisassemblerh">trunk/Source/JavaScriptCore/b3/air/AirDisassembler.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 (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx">     b3/air/AirCCallingConvention.cpp
</span><span class="cx">     b3/air/AirCode.cpp
</span><span class="cx">     b3/air/AirCustom.cpp
</span><ins>+    b3/air/AirDisassembler.cpp
</ins><span class="cx">     b3/air/AirDumpAsJS.cpp
</span><span class="cx">     b3/air/AirEliminateDeadCode.cpp
</span><span class="cx">     b3/air/AirEmitShuffle.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -1,3 +1,102 @@
</span><ins>+2017-02-21  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        Air should have a disassembly mode that dumps IR and assembly intermixed
+        https://bugs.webkit.org/show_bug.cgi?id=168629
+
+        Reviewed by Filip Pizlo.
+
+        This will make dumping FTL disassembly dump Air intermixed
+        with the assembly generated by each Air Inst. This is similar
+        to how dumpDFGDisassembly dumps the generated assembly for each
+        Node.
+        
+        Here is what the output will look like:
+        
+        Generated FTL JIT code for foo#CUaFiQ:[0x10b76c960-&gt;0x10b76c2d0-&gt;0x10b7b6da0, FTLFunctionCall, 40 (NeverInline)], instruction count = 40:
+        BB#0: ; frequency = 1.000000
+                0x469004e02e00: push %rbp
+                0x469004e02e01: mov %rsp, %rbp
+                0x469004e02e04: add $0xffffffffffffffd0, %rsp
+            Move $0x10b76c960, %rax, $4487301472(@16)
+                0x469004e02e08: mov $0x10b76c960, %rax
+            Move %rax, 16(%rbp), @19
+                0x469004e02e12: mov %rax, 0x10(%rbp)
+            Patch &amp;Patchpoint2, %rbp, %rax, @20
+                0x469004e02e16: lea -0x50(%rbp), %rax
+                0x469004e02e1a: mov $0x1084081e0, %r11
+                0x469004e02e24: cmp %rax, (%r11)
+                0x469004e02e27: ja 0x469004e02e9a
+            Move 56(%rbp), %rdx, @23
+                0x469004e02e2d: mov 0x38(%rbp), %rdx
+            Move $0xffff000000000002, %rax, $-281474976710654(@15)
+                0x469004e02e31: mov $0xffff000000000002, %rax
+            Patch &amp;BranchTest64(3,SameAsRep)1, NonZero, %rdx, %rax, %rdx, @26
+                0x469004e02e3b: test %rdx, %rax
+                0x469004e02e3e: jnz 0x469004e02f08
+            Move 48(%rbp), %rax, @29
+                0x469004e02e44: mov 0x30(%rbp), %rax
+            Move %rax, %rcx, @31
+                0x469004e02e48: mov %rax, %rcx
+            Xor64 $6, %rcx, @31
+                0x469004e02e4b: xor $0x6, %rcx
+            Patch &amp;BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35
+                0x469004e02e4f: test $0xfffffffffffffffe, %rcx
+                0x469004e02e56: jnz 0x469004e02f12
+            Patch &amp;Branch32(3,SameAsRep)0, NotEqual, (%rdx), $266, %rdx, @45
+                0x469004e02e5c: cmp $0x10a, (%rdx)
+                0x469004e02e62: jnz 0x469004e02f1c
+            BranchTest32 NonZero, %rax, $1, @49
+                0x469004e02e68: test $0x1, %al
+                0x469004e02e6a: jnz 0x469004e02e91
+          Successors: #3, #1
+        BB#1: ; frequency = 1.000000
+          Predecessors: #0
+            Move $0, %rcx, @65
+                0x469004e02e70: xor %rcx, %rcx
+            Jump @66
+          Successors: #2
+        BB#2: ; frequency = 1.000000
+          Predecessors: #1, #3
+            Move 24(%rdx), %rax, @58
+                0x469004e02e73: mov 0x18(%rdx), %rax
+            Patch &amp;BranchAdd32(4,ForceLateUseUnlessRecoverable)3, Overflow, %rcx, %rax, %rcx, %rcx, %rax, @60
+                0x469004e02e77: add %eax, %ecx
+                0x469004e02e79: jo 0x469004e02f26
+            Move $0xffff000000000000, %rax, $-281474976710656(@14)
+                0x469004e02e7f: mov $0xffff000000000000, %rax
+            Add64 %rcx, %rax, %rax, @62
+                0x469004e02e89: add %rcx, %rax
+            Ret64 %rax, @63
+                0x469004e02e8c: mov %rbp, %rsp
+                0x469004e02e8f: pop %rbp
+                0x469004e02e90: ret 
+        BB#3: ; frequency = 1.000000
+          Predecessors: #0
+            Move 16(%rdx), %rcx, @52
+                0x469004e02e91: mov 0x10(%rdx), %rcx
+            Jump @55
+                0x469004e02e95: jmp 0x469004e02e73
+          Successors: #2
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * b3/air/AirCode.h:
+        (JSC::B3::Air::Code::setDisassembler):
+        (JSC::B3::Air::Code::disassembler):
+        * b3/air/AirDisassembler.cpp: Added.
+        (JSC::B3::Air::Disassembler::startEntrypoint):
+        (JSC::B3::Air::Disassembler::endEntrypoint):
+        (JSC::B3::Air::Disassembler::startLatePath):
+        (JSC::B3::Air::Disassembler::endLatePath):
+        (JSC::B3::Air::Disassembler::startBlock):
+        (JSC::B3::Air::Disassembler::addInst):
+        (JSC::B3::Air::Disassembler::dump):
+        * b3/air/AirDisassembler.h: Added.
+        * b3/air/AirGenerate.cpp:
+        (JSC::B3::Air::generate):
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::compile):
+
</ins><span class="cx"> 2017-02-21  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r212712.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -1458,6 +1458,8 @@
</span><span class="cx">                 79A090801D768465008B889B /* HashMapImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 79A0907E1D768465008B889B /* HashMapImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79A228351D35D71E00D8E067 /* ArithProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79A228331D35D71E00D8E067 /* ArithProfile.cpp */; };
</span><span class="cx">                 79A228361D35D71F00D8E067 /* ArithProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 79A228341D35D71E00D8E067 /* ArithProfile.h */; };
</span><ins>+                79ABB17D1E5CCB570045B9A6 /* AirDisassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */; };
+                79ABB17E1E5CCB570045B9A6 /* AirDisassembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 79AF0BE41D3EFD4C00E95FA5 /* JITMathICInlineResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 79AF0BE31D3EFD4C00E95FA5 /* JITMathICInlineResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79B00CBC1C6AB07E0088C65D /* ProxyConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79B00CB81C6AB07E0088C65D /* ProxyConstructor.cpp */; };
</span><span class="cx">                 79B00CBD1C6AB07E0088C65D /* ProxyConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B00CB91C6AB07E0088C65D /* ProxyConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -3945,6 +3947,8 @@
</span><span class="cx">                 79A228331D35D71E00D8E067 /* ArithProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArithProfile.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79A228341D35D71E00D8E067 /* ArithProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArithProfile.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79A899FE1D38612E00D18C73 /* JITMathICForwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITMathICForwards.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirDisassembler.cpp; path = b3/air/AirDisassembler.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirDisassembler.h; path = b3/air/AirDisassembler.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 79AF0BE31D3EFD4C00E95FA5 /* JITMathICInlineResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITMathICInlineResult.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79B00CB81C6AB07E0088C65D /* ProxyConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyConstructor.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 79B00CB91C6AB07E0088C65D /* ProxyConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyConstructor.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5444,6 +5448,8 @@
</span><span class="cx">                                 0FEC85511BDACDC70080FF74 /* AirCode.h */,
</span><span class="cx">                                 0F6183221C45BF070072450B /* AirCustom.cpp */,
</span><span class="cx">                                 0F10F1A21C420BF0001C07D2 /* AirCustom.h */,
</span><ins>+                                79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */,
+                                79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */,
</ins><span class="cx">                                 DC454B8A1D00E81F004C18AF /* AirDumpAsJS.cpp */,
</span><span class="cx">                                 DC454B8B1D00E81F004C18AF /* AirDumpAsJS.h */,
</span><span class="cx">                                 0F4570361BE44C910062A629 /* AirEliminateDeadCode.cpp */,
</span><span class="lines">@@ -7942,6 +7948,7 @@
</span><span class="cx">                                 A5EA70E919F5B1010098F5EC /* AlternateDispatchableAgent.h in Headers */,
</span><span class="cx">                                 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */,
</span><span class="cx">                                 BC18C3E50E16F5CD00B34460 /* APICast.h in Headers */,
</span><ins>+                                79ABB17E1E5CCB570045B9A6 /* AirDisassembler.h in Headers */,
</ins><span class="cx">                                 53529A4C1C457B75000B49C6 /* APIUtils.h in Headers */,
</span><span class="cx">                                 BCF605140E203EF800B9A64D /* ArgList.h in Headers */,
</span><span class="cx">                                 0FE050141AA9091100D33B33 /* ArgumentsMode.h in Headers */,
</span><span class="lines">@@ -10280,6 +10287,7 @@
</span><span class="cx">                                 657CF45819BF6662004ACBF2 /* JSCallee.cpp in Sources */,
</span><span class="cx">                                 A7D801A81880D6A80026C39B /* JSCBuiltins.cpp in Sources */,
</span><span class="cx">                                 147F39D1107EC37600427A48 /* JSCell.cpp in Sources */,
</span><ins>+                                79ABB17D1E5CCB570045B9A6 /* AirDisassembler.cpp in Sources */,
</ins><span class="cx">                                 147F39D6107EC37600427A48 /* JSCJSValue.cpp in Sources */,
</span><span class="cx">                                 1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
</span><span class="cx">                                 86E3C616167BABEE006D760A /* JSContext.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirCodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirCode.h (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirCode.h        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/b3/air/AirCode.h        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AirArg.h&quot;
</span><span class="cx"> #include &quot;AirBasicBlock.h&quot;
</span><ins>+#include &quot;AirDisassembler.h&quot;
</ins><span class="cx"> #include &quot;AirSpecial.h&quot;
</span><span class="cx"> #include &quot;AirStackSlot.h&quot;
</span><span class="cx"> #include &quot;AirTmp.h&quot;
</span><span class="lines">@@ -51,6 +52,7 @@
</span><span class="cx"> 
</span><span class="cx"> class BlockInsertionSet;
</span><span class="cx"> class CCallSpecial;
</span><ins>+class Disassembler;
</ins><span class="cx"> 
</span><span class="cx"> typedef void WasmBoundsCheckGeneratorFunction(CCallHelpers&amp;, GPRReg, unsigned);
</span><span class="cx"> typedef SharedTask&lt;WasmBoundsCheckGeneratorFunction&gt; WasmBoundsCheckGenerator;
</span><span class="lines">@@ -275,6 +277,9 @@
</span><span class="cx">     // it's mainly for validating the results from JSAir.
</span><span class="cx">     unsigned jsHash() const;
</span><span class="cx"> 
</span><ins>+    void setDisassembler(std::unique_ptr&lt;Disassembler&gt;&amp;&amp; disassembler) { m_disassembler = WTFMove(disassembler); }
+    Disassembler* disassembler() { return m_disassembler.get(); }
+
</ins><span class="cx"> private:
</span><span class="cx">     friend class ::JSC::B3::Procedure;
</span><span class="cx">     friend class BlockInsertionSet;
</span><span class="lines">@@ -310,6 +315,7 @@
</span><span class="cx">     Vector&lt;CCallHelpers::Label&gt; m_entrypointLabels; // This is empty until code generation.
</span><span class="cx">     RefPtr&lt;WasmBoundsCheckGenerator&gt; m_wasmBoundsCheckGenerator;
</span><span class="cx">     const char* m_lastPhaseName;
</span><ins>+    std::unique_ptr&lt;Disassembler&gt; m_disassembler;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } } } // namespace JSC::B3::Air
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirDisassemblercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/b3/air/AirDisassembler.cpp (0 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirDisassembler.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/air/AirDisassembler.cpp        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -0,0 +1,112 @@
</span><ins>+/*
+ * Copyright (C) 2017 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;AirDisassembler.h&quot;
+
+#if ENABLE(B3_JIT)
+
+#include &quot;AirBasicBlock.h&quot;
+#include &quot;AirCode.h&quot;
+#include &quot;AirInst.h&quot;
+#include &quot;Disassembler.h&quot;
+#include &quot;LinkBuffer.h&quot;
+
+namespace JSC { namespace B3 { namespace Air {
+
+void Disassembler::startEntrypoint(CCallHelpers&amp; jit)
+{
+    m_entrypointStart = jit.labelIgnoringWatchpoints();
+}
+
+void Disassembler::endEntrypoint(CCallHelpers&amp; jit)
+{
+    m_entrypointEnd = jit.labelIgnoringWatchpoints();
+}
+
+void Disassembler::startLatePath(CCallHelpers&amp; jit)
+{
+    m_latePathStart = jit.labelIgnoringWatchpoints();
+}
+
+void Disassembler::endLatePath(CCallHelpers&amp; jit)
+{
+    m_latePathEnd = jit.labelIgnoringWatchpoints();
+}
+
+void Disassembler::startBlock(BasicBlock* block, CCallHelpers&amp; jit)
+{
+    UNUSED_PARAM(jit);
+    m_blocks.append(block);
+}
+
+void Disassembler::addInst(Inst* inst, CCallHelpers::Label start, CCallHelpers::Label end)
+{
+    auto addResult = m_instToRange.add(inst, std::make_pair(start, end));
+    RELEASE_ASSERT(addResult.isNewEntry);
+}
+
+void Disassembler::dump(Code&amp; code, PrintStream&amp; out, LinkBuffer&amp; linkBuffer)
+{
+    auto dumpRange = [&amp;] (CCallHelpers::Label startLabel, CCallHelpers::Label endLabel) {
+        RELEASE_ASSERT(startLabel.isSet());
+        RELEASE_ASSERT(endLabel.isSet());
+        CodeLocationLabel start = linkBuffer.locationOf(startLabel);
+        CodeLocationLabel end = linkBuffer.locationOf(endLabel);
+        RELEASE_ASSERT(bitwise_cast&lt;uintptr_t&gt;(end.executableAddress()) &gt;= bitwise_cast&lt;uintptr_t&gt;(start.executableAddress()));
+        const char* prefix = &quot;      &quot;;
+        disassemble(start, bitwise_cast&lt;uintptr_t&gt;(end.executableAddress()) - bitwise_cast&lt;uintptr_t&gt;(start.executableAddress()), prefix, out);
+    };
+
+    for (BasicBlock* block : m_blocks) {
+        block-&gt;dumpHeader(out);
+        if (code.isEntrypoint(block))
+            dumpRange(m_entrypointStart, m_entrypointEnd);
+
+        for (Inst&amp; inst : *block) {
+            out.print(&quot;    &quot;);
+            inst.dump(out);
+            out.print(&quot;\n&quot;);
+
+            auto iter = m_instToRange.find(&amp;inst);
+            if (iter == m_instToRange.end()) {
+                RELEASE_ASSERT(&amp;inst == &amp;block-&gt;last());
+                continue;
+            }
+            auto pair = iter-&gt;value;
+            dumpRange(pair.first, pair.second);
+        }
+        block-&gt;dumpFooter(out);
+    }
+
+    // FIXME: We could be better about various late paths. We can implement
+    // this later if we find a strong use for it.
+    out.print(&quot;# Late paths\n&quot;);
+    dumpRange(m_latePathStart, m_latePathEnd);
+}
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirDisassemblerh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/b3/air/AirDisassembler.h (0 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirDisassembler.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/b3/air/AirDisassembler.h        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2017 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. 
+ */
+
+#pragma once
+
+#if ENABLE(B3_JIT)
+
+#include &quot;CCallHelpers.h&quot;
+
+namespace JSC { 
+
+class LinkBuffer;
+
+namespace B3 { namespace Air {
+
+class BasicBlock;
+class Code;
+struct Inst;
+
+class Disassembler {
+public:
+    Disassembler() = default;
+
+    void startEntrypoint(CCallHelpers&amp;);
+    void endEntrypoint(CCallHelpers&amp;);
+    void startLatePath(CCallHelpers&amp;);
+    void endLatePath(CCallHelpers&amp;);
+    void startBlock(BasicBlock*, CCallHelpers&amp;);
+    void addInst(Inst*, CCallHelpers::Label, CCallHelpers::Label);
+
+    void dump(Code&amp;, PrintStream&amp;, LinkBuffer&amp;);
+
+private:
+    HashMap&lt;Inst*, std::pair&lt;CCallHelpers::Label, CCallHelpers::Label&gt;&gt; m_instToRange;
+    Vector&lt;BasicBlock*&gt; m_blocks;
+    CCallHelpers::Label m_entrypointStart;
+    CCallHelpers::Label m_entrypointEnd;
+    CCallHelpers::Label m_latePathStart;
+    CCallHelpers::Label m_latePathEnd;
+};
+
+} } } // namespace JSC::B3::Air
+
+#endif // ENABLE(B3_JIT)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3airAirGeneratecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -196,6 +196,8 @@
</span><span class="cx">         pcToOriginMap.appendItem(jit.labelIgnoringWatchpoints(), inst.origin-&gt;origin());
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    Disassembler* disassembler = code.disassembler();
+
</ins><span class="cx">     for (BasicBlock* block : code) {
</span><span class="cx">         context.currentBlock = block;
</span><span class="cx">         context.indexInBlock = UINT_MAX;
</span><span class="lines">@@ -203,7 +205,13 @@
</span><span class="cx">         CCallHelpers::Label label = jit.label();
</span><span class="cx">         *context.blockLabels[block] = label;
</span><span class="cx"> 
</span><ins>+        if (disassembler)
+            disassembler-&gt;startBlock(block, jit); 
+
</ins><span class="cx">         if (code.isEntrypoint(block)) {
</span><ins>+            if (disassembler)
+                disassembler-&gt;startEntrypoint(jit); 
+
</ins><span class="cx">             jit.emitFunctionPrologue();
</span><span class="cx">             if (code.frameSize())
</span><span class="cx">                 jit.addPtr(CCallHelpers::TrustedImm32(-code.frameSize()), MacroAssembler::stackPointerRegister);
</span><span class="lines">@@ -214,6 +222,9 @@
</span><span class="cx">                 else
</span><span class="cx">                     jit.storeDouble(entry.reg().fpr(), argFor(entry));
</span><span class="cx">             }
</span><ins>+
+            if (disassembler)
+                disassembler-&gt;endEntrypoint(jit); 
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         ASSERT(block-&gt;size() &gt;= 1);
</span><span class="lines">@@ -221,8 +232,12 @@
</span><span class="cx">             context.indexInBlock = i;
</span><span class="cx">             Inst&amp; inst = block-&gt;at(i);
</span><span class="cx">             addItem(inst);
</span><ins>+            auto start = jit.labelIgnoringWatchpoints();
</ins><span class="cx">             CCallHelpers::Jump jump = inst.generate(jit, context);
</span><span class="cx">             ASSERT_UNUSED(jump, !jump.isSet());
</span><ins>+            auto end = jit.labelIgnoringWatchpoints();
+            if (disassembler)
+                disassembler-&gt;addInst(&amp;inst, start, end);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         context.indexInBlock = block-&gt;size() - 1;
</span><span class="lines">@@ -236,6 +251,7 @@
</span><span class="cx">         if (isReturn(block-&gt;last().kind.opcode)) {
</span><span class="cx">             // We currently don't represent the full prologue/epilogue in Air, so we need to
</span><span class="cx">             // have this override.
</span><ins>+            auto start = jit.labelIgnoringWatchpoints();
</ins><span class="cx">             if (code.frameSize()) {
</span><span class="cx">                 for (const RegisterAtOffset&amp; entry : code.calleeSaveRegisters()) {
</span><span class="cx">                     if (entry.reg().isGPR())
</span><span class="lines">@@ -248,10 +264,18 @@
</span><span class="cx">                 jit.emitFunctionEpilogueWithEmptyFrame();
</span><span class="cx">             jit.ret();
</span><span class="cx">             addItem(block-&gt;last());
</span><ins>+            auto end = jit.labelIgnoringWatchpoints();
+            if (disassembler)
+                disassembler-&gt;addInst(&amp;block-&gt;last(), start, end);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        auto start = jit.labelIgnoringWatchpoints();
</ins><span class="cx">         CCallHelpers::Jump jump = block-&gt;last().generate(jit, context);
</span><ins>+        auto end = jit.labelIgnoringWatchpoints();
+        if (disassembler)
+            disassembler-&gt;addInst(&amp;block-&gt;last(), start, end);
+
</ins><span class="cx">         // The jump won't be set for patchpoints. It won't be set for Oops because then it won't have
</span><span class="cx">         // any successors.
</span><span class="cx">         if (jump.isSet()) {
</span><span class="lines">@@ -282,9 +306,15 @@
</span><span class="cx"> 
</span><span class="cx">     pcToOriginMap.appendItem(jit.label(), Origin());
</span><span class="cx">     // FIXME: Make late paths have Origins: https://bugs.webkit.org/show_bug.cgi?id=153689
</span><ins>+    if (disassembler)
+        disassembler-&gt;startLatePath(jit);
+
</ins><span class="cx">     for (auto&amp; latePath : context.latePaths)
</span><span class="cx">         latePath-&gt;run(jit, context);
</span><del>-    pcToOriginMap.appendItem(jit.label(), Origin());
</del><ins>+
+    if (disassembler)
+        disassembler-&gt;endLatePath(jit);
+    pcToOriginMap.appendItem(jit.labelIgnoringWatchpoints(), Origin());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } } } // namespace JSC::B3::Air
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLCompilecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp (212774 => 212775)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp        2017-02-21 23:49:42 UTC (rev 212774)
+++ trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp        2017-02-21 23:57:03 UTC (rev 212775)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(FTL_JIT)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AirCode.h&quot;
</span><ins>+#include &quot;AirDisassembler.h&quot;
</ins><span class="cx"> #include &quot;B3Generate.h&quot;
</span><span class="cx"> #include &quot;B3ProcedureInlines.h&quot;
</span><span class="cx"> #include &quot;B3StackSlot.h&quot;
</span><span class="lines">@@ -57,6 +58,9 @@
</span><span class="cx">     CodeBlock* codeBlock = graph.m_codeBlock;
</span><span class="cx">     VM&amp; vm = graph.m_vm;
</span><span class="cx"> 
</span><ins>+    if (shouldDumpDisassembly())
+        state.proc-&gt;code().setDisassembler(std::make_unique&lt;B3::Air::Disassembler&gt;());
+
</ins><span class="cx">     {
</span><span class="cx">         GraphSafepoint safepoint(state.graph, safepointResult);
</span><span class="cx"> 
</span><span class="lines">@@ -151,6 +155,13 @@
</span><span class="cx">     state.generatedFunction = bitwise_cast&lt;GeneratedFunction&gt;(
</span><span class="cx">         state.finalizer-&gt;b3CodeLinkBuffer-&gt;entrypoint().executableAddress());
</span><span class="cx">     state.jitCode-&gt;initializeB3Byproducts(state.proc-&gt;releaseByproducts());
</span><ins>+
+    if (B3::Air::Disassembler* disassembler = state.proc-&gt;code().disassembler()) {
+        dataLogLn(&quot;\nGenerated FTL JIT code for &quot;, CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), &quot;, instruction count = &quot;, state.graph.m_codeBlock-&gt;instructionCount(), &quot;:&quot;);
+        LinkBuffer&amp; linkBuffer = *state.finalizer-&gt;b3CodeLinkBuffer;
+        disassembler-&gt;dump(state.proc-&gt;code(), WTF::dataFile(), linkBuffer);
+        linkBuffer.didAlreadyDisassemble();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::FTL
</span></span></pre>
</div>
</div>

</body>
</html>