forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
sbarati@apple.com
committed
Feb 21, 2017
1 parent
f8added
commit e18e086
Showing
8 changed files
with
334 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* 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 "config.h" | ||
#include "AirDisassembler.h" | ||
|
||
#if ENABLE(B3_JIT) | ||
|
||
#include "AirBasicBlock.h" | ||
#include "AirCode.h" | ||
#include "AirInst.h" | ||
#include "Disassembler.h" | ||
#include "LinkBuffer.h" | ||
|
||
namespace JSC { namespace B3 { namespace Air { | ||
|
||
void Disassembler::startEntrypoint(CCallHelpers& jit) | ||
{ | ||
m_entrypointStart = jit.labelIgnoringWatchpoints(); | ||
} | ||
|
||
void Disassembler::endEntrypoint(CCallHelpers& jit) | ||
{ | ||
m_entrypointEnd = jit.labelIgnoringWatchpoints(); | ||
} | ||
|
||
void Disassembler::startLatePath(CCallHelpers& jit) | ||
{ | ||
m_latePathStart = jit.labelIgnoringWatchpoints(); | ||
} | ||
|
||
void Disassembler::endLatePath(CCallHelpers& jit) | ||
{ | ||
m_latePathEnd = jit.labelIgnoringWatchpoints(); | ||
} | ||
|
||
void Disassembler::startBlock(BasicBlock* block, CCallHelpers& 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& code, PrintStream& out, LinkBuffer& linkBuffer) | ||
{ | ||
auto dumpRange = [&] (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<uintptr_t>(end.executableAddress()) >= bitwise_cast<uintptr_t>(start.executableAddress())); | ||
const char* prefix = " "; | ||
disassemble(start, bitwise_cast<uintptr_t>(end.executableAddress()) - bitwise_cast<uintptr_t>(start.executableAddress()), prefix, out); | ||
}; | ||
|
||
for (BasicBlock* block : m_blocks) { | ||
block->dumpHeader(out); | ||
if (code.isEntrypoint(block)) | ||
dumpRange(m_entrypointStart, m_entrypointEnd); | ||
|
||
for (Inst& inst : *block) { | ||
out.print(" "); | ||
inst.dump(out); | ||
out.print("\n"); | ||
|
||
auto iter = m_instToRange.find(&inst); | ||
if (iter == m_instToRange.end()) { | ||
RELEASE_ASSERT(&inst == &block->last()); | ||
continue; | ||
} | ||
auto pair = iter->value; | ||
dumpRange(pair.first, pair.second); | ||
} | ||
block->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("# Late paths\n"); | ||
dumpRange(m_latePathStart, m_latePathEnd); | ||
} | ||
|
||
} } } // namespace JSC::B3::Air | ||
|
||
#endif // ENABLE(B3_JIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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 "CCallHelpers.h" | ||
|
||
namespace JSC { | ||
|
||
class LinkBuffer; | ||
|
||
namespace B3 { namespace Air { | ||
|
||
class BasicBlock; | ||
class Code; | ||
struct Inst; | ||
|
||
class Disassembler { | ||
public: | ||
Disassembler() = default; | ||
|
||
void startEntrypoint(CCallHelpers&); | ||
void endEntrypoint(CCallHelpers&); | ||
void startLatePath(CCallHelpers&); | ||
void endLatePath(CCallHelpers&); | ||
void startBlock(BasicBlock*, CCallHelpers&); | ||
void addInst(Inst*, CCallHelpers::Label, CCallHelpers::Label); | ||
|
||
void dump(Code&, PrintStream&, LinkBuffer&); | ||
|
||
private: | ||
HashMap<Inst*, std::pair<CCallHelpers::Label, CCallHelpers::Label>> m_instToRange; | ||
Vector<BasicBlock*> 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) |
Oops, something went wrong.