Module

This module allows for introspection of YJIT, CRuby’s just-in-time compiler. Everything in the module is highly implementation specific and the API might be less stable compared to the standard library.

This module may not exist if YJIT does not support the particular platform for which CRuby is built.

Class Methods

Discard existing compiled code to reclaim memory and allow for recompilations in the future.

Marshal dumps exit locations to the given filename.

Usage:

If --yjit-exit-locations is passed, a file named “yjit_exit_locations.dump” will automatically be generated.

If you want to collect traces manually, call dump_exit_locations directly.

Note that calling this in a script will generate stats after the dump is created, so the stats data may include exits from the dump itself.

In a script call:

at_exit do
  RubyVM::YJIT.dump_exit_locations("my_file.dump")
end

Then run the file with the following options:

ruby --yjit --yjit-trace-exits test.rb

Once the code is done running, use Stackprof to read the dump file. See Stackprof documentation for options.

Enable YJIT compilation. stats option decides whether to enable YJIT stats or not.

  • false: Disable stats.

  • true: Enable stats. Print stats at exit.

  • :quiet: Enable stats. Do not print stats at exit.

Check if YJIT is enabled.

Discard statistics collected for --yjit-stats.

Return a hash for statistics generated for the --yjit-stats command line option. Return nil when option is not passed or unavailable.

Check if --yjit-stats is used.

Format and print out counters as a String. This returns a non-empty content only when --yjit-stats is enabled.