X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fx86-64-assem.S;h=c654861cd30be40ff01372b9376b363b3c6fa61e;hb=d411bb9c10af8fb568a4a23274090ede67f738dd;hp=47916c24fda73e13958453f6f05a33347563c7c4;hpb=78fa16bf55be44cc16845be84d98023e83fb14bc;p=sbcl.git diff --git a/src/runtime/x86-64-assem.S b/src/runtime/x86-64-assem.S index 47916c2..c654861 100644 --- a/src/runtime/x86-64-assem.S +++ b/src/runtime/x86-64-assem.S @@ -97,7 +97,7 @@ GNAME(call_into_lisp_first_time): mov THREAD_CONTROL_STACK_START_OFFSET(%rax) ,%rsp /* don't think too hard about what happens if we get interrupted * here */ - add $THREAD_CONTROL_STACK_SIZE-8,%rsp + add $THREAD_CONTROL_STACK_SIZE-16,%rsp jmp Lstack .text @@ -117,20 +117,26 @@ GNAME(call_into_lisp): mov %rsp,%rbp # Establish new frame. Lstack: /* FIXME x86 saves FPU state here */ - push %rbx - push %r12 - push %r13 - push %r14 - push %r15 - + push %rbx # these regs are callee-saved according to C + push %r12 # so must be preserved and restored when + push %r13 # the lisp function returns + push %r14 # + push %r15 # mov %rsp,%rbx # remember current stack push %rbx # Save entry stack on (maybe) new stack. - /* Establish Lisp args. */ - mov %rdi,%rax # lexenv? - mov %rsi,%rbx # address of arg vec - mov %rdx,%rcx # num args + push %rdi # args from C + push %rsi # + push %rdx # +#ifdef LISP_FEATURE_SB_THREAD + mov specials,%rdi + call pthread_getspecific + mov %rax,%r12 +#endif + pop %rcx # num args + pop %rbx # arg vector + pop %rax # function ptr/lexenv xor %rdx,%rdx # clear any descriptor registers xor %rdi,%rdi # that we can't be sure we'll @@ -174,8 +180,9 @@ Lcall: pop %rbx /* FIXME Restore the NPX state. */ - pop %rbp # c-sp + /* return value is already in rax where lisp expects it */ + leave ret .size GNAME(call_into_lisp), . - GNAME(call_into_lisp) @@ -203,7 +210,7 @@ GNAME(fpu_restore): * the undefined-function trampoline */ .text - .align align_4byte,0x90 + .align align_8byte,0x90 .global GNAME(undefined_tramp) .type GNAME(undefined_tramp),@function GNAME(undefined_tramp): @@ -217,9 +224,9 @@ GNAME(undefined_tramp): .text - .align align_4byte,0x90 + .align align_8byte,0x90 .global GNAME(alloc_tramp) - .type GNAME(alooc_tramp),@function + .type GNAME(alloc_tramp),@function GNAME(alloc_tramp): push %rbp # Save old frame pointer. mov %rsp,%rbp # Establish new frame. @@ -253,7 +260,7 @@ GNAME(alloc_tramp): * the closure trampoline */ .text - .align align_4byte,0x90 + .align align_8byte,0x90 .global GNAME(closure_tramp) .type GNAME(closure_tramp),@function GNAME(closure_tramp): @@ -272,16 +279,20 @@ GNAME(closure_tramp): */ .text .global GNAME(fun_end_breakpoint_guts) - .align align_4byte + .align align_8byte GNAME(fun_end_breakpoint_guts): /* Multiple Value return */ jmp multiple_value_return + /* the above jmp is only 2 bytes long, we need to add a nop for + * padding since the single value return convention jumps to original + * return address + 3 bytes */ + nop /* Single value return: The eventual return will now use the multiple values return convention but with a return values count of one. */ mov %rsp,%rbx # Setup ebx - the ofp. - sub $4,%rsp # Allocate one stack slot for the return value - mov $4,%rcx # Setup ecx for one return value. + sub $8,%rsp # Allocate one stack slot for the return value + mov $8,%rcx # Setup ecx for one return value. mov $NIL,%rdi # default second value mov $NIL,%rsi # default third value @@ -299,37 +310,38 @@ GNAME(fun_end_breakpoint_end): .global GNAME(do_pending_interrupt) .type GNAME(do_pending_interrupt),@function - .align align_4byte,0x90 + .align align_8byte,0x90 GNAME(do_pending_interrupt): int3 .byte trap_PendingInterrupt ret .size GNAME(do_pending_interrupt),.-GNAME(do_pending_interrupt) -#ifdef LISP_FEATURE_GENCGC -/* This is a fast bzero using the FPU. The first argument is the start - * address which needs to be aligned on an 8 byte boundary, the second - * argument is the number of bytes, which must be a nonzero multiple - * of 8 bytes. */ -/* FIXME whether this is still faster than using the OS's bzero or - * equivalent, we don't know */ - .text - .globl GNAME(i586_bzero) - .type GNAME(i586_bzero),@function - .align align_4byte,0x90 -GNAME(i586_bzero): - mov 4(%rsp),%rdx # Load the start address. - mov 8(%rsp),%rax # Load the number of bytes. - fldz -l1: fstl 0(%rdx) - add $8,%rdx - sub $8,%rax - jnz l1 - fstp %st(0) + .globl GNAME(post_signal_tramp) + .type GNAME(post_signal_tramp),@function + .align align_8byte,0x90 +GNAME(post_signal_tramp): + /* this is notionally the second half of a function whose first half + * doesn't exist. This is where call_into_lisp returns when called + * using return_to_lisp_function */ + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %r11 + popq %r10 + popq %r9 + popq %r8 + popq %rdi + popq %rsi + /* skip RBP and RSP */ + popq %rbx + popq %rdx + popq %rcx + popq %rax + popfq + leave ret - .size GNAME(i586_bzero),.-GNAME(i586_bzero) -#endif + .size GNAME(post_signal_tramp),.-GNAME(post_signal_tramp) - - .end