diff options
author | Takashi Kokubun <[email protected]> | 2023-03-10 13:19:05 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-10 13:57:52 -0800 |
commit | 76808b1ee45db247ad2aad9cc950a3a3a6e888eb (patch) | |
tree | 3560cc18ab1c0c3071ccc4c27c892ab9a6911fdc /lib/ruby_vm/rjit | |
parent | 6440d159b31feb495cacb279b204cdb6b54e721f (diff) |
RJIT: Start testing Assembler
Diffstat (limited to 'lib/ruby_vm/rjit')
-rw-r--r-- | lib/ruby_vm/rjit/code_block.rb | 15 |
1 files changed, 8 insertions, 7 deletions
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 |