summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2023-11-27 19:19:41 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2023-11-28 13:03:04 -0500
commitcd4207869ff831c41db3ec873b175369ffca080a (patch)
treee3a63a06f41f952077aa84d2e300cf68b24ca113 /test/ruby
parent0704f40787d306b00db6bbdfee7e13ee172f600a (diff)
Fix cache incoherency for ME resolved through VM_METHOD_TYPE_REFINED
Previously, we didn't invalidate the method entry wrapped by VM_METHOD_TYPE_REFINED method entries which could cause calls to land in the wrong method like it did in the included test. Do the invalidation, and adjust rb_method_entry_clone() to accommodate this new invalidation vector. Fix: cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 See-also: e201b81f79828c30500947fe8c8ea3c515e3d112
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_refinement.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index c078f61895..826616eb09 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2650,6 +2650,28 @@ class TestRefinement < Test::Unit::TestCase
end;
end
+ def test_inline_cache_invalidation
+ klass = Class.new do
+ def cached_foo_callsite = foo
+
+ def foo = :v1
+
+ host = self
+ @refinement = Module.new do
+ refine(host) do
+ def foo = :unused
+ end
+ end
+ end
+
+ obj = klass.new
+ obj.cached_foo_callsite # prime cache
+ klass.class_eval do
+ def foo = :v2 # invalidate
+ end
+ assert_equal(:v2, obj.cached_foo_callsite)
+ end
+
private
def eval_using(mod, s)