diff options
author | Alan Wu <[email protected]> | 2025-06-17 01:09:09 +0900 |
---|---|---|
committer | Alan Wu <[email protected]> | 2025-06-17 20:51:58 +0900 |
commit | 0933400f451813f08671dd02462f1a718e99d564 (patch) | |
tree | 1d2aa00f17856fad6e11e57261d50d4ae8108c87 /test/ruby | |
parent | 01ff17fa40cdfbd811ec3b0c13034936451e693a (diff) |
ZJIT: Add codegen (and FrameState) for GetConstPath
Issue a call to rb_vm_opt_getconstant_path() like the interpreter, but
since that allocates the IC, we need to save the PC before calling. Add
FrameState to GetConstPath to get access to the PC.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13628
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_zjit.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 1a9f326c0a..2b171b02b1 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -678,6 +678,27 @@ class TestZJIT < Test::Unit::TestCase } end + def test_uncached_getconstant_path + assert_compiles RUBY_COPYRIGHT.dump, %q{ + def test = RUBY_COPYRIGHT + test + }, call_threshold: 1, insns: [:opt_getconstant_path] + end + + def test_getconstant_path_autoload + # A constant-referencing expression can run arbitrary code through Kernel#autoload. + Dir.mktmpdir('autoload') do |tmpdir| + autoload_path = File.join(tmpdir, 'test_getconstant_path_autoload.rb') + File.write(autoload_path, 'X = RUBY_COPYRIGHT') + + assert_compiles RUBY_COPYRIGHT.dump, %Q{ + Object.autoload(:X, #{File.realpath(autoload_path).inspect}) + def test = X + test + }, call_threshold: 1, insns: [:opt_getconstant_path] + end + end + def test_send_backtrace backtrace = [ "-e:2:in 'Object#jit_frame1'", |