diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2021-08-31 14:26:18 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:39 -0400 |
commit | 9d5b3e1d0f3d44a52dffb6ec1f09c361c3b419c7 (patch) | |
tree | 657f8f622a5b5d24b195e6655820abdde3e7333f /bootstraptest | |
parent | e527912fe0188f8dc614bdbef25bfdb724fea9ed (diff) |
Add a small test for the code GC
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 23 |
1 files changed, 23 insertions, 0 deletions
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{ 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 |