diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-07-30 10:11:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-30 10:11:10 -0700 |
| commit | 2cd10de33097d44f85a42bcde0f8bf17c90cd53a (patch) | |
| tree | 221d1237964ae879b37eb4352e6c2d0fa950eac7 /jit_hook.rb | |
| parent | 4263c49d1ce61a4e8d1a84cc144d4185ccf935f9 (diff) | |
ZJIT: Prepare for sharing JIT hooks with ZJIT (#14044)
Diffstat (limited to 'jit_hook.rb')
| -rw-r--r-- | jit_hook.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 |
