Skip to content

ZJIT: Support enabling ZJIT lazily with RubyVM::ZJIT.enable #854

@k0kubun

Description

@k0kubun

We should have RubyVM::ZJIT.enable that allows a Ruby process that started with JIT disabled to lazily enable ZJIT. It allows to skip wasting the code region for boot time-only code, also avoiding unnecessary compilation overhead on warmup.

The patch should look similar to RubyVM::YJIT.enable ruby#8705. The PR already took care of the cont.c changes needed for any JIT, so you shouldn't need to touch the file this time.

  1. You need to update zjit/src/state.rs a little to make sure boot-time initialization is called at boot even if ZJIT is disabled.
    • cruby_methods::init() should be called at boot, not at RubyVM::ZJIT.enable. cmes could have been re-defined after boot.
  2. Add RubyVM::ZJIT.enable to zjit.rb.
    • Use Primitive to call a Rust function like yjit.rb does. It should do the current rb_zjit_init() but without (1).
    • Similarly to ruby_set_yjit_description, you need to define ruby_set_zjit_description in version.c. The Rust function should call it too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions