Document the public interface of YJIT [ci skip]

This commit is contained in:
Takashi Kokubun 2022-12-22 14:43:58 -08:00
parent 0b2aea861c
commit 033e19dabf
2 changed files with 8 additions and 6 deletions

View File

@ -29,6 +29,7 @@ timev.rb
thread_sync.rb thread_sync.rb
trace_point.rb trace_point.rb
warning.rb warning.rb
yjit.rb
# the lib/ directory (which has its own .document file) # the lib/ directory (which has its own .document file)
lib lib

13
yjit.rb
View File

@ -14,6 +14,7 @@ module RubyVM::YJIT
Primitive.cexpr! 'RBOOL(rb_yjit_enabled_p())' Primitive.cexpr! 'RBOOL(rb_yjit_enabled_p())'
end end
# Check if --yjit-stats is used.
def self.stats_enabled? def self.stats_enabled?
Primitive.rb_yjit_stats_enabled_p Primitive.rb_yjit_stats_enabled_p
end end
@ -209,7 +210,7 @@ module RubyVM::YJIT
Primitive.rb_yjit_code_gc Primitive.rb_yjit_code_gc
end end
def self.simulate_oom! def self.simulate_oom! # :nodoc:
Primitive.rb_yjit_simulate_oom_bang Primitive.rb_yjit_simulate_oom_bang
end end
@ -224,7 +225,7 @@ module RubyVM::YJIT
class << self class << self
private private
def _dump_locations def _dump_locations # :nodoc:
return unless trace_exit_locations_enabled? return unless trace_exit_locations_enabled?
filename = "yjit_exit_locations.dump" filename = "yjit_exit_locations.dump"
@ -234,7 +235,7 @@ module RubyVM::YJIT
end end
# Format and print out counters # Format and print out counters
def _print_stats def _print_stats # :nodoc:
stats = runtime_stats stats = runtime_stats
return unless stats return unless stats
@ -291,7 +292,7 @@ module RubyVM::YJIT
print_sorted_exit_counts(stats, prefix: "exit_") print_sorted_exit_counts(stats, prefix: "exit_")
end end
def print_sorted_exit_counts(stats, prefix:, how_many: 20, left_pad: 4) def print_sorted_exit_counts(stats, prefix:, how_many: 20, left_pad: 4) # :nodoc:
exits = [] exits = []
stats.each do |k, v| stats.each do |k, v|
if k.start_with?(prefix) if k.start_with?(prefix)
@ -322,7 +323,7 @@ module RubyVM::YJIT
end end
end end
def total_exit_count(stats, prefix: "exit_") def total_exit_count(stats, prefix: "exit_") # :nodoc:
total = 0 total = 0
stats.each do |k,v| stats.each do |k,v|
total += v if k.start_with?(prefix) total += v if k.start_with?(prefix)
@ -330,7 +331,7 @@ module RubyVM::YJIT
total total
end end
def print_counters(counters, prefix:, prompt:) def print_counters(counters, prefix:, prompt:) # :nodoc:
$stderr.puts(prompt) $stderr.puts(prompt)
counters = counters.filter { |key, _| key.start_with?(prefix) } counters = counters.filter { |key, _| key.start_with?(prefix) }
counters.filter! { |_, value| value != 0 } counters.filter! { |_, value| value != 0 }