From 2cd10de33097d44f85a42bcde0f8bf17c90cd53a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 30 Jul 2025 10:11:10 -0700 Subject: ZJIT: Prepare for sharing JIT hooks with ZJIT (#14044) --- jit_hook.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 jit_hook.rb (limited to 'jit_hook.rb') diff --git a/jit_hook.rb b/jit_hook.rb new file mode 100644 index 0000000000..487361c049 --- /dev/null +++ b/jit_hook.rb @@ -0,0 +1,13 @@ +class Module + # Internal helper for built-in initializations to define methods only when JIT is enabled. + # This method is removed in jit_undef.rb. + private def with_jit(&block) # :nodoc: + # ZJIT currently doesn't compile Array#each properly, so it's disabled for now. + if defined?(RubyVM::ZJIT) && Primitive.rb_zjit_option_enabled_p && false # TODO: remove `&& false` (Shopify/ruby#667) + # We don't support lazily enabling ZJIT yet, so we can call the block right away. + block.call + elsif defined?(RubyVM::YJIT) + RubyVM::YJIT.send(:add_jit_hook, block) + end + end +end -- cgit v1.2.3