diff --git a/src/julia.h b/src/julia.h index 8d6368efdeb52..00f2146ed2e09 100644 --- a/src/julia.h +++ b/src/julia.h @@ -992,11 +992,12 @@ DLLEXPORT void jl_handle_stack_switch(); #ifdef COPY_STACKS // initialize base context of root task +extern jl_jmp_buf jl_base_ctx; #define JL_SET_STACK_BASE \ { \ int __stk; \ jl_root_task->stackbase = (char*)&__stk; \ - if (jl_setjmp(jl_root_task->base_ctx, 1)) { \ + if (jl_setjmp(jl_base_ctx, 1)) { \ jl_handle_stack_switch(); \ } \ } @@ -1145,7 +1146,6 @@ typedef struct _jl_task_t { void *stackbase; void *stack; }; - jl_jmp_buf base_ctx; size_t bufsz; void *stkbuf; size_t ssize; diff --git a/src/task.c b/src/task.c index 3fa0e52fdc878..6804376c75e25 100644 --- a/src/task.c +++ b/src/task.c @@ -30,6 +30,8 @@ volatile int jl_in_stackwalk = 0; #include // for dladdr #endif +jl_jmp_buf jl_base_ctx; + /* This probing code is derived from Douglas Jones' user thread library */ /* true if stack grows up, false if down */ @@ -211,11 +213,6 @@ static void switch_stack(jl_task_t *t, jl_jmp_buf *where) restore_stack(t, where, NULL); } } - -void jl_switch_stack(jl_task_t *t, jl_jmp_buf *where) -{ - switch_stack(t, where); -} #endif static void ctx_switch(jl_task_t *t, jl_jmp_buf *where) @@ -262,7 +259,7 @@ static void ctx_switch(jl_task_t *t, jl_jmp_buf *where) #ifdef COPY_STACKS jl_jmp_target = where; - jl_longjmp(lastt->base_ctx, 1); + jl_longjmp(jl_base_ctx, 1); #else jl_longjmp(*where, 1); #endif @@ -418,10 +415,6 @@ static void start_task(jl_task_t *t) local_sp += sizeof(jl_gcframe_t); local_sp += 12*sizeof(void*); t->stackbase = (void*)(local_sp + _frame_offset); - if (jl_setjmp(t->base_ctx, 0)) { - // we get here to remove our data from the process stack - switch_stack(jl_current_task, jl_jmp_target); - } #endif res = jl_apply(t->start, NULL, 0); JL_GC_POP(); @@ -431,7 +424,7 @@ static void start_task(jl_task_t *t) DLLEXPORT void jl_handle_stack_switch() { - jl_switch_stack(jl_current_task, jl_jmp_target); + switch_stack(jl_current_task, jl_jmp_target); } #ifndef COPY_STACKS