ruby-changes:69127
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:56 +0900 (JST)
Subject: [ruby-changes:69127] 9d5b3e1d0f (master): Add a small test for the code GC
https://git.ruby-lang.org/ruby.git/commit/?id=9d5b3e1d0f From 9d5b3e1d0f3d44a52dffb6ec1f09c361c3b419c7 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Tue, 31 Aug 2021 14:26:18 -0400 Subject: Add a small test for the code GC --- bootstraptest/test_yjit.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index ea20224ec2..d91daea8ac 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -441,6 +441,29 @@ assert_equal '7', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L441 foo(4)[1] } +# Method redefinition while the method is on the stack +assert_equal '[777, 1]', %q{ + def foo + redef() + 777 + end + + def redef + # Redefine the global foo + eval("def foo; 1; end", TOPLEVEL_BINDING) + + # Collect dead code + GC.stress = true + GC.start + + # But we will return to the original foo, + # which remains alive because it's on the stack + end + + # Must produce [777, 1] + [foo, foo] +} + # Test for GC safety. Don't invalidate dead iseqs. assert_normal_exit %q{ Class.new do -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/