diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-12-24 01:13:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-24 01:13:40 -0800 |
commit | b9332ac8e7126066ac4238443d63eaa4c06789f9 (patch) | |
tree | 1d3d45ec28ddbcc7e124d026540be61cf4ef3840 /vm_trace.c | |
parent | d521c9e5a7ed603f8f1aaa9a9a66c3cc80599b0c (diff) |
MJIT: Cancel all on disastrous situations (#7019)
I noticed this while running test_yjit with --mjit-call-threshold=1,
which redefines `Integer#<`. When Ruby is monkey-patched,
MJIT itself could be broken.
Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.
Notes
Notes:
Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'vm_trace.c')
-rw-r--r-- | vm_trace.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/vm_trace.c b/vm_trace.c index 69b360dae9..3051266c57 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -106,12 +106,6 @@ update_global_event_hook(rb_event_flag_t prev_events, rb_event_flag_t new_events rb_objspace_set_event_hook(new_events); // Invalidate JIT code as needed - if (first_time_iseq_events_p && new_iseq_events != RUBY_EVENT_CLASS) { - // Stop calling all JIT-ed code. We can't rewrite existing JIT-ed code to trace_ insns for now. - // :class events are triggered only in ISEQ_TYPE_CLASS, but mjit_target_iseq_p ignores such iseqs. - // Thus we don't need to cancel JIT-ed code for :class events. - mjit_cancel_all("TracePoint is enabled"); - } if (first_time_iseq_events_p || enable_c_call || enable_c_return) { // Invalidate all code when ISEQs are modified to use trace_* insns above. // Also invalidate when enabling c_call or c_return because generated code @@ -120,6 +114,7 @@ update_global_event_hook(rb_event_flag_t prev_events, rb_event_flag_t new_events // Do this after event flags updates so other ractors see updated vm events // when they wake up. rb_yjit_tracing_invalidate_all(); + rb_mjit_tracing_invalidate_all(new_iseq_events); } } @@ -1257,6 +1252,7 @@ rb_tracepoint_enable_for_target(VALUE tpval, VALUE target, VALUE target_line) } rb_yjit_tracing_invalidate_all(); + rb_mjit_tracing_invalidate_all(tp->events); ruby_vm_event_local_num++; |