[前][次][番号順一覧][スレッド一覧]

ruby-changes:55422

From: k0kubun <ko1@a...>
Date: Sat, 20 Apr 2019 13:50:26 +0900 (JST)
Subject: [ruby-changes:55422] k0kubun:r67631 (trunk): Check ISeq references in stale_units too

k0kubun	2019-04-20 13:50:21 +0900 (Sat, 20 Apr 2019)

  New Revision: 67631

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67631

  Log:
    Check ISeq references in stale_units too
    
    This is a possible bug from recent "JIT recompile" introduction.

  Modified files:
    trunk/mjit.c
Index: mjit.c
===================================================================
--- mjit.c	(revision 67630)
+++ mjit.c	(revision 67631)
@@ -141,6 +141,7 @@ mjit_free_iseq(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/mjit.c#L141
 {
     if (!mjit_enabled)
         return;
+
     CRITICAL_SECTION_START(4, "mjit_free_iseq");
     if (mjit_copy_job.iseq == iseq) {
         mjit_copy_job.iseq = NULL;
@@ -150,6 +151,15 @@ mjit_free_iseq(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/mjit.c#L151
         // lists of units. `get_from_list` and `mjit_finish` do the job.
         iseq->body->jit_unit->iseq = NULL;
     }
+    // Units in stale_units (list of over-speculated and invalidated code) are not referenced from
+    // `iseq->body->jit_unit` anymore (because new one replaces that). So we need to check them too.
+    // TODO: we should be able to reduce the number of units checked here.
+    struct rb_mjit_unit *unit = NULL;
+    list_for_each(&stale_units.head, unit, unode) {
+        if (unit->iseq == iseq) {
+            unit->iseq = NULL;
+        }
+    }
     CRITICAL_SECTION_FINISH(4, "mjit_free_iseq");
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]