summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-07-19 11:12:51 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:38 -0400
commit71cef74432ef67edfd5635a9b9f8dffbbc33d392 (patch)
treef445f22df98ec453d4d9e1a02824213b1f4b7a58 /bootstraptest
parente8617d0e7ea8039f3757896f547107f51566256b (diff)
Clear JIT code when tracepoints get enabled
Clear out any JIT code on iseqs when tracepoints get enabled. We can't handle tracepoints right now, so we'll just try to recompile later.
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 0ca293f59a..9bce707cb5 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1,3 +1,45 @@
+# Check that global tracepoints work
+assert_equal 'true', %q{
+ def foo
+ 1
+ end
+
+ foo
+ foo
+ foo
+
+ called = false
+
+ tp = TracePoint.new(:return) { |event|
+ if event.method_id == :foo
+ called = true
+ end
+ }
+ tp.enable
+ foo
+ tp.disable
+ called
+}
+
+# Check that local tracepoints work
+assert_equal 'true', %q{
+ def foo
+ 1
+ end
+
+ foo
+ foo
+ foo
+
+ called = false
+
+ tp = TracePoint.new(:return) { |_| called = true }
+ tp.enable(target: method(:foo))
+ foo
+ tp.disable
+ called
+}
+
# Make sure that optional param methods return the correct value
assert_equal '1', %q{
def m(ary = [])