Fix cut-to-width in the presence of bad constants in dead code.
[sbcl.git] / src / runtime / x86-assem.S
index 22f38f1..fba970b 100644 (file)
  *                           |XXXXXXXX| e4e
  *     TLS ends here>     ,- |XXXXXXXX| e4f = TEB_STATIC_TLS_SLOTS_OFFSET+63
  *                       /   z        z
- *                       |   ----------
- *                       |
- *                       |   big blob of SBCL-specific thread-local data
- *                       |     |----------------------------------------|
+ *                       |   ----------                    "os_address" ----.
+ *                       |                                                   |
+ *                       |   big blob of SBCL-specific thread-local data     |
+ *                       |     |----------------------------------------| <--'
  *                       |     |   CONTROL, BINDING, ALIEN STACK        |
  *                       |     z                                        z
  * ==================    |     |----------------------------------------|
 # define LoadCurrentThreadSlot(offset,reg);     \
        movl    SBCL_THREAD_BASE_EA, reg ;      \
        movl    offset(reg), reg ;
-#elif defined(LISP_FEATURE_LINUX) || defined(LISP_FEATURE_SUNOS)
+#elif defined(LISP_FEATURE_LINUX) || defined(LISP_FEATURE_SUNOS) || defined(LISP_FEATURE_FREEBSD)
   /* see comment in arch_os_thread_init */
 # define SBCL_THREAD_BASE_EA %fs:THREAD_SELFPTR_OFFSET
 # define MAYBE_FS(addr) addr
@@ -424,8 +424,13 @@ Ldone:
 #ifdef LISP_FEATURE_WIN32
        /* Establish an SEH frame. */
 #ifdef LISP_FEATURE_SB_THREAD
-       /* FIXME: need to save BSP here. */
-#error "need to save BSP here, but don't know how yet."
+       /* Save binding stack pointer */
+       subl $4, %esp
+       pushl %eax
+        movl SBCL_THREAD_BASE_EA, %eax
+       movl THREAD_BINDING_STACK_POINTER_OFFSET(%eax), %eax
+       movl %eax, 4(%esp)
+       popl %eax
 #else
        pushl   BINDING_STACK_POINTER + SYMBOL_VALUE_OFFSET
 #endif
@@ -451,6 +456,7 @@ LsingleValue:
 
 #ifdef LISP_FEATURE_WIN32
        /* Remove our SEH frame. */
+       mov     %fs:0,%esp
        popl    %fs:0
        add     $8, %esp
 #endif
@@ -712,10 +718,18 @@ DEFINE_ALLOC_TO_REG(alloc_16_to_edi,%edi,$16)
 #define START_REGION GNAME(boxed_region)
 #endif
 
-#define ALLOC_OVERFLOW(size)                                    \
-        /* Calculate the size for the allocation. */            \
-        subl    START_REGION,size;                              \
-        ALLOC(size)
+#if defined(LISP_FEATURE_SB_THREAD) && defined(LISP_FEATURE_WIN32)
+#define ALLOC_OVERFLOW(size,scratch)                           \
+       movl SBCL_THREAD_BASE_EA, scratch;                      \
+       /* Calculate the size for the allocation. */            \
+       subl THREAD_ALLOC_REGION_OFFSET(scratch),size;          \
+       ALLOC(size)
+#else
+#define ALLOC_OVERFLOW(size,scratch)                   \
+         /* Calculate the size for the allocation. */  \
+         subl    START_REGION,size;                    \
+         ALLOC(size)
+#endif
 
 /* This routine handles an overflow with eax=crfp+size. So the
    size=eax-crfp. */
@@ -725,7 +739,7 @@ DEFINE_ALLOC_TO_REG(alloc_16_to_edi,%edi,$16)
 GNAME(alloc_overflow_eax):
         pushl   %ecx            # Save ecx
         pushl   %edx            # Save edx
-       ALLOC_OVERFLOW(%eax)
+       ALLOC_OVERFLOW(%eax,%edx)
         popl    %edx    # Restore edx.
         popl    %ecx    # Restore ecx.
         ret
@@ -737,7 +751,7 @@ GNAME(alloc_overflow_eax):
 GNAME(alloc_overflow_ecx):
         pushl   %eax            # Save eax
         pushl   %edx            # Save edx
-       ALLOC_OVERFLOW(%ecx)
+       ALLOC_OVERFLOW(%ecx,%edx)
         movl    %eax,%ecx       # setup the destination.
         popl    %edx    # Restore edx.
         popl    %eax    # Restore eax.
@@ -750,7 +764,7 @@ GNAME(alloc_overflow_ecx):
 GNAME(alloc_overflow_edx):
         pushl   %eax            # Save eax
         pushl   %ecx            # Save ecx
-       ALLOC_OVERFLOW(%edx)
+       ALLOC_OVERFLOW(%edx,%ecx)
         movl    %eax,%edx       # setup the destination.
         popl    %ecx    # Restore ecx.
         popl    %eax    # Restore eax.
@@ -766,7 +780,7 @@ GNAME(alloc_overflow_ebx):
         pushl   %eax            # Save eax
         pushl   %ecx            # Save ecx
         pushl   %edx            # Save edx
-       ALLOC_OVERFLOW(%ebx)
+       ALLOC_OVERFLOW(%ebx,%edx)
         movl    %eax,%ebx       # setup the destination.
         popl    %edx    # Restore edx.
         popl    %ecx    # Restore ecx.
@@ -783,7 +797,7 @@ GNAME(alloc_overflow_esi):
         pushl   %eax            # Save eax
         pushl   %ecx            # Save ecx
         pushl   %edx            # Save edx
-       ALLOC_OVERFLOW(%esi)
+       ALLOC_OVERFLOW(%esi,%edx)
         movl    %eax,%esi       # setup the destination.
         popl    %edx    # Restore edx.
         popl    %ecx    # Restore ecx.
@@ -798,7 +812,7 @@ GNAME(alloc_overflow_edi):
         pushl   %eax            # Save eax
         pushl   %ecx            # Save ecx
         pushl   %edx            # Save edx
-       ALLOC_OVERFLOW(%edi)
+       ALLOC_OVERFLOW(%edi,%edx)
         movl    %eax,%edi       # setup the destination.
         popl    %edx    # Restore edx.
         popl    %ecx    # Restore ecx.
@@ -926,12 +940,6 @@ GNAME(fast_bzero_pointer):
          * to fast_bzero_detect if OS supports SSE.  */
         .long GNAME(fast_bzero_base)
 \f
-       .globl GNAME(gc_safepoint_page)
-       .data
-        .align  align_page
-GNAME(gc_safepoint_page):
-        .fill BACKEND_PAGE_BYTES
-\f
        .text
        .align  align_16byte,0x90
        .globl GNAME(fast_bzero)