[前][次][番号順一覧][スレッド一覧]

ruby-changes:68832

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:14:10 +0900 (JST)
Subject: [ruby-changes:68832] 7f7e79d802 (master): YJIT: handle when all counters are zero in printout code

https://git.ruby-lang.org/ruby.git/commit/?id=7f7e79d802

From 7f7e79d80221949f93c7ded7cbd8d26afd3dea1d Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Sat, 6 Mar 2021 11:05:55 -0500
Subject: YJIT: handle when all counters are zero in printout code

Also filter with not equal to zero instead of greater than zero, in case
there is memory corruption and counters are negative.

Fixes Shopify/ruby#70
---
 ujit.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ujit.rb b/ujit.rb
index a2f61b1021..d27d200daf 100644
--- a/ujit.rb
+++ b/ujit.rb
@@ -67,9 +67,14 @@ module UJIT https://github.com/ruby/ruby/blob/trunk/ujit.rb#L67
     def print_counters(counters, prefix:, prompt:)
       $stderr.puts(prompt)
       counters = counters.filter { |key, _| key.start_with?(prefix) }
-      counters.filter! { |_, value| value > 0 }
+      counters.filter! { |_, value| value != 0 }
       counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) }
 
+      if counters.empty?
+        $stderr.puts("    (all relevant counters are zero)")
+        return
+      end
+
       counters = counters.to_a
       counters.sort_by! { |(_, counter_value)| counter_value }
       longest_name_length = counters.max_by { |(name, _)| name.length }.first.length
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]