mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ZJIT: Add RubyVM::ZJIT.enabled? (#14159)
Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
This commit is contained in:
parent
6e3790b17f
commit
6968668570
2 changed files with 33 additions and 10 deletions
|
@ -9,6 +9,15 @@ require_relative '../lib/jit_support'
|
|||
return unless JITSupport.zjit_supported?
|
||||
|
||||
class TestZJIT < Test::Unit::TestCase
|
||||
def test_enabled
|
||||
assert_runs 'false', <<~RUBY, zjit: false
|
||||
RubyVM::ZJIT.enabled?
|
||||
RUBY
|
||||
assert_runs 'true', <<~RUBY, zjit: true
|
||||
RubyVM::ZJIT.enabled?
|
||||
RUBY
|
||||
end
|
||||
|
||||
def test_call_itself
|
||||
assert_compiles '42', <<~RUBY, call_threshold: 2
|
||||
def test = 42.itself
|
||||
|
@ -1547,14 +1556,23 @@ class TestZJIT < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
# Run a Ruby process with ZJIT options and a pipe for writing test results
|
||||
def eval_with_jit(script, call_threshold: 1, num_profiles: 1, stats: false, debug: true, timeout: 1000, pipe_fd:)
|
||||
args = [
|
||||
"--disable-gems",
|
||||
"--zjit-call-threshold=#{call_threshold}",
|
||||
"--zjit-num-profiles=#{num_profiles}",
|
||||
]
|
||||
args << "--zjit-stats" if stats
|
||||
args << "--zjit-debug" if debug
|
||||
def eval_with_jit(
|
||||
script,
|
||||
call_threshold: 1,
|
||||
num_profiles: 1,
|
||||
zjit: true,
|
||||
stats: false,
|
||||
debug: true,
|
||||
timeout: 1000,
|
||||
pipe_fd:
|
||||
)
|
||||
args = ["--disable-gems"]
|
||||
if zjit
|
||||
args << "--zjit-call-threshold=#{call_threshold}"
|
||||
args << "--zjit-num-profiles=#{num_profiles}"
|
||||
args << "--zjit-stats" if stats
|
||||
args << "--zjit-debug" if debug
|
||||
end
|
||||
args << "-e" << script_shell_encode(script)
|
||||
pipe_r, pipe_w = IO.pipe
|
||||
# Separate thread so we don't deadlock when
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue