diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ruby_vm/mjit/code_block.rb | 17 | ||||
-rw-r--r-- | lib/ruby_vm/mjit/compiler.rb | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/ruby_vm/mjit/code_block.rb b/lib/ruby_vm/mjit/code_block.rb index 464d13ba8d..b4cc3d721c 100644 --- a/lib/ruby_vm/mjit/code_block.rb +++ b/lib/ruby_vm/mjit/code_block.rb @@ -2,11 +2,13 @@ module RubyVM::MJIT class CodeBlock # @param mem_block [Integer] JIT buffer address # @param mem_size [Integer] JIT buffer size - def initialize(mem_block:, mem_size:) + # @param outliend [TrueClass,FalseClass] true for outlined CodeBlock + def initialize(mem_block:, mem_size:, outlined: false) @comments = Hash.new { |h, k| h[k] = [] } @mem_block = mem_block @mem_size = mem_size @write_pos = 0 + @outlined = outlined end # @param asm [RubyVM::MJIT::Assembler] @@ -44,13 +46,22 @@ module RubyVM::MJIT def dump_disasm(from, to) C.dump_disasm(from, to).each do |address, mnemonic, op_str| @comments.fetch(address, []).each do |comment| - puts bold(" # #{comment}") + puts colorize(" # #{comment}", bold: true) end - puts " 0x#{format("%x", address)}: #{mnemonic} #{op_str}" + puts colorize(" 0x#{format("%x", address)}: #{mnemonic} #{op_str}") end puts end + def colorize(text, bold: false) + buf = +'' + buf << "\e[1m" if bold + buf << "\e[34m" if @outlined + buf << text + buf << "\e[0m" + buf + end + def bold(text) "\e[1m#{text}\e[0m" end diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb index e114d43e0d..6203863218 100644 --- a/lib/ruby_vm/mjit/compiler.rb +++ b/lib/ruby_vm/mjit/compiler.rb @@ -32,7 +32,7 @@ module RubyVM::MJIT # @param mem_size [Integer] JIT buffer size def initialize(mem_block, mem_size) @cb = CodeBlock.new(mem_block: mem_block, mem_size: mem_size / 2) - @ocb = CodeBlock.new(mem_block: mem_block + mem_size / 2, mem_size: mem_size / 2) + @ocb = CodeBlock.new(mem_block: mem_block + mem_size / 2, mem_size: mem_size / 2, outlined: true) @exit_compiler = ExitCompiler.new @insn_compiler = InsnCompiler.new(@ocb) end |