From c784da17448c40e55cdd231724bfe4bf53da35a1 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Sat, 20 Apr 2019 02:40:41 +0000 Subject: [PATCH] Update MJIT references ISeq can move, so we need to tell MJIT where the new location is. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 3 +++ mjit.c | 13 +++++++++++++ mjit.h | 1 + 3 files changed, 17 insertions(+) diff --git a/iseq.c b/iseq.c index 82f045d62a..0ead40fec2 100644 --- a/iseq.c +++ b/iseq.c @@ -262,6 +262,9 @@ rb_iseq_update_references(rb_iseq_t *iseq) } } } +#if USE_MJIT + mjit_update_references(iseq); +#endif } } diff --git a/mjit.c b/mjit.c index bd5dd46b19..3eb2ee8a50 100644 --- a/mjit.c +++ b/mjit.c @@ -110,6 +110,19 @@ mjit_gc_finish_hook(void) CRITICAL_SECTION_FINISH(4, "mjit_gc_finish_hook"); } +// Deal with ISeq movement from compactor +void +mjit_update_references(const rb_iseq_t *iseq) +{ + if (!mjit_enabled) + return; + CRITICAL_SECTION_START(4, "mjit_free_iseq"); + if (iseq->body->jit_unit) { + iseq->body->jit_unit->iseq = (rb_iseq_t *)rb_gc_new_location(iseq->body->jit_unit->iseq); + } + CRITICAL_SECTION_FINISH(4, "mjit_free_iseq"); +} + // Iseqs can be garbage collected. This function should call when it // happens. It removes iseq from the unit. void diff --git a/mjit.h b/mjit.h index 4aadc8eb6f..e71df7f07c 100644 --- a/mjit.h +++ b/mjit.h @@ -84,6 +84,7 @@ extern void mjit_postponed_job_register_finish_hook(void); extern void mjit_gc_start_hook(void); extern void mjit_gc_finish_hook(void); extern void mjit_free_iseq(const rb_iseq_t *iseq); +extern void mjit_update_references(const rb_iseq_t *iseq); extern void mjit_mark(void); extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec); extern void mjit_cont_free(struct mjit_cont *cont);