From f4f940e5a63e542a59fc7510332efb38ccafc10f Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 29 Jul 2021 12:41:59 -0400 Subject: Save PC and SP before accessing globals These instructions are marked as not leaf in insns.def, which indicate that they could raise exceptions and/or call Ruby methods. --- bootstraptest/test_yjit.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'bootstraptest') diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 1a683c1c41..a164b7a413 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -7,6 +7,19 @@ assert_equal 'string', %q{ foo } +# Check that exceptions work when setting global variables +assert_equal 'rescued', %q{ + def set_var + $var = 100 + rescue + :rescued + end + + set_var + trace_var(:$var) { raise } + set_var +} + # Check that global variables work assert_equal 'string', %q{ $foo = "string" @@ -18,6 +31,25 @@ assert_equal 'string', %q{ foo } +# Check that exceptions work when getting global variable +assert_equal 'rescued', %q{ + module Warning + def warn(message) + raise + end + end + + def get_var + $= + rescue + :rescued + end + + $VERBOSE = true + get_var + get_var +} + # Check that global tracepoints work assert_equal 'true', %q{ def foo -- cgit v1.2.3