🌐 AI搜索 & 代理 主页
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_stats_enabled
end

def test_stats_quiet
# Test that --zjit-stats=quiet collects stats but doesn't print them
# Test that --zjit-stats-quiet collects stats but doesn't print them
script = <<~RUBY
def test = 42
test
Expand All @@ -44,11 +44,24 @@ def test = 42
assert_includes(err, stats_header)
assert_equal("true\n", out)

# With --zjit-stats=quiet, stats should NOT be printed but still enabled
# With --zjit-stats-quiet, stats should NOT be printed but still enabled
out, err, status = eval_with_jit(script, stats: :quiet)
assert_success(out, err, status)
refute_includes(err, stats_header)
assert_equal("true\n", out)

# With --zjit-stats=<path>, stats should be printed to the path
Tempfile.create("zjit-stats-") {|tmp|
stats_file = tmp.path
tmp.puts("Lorem ipsum dolor sit amet, consectetur adipiscing elit, ...")
tmp.close

out, err, status = eval_with_jit(script, stats: stats_file)
assert_success(out, err, status)
refute_includes(err, stats_header)
assert_equal("true\n", out)
assert_equal stats_header, File.open(stats_file) {|f| f.gets(chomp: true)}, "should be overwritten"
}
end

def test_enable_through_env
Expand Down Expand Up @@ -88,7 +101,7 @@ def test_zjit_disable
end

def test_zjit_enable_respects_existing_options
assert_separately(['--zjit-disable', '--zjit-stats=quiet'], <<~RUBY)
assert_separately(['--zjit-disable', '--zjit-stats-quiet'], <<~RUBY)
refute_predicate RubyVM::ZJIT, :enabled?
assert_predicate RubyVM::ZJIT, :stats_enabled?

Expand Down Expand Up @@ -3622,7 +3635,14 @@ def eval_with_jit(
if zjit
args << "--zjit-call-threshold=#{call_threshold}"
args << "--zjit-num-profiles=#{num_profiles}"
args << "--zjit-stats#{"=#{stats}" unless stats == true}" if stats
case stats
when true
args << "--zjit-stats"
when :quiet
args << "--zjit-stats-quiet"
else
args << "--zjit-stats=#{stats}" if stats
end
args << "--zjit-debug" if debug
if allowed_iseqs
jitlist = Tempfile.new("jitlist")
Expand Down
Loading