aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.h
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-12-24 01:13:40 -0800
committerGitHub <noreply@github.com>2022-12-24 01:13:40 -0800
commitb9332ac8e7126066ac4238443d63eaa4c06789f9 (patch)
tree1d3d45ec28ddbcc7e124d026540be61cf4ef3840 /mjit.h
parentd521c9e5a7ed603f8f1aaa9a9a66c3cc80599b0c (diff)
downloadruby-b9332ac8e7126066ac4238443d63eaa4c06789f9.tar.gz
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.
Diffstat (limited to 'mjit.h')
-rw-r--r--mjit.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/mjit.h b/mjit.h
index dc46ef2112..260cf4af78 100644
--- a/mjit.h
+++ b/mjit.h
@@ -103,6 +103,13 @@ extern void mjit_mark(void);
extern void mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body);
extern void mjit_notify_waitpid(int exit_code);
+extern void rb_mjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop);
+extern void rb_mjit_cme_invalidate(rb_callable_method_entry_t *cme);
+extern void rb_mjit_before_ractor_spawn(void);
+extern void rb_mjit_constant_state_changed(ID id);
+extern void rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx);
+extern void rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events);
+
void mjit_child_after_fork(void);
# ifdef MJIT_HEADER
@@ -122,6 +129,13 @@ static inline void mjit_mark(void){}
static inline VALUE jit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
static inline void mjit_child_after_fork(void){}
+static inline void rb_mjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop) {}
+static inline void rb_mjit_cme_invalidate(rb_callable_method_entry_t *cme) {}
+static inline void rb_mjit_before_ractor_spawn(void) {}
+static inline void rb_mjit_constant_state_changed(ID id) {}
+static inline void rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx) {}
+static inline void rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events) {}
+
#define mjit_enabled false
static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
static inline VALUE mjit_resume(void){ return Qnil; } // unreachable