From 5d8f112505fbc3f9b008ce4ec40fc74f9f623c4a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 26 Sep 2019 12:53:41 +0900 Subject: RubyVM::MJIT.pause(wait: true) should wait for all compilations and compaction. Prior to this commit, the last-compiled code has not been used because MJIT worker is stopped before setting the code, and compaction has also been skipped. But it was not intentional and `wait: true` pause should wait until those two things by its feature. --- test/lib/jit_support.rb | 1 + test/ruby/test_rubyvm_mjit.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'test') diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index acda166eb2..fc5c12e871 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -3,6 +3,7 @@ require 'rbconfig' module JITSupport JIT_TIMEOUT = 600 # 10min for each... JIT_SUCCESS_PREFIX = 'JIT success \(\d+\.\dms\)' + JIT_COMPACTION_PREFIX = 'JIT compaction \(\d+\.\dms\)' UNSUPPORTED_COMPILERS = [ %r[\Aicc\b], %r[\A/opt/developerstudio\d+\.\d+/bin/cc\z], diff --git a/test/ruby/test_rubyvm_mjit.rb b/test/ruby/test_rubyvm_mjit.rb index 12772320f5..ef7475670c 100644 --- a/test/ruby/test_rubyvm_mjit.rb +++ b/test/ruby/test_rubyvm_mjit.rb @@ -35,6 +35,22 @@ class TestRubyVMMJIT < Test::Unit::TestCase ) end + def test_pause_waits_until_compaction + out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) + def a() end; a + def b() end; b + RubyVM::MJIT.pause + EOS + assert_equal( + 2, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, + "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", + ) + assert_equal( + 1, err.scan(/#{JITSupport::JIT_COMPACTION_PREFIX}/).size, + "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", + ) unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet + end + def test_pause_does_not_hang_on_full_units out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false) i = 0 -- cgit v1.2.3