From 7ec23593746c8ccabd6c005cc34dde77d564c6c9 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 25 Feb 2020 11:03:17 +0900 Subject: prevent GC from mjit worker. ALLOC_N() can causes GC. Sometimes `mjit_copy_job_handler()` can be called by mjit_worker thread which is not a Ruby thread, so we need to prevent GC in this function. This patch has some issues, but I introduce it to pass the tests. --- mjit.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'mjit.c') diff --git a/mjit.c b/mjit.c index d3cb063ff9..bcf773d2d7 100644 --- a/mjit.c +++ b/mjit.c @@ -54,13 +54,13 @@ mjit_copy_job_handler(void *data) } const struct rb_iseq_constant_body *body = job->iseq->body; - unsigned int ci_size = body->ci_size; + const unsigned int ci_size = body->ci_size; if (ci_size > 0) { - const struct rb_callcache **cc_entries = ALLOC_N(const struct rb_callcache *, ci_size); - if (body->jit_unit == NULL) { - create_unit(job->iseq); - } - body->jit_unit->cc_entries = cc_entries; + VM_ASSERT(body->jit_unit != NULL); + VM_ASSERT(body->jit_unit->cc_entries != NULL); + + const struct rb_callcache **cc_entries = body->jit_unit->cc_entries; + for (unsigned int i=0; icall_data[i].cc; } @@ -294,6 +294,9 @@ create_unit(const rb_iseq_t *iseq) unit->id = current_unit_num++; unit->iseq = (rb_iseq_t *)iseq; + if (iseq->body->ci_size > 0) { + unit->cc_entries = ALLOC_N(const struct rb_callcache *, iseq->body->ci_size); + } iseq->body->jit_unit = unit; } -- cgit v1.2.3