diff options
Diffstat (limited to 'mjit.c')
-rw-r--r-- | mjit.c | 36 |
1 files changed, 3 insertions, 33 deletions
@@ -1050,11 +1050,8 @@ mjit_finish(bool close_handle_p) // Called by rb_vm_mark(). // -// Mark an ISeq being compiled to prevent its CCs from being GC-ed, which -// an MJIT worker may concurrently see. -// -// Also mark active_units so that we do not GC ISeq which may still be -// referred to by mjit_recompile() or compact_all_jit_code(). +// Mark active_units so that we do not GC ISeq which may still be +// referenced by mjit_recompile() or mjit_compact(). void mjit_mark(void) { @@ -1062,36 +1059,9 @@ mjit_mark(void) return; RUBY_MARK_ENTER("mjit"); - // We need to release a lock when calling rb_gc_mark to avoid doubly acquiring - // a lock by by mjit_gc_start_hook inside rb_gc_mark. - // - // Because an MJIT worker may modify active_units anytime, we need to convert - // the linked list to an array to safely loop its ISeqs without keeping a lock. - int length = 0; - if (compiling_iseqs != NULL) { - while (compiling_iseqs[length]) length++; - } - length += active_units.length; - const rb_iseq_t **iseqs = ALLOCA_N(const rb_iseq_t *, length); - struct rb_mjit_unit *unit = NULL; - int i = 0; - if (compiling_iseqs != NULL) { - while (compiling_iseqs[i]) { - iseqs[i] = compiling_iseqs[i]; - i++; - } - } ccan_list_for_each(&active_units.head, unit, unode) { - iseqs[i] = unit->iseq; - i++; - } - assert(i == length); - - for (i = 0; i < length; i++) { - if (iseqs[i] == NULL) // ISeq is GC-ed - continue; - rb_gc_mark((VALUE)iseqs[i]); + rb_gc_mark((VALUE)unit->iseq); } RUBY_MARK_LEAVE("mjit"); |