Port-sparc64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Stack bias



On Mon, 10 Aug 2009 22:09:38 -0400 (EDT)
der Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:

> > OK, how does bias of 2047 allow to address more stack space, vs.
> > 32-bit mode with no bias?
> 
> It doesn't.  But it lets you address more _useful_ stack space.
> 
> This is an artifact of the addressing modes the hardware provides.
> With zero bias, half the space you can address with the
> literal-constant-offset addressing modes most commonly used to access
> the stack is space which isn't yours because it's below the bottom of
> the stack and thus owned by asynchronous events like signals (or, in
> the kernel, interrupts).  With the bias, that space cannot be
> addressed without using multiple instructions to construct a larger
> offset, but you can address twice as much of the usable stack space.
> 
> It's only a factor of two, but that's enough to be of some use.
> 
> However, I saw something upthread implying that the kernel treated the
> low bit of %sp as a 64-bit flag, meaning that using %o6/%sp as an
> ordinary register is not possible even if you're _not_ using the stack
> (if it happens to hold an even value, halves of other registers can be
> destroyed at unpredictable times).  Perhaps I misunderstood; I
> certainly hope so, because this seems broken to me.

I don't really get it. Below is how I understand a stack frame. Stack
grows down from high addresses to low addresses, so bottom of stack is
pointed by %fp and top is pointed by %sp. So with the BIAS of 2047,
there is an area starting at the top, between %sp and %sp+BIAS of
2046 (2047-1) bytes. What is that area used for?


## High Address ##

---------------------------------------------------------
%fp+BIAS        <-- start of previous stack frame
---------------------------------------------------------
%fp+BIAS-1      1st local variable
---------------------------------------------------------
%fp+BIAS-N      2nd local variable, etc.
---------------------------------------------------------
%sp+BIAS+186    if needed, outgoing arguments 6 to ...
---------------------------------------------------------


%sp+BIAS+138    space for arguments 0 to 5 (6*8=48 bytes)
---------------------------------------------------------
%sp+BIAS+128    struct/union return pointer (8 bytes)
---------------------------------------------------------




                window save area for 16 registers 
%sp+BIAS        (16*8=128 bytes)
---------------------------------------------------------
                |
                2047-1 bytes
%sp             |
---------------------------------------------------------

## Low Address ##


Home | Main Index | Thread Index | Old Index