8000 YJIT: Respect writable_addrs on --yjit-dump-iseq-disasm as well by k0kubun · Pull Request #6596 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

YJIT: Respect writable_addrs on --yjit-dump-iseq-disasm as well #6596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
2 changes: 1 addition & 1 deletion yjit/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ fn gen_block_series_body(
if iseq_location.contains(substr) {
let last_block = last_blockref.borrow();
println!("Compiling {} block(s) for {}, ISEQ offsets [{}, {})", batch.len(), iseq_location, blockid.idx, last_block.end_idx);
println!("{}", disasm_iseq_insn_range(blockid.iseq, blockid.idx, last_block.end_idx));
print!("{}", disasm_iseq_insn_range(blockid.iseq, blockid.idx, last_block.end_idx));
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions yjit/src/disasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub fn disasm_iseq_insn_range(iseq: IseqPtr, start_idx: u32, end_idx: u32) -> St
let blockid = block.get_blockid();
if blockid.idx >= start_idx && blockid.idx < end_idx {
let end_idx = block.get_end_idx();
let start_addr = block.get_start_addr().unwrap().raw_ptr();
let end_addr = block.get_end_addr().unwrap().raw_ptr();
let start_addr = block.get_start_addr().unwrap();
let end_addr = block.get_end_addr().unwrap();
let code_size = block.code_size();

// Write some info about the current block
Expand All @@ -101,14 +101,17 @@ pub fn disasm_iseq_insn_range(iseq: IseqPtr, start_idx: u32, end_idx: u32) -> St
writeln!(out, "== {:=<60}", block_ident).unwrap();

// Disassemble the instructions
out.push_str(&disasm_addr_range(global_cb, start_addr, (start_addr as usize + code_size) as *const u8));
for (start_addr, end_addr) in global_cb.writable_addrs(start_addr, end_addr) {
out.push_str(&disasm_addr_range(global_cb, start_addr, end_addr));
writeln!(out).unwrap();
}

// If this is not the last block
if block_idx < block_list.len() - 1 {
// Compute the size of the gap between this block and the next
let next_block = block_list[block_idx + 1].borrow();
let next_start_addr = next_block.get_start_addr().unwrap().raw_ptr();
let gap_size = (next_start_addr as usize) - (end_addr as usize);
let next_start_addr = next_block.get_start_addr().unwrap();
let gap_size = next_start_addr.into_usize() - end_addr.into_usize();

// Log the size of the gap between the blocks if nonzero
if gap_size > 0 {
Expand All @@ -127,7 +130,7 @@ pub fn dump_disasm_addr_range(cb: &CodeBlock, start_addr: CodePtr, end_addr: Cod
use std::io::Write;

for (start_addr, end_addr) in cb.writable_addrs(start_addr, end_addr) {
let disasm = disasm_addr_range(cb, start_addr as *const u8, end_addr as *const u8);
let disasm = disasm_addr_range(cb, start_addr, end_addr);
if disasm.len() > 0 {
match dump_disasm {
DumpDisasm::Stdout => println!("{disasm}"),
Expand All @@ -141,7 +144,7 @@ pub fn dump_disasm_addr_range(cb: &CodeBlock, start_addr: CodePtr, end_addr: Cod
}

#[cfg(feature = "disasm")]
pub fn disasm_addr_range(cb: &CodeBlock, start_addr: *const u8, end_addr: *const u8) -> String {
pub fn disasm_addr_range(cb: &CodeBlock, start_addr: usize, end_addr: usize) -> String {
let mut out = String::from("");

// Initialize capstone
Expand All @@ -165,8 +168,8 @@ pub fn disasm_addr_range(cb: &CodeBlock, start_addr: *const u8, end_addr: *const
cs.set_skipdata(true).unwrap();

// Disassemble the instructions
let code_size = end_addr as usize - start_addr as usize;
let code_slice = unsafe { std::slice::from_raw_parts(start_addr, code_size) };
let code_size = end_addr - start_addr;
let code_slice = unsafe { std::slice::from_raw_parts(start_addr as _, code_size) };
let insns = cs.disasm_all(code_slice, start_addr as u64).unwrap();

// For each instruction in this block
Expand Down
0