diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-23 13:46:43 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-29 09:09:41 -0700 |
| commit | def3ade8a809a230648cdffbf4ab066b07fe7bf1 (patch) | |
| tree | 8d976629754280b8bf0777a846a7267900cd0f1e /yjit/src/backend | |
| parent | 54c7bc67a2d54311b77aca9233b23a9e7a1ca581 (diff) | |
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
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6289
Diffstat (limited to 'yjit/src/backend')
| -rw-r--r-- | yjit/src/backend/ir.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs index f01ab398da..33a79a4179 100644 --- a/yjit/src/backend/ir.rs +++ b/yjit/src/backend/ir.rs @@ -10,6 +10,7 @@ use crate::cruby::{VALUE}; use crate::virtualmem::{CodePtr}; use crate::asm::{CodeBlock, uimm_num_bits, imm_num_bits}; use crate::core::{Context, Type, TempMapping}; +use crate::options::*; #[cfg(target_arch = "x86_64")] use crate::backend::x86_64::*; @@ -1075,11 +1076,25 @@ impl Assembler /// compiling multiple blocks at a time? pub fn compile(self, cb: &mut CodeBlock) -> Vec<u32> { + #[cfg(feature = "disasm")] + let start_addr = cb.get_write_ptr().raw_ptr(); + let alloc_regs = Self::get_alloc_regs(); - self.compile_with_regs(cb, alloc_regs) + let gc_offsets = self.compile_with_regs(cb, alloc_regs); + + #[cfg(feature = "disasm")] + if get_option!(dump_disasm) && !cb.outlined { + use crate::disasm::disasm_addr_range; + let last_ptr = cb.get_write_ptr(); + let disasm = disasm_addr_range(cb, start_addr, last_ptr.raw_ptr() as usize - start_addr as usize); + if disasm.len() > 0 { + println!("{disasm}"); + } + } + gc_offsets } - /// Compile with a limited number of registers + /// Compile with a limited number of registers. Used only for unit tests. pub fn compile_with_num_regs(self, cb: &mut CodeBlock, num_regs: usize) -> Vec<u32> { let mut alloc_regs = Self::get_alloc_regs(); |
