Changeset 11246


Ignore:
Timestamp:
Oct 30, 2008, 1:09:51 PM (11 years ago)
Author:
gb
Message:

Simplify the code in (and the comments preceding) switch_to_foreign_stack;
we're only called from one place and always get 3 arguments that'll go
on the new stack, and we may need to push a fourth word (or be very
careful not to do so) in some cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/x86-asmutils32.s

    r11114 r11246  
    135135_endfn
    136136
    137 /* switch_to_foreign_stack(new_sp, func, arg_0, arg_1, arg_2, arg_3)  */
     137/* switch_to_foreign_stack(new_sp, func, arg_0, arg_1, arg_2)  */
    138138/*   Not fully general, but should get us off of the signal stack */
    139139/* Beware: on Darwin, GDB can get very confused by this code, and
    140140   doesn't really get unconfused until the target function - the
    141    handler - has built its stack frame */
    142 /* The lone caller of this function actually doesn't pass arg_3.
     141   handler - has built its stack frame
     142   The lone caller of this function passes 3 arguments (besides
     143   the new stack pointer and the handler address.)
    143144   On platforms where the C stack must be 16-byte aligned, pushing
    144    4 words (arg_0-arg_3) helps make it aligned before the return
     145   a 4th word helps make the stack aligned before the return
    145146   address is (re-)pushed.
    146147   On Linux, there are severe constraints on what the top of stack
    147148   can look like when rt_sigreturn (the code at the return address)
    148149   runs, and there aren't any constraints on stack alignment, so
    149    we don't push "arg_3" on the new stack.*/
     150   we don't push the extra word on the new stack.*/
    150151_exportfn(C(switch_to_foreign_stack))
    151152        __(addl $4,%esp)        /* discard return address, on wrong stack */
     
    155156        __(pop %ebx)            /* arg_1 */
    156157        __(pop %ecx)            /* arg_2 */
    157         __ifndef([LINUX])       
    158         __(pop %edx)            /* arg_3 */
    159         __endif
    160158        __(mov %edi,%esp)
    161159        __(pop %edi)            /* Return address pushed by caller */
    162160        __ifndef([LINUX])
    163         __(push %edx)
    164         __endif
    165         __(push %ecx)
    166         __(push %ebx)
    167         __(push %eax)
    168         __(push %edi)           /* On some platforms, we don't really return */
    169         __(jmp *%esi)
     161        __(push $0)             /* For alignment. See comment above */
     162        __endif
     163        __(push %ecx)           /* arg_2 */
     164        __(push %ebx)           /* arg_1 */
     165        __(push %eax)           /* arg_0 */
     166        __(push %edi)           /* return address */
     167        __(jmp *%esi)           /* On some platforms, we don't really return */
    170168_endfn
    171169
Note: See TracChangeset for help on using the changeset viewer.