Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASM_COPY_STACKS for aarch64 #16621

Merged
merged 1 commit into from
May 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extern size_t jl_page_size;
jl_datatype_t *jl_task_type;

#ifdef COPY_STACKS
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_)) && !defined(_COMPILER_MICROSOFT_)
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_) || defined(_CPU_AARCH64_)) && !defined(_COMPILER_MICROSOFT_)
#define ASM_COPY_STACKS
#endif

Expand Down Expand Up @@ -324,6 +324,7 @@ static void ctx_switch(jl_tls_states_t *ptls, jl_task_t *t, jl_jmp_buf *where)
}
else {
#ifdef ASM_COPY_STACKS
// Start the task without `setjmp`
void *stackbase = ptls->stackbase;
#ifdef _CPU_X86_64_
#ifdef _OS_WINDOWS_
Expand All @@ -332,16 +333,23 @@ static void ctx_switch(jl_tls_states_t *ptls, jl_task_t *t, jl_jmp_buf *where)
asm(" movq %0, %%rsp;\n"
" xorq %%rbp, %%rbp;\n"
" push %%rbp;\n" // instead of RSP
" jmp %P1;\n" // call stack_task with fake stack frame
" jmp %P1;\n" // call `start_task` with fake stack frame
" ud2"
: : "r"(stackbase), "i"(&start_task) : "memory" );
#elif defined(_CPU_X86_)
asm(" movl %0, %%esp;\n"
" xorl %%ebp, %%ebp;\n"
" push %%ebp;\n" // instead of ESP
" jmp %P1;\n" // call stack_task with fake stack frame
" jmp %P1;\n" // call `start_task` with fake stack frame
" ud2"
: : "r" (stackbase), ""(&start_task) : "memory" );
#elif defined(_CPU_AARCH64_)
asm(" mov sp, %0;\n"
" mov x29, xzr;\n" // Clear link register (x29) and frame pointer
" mov x30, xzr;\n" // (x30) to terminate unwinder.
" br %1;\n" // call `start_task` with fake stack frame
" brk #0x1" // abort
: : "r" (stackbase), "r"(&start_task) : "memory" );
#else
#error ASM_COPY_STACKS not supported on this cpu architecture
#endif
Expand Down