summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mjit.c b/mjit.c
index b9a5b025ce..fe5e2976a7 100644
--- a/mjit.c
+++ b/mjit.c
@@ -353,6 +353,28 @@ rb_mjit_before_ractor_spawn(void)
mjit_call_p = false;
}
+static void
+mjit_constant_state_changed(void *data)
+{
+ if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
+ RB_VM_LOCK_ENTER();
+ rb_vm_barrier();
+
+ WITH_MJIT_ISOLATED({
+ rb_funcall(rb_mMJITHooks, rb_intern("on_constant_state_changed"), 1, SIZET2NUM((size_t)data));
+ });
+
+ RB_VM_LOCK_LEAVE();
+}
+
+void
+rb_mjit_constant_state_changed(ID id)
+{
+ if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
+ // Asynchronously hook the Ruby code since this is hooked during a "Ruby critical section".
+ rb_workqueue_register(0, mjit_constant_state_changed, (void *)id);
+}
+
void
rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx)
{