diff options
author | Takashi Kokubun <[email protected]> | 2023-04-03 22:52:38 -0700 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-04-04 00:35:29 -0700 |
commit | 19506650efeb8b19cea3f72d3f95547c5cbc3659 () | |
tree | be5eacc769e42bd350dd5420e265d052f168c9dc /lib/ruby_vm | |
parent | 2c560b976ed86730dfa305266fcc69033f6790cc (diff) |
RJIT: Add --rjit-verify-ctx option
-rw-r--r-- | lib/ruby_vm/rjit/compiler.rb | 70 | ||||
-rw-r--r-- | lib/ruby_vm/rjit/insn_compiler.rb | 18 | ||||
-rw-r--r-- | lib/ruby_vm/rjit/jit_state.rb | 7 |
3 files changed, 86 insertions, 9 deletions
@@ -279,6 +279,8 @@ module RubyVM::RJIT end # @param asm [RubyVM::RJIT::Assembler] def compile_block(asm, jit:, pc:, ctx: Context.new) # Mark the block start address and prepare an exit code storage ctx = limit_block_versions(jit.iseq, pc, ctx) @@ -292,6 +294,7 @@ module RubyVM::RJIT # Compile each insn index = (pc - iseq.body.iseq_encoded.to_i) / C.VALUE.size while index < iseq.body.iseq_size insn = self.class.decode_insn(iseq.body.iseq_encoded[index]) jit.pc = (iseq.body.iseq_encoded + index).to_i jit.stack_size_for_pc = ctx.stack_size @@ -308,6 +311,11 @@ module RubyVM::RJIT jit.record_boundary__point = false end case status = @insn_compiler.compile(jit, ctx, asm, insn) when KeepCompiling # For now, reset the chain depth after each instruction as only the @@ -435,5 +443,67 @@ module RubyVM::RJIT rescue RangeError # bignum too big to convert into `unsigned long long' (RangeError) -1 end end end @@ -21,16 +21,16 @@ module RubyVM::RJIT # @param insn `RubyVM::RJIT::Instruction` def compile(jit, ctx, asm, insn) asm.incr_counter(:rjit_insns_count) - insn_idx = format('%04d', (jit.pc.to_i - jit.iseq.body.iseq_encoded.to_i) / C.VALUE.size) - asm.comment("Insn: #{insn_idx} #{insn.name}") - # stack = ctx.stack_size.times.map do |stack_idx| - # ctx.get_opnd_type(StackOpnd[ctx.stack_size - stack_idx - 1]).type - # end - # locals = jit.iseq.body.local_table_size.times.map do |local_idx| - # (ctx.local_types[local_idx] || Type::Unknown).type - # end - # asm.comment("Insn: #{insn_idx} #{insn.name} (stack: [#{stack.join(', ')}], locals: [#{locals.join(', ')}])") # 83/102 case insn.name @@ -27,6 +27,13 @@ module RubyVM::RJIT pc == cfp.pc.to_i end def peek_at_stack(depth_from_top) raise 'not at current insn' unless at_current_insn? offset = -(1 + depth_from_top) |