mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mjit.c: add :wait option to RubyVM::MJIT.pause
and wait until JIT queue is flushed when wait option is not passed or `wait: true` is passed. vm.c: ditto test/ruby/test_rubyvm_mjit.rb: added test for pause/resume test/lib/jit_support.rb: allow retrying MJIT on JITSupport level test/ruby/test_jit.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
82de3b95c4
commit
510cd06c78
5 changed files with 107 additions and 29 deletions
52
test/ruby/test_rubyvm_mjit.rb
Normal file
52
test/ruby/test_rubyvm_mjit.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test/unit'
|
||||
require_relative '../lib/jit_support'
|
||||
|
||||
class TestRubyVMMJIT < Test::Unit::TestCase
|
||||
include JITSupport
|
||||
|
||||
def test_pause
|
||||
out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
|
||||
i = 0
|
||||
while i < 5
|
||||
eval("def mjit#{i}; end; mjit#{i}")
|
||||
i += 1
|
||||
end
|
||||
print RubyVM::MJIT.pause
|
||||
print RubyVM::MJIT.pause
|
||||
while i < 10
|
||||
eval("def mjit#{i}; end; mjit#{i}")
|
||||
i += 1
|
||||
end
|
||||
print RubyVM::MJIT.pause # no JIT here
|
||||
EOS
|
||||
assert_equal('truefalsefalse', out)
|
||||
assert_equal(5, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size)
|
||||
end
|
||||
|
||||
def test_pause_wait_false
|
||||
out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
|
||||
i = 0
|
||||
while i < 10
|
||||
eval("def mjit#{i}; end; mjit#{i}")
|
||||
i += 1
|
||||
end
|
||||
print RubyVM::MJIT.pause(wait: false)
|
||||
print RubyVM::MJIT.pause(wait: false)
|
||||
EOS
|
||||
assert_equal('truefalse', out)
|
||||
assert_equal(true, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size < 10)
|
||||
end
|
||||
|
||||
def test_resume
|
||||
out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
|
||||
print RubyVM::MJIT.resume
|
||||
print RubyVM::MJIT.pause
|
||||
print RubyVM::MJIT.resume
|
||||
print RubyVM::MJIT.resume
|
||||
print RubyVM::MJIT.pause
|
||||
EOS
|
||||
assert_equal('falsetruetruefalsetrue', out)
|
||||
assert_equal(0, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue