From 76808b1ee45db247ad2aad9cc950a3a3a6e888eb Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 10 Mar 2023 13:19:05 -0800 Subject: RJIT: Start testing Assembler --- lib/ruby_vm/rjit/code_block.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/ruby_vm/rjit/code_block.rb') diff --git a/lib/ruby_vm/rjit/code_block.rb b/lib/ruby_vm/rjit/code_block.rb index 33b96334b6..196e42d6a8 100644 --- a/lib/ruby_vm/rjit/code_block.rb +++ b/lib/ruby_vm/rjit/code_block.rb @@ -58,19 +58,20 @@ module RubyVM::RJIT (@mem_block...(@mem_block + @mem_size)).include?(addr) end - private - - def dump_disasm(from, to) + def dump_disasm(from, to, io: STDOUT, color: true) C.dump_disasm(from, to).each do |address, mnemonic, op_str| @comments.fetch(address, []).each do |comment| - puts colorize(" # #{comment}", bold: true) + io.puts colorize(" # #{comment}", bold: true, color:) end - puts colorize(" 0x#{format("%x", address)}: #{mnemonic} #{op_str}") + io.puts colorize(" 0x#{format("%x", address)}: #{mnemonic} #{op_str}", color:) end - puts + io.puts end - def colorize(text, bold: false) + private + + def colorize(text, bold: false, color:) + return text unless color buf = +'' buf << "\e[1m" if bold buf << "\e[34m" if @outlined -- cgit v1.2.3