0.9.6.42:
[sbcl.git] / src / runtime / x86-64-assem.S
index cf5b970..c654861 100644 (file)
@@ -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
 \f
        .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)
 \f
@@ -327,12 +334,12 @@ GNAME(post_signal_tramp):
        popq %r8
        popq %rdi
        popq %rsi
-       addq $8, %rsp
-       popq %rsp
-       popq %rdx
+        /* skip RBP and RSP */
        popq %rbx
+       popq %rdx
        popq %rcx
        popq %rax
+        popfq
        leave
        ret
        .size GNAME(post_signal_tramp),.-GNAME(post_signal_tramp)