Add --yjit-dump-disasm to dump every compiled code (https://github.com/Shopify/ruby/pull/430)

* Add --yjit-dump-disasm to dump every compiled code

* Just use get_option

* Carve out disasm_from_addr

* Avoid push_str with format!

* Share the logic through asm.compile

* This seems to negatively impact the compilation speed
This commit is contained in:
Takashi Kokubun 2022-08-23 13:46:43 -07:00
parent 54c7bc67a2
commit def3ade8a8
Notes: git 2022-08-30 01:10:11 +09:00
6 changed files with 91 additions and 41 deletions

View file

@ -622,9 +622,13 @@ pub fn gen_entry_prologue(cb: &mut CodeBlock, iseq: IseqPtr, insn_idx: u32) -> O
cb.align_pos(64);
let code_ptr = cb.get_write_ptr();
add_comment(cb, "yjit entry");
let mut asm = Assembler::new();
if get_option!(dump_disasm) {
asm.comment(&format!("YJIT entry: {}", iseq_get_location(iseq)));
} else {
asm.comment("YJIT entry");
}
asm.frame_setup();
@ -748,6 +752,11 @@ pub fn gen_single_block(
// Create a backend assembler instance
let mut asm = Assembler::new();
#[cfg(feature = "disasm")]
if get_option!(dump_disasm) {
asm.comment(&format!("Block: {} (ISEQ offset: {})", iseq_get_location(blockid.iseq), blockid.idx));
}
// For each instruction to compile
// NOTE: could rewrite this loop with a std::iter::Iterator
while insn_idx < iseq_size {
@ -6049,8 +6058,8 @@ impl CodegenGlobals {
half_size
);
let cb = CodeBlock::new(first_half);
let ocb = OutlinedCb::wrap(CodeBlock::new(second_half));
let cb = CodeBlock::new(first_half, false);
let ocb = OutlinedCb::wrap(CodeBlock::new(second_half, true));
(cb, ocb)
};