Ignore:
Timestamp:
Jan 6, 2009, 6:00:06 PM (11 years ago)
Author:
rme
Message:

Additional x8632 FFI details involving structure return and callbacks.

DEFINE-CALLBACK: add hair to recognize when a hidden first argument
will need to be discarded on return. Try to deal with interactions
with the win32 _stdcall case, too. Pass info argument to
DEFINE-CALLBACK-FUNCTION that encodes the arg discard information.

DEFINE-CALLBACK-FUNCTION: pass said info argument to
MAKE-CALLBACK-TRAMPOLINE.

MAKE-CALLBACK-TRAMPOLINE: pack arg discarding information and the
callback index into the value that gets passed to .SPcallback via
the %eax register.

.SPcallback: decode this information, and handle discarding the
appropriate number of args on return.

File:
1 edited

Legend:

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

    r11449 r11590  
    42524252        /* arg word 0 at 8(%ebp), word 1 at 12(%ebp), etc. */
    42534253
     4254        /* %eax is passed to us via the callback trampoline.
     4255           bits 0-22: callback index
     4256           bit 23: flag, set if we need to discard hidden arg on return
     4257                   (ignored when upper 8 bits are non-zero)
     4258           bits 24-31: arg words to discard on return (_stdcall for win32) */
     4259       
    42544260        /* Reserve some space for results, relative to the
    42554261           current %ebp.  We may need quite a bit of it. */
    4256         __(subl $24,%esp)
     4262        __(subl $20,%esp)
    42574263        __(movl $0,-16(%ebp)) /* No FP result */
     4264        __(btl $23,%eax)      /* set CF if we need to discard hidden arg */
     4265        __(pushfl)            /* and save for later */
    42584266        __(movl %eax,%ecx)    /* extract args-discard count */
    42594267        __(shrl $24,%ecx)
    4260         __(andl $0x00ffffff,%eax)
     4268        __(andl $0x007fffff,%eax) /* callback index */
    42614269        __(movl %ecx,-12(%ebp))
    42624270        /* If the C stack is 16-byte aligned by convention,
     
    43284336        __(movl -8(%ebp),%eax)
    43294337        __(movl -4(%ebp),%edx)
    4330         __(leave)
    43314338        __ifdef([WIN_32])
    43324339         __(testl %ecx,%ecx)
    43334340         __(jne local_label(winapi_return))
    4334          __(repret)
    4335         __else
    4336          __(ret)
    4337         __endif
     4341        __endif
     4342        __(popfl)       /* flags from bt way back when */
     4343        __(jc local_label(discard_first_arg))
     4344        __(leave)
     4345        __(ret)
    433843461:      __(jne 2f)
    43394347        /* single float return in x87 */
    43404348        __(flds -8(%ebp))
    4341         __(leave)
    43424349        __ifdef([WIN_32])
    43434350         __(testl %ecx,%ecx)
    43444351         __(jne local_label(winapi_return))
    4345          __(repret)
    4346         __else
    4347          __(ret)
    43484352        __endif
     4353        __(leave)
     4354        __(ret)
    434943552:      /* double-float return in x87 */
    43504356        __(fldl -8(%ebp))
    4351         __(leave)
    43524357        __ifdef([WIN_32])
    43534358         __(testl %ecx,%ecx)
    43544359         __(jne local_label(winapi_return))
    4355          __(repret)
    4356         __else
    4357          __(ret)
    43584360        __endif
     4361        __(leave)
     4362        __(ret)
    43594363        __ifdef([WIN_32])
    4360 local_label(winapi_return):             
     4364local_label(winapi_return):
     4365          __(leave)
    43614366         /* %ecx is non-zero and contains count of arg words to pop */
    43624367          __(popl -4(%esp,%ecx,4))
     
    43644369          __(ret)
    43654370        __endif
     4371local_label(discard_first_arg):
     4372        __(leave)
     4373        __(ret $4)
    43664374_endsubp(callback)
    43674375
Note: See TracChangeset for help on using the changeset viewer.