[m-dev.] diff: Runtime support for stack layouts, round 2

Tyson Dowd trd at cs.mu.oz.au
Wed Nov 26 18:27:20 AEDT 1997


On 26-Nov-1997, Fergus Henderson <fjh at cs.mu.oz.au> wrote:
> On Wed, Nov 26, 1997 at 05:06:05PM +1100, Tyson Dowd wrote:
> > runtime/mercury_calls.h:
> > 	Instead of doing ASM_FIXUP_REGS as part of the call macro, do
> > 	it as part of the proceed macro.
> 
> I don't think this change is correct.
> For example, consider the code for ASM_FIXUP_REGS on the Alpha:
> 
>   /*
>   ** on entry to a procedure, we need to load the $gp register
>   ** with the correct value relative to the current address in $27
>   */
>   #define INLINE_ASM_FIXUP_REGS				\
>   	"	ldgp $gp, 0($27)\n" : : : "memory"
> 
> Here the Alpha ASM_FIXUP_REGS sets the gp register based on the contents of
> the procedure call ($27) register.  If you make ASM_FIXUP_REGS precede
> the call, then it will set the gp register based on the _previous_
> value in register $27, which may be the address of the wrong procedure. 
> Furthermore, I think the `ldgp' assembler pseudo-instruction assumes that
> $27 holds the address of the current instruction, and your change violates
> that assumption.

Well, now that I think about it, because all the labels are treated as
entry labels, they do their own FIXUP anyway, so this
INLINE_ASM_FIXUP_REGS is not necesary as part of the proceed() macro for
.agc grades. So I should make it conditional.

If I'm wrong, it's a real problem that succip points to some code in the
caller, rather than the next continuation.  The way we presently
handle calls makes it very difficult to find the continuation address
from the succip.

Other solutions:
	- Couldn't we set $gp using succip instead of ($27)?
	  Don't we just set it as part of ASM_JUMP anyway?
	  So instead of jump, return, fixup relative to here, jump, 
	  it would be jump, fixup relative to return, return

	  (I assume we would have to do similar things to get 
	  it working with PIC).

> Note that tools/bootcheck does not test linking with shared libraries.
> To test that, you need to do `make install' into some temporary install
> directory, and then do `tests/runtests'.

I thought the Alpha code was needed to use asm labels whether static
or shared, (but the Sparc and i386 FIXUP code was necessary only for
PIC with asm labels).

-- 
       Tyson Dowd           # 
                            #         Linux versus Windows is a 
     trd at cs.mu.oz.au        #            Win lose situation.
http://www.cs.mu.oz.au/~trd #



More information about the developers mailing list