diff options
author | Takashi Kokubun <[email protected]> | 2023-02-10 11:43:53 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-05 22:41:35 -0800 |
commit | aba530e23b463c3a682ab9bc233568c684d1fe81 (patch) | |
tree | 166f9e9aa26f0f0f7e3901efef4c7520763c83aa /lib/ruby_vm/mjit/exit_compiler.rb | |
parent | 494989e87e5095a2789c110972c0a1a43f544601 (diff) |
Implement invalidation after cfunc
Diffstat (limited to 'lib/ruby_vm/mjit/exit_compiler.rb')
-rw-r--r-- | lib/ruby_vm/mjit/exit_compiler.rb | 25 |
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] |