diff options
author | Takashi Kokubun <[email protected]> | 2020-11-21 19:24:59 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2020-11-21 19:36:55 -0800 |
commit | e0156bd39656e26971e4236747e9cd4f45f8b35f (patch) | |
tree | eea453a551e34906c5208299d516795cf94318ba /cont.c | |
parent | eb3906c6b8ea3d88c5c53cb420e18dcda4d7081e (diff) |
Make sure all threads are scanned on unload_units
This has been a TODO since 79df14c04b. While adcf0316d1 covered the
root_fiber of the initial thread, it didn't cover root_fibers of other
threads. Now it's hooked properly in rb_threadptr_root_fiber_setup.
With regards to "XXX: Is this mjit_cont `mjit_cont_free`d?", when
rb_threadptr_root_fiber_release is called, although I'm not sure when
th->root_fiber is truthy, fiber_free seems to call cont_free and
mjit_cont_free. So mjit_conts of root_fibers seem to be freed properly.
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -945,7 +945,8 @@ cont_free(void *ptr) RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr); - if (mjit_enabled && cont->mjit_cont != NULL) { + if (mjit_enabled) { + VM_ASSERT(cont->mjit_cont != NULL); mjit_cont_free(cont->mjit_cont); } /* free rb_cont_t or rb_fiber_t */ @@ -1155,11 +1156,10 @@ VALUE rb_fiberptr_self(struct rb_fiber_struct *fiber) return fiber->cont.self; } +// This is used for root_fiber because other fibers call cont_init_mjit_cont through cont_new. void rb_fiber_init_mjit_cont(struct rb_fiber_struct *fiber) { - // Currently this function is meant for root_fiber. Others go through cont_new. - // XXX: Is this mjit_cont `mjit_cont_free`d? cont_init_mjit_cont(&fiber->cont); } @@ -1987,6 +1987,9 @@ rb_threadptr_root_fiber_setup(rb_thread_t *th) fiber->blocking = 1; fiber_status_set(fiber, FIBER_RESUMED); /* skip CREATED */ th->ec = &fiber->cont.saved_ec; + // This skips mjit_cont_new for the initial thread because mjit_enabled is always false + // at this point. mjit_init calls rb_fiber_init_mjit_cont again for this root_fiber. + rb_fiber_init_mjit_cont(fiber); } void |