ruby-changes:72302
From: Alan <ko1@a...>
Date: Fri, 24 Jun 2022 09:28:36 +0900 (JST)
Subject: [ruby-changes:72302] 333754ace8 (master): YJIT: Add regression test for local type tracking
https://git.ruby-lang.org/ruby.git/commit/?id=333754ace8 From 333754ace8ae9bc5d2dfb4aee160fcfa0f38350d Mon Sep 17 00:00:00 2001 From: Alan Wu <alanwu@r...> Date: Thu, 23 Jun 2022 20:27:02 -0400 Subject: YJIT: Add regression test for local type tracking The test in [1] was removed because it stopped working when we limited the power of Kernel#binding in [2]. However, the underlying issue could still be reproduced using blocks. Add back a regression test. I tested the test by commenting out the fix from [1]. [1]: 54c91042ed61a869d4a66fc089b21f56d165265f [2]: 343ea9967e4a6b279eed6bd8e81ad0bdc747f254 --- bootstraptest/test_yjit.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 09bce6735b..ea564a6a6e 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1,3 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L1 +assert_equal 'true', %q{ + # regression test for tracking type of locals for too long + def local_setting_cmp(five) + victim = 5 + five.define_singleton_method(:respond_to?) do |_, _| + victim = nil + end + + # +1 makes YJIT track that victim is a number and + # defined? calls respond_to? from above indirectly + unless (victim + 1) && defined?(five.something) + # Would return wrong result if we still think `five` is a number + victim.nil? + end + end + + local_setting_cmp(Object.new) + local_setting_cmp(Object.new) +} + assert_equal '18374962167983112447', %q{ # regression test for incorrectly discarding 32 bits of a pointer when it # comes to default values. -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/