зеркало из https://github.com/github/ruby.git
YJIT: Let RubyVM::YJIT.enable respect --yjit-stats (#9415)
This commit is contained in:
Родитель
4d03140009
Коммит
7f9c174102
|
@ -67,7 +67,19 @@ class TestYJIT < Test::Unit::TestCase
|
|||
RUBY
|
||||
end
|
||||
|
||||
def test_yjit_enable_stats
|
||||
def test_yjit_enable_stats_false
|
||||
assert_separately(["--yjit-disable", "--yjit-stats"], <<~RUBY, ignore_stderr: true)
|
||||
assert_false RubyVM::YJIT.enabled?
|
||||
assert_nil RubyVM::YJIT.runtime_stats
|
||||
|
||||
RubyVM::YJIT.enable
|
||||
|
||||
assert_true RubyVM::YJIT.enabled?
|
||||
assert_true RubyVM::YJIT.runtime_stats[:all_stats]
|
||||
RUBY
|
||||
end
|
||||
|
||||
def test_yjit_enable_stats_true
|
||||
args = []
|
||||
args << "--disable=yjit" if RubyVM::YJIT.enabled?
|
||||
assert_separately(args, <<~RUBY, ignore_stderr: true)
|
||||
|
|
6
yjit.rb
6
yjit.rb
|
@ -28,7 +28,11 @@ module RubyVM::YJIT
|
|||
Primitive.rb_yjit_reset_stats_bang
|
||||
end
|
||||
|
||||
# Enable \YJIT compilation.
|
||||
# Enable \YJIT compilation. `stats` option decides whether to enable \YJIT stats or not.
|
||||
#
|
||||
# * `false`: Disable stats.
|
||||
# * `true`: Enable stats. Print stats at exit.
|
||||
# * `:quiet`: Enable stats. Do not print stats at exit.
|
||||
def self.enable(stats: false)
|
||||
return false if enabled?
|
||||
at_exit { print_and_dump_stats } if stats
|
||||
|
|
|
@ -171,9 +171,11 @@ pub extern "C" fn rb_yjit_code_gc(_ec: EcPtr, _ruby_self: VALUE) -> VALUE {
|
|||
pub extern "C" fn rb_yjit_enable(_ec: EcPtr, _ruby_self: VALUE, gen_stats: VALUE, print_stats: VALUE) -> VALUE {
|
||||
with_vm_lock(src_loc!(), || {
|
||||
// Initialize and enable YJIT
|
||||
unsafe {
|
||||
OPTIONS.gen_stats = gen_stats.test();
|
||||
OPTIONS.print_stats = print_stats.test();
|
||||
if gen_stats.test() {
|
||||
unsafe {
|
||||
OPTIONS.gen_stats = gen_stats.test();
|
||||
OPTIONS.print_stats = print_stats.test();
|
||||
}
|
||||
}
|
||||
yjit_init();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче