ZJIT: Prepare for sharing JIT hooks with ZJIT (#14044)

This commit is contained in:
Takashi Kokubun 2025-07-30 10:11:10 -07:00 committed by GitHub
parent 4263c49d1c
commit 2cd10de330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 142 additions and 118 deletions

14
yjit.rb
View file

@ -264,23 +264,23 @@ module RubyVM::YJIT
end
# Blocks that are called when YJIT is enabled
@yjit_hooks = []
@jit_hooks = []
class << self
# :stopdoc:
private
# Register a block to be called when YJIT is enabled
def add_yjit_hook(hook)
@yjit_hooks << hook
def add_jit_hook(hook)
@jit_hooks << hook
end
# Run YJIT hooks registered by RubyVM::YJIT.with_yjit
def call_yjit_hooks
# Run YJIT hooks registered by `#with_jit`
def call_jit_hooks
# Skip using builtin methods in Ruby if --yjit-c-builtin is given
return if Primitive.yjit_c_builtin_p
@yjit_hooks.each(&:call)
@yjit_hooks.clear
@jit_hooks.each(&:call)
@jit_hooks.clear
end
# Print stats and dump exit locations