8000 Merge pull request #194 from Shopify/tiny_gc_test · jhawthorn/ruby@d130c0b · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit d130c0b

Browse files
authored
Merge pull request ruby#194 from Shopify/tiny_gc_test
Add a small test for the code GC
2 parents 093740a + 0001e7a commit d130c0b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bootstraptest/test_yjit.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,29 @@ def bar()
441441
foo(4)[1]
442442
}
443443

444+
# Method redefinition while the method is on the stack
445+
assert_equal '[777, 1]', %q{
446+
def foo
447+
redef()
448+
777
449+
end
450+
451+
def redef
452+
# Redefine the global foo
453+
eval("def foo; 1; end", TOPLEVEL_BINDING)
454+
455+
# Collect dead code
456+
GC.stress = true
457+
GC.start
458+
459+
# But we will return to the original foo,
460+
# which remains alive because it's on the stack
461+
end
462+
463+
# Must produce [777, 1]
464+
[foo, foo]
465+
}
466+
444467
# Test for GC safety. Don't invalidate dead iseqs.
445468
assert_normal_exit %q{
446469
Class.new do

0 commit comments

Comments
 (0)
0