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

ruby-changes:64402

From: Takashi <ko1@a...>
Date: Mon, 21 Dec 2020 15:03:51 +0900 (JST)
Subject: [ruby-changes:64402] a574df14e4 (master): Stop marking unit_queue

https://git.ruby-lang.org/ruby.git/commit/?id=a574df14e4

From a574df14e45b8b5a1de7bfe949e08b61ae51b0bd Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sun, 20 Dec 2020 21:54:27 -0800
Subject: Stop marking unit_queue

The original motivation of this marking was https://github.com/k0kubun/yarv-mjit/issues/20.
As wanabe said, there are multiple options to mitigate the issue, and
Eric Wong introduced another fix at 143776f6fe by checking unit->iseq
inside the lock.

Therefore this particular condition has been covered in two ways, and
the script given by wanabe no longer crashes without mjit_mark().

diff --git a/mjit.c b/mjit.c
index 564d10d..5c2042b 100644
--- a/mjit.c
+++ b/mjit.c
@@ -937,33 +937,6 @@ mjit_finish(bool close_handle_p) https://github.com/ruby/ruby/blob/trunk/mjit.c#L937
     verbose(1, "Successful MJIT finish");
 }
 
-// Called by rb_vm_mark() to mark iseq being JIT-ed and iseqs in the unit queue.
-void
-mjit_mark(void)
-{
-    if (!mjit_enabled)
-        return;
-    RUBY_MARK_ENTER("mjit");
-
-    struct rb_mjit_unit *unit = NULL;
-    CRITICAL_SECTION_START(4, "mjit_mark");
-    list_for_each(&unit_queue.head, unit, unode) {
-        if (unit->iseq) { // ISeq is still not GCed
-            VALUE iseq = (VALUE)unit->iseq;
-            CRITICAL_SECTION_FINISH(4, "mjit_mark rb_gc_mark");
-
-            // Don't wrap critical section with this. This may trigger GC,
-            // and in that case mjit_gc_start_hook causes deadlock.
-            rb_gc_mark(iseq);
-
-            CRITICAL_SECTION_START(4, "mjit_mark rb_gc_mark");
-        }
-    }
-    CRITICAL_SECTION_FINISH(4, "mjit_mark");
-
-    RUBY_MARK_LEAVE("mjit");
-}
-
 // Called by rb_iseq_mark() to mark cc_entries captured for MJIT
 void
 mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body)
diff --git a/mjit.h b/mjit.h
index a523bc9..89d9a7a 100644
--- a/mjit.h
+++ b/mjit.h
@@ -98,7 +98,6 @@ extern void mjit_gc_start_hook(void); https://github.com/ruby/ruby/blob/trunk/mjit.h#L98
 extern void mjit_gc_exit_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);
 extern void mjit_add_class_serial(rb_serial_t class_serial);
@@ -201,7 +200,6 @@ static inline void mjit_cont_free(struct mjit_cont *cont){} https://github.com/ruby/ruby/blob/trunk/mjit.h#L200
 static inline void mjit_gc_start_hook(void){}
 static inline void mjit_gc_exit_hook(void){}
 static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
-static inline void mjit_mark(void){}
 static inline void mjit_add_class_serial(rb_serial_t class_serial){}
 static inline void mjit_remove_class_serial(rb_serial_t class_serial){}
 static inline VALUE mjit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
diff --git a/vm.c b/vm.c
index ee28a2d..0c2ffd9 100644
--- a/vm.c
+++ b/vm.c
@@ -2594,8 +2594,6 @@ rb_vm_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2594
 	rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
 
         rb_id_table_foreach_values(vm->negative_cme_table, vm_mark_negative_cme, NULL);
-
-        mjit_mark();
     }
 
     RUBY_MARK_LEAVE("vm");
-- 
cgit v0.10.2


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

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