8000 YJIT: Skip dumping code for the other cb on --yjit-dump-disasm by k0kubun · Pull Request #6592 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

YJIT: Skip dumping code for the other cb on --yjit-dump-disasm #6592

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 19, 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
Diff view
3 changes: 1 addition & 2 deletions yjit/src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ impl CodeBlock {
self.page_end_reserve = old_page_end_reserve;
}

#[cfg(target_arch = "aarch64")]
#[cfg(not(test))]
/// Return the address ranges of a given address range that this CodeBlock can write.
#[cfg(any(feature = "disasm", target_arch = "aarch64"))]
pub fn writable_addrs(&self, start_ptr: CodePtr, end_ptr: CodePtr) -> Vec<(usize, usize)> {
let mut addrs = vec![];
let mut start = start_ptr.raw_ptr() as usize;
Expand Down
4 changes: 2 additions & 2 deletions yjit/src/backend/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,15 +1094,15 @@ impl Assembler
pub fn compile(self, cb: &mut CodeBlock) -> Vec<u32>
{
#[cfg(feature = "disasm")]
let start_addr = cb.get_write_ptr().raw_ptr();
let start_addr = cb.get_write_ptr();

let alloc_regs = Self::get_alloc_regs();
let gc_offsets = self.compile_with_regs(cb, alloc_regs);

#[cfg(feature = "disasm")]
if let Some(dump_disasm) = get_option_ref!(dump_disasm) {
use crate::disasm::dump_disasm_addr_range;
let end_addr = cb.get_write_ptr().raw_ptr();
let end_addr = cb.get_write_ptr();
dump_disasm_addr_range(cb, start_addr, end_addr, dump_disasm)
}
gc_offsets
Expand Down
24 changes: 14 additions & 10 deletions yjit/src/disasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use crate::yjit::yjit_enabled_p;
#[cfg(feature = "disasm")]
use crate::asm::CodeBlock;
#[cfg(feature = "disasm")]
use crate::codegen::CodePtr;
#[cfg(feature = "disasm")]
use crate::options::DumpDisasm;

#[cfg(feature = "disasm")]
Expand Down Expand Up @@ -120,19 +122,21 @@ pub fn disasm_iseq_insn_range(iseq: IseqPtr, start_idx: u32, end_idx: u32) -> St
}

#[cfg(feature = "disasm")]
pub fn dump_disasm_addr_range(cb: &CodeBlock, start_addr: *const u8, end_addr: *const u8, dump_disasm: &DumpDisasm) {
pub fn dump_disasm_addr_range(cb: &CodeBlock, start_addr: CodePtr, end_addr: CodePtr, dump_disasm: &DumpDisasm) {
use std::fs::File;
use std::io::Write;

let disasm = disasm_addr_range(cb, start_addr, end_addr);
if disasm.len() > 0 {
match dump_disasm {
DumpDisasm::Stdout => println!("{disasm}"),
DumpDisasm::File(path) => {
let mut f = File::options().append(true).create(true).open(path).unwrap();
f.write_all(disasm.as_bytes()).unwrap();
}
};
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);
if disasm.len() > 0 {
match dump_disasm {
DumpDisasm::Stdout => println!("{disasm}"),
DumpDisasm::File(path) => {
let mut f = File::options().create(true).append(true).open(path).unwrap();
f.write_all(disasm.as_bytes()).unwrap();
}
};
}
}
}

Expand Down
0