module RubyVM::RJIT

Public Class Methods

enable ()

Start JIT compilation after --rjit-disable.

# File rjit.rb, line 8
def self.enable
  Primitive.cstmt! %{
    rb_rjit_call_p = true;
    return Qnil;
  }
end
enabled? ()

Return true if RJIT is enabled.

# File rjit.rb, line 3
def self.enabled?
  Primitive.cexpr! 'RBOOL(rb_rjit_enabled)'
end
runtime_stats ()

Return a Hash for RJIT statistics. --rjit-stats makes more information available.

# File lib/ruby_vm/rjit/stats.rb, line 4
def self.runtime_stats
  stats = {}

  # Insn exits
  INSNS.each_value do |insn|
    exits = C.rjit_insn_exits[insn.bin]
    if exits > 0
      stats[:"exit_#{insn.name}"] = exits
    end
  end

  # Runtime stats
  C.rb_rjit_runtime_counters.members.each do |member|
    stats[member] = C.rb_rjit_counters.public_send(member)
  end
  stats[:vm_insns_count] = C.rb_vm_insns_count

  # Other stats are calculated here
  stats[:side_exit_count] = stats.select { |name, _count| name.start_with?('exit_') }.sum(&:last)
  if stats[:vm_insns_count] > 0
    retired_in_rjit = stats[:rjit_insns_count] - stats[:side_exit_count]
    stats[:total_insns_count] = retired_in_rjit + stats[:vm_insns_count]
    stats[:ratio_in_rjit] = 100.0 * retired_in_rjit / stats[:total_insns_count]
  else
    stats.delete(:vm_insns_count)
  end

  stats
end