summaryrefslogtreecommitdiff
path: root/lib/ruby_vm/rjit/exit_compiler.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-12 13:55:39 -0700
committerTakashi Kokubun <[email protected]>2023-03-12 15:15:08 -0700
commit9cd5441d28002768d9f492140757652548b86727 (patch)
tree0ad4ac8e4c56c64d0ced398cdbdd8a3878d7f862 /lib/ruby_vm/rjit/exit_compiler.rb
parentbbd9221e46649cc0d620efe4542bb93ff89fcb47 (diff)
RJIT: Implement --rjit-trace-exits
Diffstat (limited to 'lib/ruby_vm/rjit/exit_compiler.rb')
-rw-r--r--lib/ruby_vm/rjit/exit_compiler.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/ruby_vm/rjit/exit_compiler.rb b/lib/ruby_vm/rjit/exit_compiler.rb
index c082cc3660..b7beb22177 100644
--- a/lib/ruby_vm/rjit/exit_compiler.rb
+++ b/lib/ruby_vm/rjit/exit_compiler.rb
@@ -6,12 +6,12 @@ module RubyVM::RJIT
# @param pc [Integer]
# @param asm [RubyVM::RJIT::Assembler]
def compile_entry_exit(pc, ctx, asm, cause:)
- # Increment per-insn exit counter
- incr_insn_exit(pc, asm)
-
# Fix pc/sp offsets for the interpreter
save_pc_and_sp(pc, ctx, asm, reset_sp_offset: false)
+ # Increment per-insn exit counter
+ count_insn_exit(pc, asm)
+
# Restore callee-saved registers
asm.comment("#{cause}: entry exit")
asm.pop(SP)
@@ -62,12 +62,12 @@ module RubyVM::RJIT
# @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::RJIT::Assembler]
def compile_side_exit(pc, ctx, asm)
- # Increment per-insn exit counter
- incr_insn_exit(pc, asm)
-
# Fix pc/sp offsets for the interpreter
save_pc_and_sp(pc, ctx.dup, asm) # dup to avoid sp_offset update
+ # Increment per-insn exit counter
+ count_insn_exit(pc, asm)
+
# Restore callee-saved registers
asm.comment("exit to interpreter on #{pc_to_insn(pc).name}")
asm.pop(SP)
@@ -105,13 +105,18 @@ module RubyVM::RJIT
# @param pc [Integer]
# @param asm [RubyVM::RJIT::Assembler]
- def incr_insn_exit(pc, asm)
+ def count_insn_exit(pc, asm)
if C.rjit_opts.stats
insn = Compiler.decode_insn(C.VALUE.new(pc).*)
asm.comment("increment insn exit: #{insn.name}")
asm.mov(:rax, (C.rjit_insn_exits + insn.bin).to_i)
asm.add([:rax], 1) # TODO: lock
end
+ if C.rjit_opts.trace_exits
+ asm.comment('rjit_record_exit_stack')
+ asm.mov(C_ARGS[0], pc)
+ asm.call(C.rjit_record_exit_stack)
+ end
end
# @param jit [RubyVM::RJIT::JITState]