Skip to content

Commit

Permalink
Merge pull request #29559 from JuliaLang/vc/debug_tasks
Browse files Browse the repository at this point in the history
Adjust gc-debug for new task interface
  • Loading branch information
vchuravy authored Oct 9, 2018
2 parents 9616406 + 93cab90 commit 4016019
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
34 changes: 16 additions & 18 deletions src/gc-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,27 +579,25 @@ static void gc_scrub_task(jl_task_t *ta)
int16_t tid = ta->tid;
jl_ptls_t ptls = jl_get_ptls_states();
jl_ptls_t ptls2 = jl_all_tls_states[tid];

char *low;
char *high;
if (ta->copy_stack && ta == ptls2->current_task) {
low = (char*)ptls2->stackbase;
high = (char*)ptls2->stackbase + ptls2->stacksize;
}
else if (ta->stkbuf) {
low = (char*)ta->stkbuf;
high = (char*)ta->stkbuf + ta->bufsz;
}
else
return;

if (ptls == ptls2 && ta == ptls2->current_task) {
// scan up to current `sp` for current thread and task
char *low = (char*)jl_get_frame_addr();
#ifdef COPY_STACKS
gc_scrub_range(low, ptls2->stack_hi);
#else
gc_scrub_range(low, (char*)ta->stkbuf + ta->ssize);
#endif
return;
low = (char*)jl_get_frame_addr();
}
// The task that owns/is running on the threads's stack.
#ifdef COPY_STACKS
jl_task_t *thread_task = ptls2->current_task;
#else
jl_task_t *thread_task = ptls2->root_task;
#endif
void *stkbuf = ta->stkbuf;
if (ta == thread_task && ptls->copy_stack)
gc_scrub_range(ptls2->stackbase, ptls2->stacksize);
else if (stkbuf)
gc_scrub_range((char*)stkbuf, (char*)stkbuf + ta->bufsz);
gc_scrub_range(low, high);
}

void gc_scrub(void)
Expand Down
2 changes: 0 additions & 2 deletions src/julia_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,9 @@ struct _jl_tls_states_t {
volatile sig_atomic_t defer_signal;
struct _jl_task_t *volatile current_task;
struct _jl_task_t *root_task;
//#ifdef COPY_STACKS
void *stackbase;
size_t stacksize;
jl_ucontext_t base_ctx; // base context of stack
//#endif
jl_jmp_buf *safe_restore;
int16_t tid;
size_t bt_size;
Expand Down
2 changes: 2 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
// select whether to enable the COPY_STACKS stack switching optimization
#define COPY_STACKS

// If you disbable COPY_STACKS the task-system is not as memory efficient so
// you probably want to choose a smaller default stack size (factor of 8-10)
#define JL_STACK_SIZE (8*1024*1024)

// threading options ----------------------------------------------------------
Expand Down

0 comments on commit 4016019

Please sign in to comment.