Commit 98ddfe77 authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[disassembler] Add more padding for printing instruction bytes

We can emit a 9-byte nop, so leave more padding, otherwise the
disassembled code looks a bit off, e.g.:

0x265ef7799a73   5b3  e902010000     jmp 0x265ef7799b7a  <+0x6ba>
0x265ef7799a78   5b8  0f1f840000000000 nop
0x265ef7799a80   5c0  83c004         addl rax,0x4

Bug: v8:11879
Change-Id: I697e97b45644e28e544705b972c88702f7f27ffc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3054255Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75944}
parent 368f27ca
......@@ -326,14 +326,15 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
byte* ptr =
base::ReadUnalignedValue<byte*>(reinterpret_cast<Address>(pc));
if (RelocInfo::IsInternalReference(it->rinfo()->rmode())) {
SNPrintF(decode_buffer, "%08" V8PRIxPTR " jump table entry %4zu",
SNPrintF(decode_buffer,
"%08" V8PRIxPTR " jump table entry %4zu",
reinterpret_cast<intptr_t>(ptr),
static_cast<size_t>(ptr - begin));
} else {
const char* kType = RelocInfo::IsLiteralConstant(it->rinfo()->rmode())
? " literal constant"
: "embedded data object";
SNPrintF(decode_buffer, "%08" V8PRIxPTR " %s 0x%08" V8PRIxPTR,
SNPrintF(decode_buffer, "%08" V8PRIxPTR " %s 0x%08" V8PRIxPTR,
reinterpret_cast<intptr_t>(ptr), kType,
reinterpret_cast<intptr_t>(ptr));
}
......
......@@ -2799,8 +2799,9 @@ int DisassemblerX64::InstructionDecode(v8::base::Vector<char> out_buffer,
for (byte* bp = instr; bp < data; bp++) {
outp += v8::base::SNPrintF(out_buffer + outp, "%02x", *bp);
}
// Indent instruction, leaving space for 7 bytes, i.e. 14 characters in hex.
while (outp < 14) {
// Indent instruction, leaving space for 9 bytes, i.e. 18 characters in hex.
// 9-byte nop and rip-relative mov are (probably) the largest we emit.
while (outp < 18) {
outp += v8::base::SNPrintF(out_buffer + outp, " ");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment