diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-12-18 22:21:31 -0800 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-12-19 00:05:19 -0800 |
commit | 8d5af353b2ab6c774a473fdb010dcbe3d4e90f0e (patch) | |
tree | 4e828b32f41142240d1f487f3971c6a8c5791028 /lib | |
parent | 8671cd59f78a2bf28d323b6d0c5314e090811a65 (diff) |
RJIT: Avoid retaining comments unless --rjit-dump-disasm
This significantly reduces retained objects on RJIT.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ruby_vm/rjit/code_block.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ruby_vm/rjit/code_block.rb b/lib/ruby_vm/rjit/code_block.rb index 6260ec8b4b..260bd98671 100644 --- a/lib/ruby_vm/rjit/code_block.rb +++ b/lib/ruby_vm/rjit/code_block.rb @@ -4,7 +4,7 @@ module RubyVM::RJIT # @param mem_size [Integer] JIT buffer size # @param outliend [TrueClass,FalseClass] true for outlined CodeBlock def initialize(mem_block:, mem_size:, outlined: false) - @comments = Hash.new { |h, k| h[k] = [] } + @comments = Hash.new { |h, k| h[k] = [] } if dump_disasm? @mem_block = mem_block @mem_size = mem_size @write_pos = 0 @@ -26,7 +26,7 @@ module RubyVM::RJIT # Convert comment indexes to addresses asm.comments.each do |index, comments| - @comments[start_addr + index] += comments + @comments[start_addr + index] += comments if dump_disasm? end asm.comments.clear @@ -39,7 +39,7 @@ module RubyVM::RJIT def set_write_addr(addr) @write_pos = addr - @mem_block - @comments.delete(addr) # TODO: clean up old comments for all the overwritten range? + @comments.delete(addr) if dump_disasm? end def with_write_addr(addr) @@ -83,5 +83,9 @@ module RubyVM::RJIT def bold(text) "\e[1m#{text}\e[0m" end + + def dump_disasm? + C.rjit_opts.dump_disasm + end end end |