mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
Refactor callee with BranchStub
This commit is contained in:
parent
d88b59be92
commit
47e2ea3a80
2 changed files with 26 additions and 1 deletions
|
@ -733,7 +733,7 @@ module RubyVM::MJIT
|
||||||
|
|
||||||
# Jump to a stub for the callee ISEQ
|
# Jump to a stub for the callee ISEQ
|
||||||
callee_ctx = Context.new
|
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
|
EndBlock
|
||||||
end
|
end
|
||||||
|
@ -832,6 +832,30 @@ module RubyVM::MJIT
|
||||||
block_stub.change_block.call(asm, stub_hit)
|
block_stub.change_block.call(asm, stub_hit)
|
||||||
end
|
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 jit [RubyVM::MJIT::JITState]
|
||||||
# @param ctx [RubyVM::MJIT::Context]
|
# @param ctx [RubyVM::MJIT::Context]
|
||||||
def side_exit(jit, ctx)
|
def side_exit(jit, ctx)
|
||||||
|
|
|
@ -44,6 +44,7 @@ module RubyVM::MJIT
|
||||||
asm.jmp(block.entry_exit)
|
asm.jmp(block.entry_exit)
|
||||||
@cb.write(asm)
|
@cb.write(asm)
|
||||||
end
|
end
|
||||||
|
# TODO: re-generate branches that refer to this block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue