Skip to content

Commit

Permalink
Rephrase comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed May 25, 2023
1 parent 7109159 commit 87c0015
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,24 +408,23 @@ jl_ptls_t jl_init_threadtls(int16_t tid)

JL_DLLEXPORT jl_gcframe_t **jl_adopt_thread(void)
{
// jl_init_threadtls puts us in a GC unsafe region, so ensure GC isn't running.
// `jl_init_threadtls` puts us in a GC unsafe region, so ensure GC isn't running.
// we can't use a normal safepoint because we don't have signal handlers yet.
// we also can't use jl_safepoint_wait_gc because that assumes we're in a task.
jl_atomic_fetch_add(&jl_gc_disable_counter, 1);
while (jl_atomic_load_acquire(&jl_gc_running)) {
jl_cpu_pause();
}
// In `jl_safepoint_start_gc` we observe if a foreign thread has asked to disable the GC
// Guaranteeing the order of events.
// this check is coupled with the one in `jl_safepoint_wait_gc`, where we observe if a
// foreign thread has asked to disable the GC, guaranteeing the order of events.

// initialize this thread (assign tid, create heap, set up root task)
jl_ptls_t ptls = jl_init_threadtls(-1);
void *stack_lo, *stack_hi;
jl_init_stack_limits(0, &stack_lo, &stack_hi);

// warning: this changes `jl_current_task`, so be careful not to call that from this function
// `jl_init_root_task` assumes that GC is disabled.
jl_task_t *ct = jl_init_root_task(ptls, stack_lo, stack_hi);
jl_task_t *ct = jl_init_root_task(ptls, stack_lo, stack_hi); // assumes the GC is disabled
JL_GC_PROMISE_ROOTED(ct);
uv_random(NULL, NULL, &ct->rngState, sizeof(ct->rngState), 0, NULL);
jl_atomic_fetch_add(&jl_gc_disable_counter, -1);
Expand Down

0 comments on commit 87c0015

Please sign in to comment.