diff options
author | Takashi Kokubun <[email protected]> | 2023-02-07 11:51:11 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-05 22:11:20 -0800 |
commit | 47e2ea3a800dae6ac4d427ad9524a7d61dd992ee (patch) | |
tree | 14aa419be4c3cf9f7343565f6a1a59bd4dbacd0e | |
parent | d88b59be92eeeeaddf5b15c57b807a4e3908b12b (diff) |
Refactor callee with BranchStub
-rw-r--r-- | lib/ruby_vm/mjit/insn_compiler.rb | 26 | ||||
-rw-r--r-- | lib/ruby_vm/mjit/invariants.rb | 1 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/ruby_vm/mjit/insn_compiler.rb b/lib/ruby_vm/mjit/insn_compiler.rb index 11fb045178..1d14fcb925 100644 --- a/lib/ruby_vm/mjit/insn_compiler.rb +++ b/lib/ruby_vm/mjit/insn_compiler.rb @@ -733,7 +733,7 @@ module RubyVM::MJIT # Jump to a stub for the callee ISEQ callee_ctx = Context.new - compile_block_stub(iseq, iseq.body.iseq_encoded.to_i, callee_ctx, asm) + stub_next_block(iseq, iseq.body.iseq_encoded.to_i, callee_ctx, asm) EndBlock end @@ -832,6 +832,30 @@ module RubyVM::MJIT block_stub.change_block.call(asm, stub_hit) end + def stub_next_block(iseq, pc, ctx, asm, comment: 'stub_next_block') + branch_stub = BranchStub.new( + iseq:, + shape: Default, + target0: BranchTarget.new(ctx:, pc:), + ) + branch_stub.target0.address = Assembler.new.then do |ocb_asm| + @exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true) + @ocb.write(ocb_asm) + end + branch_stub.compile = proc do |branch_asm| + branch_asm.comment(comment) + branch_asm.stub(branch_stub) do + case branch_stub.shape + in Default + branch_asm.jmp(branch_stub.target0.address) + in Next0 + # Just write the block without a jump + end + end + end + branch_stub.compile.call(asm) + end + # @param jit [RubyVM::MJIT::JITState] # @param ctx [RubyVM::MJIT::Context] def side_exit(jit, ctx) diff --git a/lib/ruby_vm/mjit/invariants.rb b/lib/ruby_vm/mjit/invariants.rb index fdd39ba466..49cd2dee4d 100644 --- a/lib/ruby_vm/mjit/invariants.rb +++ b/lib/ruby_vm/mjit/invariants.rb @@ -44,6 +44,7 @@ module RubyVM::MJIT asm.jmp(block.entry_exit) @cb.write(asm) end + # TODO: re-generate branches that refer to this block end end |