RJIT: Avoid retaining unrelated local variables in memory
This commit is contained in:
parent
ef4797bb03
commit
f263e44746
@ -1924,7 +1924,15 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Jump to target0 on jnz
|
# Jump to target0 on jnz
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_branchif(branch_stub)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
end
|
||||||
|
|
||||||
|
EndBlock
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_branchif(branch_stub) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
branch_asm.comment("branchif #{branch_stub.shape}")
|
branch_asm.comment("branchif #{branch_stub.shape}")
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -1938,10 +1946,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndBlock
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param jit [RubyVM::RJIT::JITState]
|
# @param jit [RubyVM::RJIT::JITState]
|
||||||
@ -1985,7 +1989,15 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Jump to target0 on jz
|
# Jump to target0 on jz
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_branchunless(branch_stub)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
end
|
||||||
|
|
||||||
|
EndBlock
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_branchunless(branch_stub) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
branch_asm.comment("branchunless #{branch_stub.shape}")
|
branch_asm.comment("branchunless #{branch_stub.shape}")
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -1999,10 +2011,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndBlock
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param jit [RubyVM::RJIT::JITState]
|
# @param jit [RubyVM::RJIT::JITState]
|
||||||
@ -2045,7 +2053,15 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Jump to target0 on je
|
# Jump to target0 on je
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_branchnil(branch_stub)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
end
|
||||||
|
|
||||||
|
EndBlock
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_branchnil(branch_stub) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
branch_asm.comment("branchnil #{branch_stub.shape}")
|
branch_asm.comment("branchnil #{branch_stub.shape}")
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -2059,10 +2075,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
end
|
|
||||||
|
|
||||||
EndBlock
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# once
|
# once
|
||||||
@ -3625,7 +3637,15 @@ module RubyVM::RJIT
|
|||||||
@exit_compiler.compile_branch_stub(deeper, ocb_asm, branch_stub, true)
|
@exit_compiler.compile_branch_stub(deeper, ocb_asm, branch_stub, true)
|
||||||
@ocb.write(ocb_asm)
|
@ocb.write(ocb_asm)
|
||||||
end
|
end
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_jit_chain_guard(branch_stub, opcode:)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
else
|
||||||
|
asm.public_send(opcode, side_exit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_jit_chain_guard(branch_stub, opcode:) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
# Not using `asm.comment` here since it's usually put before cmp/test before this.
|
# Not using `asm.comment` here since it's usually put before cmp/test before this.
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -3634,10 +3654,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
else
|
|
||||||
asm.public_send(opcode, side_exit)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param jit [RubyVM::RJIT::JITState]
|
# @param jit [RubyVM::RJIT::JITState]
|
||||||
@ -5628,7 +5644,19 @@ module RubyVM::RJIT
|
|||||||
@exit_compiler.compile_branch_stub(return_ctx, ocb_asm, branch_stub, true)
|
@exit_compiler.compile_branch_stub(return_ctx, ocb_asm, branch_stub, true)
|
||||||
@ocb.write(ocb_asm)
|
@ocb.write(ocb_asm)
|
||||||
end
|
end
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_jit_return(branch_stub, cfp_offset:)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
end
|
||||||
|
|
||||||
|
asm.comment('switch to callee CFP')
|
||||||
|
# Update CFP register only for ISEQ calls
|
||||||
|
cfp_reg = iseq ? CFP : :rax
|
||||||
|
asm.lea(cfp_reg, [CFP, cfp_offset])
|
||||||
|
asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], cfp_reg)
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_jit_return(branch_stub, cfp_offset:) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
branch_asm.comment('set jit_return to callee CFP')
|
branch_asm.comment('set jit_return to callee CFP')
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -5638,14 +5666,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
end
|
|
||||||
|
|
||||||
asm.comment('switch to callee CFP')
|
|
||||||
# Update CFP register only for ISEQ calls
|
|
||||||
cfp_reg = iseq ? CFP : :rax
|
|
||||||
asm.lea(cfp_reg, [CFP, cfp_offset])
|
|
||||||
asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], cfp_reg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# CALLER_SETUP_ARG: Return CantCompile if not supported
|
# CALLER_SETUP_ARG: Return CantCompile if not supported
|
||||||
@ -5868,7 +5888,12 @@ module RubyVM::RJIT
|
|||||||
@exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
|
@exit_compiler.compile_branch_stub(ctx, ocb_asm, branch_stub, true)
|
||||||
@ocb.write(ocb_asm)
|
@ocb.write(ocb_asm)
|
||||||
end
|
end
|
||||||
branch_stub.compile = proc do |branch_asm|
|
branch_stub.compile = compile_jit_direct_jump(branch_stub, comment:)
|
||||||
|
branch_stub.compile.call(asm)
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile_jit_direct_jump(branch_stub, comment:) # Proc escapes arguments in memory
|
||||||
|
proc do |branch_asm|
|
||||||
branch_asm.comment(comment)
|
branch_asm.comment(comment)
|
||||||
branch_asm.stub(branch_stub) do
|
branch_asm.stub(branch_stub) do
|
||||||
case branch_stub.shape
|
case branch_stub.shape
|
||||||
@ -5879,7 +5904,6 @@ module RubyVM::RJIT
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
branch_stub.compile.call(asm)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param jit [RubyVM::RJIT::JITState]
|
# @param jit [RubyVM::RJIT::JITState]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user