PPC & GC [Was: Re: [gclist] Re: gclist-digest V2 #110]

Hans Boehm boehm@hoh.mti.sgi.com
Mon, 26 Jan 1998 10:17:19 -0800


On Jan 22,  3:49pm, Eugene Kuznetsov wrote:
> Subject: PPC & GC [Was: Re: [gclist] Re: gclist-digest V2 #110]
>
> >you should see something like (using the PPC mnemonics)
> >
> >  addis r3,r3,1       // adds 1 << 16 = 65536 to r3
> >  lwz   r3,-25536(r3) // r3+65536-25536=40000
>
> Ah, that is a good one!  This could definitely be very unpleasant with
> preemptive multitasking, since (unlike array iterators and other
optimizations)
> for that brief moment there is no pointer to anywhere in the object/struct.
>
> I think that if one has control over the code-generation, however, this
> problem can be avoided without any additional overhead:
>
>    addi  r3, r3, 32000    // adds 32000 to r3
>    lwz   r3, 8000(r3)     // 32000+8000 = 40000
>
> (For larger structures, one could resume the use of 'addis', since it
> would no longer produce an intermediary pointer pointing to the
> _outside_ of the object).
>
In most cases this is much cleverer than necessary.  The problem arises because
of the reuse of r3 by the addis instruction.  If you have a spare caller-save
register, you can just put the intermediate result there and use the same
instruction sequence as at the beginning with a different intermediate
register. I suspect there are very few places in pointer-intensive PPC code
where you can't come up with a caller-save register.  (I don't remember the PPC
calling convention.  Please correct me if I'm wrong.)

Hans


-- 
Hans-Juergen Boehm
boehm@mti.sgi.com