summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/mjit/exit_compiler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ruby_vm/mjit/exit_compiler.rb')
-rw-r--r--lib/ruby_vm/mjit/exit_compiler.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/ruby_vm/mjit/exit_compiler.rb b/lib/ruby_vm/mjit/exit_compiler.rb
index ef12740153..531fe3f426 100644
--- a/lib/ruby_vm/mjit/exit_compiler.rb
+++ b/lib/ruby_vm/mjit/exit_compiler.rb
@@ -24,7 +24,8 @@ module RubyVM::MJIT
asm.ret
end
- # @param ocb [CodeBlock]
+ # Set to cfp->jit_return by default for leave insn
+ # @param asm [RubyVM::MJIT::Assembler]
def compile_leave_exit(asm)
asm.comment('default cfp->jit_return')
@@ -37,6 +38,28 @@ module RubyVM::MJIT
asm.ret
end
+ # Fire cfunc events on invalidation by TracePoint
+ # @param asm [RubyVM::MJIT::Assembler]
+ def compile_full_cfunc_return(asm)
+ # This chunk of code expects REG_EC to be filled properly and
+ # RAX to contain the return value of the C method.
+
+ asm.comment('full cfunc return')
+ asm.mov(C_ARG_OPNDS[0], EC)
+ asm.mov(C_ARG_OPNDS[1], :rax)
+ asm.call(C.rb_full_cfunc_return)
+
+ # TODO: count the exit
+
+ # Restore callee-saved registers
+ asm.pop(SP)
+ asm.pop(EC)
+ asm.pop(CFP)
+
+ asm.mov(:rax, Qundef)
+ asm.ret
+ end
+
# @param jit [RubyVM::MJIT::JITState]
# @param ctx [RubyVM::MJIT::Context]
# @param asm [RubyVM::MJIT::Assembler]