From b2ffafd2383fef50933a725797b1ea7ae4fbdaea Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sat, 20 Apr 2019 05:48:22 +0000 Subject: Invalidate JIT-ed code if ISeq is moved by GC.compact git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mjit.c') diff --git a/mjit.c b/mjit.c index 0cedd55e57..186702270d 100644 --- a/mjit.c +++ b/mjit.c @@ -120,6 +120,9 @@ mjit_update_references(const rb_iseq_t *iseq) CRITICAL_SECTION_START(4, "mjit_free_iseq"); if (iseq->body->jit_unit) { iseq->body->jit_unit->iseq = (rb_iseq_t *)rb_gc_new_location((VALUE)iseq->body->jit_unit->iseq); + // We need to invalidate JIT-ed code for the ISeq because it embeds pointer addresses. + // To efficiently do that, we use the same thing as TracePoint and thus everything is cancelled for now. + mjit_call_p = false; // TODO: instead of cancelling all, invalidate only this one and recompile it with some threshold. } // Units in stale_units (list of over-speculated and invalidated code) are not referenced from @@ -313,6 +316,7 @@ unload_units(void) for (cont = first_cont; cont != NULL; cont = cont->next) { mark_ec_units(cont->ec); } + // TODO: check slale_units and unload unused ones! (note that the unit is not associated to ISeq anymore) // Remove 1/10 units more to decrease unloading calls. // TODO: Calculate max total_calls in unit_queue and don't unload units -- cgit v1.2.3