class method
RubyVM::YJIT.enable
(?stats: false | true | :quiet) -> void
enable(stats: false, log: false, mem_size: nil, call_threshold: nil)
yjit.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/yjit.rb, line 48
def self.enable(stats: false, log: false, mem_size: nil, call_threshold: nil)
return false if enabled?
if Primitive.cexpr! 'RBOOL(rb_zjit_enabled_p)'
warn("Only one JIT can be enabled at the same time.")
return false
end
if mem_size
raise ArgumentError, "mem_size must be a Integer" unless mem_size.is_a?(Integer)
raise ArgumentError, "mem_size must be between 1 and 2048 MB" unless (1..2048).include?(mem_size)
end
if call_threshold
raise ArgumentError, "call_threshold must be a Integer" unless call_threshold.is_a?(Integer)
raise ArgumentError, "call_threshold must be a positive integer" unless call_threshold.positive?
end
at_exit { print_and_dump_stats } if stats
Primitive.rb_yjit_enable(stats, stats != :quiet, log, log != :quiet, mem_size, call_threshold)
end
Enable YJIT compilation. stats option decides whether to enable YJIT stats or not. log decides whether to enable YJIT compilation logging or not. Optional mem_size and call_threshold can be provided to override default configuration.
-
stats:-
false: Don’t enable stats. -
true: Enable stats. Print stats at exit. -
:quiet: Enable stats. Do not print stats at exit.
-
-
log:-
false: Don’t enable the log. -
true: Enable the log. Print log at exit. -
:quiet: Enable the log. Do not print log at exit.
-