ruby-changes:68749
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:25 +0900 (JST)
Subject: [ruby-changes:68749] d2d564be1d (master): Moved ujit code invalidation test into bootstraptest
https://git.ruby-lang.org/ruby.git/commit/?id=d2d564be1d From d2d564be1db247f21e15c847584b0ec2cae4428d Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Wed, 3 Feb 2021 17:39:38 -0500 Subject: Moved ujit code invalidation test into bootstraptest --- bootstraptest/test_ujit.rb | 30 ++++++++++++++++++++++++++++++ test/ruby/test_microjit.rb | 27 --------------------------- 2 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 bootstraptest/test_ujit.rb delete mode 100644 test/ruby/test_microjit.rb diff --git a/bootstraptest/test_ujit.rb b/bootstraptest/test_ujit.rb new file mode 100644 index 0000000000..9d26aec347 --- /dev/null +++ b/bootstraptest/test_ujit.rb @@ -0,0 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ujit.rb#L1 +# Method redefinition (code invalidation) test +assert_equal '1', %q{ + def ret1 + return 1 + end + + klass = Class.new do + def alias_then_hash(klass, method_to_redefine) + # Redefine the method to be ret1 + klass.alias_method(method_to_redefine, :ret1) + hash + end + end + + instance = klass.new + + i = 0 + while i < 12 + if i < 11 + # Redefine the bar method + instance.alias_then_hash(klass, :bar) + else + # Redefine the hash method to be ret1 + retval = instance.alias_then_hash(klass, :hash) + end + i += 1 + end + + retval +} \ No newline at end of file diff --git a/test/ruby/test_microjit.rb b/test/ruby/test_microjit.rb deleted file mode 100644 index f0c876b70f..0000000000 --- a/test/ruby/test_microjit.rb +++ /dev/null @@ -1,27 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ujit.rb#L0 -# 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/