summaryrefslogtreecommitdiff
path: root/test/ruby/test_zjit.rb
diff options
context:
space:
mode:
authorStan Lo <stan.lo@shopify.com>2025-08-13 01:39:46 +0100
committerGitHub <noreply@github.com>2025-08-12 17:39:46 -0700
commitdf7d9812cc504f3361792f3dd4843d1ffa3c5ead (patch)
tree20f117b9c0ab164d71561096e63ef43f78e3751c /test/ruby/test_zjit.rb
parent1afc07e815051e2f73493f055f2130cb642ba12a (diff)
ZJIT: Prepare non-leaf calls for SetGlobal (#14197)
When trace_var is used, setting a global variable can cause exceptions to be raised. We need to prepare for that.
Diffstat (limited to 'test/ruby/test_zjit.rb')
-rw-r--r--test/ruby/test_zjit.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index 4dc0919b6b..98146b80db 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -61,6 +61,30 @@ class TestZJIT < Test::Unit::TestCase
}
end
+ def test_setglobal
+ assert_compiles '1', %q{
+ def test
+ $a = 1
+ $a
+ end
+
+ test
+ }, insns: [:setglobal]
+ end
+
+ def test_setglobal_with_trace_var_exception
+ assert_compiles '"rescued"', %q{
+ def test
+ $a = 1
+ rescue
+ "rescued"
+ end
+
+ trace_var(:$a) { raise }
+ test
+ }, insns: [:setglobal]
+ end
+
def test_setlocal
assert_compiles '3', %q{
def test(n)