From 39a34694a0e33e18b4ac6e43cb8042e2d818ecd4 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Tue, 28 Mar 2023 15:21:19 -0400 Subject: YJIT: Add `--yjit-pause` and `RubyVM::YJIT.resume` (#7609) * YJIT: Add --yjit-pause and RubyVM::YJIT.resume This allows booting YJIT in a suspended state. We chose to add a new command line option as opposed to simply allowing YJIT.resume to work without any command line option because it allows for combining with YJIT tuning command line options. It also simpifies implementation. Paired with Kokubun and Maxime. * Update yjit.rb Co-authored-by: Takashi Kokubun --------- Co-authored-by: Alan Wu Co-authored-by: Takashi Kokubun --- test/ruby/test_yjit.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 925efdf39f..af7309385f 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -51,6 +51,29 @@ class TestYJIT < Test::Unit::TestCase #assert_in_out_err('--yjit-call-threshold=', '', [], /--yjit-call-threshold needs an argument/) end + def test_starting_paused + program = <<~RUBY + def not_compiled = nil + def will_compile = nil + def compiled_counts = RubyVM::YJIT.runtime_stats[:compiled_iseq_count] + counts = [] + not_compiled + counts << compiled_counts + + RubyVM::YJIT.resume + + will_compile + counts << compiled_counts + + if counts[0] == 0 && counts[1] > 0 + p :ok + end + RUBY + assert_in_out_err(%w[--yjit-pause --yjit-stats --yjit-call-threshold=1], program, success: true) do |stdout, stderr| + assert_equal([":ok"], stdout) + end + end + def test_yjit_stats_and_v_no_error _stdout, stderr, _status = EnvUtil.invoke_ruby(%w(-v --yjit-stats), '', true, true) refute_includes(stderr, "NoMethodError") -- cgit v1.2.1