summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-01 21:32:36 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 23:28:59 -0800
commit7dcdffebc8da9319bc2a0a2e0d9e90fdc140d79c (patch)
treee5986e96dd8f637cf27e16d14e8773103838bc60 /mjit.c
parentb5fbc9f59f760f5faaca82c5b2bc869a6f38ade5 (diff)
Invalidate blocks on global constant changes
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7448
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)
{