YJIT: Add stats option to RubyVM::YJIT.enable (#9297)

This commit is contained in:
Takashi Kokubun 2023-12-19 11:47:27 -08:00 committed by GitHub
parent 084b44e79d
commit bd91c5127f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 17 deletions

21
yjit.rb
View file

@ -29,8 +29,10 @@ module RubyVM::YJIT
end
# Enable \YJIT compilation.
def self.enable
Primitive.rb_yjit_enable
def self.enable(stats: false)
return false if enabled?
at_exit { print_and_dump_stats } if stats
Primitive.rb_yjit_enable(stats, stats != :quiet)
end
# If --yjit-trace-exits is enabled parse the hashes from
@ -223,18 +225,21 @@ module RubyVM::YJIT
Primitive.rb_yjit_simulate_oom_bang
end
# Avoid calling a method here to not interfere with compilation tests
# Avoid calling a Ruby method here to not interfere with compilation tests
if Primitive.rb_yjit_stats_enabled_p
at_exit do
at_exit { print_and_dump_stats }
end
class << self # :stopdoc:
private
# Print stats and dump exit locations
def print_and_dump_stats
if Primitive.rb_yjit_print_stats_p
_print_stats
end
_dump_locations
end
end
class << self # :stopdoc:
private
def _dump_locations # :nodoc:
return unless trace_exit_locations_enabled?