Some support for platforms whose libraries do not maintain a frame pointer
[sbcl.git] / src / runtime / x86-64-assem.S
index 7c91ef0..b85639e 100644 (file)
@@ -156,12 +156,23 @@ GNAME(call_into_lisp_first_time):
  * return values in rax rdx
  * callee saves rbp rbx r12-15 if it uses them
  */
-       
+#ifdef LISP_FEATURE_WIN32
+# define SUPPORT_FOMIT_FRAME_POINTER
+#endif
        .align  align_16byte,0x90
 GNAME(call_into_lisp):
+#ifdef SUPPORT_FOMIT_FRAME_POINTER
+       mov     %rbp,%rax
+#endif
        push    %rbp            # Save old frame pointer.
        mov     %rsp,%rbp       # Establish new frame.
 Lstack:
+#ifdef SUPPORT_FOMIT_FRAME_POINTER
+       /* If called through call_into_lisp_first_time, %r15 becomes invalid
+        * here, but we will not return in that case. */
+       push    %r15
+       mov     %rax,%r15
+#endif
        /* FIXME x86 saves FPU state here */
        push    %rbx    # these regs are callee-saved according to C
        push    %r12    # so must be preserved and restored when 
@@ -176,6 +187,13 @@ Lstack:
        push    %rsi    #
        push    %rdx    #
 #ifdef LISP_FEATURE_SB_THREAD
+# ifdef SUPPORT_FOMIT_FRAME_POINTER
+       mov     (%rbp),%rcx
+       sub     $32,%rsp
+       call    GNAME(carry_frame_pointer)
+       add     $32,%rsp
+       mov     %rax,(%rbp)
+# endif
 #ifdef LISP_FEATURE_GCC_TLS
        movq    %fs:0, %rax
        movq    GNAME(current_thread)@TPOFF(%rax), %r12
@@ -238,7 +256,13 @@ LsingleValue:
 /* FIXME Restore the NPX state. */
 
        mov     %rdx,%rax       # c-val
+#ifdef SUPPORT_FOMIT_FRAME_POINTER
+       mov     %r15,%rbp       # orig rbp
+       pop     %r15            # orig r15
+       add     $8,%rsp         # no need for saved (overridden) rbp
+#else
        leave
+#endif
        ret
        SIZE(GNAME(call_into_lisp))
 \f