aboutsummaryrefslogtreecommitdiffstats
path: root/yjit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'yjit.rb')
-rw-r--r--yjit.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/yjit.rb b/yjit.rb
index fe6e7debd4..0365e1635e 100644
--- a/yjit.rb
+++ b/yjit.rb
@@ -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?