模块 RubyVM::RJIT
公共类方法
enable() 点击切换源代码
在 --rjit-disable 后启动 JIT 编译。
# File rjit.rb, line 8 def self.enable Primitive.cstmt! %{ rb_rjit_call_p = true; return Qnil; } end
enabled?() 点击切换源代码
如果 RJIT 已启用,则返回 true。
# File rjit.rb, line 3 def self.enabled? Primitive.cexpr! 'RBOOL(rb_rjit_enabled)' end
runtime_stats() 点击切换源代码
返回一个 Hash
用于 RJIT 统计信息。--rjit-stats 提供更多信息。
# 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