diff options
Diffstat (limited to 'lib/ruby_vm')
-rw-r--r-- | lib/ruby_vm/mjit/block_stub.rb | 9 | ||||
-rw-r--r-- | lib/ruby_vm/mjit/compiler.rb | 32 | ||||
-rw-r--r-- | lib/ruby_vm/mjit/exit_compiler.rb | 14 | ||||
-rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 19 |
4 files changed, 1 insertions, 73 deletions
diff --git a/lib/ruby_vm/mjit/block_stub.rb b/lib/ruby_vm/mjit/block_stub.rb deleted file mode 100644 index f676374fa0..0000000000 --- a/lib/ruby_vm/mjit/block_stub.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RubyVM::MJIT::BlockStub < Struct.new( - :iseq, # @param [RubyVM::MJIT::CPointer::Struct_rb_iseq_struct] Stub target ISEQ - :ctx, # @param [RubyVM::MJIT::Context] Stub target context - :pc, # @param [Integer] Stub target pc - :start_addr, # @param [Integer] Stub source start address to be re-generated - :end_addr, # @param [Integer] Stub source end address to be re-generated - :change_block, # @param [Proc] Recompile the source address with a new block address -) -end diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb index 0ad289c063..26e3d75d34 100644 --- a/lib/ruby_vm/mjit/compiler.rb +++ b/lib/ruby_vm/mjit/compiler.rb @@ -1,6 +1,5 @@ require 'ruby_vm/mjit/assembler' require 'ruby_vm/mjit/block' -require 'ruby_vm/mjit/block_stub' require 'ruby_vm/mjit/branch_stub' require 'ruby_vm/mjit/code_block' require 'ruby_vm/mjit/context' @@ -68,37 +67,6 @@ module RubyVM::MJIT $stderr.puts e.full_message # TODO: check verbose end - # Continue compilation from a block stub. - # @param block_stub [RubyVM::MJIT::BlockStub] - # @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` - # @return [Integer] The starting address of the compiled block stub - def block_stub_hit(block_stub, cfp) - # Update cfp->pc for `jit.at_current_insn?` - cfp.pc = block_stub.pc - - # Prepare the jump target - jit = JITState.new(iseq: block_stub.iseq, cfp:) - new_asm = Assembler.new.tap do |asm| - compile_block(asm, jit:, pc: block_stub.pc, ctx: block_stub.ctx) - end - - # Rewrite the block stub - if @cb.write_addr == block_stub.end_addr - # If the block stub's jump is the last code, overwrite the jump with the new code. - @cb.set_write_addr(block_stub.start_addr) - @cb.write(new_asm) - else - # If the block stub's jump is old code, change the jump target to the new code. - new_addr = @cb.write(new_asm) - @cb.with_write_addr(block_stub.start_addr) do - asm = Assembler.new - block_stub.change_block.call(asm, new_addr) - @cb.write(asm) - end - new_addr - end - end - # Compile a branch stub. # @param branch_stub [RubyVM::MJIT::BranchStub] # @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` diff --git a/lib/ruby_vm/mjit/exit_compiler.rb b/lib/ruby_vm/mjit/exit_compiler.rb index 8f610e91cc..0019eda7bd 100644 --- a/lib/ruby_vm/mjit/exit_compiler.rb +++ b/lib/ruby_vm/mjit/exit_compiler.rb @@ -59,20 +59,6 @@ module RubyVM::MJIT # @param ctx [RubyVM::MJIT::Context] # @param asm [RubyVM::MJIT::Assembler] - # @param block_stub [RubyVM::MJIT::BlockStub] - def compile_block_stub(ctx, asm, block_stub) - # Call rb_mjit_block_stub_hit - asm.comment("block stub hit: #{block_stub.iseq.body.location.label}@#{C.rb_iseq_path(block_stub.iseq)}:#{iseq_lineno(block_stub.iseq, block_stub.pc)}") - asm.mov(:rdi, to_value(block_stub)) - asm.mov(:esi, ctx.sp_offset) - asm.call(C.rb_mjit_block_stub_hit) - - # Jump to the address returned by rb_mjit_stub_hit - asm.jmp(:rax) - end - - # @param ctx [RubyVM::MJIT::Context] - # @param asm [RubyVM::MJIT::Assembler] # @param branch_stub [RubyVM::MJIT::BranchStub] # @param target0_p [TrueClass,FalseClass] def compile_branch_stub(ctx, asm, branch_stub, target0_p) diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 1d14fcb925..0ea0020f19 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -812,24 +812,7 @@ module RubyVM::MJIT # @param asm [RubyVM::MJIT::Assembler] def defer_compilation(jit, ctx, asm) # Make a stub to compile the current insn - compile_block_stub(jit.iseq, jit.pc, ctx, asm, comment: 'defer_compilation: block stub') - end - - def compile_block_stub(iseq, pc, ctx, asm, comment: 'block stub') - block_stub = BlockStub.new(iseq:, pc:, ctx: ctx.dup) - - stub_hit = Assembler.new.then do |ocb_asm| - @exit_compiler.compile_block_stub(ctx, ocb_asm, block_stub) - @ocb.write(ocb_asm) - end - - block_stub.change_block = proc do |jump_asm, new_addr| - jump_asm.comment(comment) - jump_asm.stub(block_stub) do - jump_asm.jmp(new_addr) - end - end - block_stub.change_block.call(asm, stub_hit) + stub_next_block(jit.iseq, jit.pc, ctx, asm, comment: 'defer_compilation') end def stub_next_block(iseq, pc, ctx, asm, comment: 'stub_next_block') |