Skip to content

Commit e18e086

Browse files
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->0x10b76c2d0->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 &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 &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 &BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35 0x469004e02e4f: test $0xfffffffffffffffe, %rcx 0x469004e02e56: jnz 0x469004e02f12 Patch &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 &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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@212775 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f8added commit e18e086

8 files changed

Lines changed: 334 additions & 1 deletion

File tree

‎Source/JavaScriptCore/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ set(JavaScriptCore_SOURCES
7979
b3/air/AirCCallingConvention.cpp
8080
b3/air/AirCode.cpp
8181
b3/air/AirCustom.cpp
82+
b3/air/AirDisassembler.cpp
8283
b3/air/AirDumpAsJS.cpp
8384
b3/air/AirEliminateDeadCode.cpp
8485
b3/air/AirEmitShuffle.cpp

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,102 @@
1+
2017-02-21 Saam Barati <[email protected]>
2+
3+
Air should have a disassembly mode that dumps IR and assembly intermixed
4+
https://bugs.webkit.org/show_bug.cgi?id=168629
5+
6+
Reviewed by Filip Pizlo.
7+
8+
This will make dumping FTL disassembly dump Air intermixed
9+
with the assembly generated by each Air Inst. This is similar
10+
to how dumpDFGDisassembly dumps the generated assembly for each
11+
Node.
12+
13+
Here is what the output will look like:
14+
15+
Generated FTL JIT code for foo#CUaFiQ:[0x10b76c960->0x10b76c2d0->0x10b7b6da0, FTLFunctionCall, 40 (NeverInline)], instruction count = 40:
16+
BB#0: ; frequency = 1.000000
17+
0x469004e02e00: push %rbp
18+
0x469004e02e01: mov %rsp, %rbp
19+
0x469004e02e04: add $0xffffffffffffffd0, %rsp
20+
Move $0x10b76c960, %rax, $4487301472(@16)
21+
0x469004e02e08: mov $0x10b76c960, %rax
22+
Move %rax, 16(%rbp), @19
23+
0x469004e02e12: mov %rax, 0x10(%rbp)
24+
Patch &Patchpoint2, %rbp, %rax, @20
25+
0x469004e02e16: lea -0x50(%rbp), %rax
26+
0x469004e02e1a: mov $0x1084081e0, %r11
27+
0x469004e02e24: cmp %rax, (%r11)
28+
0x469004e02e27: ja 0x469004e02e9a
29+
Move 56(%rbp), %rdx, @23
30+
0x469004e02e2d: mov 0x38(%rbp), %rdx
31+
Move $0xffff000000000002, %rax, $-281474976710654(@15)
32+
0x469004e02e31: mov $0xffff000000000002, %rax
33+
Patch &BranchTest64(3,SameAsRep)1, NonZero, %rdx, %rax, %rdx, @26
34+
0x469004e02e3b: test %rdx, %rax
35+
0x469004e02e3e: jnz 0x469004e02f08
36+
Move 48(%rbp), %rax, @29
37+
0x469004e02e44: mov 0x30(%rbp), %rax
38+
Move %rax, %rcx, @31
39+
0x469004e02e48: mov %rax, %rcx
40+
Xor64 $6, %rcx, @31
41+
0x469004e02e4b: xor $0x6, %rcx
42+
Patch &BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35
43+
0x469004e02e4f: test $0xfffffffffffffffe, %rcx
44+
0x469004e02e56: jnz 0x469004e02f12
45+
Patch &Branch32(3,SameAsRep)0, NotEqual, (%rdx), $266, %rdx, @45
46+
0x469004e02e5c: cmp $0x10a, (%rdx)
47+
0x469004e02e62: jnz 0x469004e02f1c
48+
BranchTest32 NonZero, %rax, $1, @49
49+
0x469004e02e68: test $0x1, %al
50+
0x469004e02e6a: jnz 0x469004e02e91
51+
Successors: #3, #1
52+
BB#1: ; frequency = 1.000000
53+
Predecessors: #0
54+
Move $0, %rcx, @65
55+
0x469004e02e70: xor %rcx, %rcx
56+
Jump @66
57+
Successors: #2
58+
BB#2: ; frequency = 1.000000
59+
Predecessors: #1, #3
60+
Move 24(%rdx), %rax, @58
61+
0x469004e02e73: mov 0x18(%rdx), %rax
62+
Patch &BranchAdd32(4,ForceLateUseUnlessRecoverable)3, Overflow, %rcx, %rax, %rcx, %rcx, %rax, @60
63+
0x469004e02e77: add %eax, %ecx
64+
0x469004e02e79: jo 0x469004e02f26
65+
Move $0xffff000000000000, %rax, $-281474976710656(@14)
66+
0x469004e02e7f: mov $0xffff000000000000, %rax
67+
Add64 %rcx, %rax, %rax, @62
68+
0x469004e02e89: add %rcx, %rax
69+
Ret64 %rax, @63
70+
0x469004e02e8c: mov %rbp, %rsp
71+
0x469004e02e8f: pop %rbp
72+
0x469004e02e90: ret
73+
BB#3: ; frequency = 1.000000
74+
Predecessors: #0
75+
Move 16(%rdx), %rcx, @52
76+
0x469004e02e91: mov 0x10(%rdx), %rcx
77+
Jump @55
78+
0x469004e02e95: jmp 0x469004e02e73
79+
Successors: #2
80+
81+
* CMakeLists.txt:
82+
* JavaScriptCore.xcodeproj/project.pbxproj:
83+
* b3/air/AirCode.h:
84+
(JSC::B3::Air::Code::setDisassembler):
85+
(JSC::B3::Air::Code::disassembler):
86+
* b3/air/AirDisassembler.cpp: Added.
87+
(JSC::B3::Air::Disassembler::startEntrypoint):
88+
(JSC::B3::Air::Disassembler::endEntrypoint):
89+
(JSC::B3::Air::Disassembler::startLatePath):
90+
(JSC::B3::Air::Disassembler::endLatePath):
91+
(JSC::B3::Air::Disassembler::startBlock):
92+
(JSC::B3::Air::Disassembler::addInst):
93+
(JSC::B3::Air::Disassembler::dump):
94+
* b3/air/AirDisassembler.h: Added.
95+
* b3/air/AirGenerate.cpp:
96+
(JSC::B3::Air::generate):
97+
* ftl/FTLCompile.cpp:
98+
(JSC::FTL::compile):
99+
1100
2017-02-21 Ryan Haddad <[email protected]>
2101

3102
Unreviewed, rolling out r212712.

‎Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,8 @@
14581458
79A090801D768465008B889B /* HashMapImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 79A0907E1D768465008B889B /* HashMapImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
14591459
79A228351D35D71E00D8E067 /* ArithProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79A228331D35D71E00D8E067 /* ArithProfile.cpp */; };
14601460
79A228361D35D71F00D8E067 /* ArithProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 79A228341D35D71E00D8E067 /* ArithProfile.h */; };
1461+
79ABB17D1E5CCB570045B9A6 /* AirDisassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */; };
1462+
79ABB17E1E5CCB570045B9A6 /* AirDisassembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
14611463
79AF0BE41D3EFD4C00E95FA5 /* JITMathICInlineResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 79AF0BE31D3EFD4C00E95FA5 /* JITMathICInlineResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
14621464
79B00CBC1C6AB07E0088C65D /* ProxyConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79B00CB81C6AB07E0088C65D /* ProxyConstructor.cpp */; };
14631465
79B00CBD1C6AB07E0088C65D /* ProxyConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 79B00CB91C6AB07E0088C65D /* ProxyConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3945,6 +3947,8 @@
39453947
79A228331D35D71E00D8E067 /* ArithProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArithProfile.cpp; sourceTree = "<group>"; };
39463948
79A228341D35D71E00D8E067 /* ArithProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArithProfile.h; sourceTree = "<group>"; };
39473949
79A899FE1D38612E00D18C73 /* JITMathICForwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITMathICForwards.h; sourceTree = "<group>"; };
3950+
79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirDisassembler.cpp; path = b3/air/AirDisassembler.cpp; sourceTree = "<group>"; };
3951+
79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirDisassembler.h; path = b3/air/AirDisassembler.h; sourceTree = "<group>"; };
39483952
79AF0BE31D3EFD4C00E95FA5 /* JITMathICInlineResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITMathICInlineResult.h; sourceTree = "<group>"; };
39493953
79B00CB81C6AB07E0088C65D /* ProxyConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyConstructor.cpp; sourceTree = "<group>"; };
39503954
79B00CB91C6AB07E0088C65D /* ProxyConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyConstructor.h; sourceTree = "<group>"; };
@@ -5444,6 +5448,8 @@
54445448
0FEC85511BDACDC70080FF74 /* AirCode.h */,
54455449
0F6183221C45BF070072450B /* AirCustom.cpp */,
54465450
0F10F1A21C420BF0001C07D2 /* AirCustom.h */,
5451+
79ABB17B1E5CCB570045B9A6 /* AirDisassembler.cpp */,
5452+
79ABB17C1E5CCB570045B9A6 /* AirDisassembler.h */,
54475453
DC454B8A1D00E81F004C18AF /* AirDumpAsJS.cpp */,
54485454
DC454B8B1D00E81F004C18AF /* AirDumpAsJS.h */,
54495455
0F4570361BE44C910062A629 /* AirEliminateDeadCode.cpp */,
@@ -7942,6 +7948,7 @@
79427948
A5EA70E919F5B1010098F5EC /* AlternateDispatchableAgent.h in Headers */,
79437949
2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */,
79447950
BC18C3E50E16F5CD00B34460 /* APICast.h in Headers */,
7951+
79ABB17E1E5CCB570045B9A6 /* AirDisassembler.h in Headers */,
79457952
53529A4C1C457B75000B49C6 /* APIUtils.h in Headers */,
79467953
BCF605140E203EF800B9A64D /* ArgList.h in Headers */,
79477954
0FE050141AA9091100D33B33 /* ArgumentsMode.h in Headers */,
@@ -10280,6 +10287,7 @@
1028010287
657CF45819BF6662004ACBF2 /* JSCallee.cpp in Sources */,
1028110288
A7D801A81880D6A80026C39B /* JSCBuiltins.cpp in Sources */,
1028210289
147F39D1107EC37600427A48 /* JSCell.cpp in Sources */,
10290+
79ABB17D1E5CCB570045B9A6 /* AirDisassembler.cpp in Sources */,
1028310291
147F39D6107EC37600427A48 /* JSCJSValue.cpp in Sources */,
1028410292
1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
1028510293
86E3C616167BABEE006D760A /* JSContext.mm in Sources */,

‎Source/JavaScriptCore/b3/air/AirCode.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "AirArg.h"
3131
#include "AirBasicBlock.h"
32+
#include "AirDisassembler.h"
3233
#include "AirSpecial.h"
3334
#include "AirStackSlot.h"
3435
#include "AirTmp.h"
@@ -51,6 +52,7 @@ namespace Air {
5152

5253
class BlockInsertionSet;
5354
class CCallSpecial;
55+
class Disassembler;
5456

5557
typedef void WasmBoundsCheckGeneratorFunction(CCallHelpers&, GPRReg, unsigned);
5658
typedef SharedTask<WasmBoundsCheckGeneratorFunction> WasmBoundsCheckGenerator;
@@ -275,6 +277,9 @@ class Code {
275277
// it's mainly for validating the results from JSAir.
276278
unsigned jsHash() const;
277279

280+
void setDisassembler(std::unique_ptr<Disassembler>&& disassembler) { m_disassembler = WTFMove(disassembler); }
281+
Disassembler* disassembler() { return m_disassembler.get(); }
282+
278283
private:
279284
friend class ::JSC::B3::Procedure;
280285
friend class BlockInsertionSet;
@@ -310,6 +315,7 @@ class Code {
310315
Vector<CCallHelpers::Label> m_entrypointLabels; // This is empty until code generation.
311316
RefPtr<WasmBoundsCheckGenerator> m_wasmBoundsCheckGenerator;
312317
const char* m_lastPhaseName;
318+
std::unique_ptr<Disassembler> m_disassembler;
313319
};
314320

315321
} } } // namespace JSC::B3::Air
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (C) 2017 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "AirDisassembler.h"
28+
29+
#if ENABLE(B3_JIT)
30+
31+
#include "AirBasicBlock.h"
32+
#include "AirCode.h"
33+
#include "AirInst.h"
34+
#include "Disassembler.h"
35+
#include "LinkBuffer.h"
36+
37+
namespace JSC { namespace B3 { namespace Air {
38+
39+
void Disassembler::startEntrypoint(CCallHelpers& jit)
40+
{
41+
m_entrypointStart = jit.labelIgnoringWatchpoints();
42+
}
43+
44+
void Disassembler::endEntrypoint(CCallHelpers& jit)
45+
{
46+
m_entrypointEnd = jit.labelIgnoringWatchpoints();
47+
}
48+
49+
void Disassembler::startLatePath(CCallHelpers& jit)
50+
{
51+
m_latePathStart = jit.labelIgnoringWatchpoints();
52+
}
53+
54+
void Disassembler::endLatePath(CCallHelpers& jit)
55+
{
56+
m_latePathEnd = jit.labelIgnoringWatchpoints();
57+
}
58+
59+
void Disassembler::startBlock(BasicBlock* block, CCallHelpers& jit)
60+
{
61+
UNUSED_PARAM(jit);
62+
m_blocks.append(block);
63+
}
64+
65+
void Disassembler::addInst(Inst* inst, CCallHelpers::Label start, CCallHelpers::Label end)
66+
{
67+
auto addResult = m_instToRange.add(inst, std::make_pair(start, end));
68+
RELEASE_ASSERT(addResult.isNewEntry);
69+
}
70+
71+
void Disassembler::dump(Code& code, PrintStream& out, LinkBuffer& linkBuffer)
72+
{
73+
auto dumpRange = [&] (CCallHelpers::Label startLabel, CCallHelpers::Label endLabel) {
74+
RELEASE_ASSERT(startLabel.isSet());
75+
RELEASE_ASSERT(endLabel.isSet());
76+
CodeLocationLabel start = linkBuffer.locationOf(startLabel);
77+
CodeLocationLabel end = linkBuffer.locationOf(endLabel);
78+
RELEASE_ASSERT(bitwise_cast<uintptr_t>(end.executableAddress()) >= bitwise_cast<uintptr_t>(start.executableAddress()));
79+
const char* prefix = " ";
80+
disassemble(start, bitwise_cast<uintptr_t>(end.executableAddress()) - bitwise_cast<uintptr_t>(start.executableAddress()), prefix, out);
81+
};
82+
83+
for (BasicBlock* block : m_blocks) {
84+
block->dumpHeader(out);
85+
if (code.isEntrypoint(block))
86+
dumpRange(m_entrypointStart, m_entrypointEnd);
87+
88+
for (Inst& inst : *block) {
89+
out.print(" ");
90+
inst.dump(out);
91+
out.print("\n");
92+
93+
auto iter = m_instToRange.find(&inst);
94+
if (iter == m_instToRange.end()) {
95+
RELEASE_ASSERT(&inst == &block->last());
96+
continue;
97+
}
98+
auto pair = iter->value;
99+
dumpRange(pair.first, pair.second);
100+
}
101+
block->dumpFooter(out);
102+
}
103+
104+
// FIXME: We could be better about various late paths. We can implement
105+
// this later if we find a strong use for it.
106+
out.print("# Late paths\n");
107+
dumpRange(m_latePathStart, m_latePathEnd);
108+
}
109+
110+
} } } // namespace JSC::B3::Air
111+
112+
#endif // ENABLE(B3_JIT)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2017 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if ENABLE(B3_JIT)
29+
30+
#include "CCallHelpers.h"
31+
32+
namespace JSC {
33+
34+
class LinkBuffer;
35+
36+
namespace B3 { namespace Air {
37+
38+
class BasicBlock;
39+
class Code;
40+
struct Inst;
41+
42+
class Disassembler {
43+
public:
44+
Disassembler() = default;
45+
46+
void startEntrypoint(CCallHelpers&);
47+
void endEntrypoint(CCallHelpers&);
48+
void startLatePath(CCallHelpers&);
49+
void endLatePath(CCallHelpers&);
50+
void startBlock(BasicBlock*, CCallHelpers&);
51+
void addInst(Inst*, CCallHelpers::Label, CCallHelpers::Label);
52+
53+
void dump(Code&, PrintStream&, LinkBuffer&);
54+
55+
private:
56+
HashMap<Inst*, std::pair<CCallHelpers::Label, CCallHelpers::Label>> m_instToRange;
57+
Vector<BasicBlock*> m_blocks;
58+
CCallHelpers::Label m_entrypointStart;
59+
CCallHelpers::Label m_entrypointEnd;
60+
CCallHelpers::Label m_latePathStart;
61+
CCallHelpers::Label m_latePathEnd;
62+
};
63+
64+
} } } // namespace JSC::B3::Air
65+
66+
#endif // ENABLE(B3_JIT)

0 commit comments

Comments
 (0)