diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2020-10-29 17:26:49 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:26 -0400 |
commit | 188c54428c46c1098cda0e366ee8c974f25ac07b (patch) | |
tree | 07f2c5be723416510ee498b6a732e351f11163dd /test | |
parent | 9ce9f613b0b3a1b222055fac93969f588cfd7e7b (diff) |
MicroJIT: avoid having to invalidate running output code
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_microjit.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_microjit.rb b/test/ruby/test_microjit.rb new file mode 100644 index 0000000000..f0c876b70f --- /dev/null +++ b/test/ruby/test_microjit.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +require 'test/unit' + +class TestMicroJIT < Test::Unit::TestCase + # MicroJIT's code invalidation mechanism can't invalidate + # code that is executing. Test that we don't try to do that. + def test_code_invalidation + klass = Class.new do + def alias_then_hash(klass, method_to_redefine) + klass.alias_method(method_to_redefine, :itself) + hash + end + end + + instance = klass.new + i = 0 + while i < 12 + if i < 11 + instance.alias_then_hash(klass, :bar) + else + ret = instance.alias_then_hash(klass, :hash) + assert(instance.equal?(ret)) + end + i += 1 + end + end +end |