> Here is an example.
>
> #*if* *defined*(__sparcv9 
> <http://src.opensolaris.org/source/s?defs=__sparcv9>)
>      79 /*
>      80  * The 64-bit C ABI uses a stack frame that looks like:
>      81  *
>      82  *      |                             |
>      83  *    |-------------------------------|
>      84  *    |  Locals, temps, saved floats  |
>      85  *    |-------------------------------|
>      86  *    |  outgoing parameters past 6   |
>      87  *    |-------------------------------|-\
>      88  *    |  outgoing parameters thru 6   | |
>      89  *    |-------------------------------|  > minimum stack frame
>      90  *    |  16 xwords to save IN and     | |
>      91  *      |  LOCAL register on overflow | |
>      92  *    |-------------------------------|-/-\
>      93  *      |                             |   |
>      94  *      |                             |    > v9 abi bias
>      95  *      |                             |   |
>      96  * %sp->|-------------------------------|---/
>      97  */
>
> [0]> ddi_regs_map_setup::dis
> ddi_regs_map_setup:             save      %sp, -0xe0, %sp
> ddi_regs_map_setup+4:           ldx       [%fp + 0x8af], %l0  >>>>> 0x8af = 
> 0x7ff + 0xb0, access the Locals here.
> ddi_regs_map_setup+8:           clr       %o0
> ddi_regs_map_setup+0xc:         mov       0x1, %l1
> ddi_regs_map_setup+0x10:        call      -0x2400cc     <impl_acc_hdl_alloc>
> ddi_regs_map_setup+0x14:        clr       %o1
> ddi_regs_map_setup+0x18:        call      -0x2400dc     <impl_acc_hdl_get>
> ddi_regs_map_setup+0x1c:        stx       %o0, [%l0]
> ddi_regs_map_setup+0x20:        st        %l1, [%o0]
> ddi_regs_map_setup+0x24:        mov       0x3, %l5
> ddi_regs_map_setup+0x28:        mov       0x2, %l4
> ddi_regs_map_setup+0x2c:        stx       %i0, [%o0 + 0x18]
> ddi_regs_map_setup+0x30:        mov       %o0, %l2
> ddi_regs_map_setup+0x34:        add       %fp, 0x7cf, %o1
> ...
>
> My questions:
>
> 1. when the bias 0x7ff is subtracted from %sp? implicitly by the 'save'?
>
> 2. the bias area can also be used as Locals, temps, then when it is used? and 
> when the explicitly allocated area is used?
>
> Thanks,
> Brian
>
>   
>
Hi,

The bias is only used in 64 bit mode, and it's part of the ABI (which 
Max had said).

The bias is applied to the loads and stores that reference the stack and 
frame pointers, but not the instructions that adjust the stack/frame 
pointer (i.e. you won't see the bias in save or restore instructions).

It's a not a bias area, but it's biasing the frame pointer to give you 
greater reach on one side. SPARC has fixed size instructions, and the 
offsets for the loads & stores are fixed at 13 bits (i.e. an 8K span). 
The stack/frame pointer is used to access the incoming args, local 
variables and outgoing args. If a bias were not used, the amount of 
memory that could be "reached" above or below the pointer would be equal 
(4KB each side). While the space available for incoming and outgoing 
args should be the same, local variables are kept in the stack frame, 
and are only ever accessed by the owning function itself. When we are 
going to pass args to a function, we store them in the callers frame, 
then after the function call happens, then callee accesses them from the 
callers frame.

Because we only ever need to get arguments from the callers frame, we 
don't need to be able to reach very far on that side of the pointer, so 
to give us more space for local variables (which are in our own frame), 
we apply the bias (2KB) to all the loads and stores that access incoming 
args, outgoing args and local variables. This means we're limited to 2KB 
of incoming args, but about 6KB of outgoing args AND local variables.

Make sense?

Cheers,
Greg


Reply via email to