This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: sysdep/*/locks.h


Is it better to just pass the address (as opposed to its contents) as
an "r" input?  That probably costs an additional add instruction, since
gcc can no longer use base+offset addressing.  But I really hate to rely on
programming language constructs whose semantics are defined only by the gcc
back-end source code.

I'm pursuing this, since I'm working on an "atomic operations" package
(see http://www.hpl.hp.com/research/linux/qprof/ , "other included packages")
which I would like to use in the garbage collector instead of the current hacks.
It has the same problem, replicated a few more times.

Hans


> -----Original Message-----
> From: java-patches-owner@gcc.gnu.org
> [mailto:java-patches-owner@gcc.gnu.org]On Behalf Of Andrew Haley
> Sent: Wednesday, January 21, 2004 9:26 AM
> To: Hans Boehm
> Cc: java-patches@gcc.gnu.org
> Subject: Re: sysdep/*/locks.h
> 
> 
> Hans Boehm writes:
>  > Andrew -
>  > This doesn't look right to me.  
> 
> AFAICS gcc is not honouring the in/out memory constraints.
>  
>  > If I understand this correctly, we've lost the constraint that the
>  > input and output versions of *addr must be in the same location.
>  > Gcc could correctly load the input version into one stack location,
>  > and then take the output from another location.
> 
> This is true even in the original code: gcc could copy from the lock
> into a stack slot, pass the address of that slot to the asm, and then
> copy the result back.  But we know gcc doesn't do that.
> 
>  > Since only the output version is mentioned in the instruction, this
>  > would clearly be incorrect.
> 
> This is the same techinique that is used in glibc, so I presume it's
> the right thing to do.  
> 
> I think that breaking this would require a chunk of the compiler to be
> rewritten.
> 
> This is the glibc code, FYI:
> 
> PT_EI long int
> testandset (int *spinlock)
> {
>   long int ret;
> 
>   __asm__ __volatile__(
>        "xchgl %0, %1"
>        : "=r"(ret), "=m"(*spinlock)
>        : "0"(1), "m"(*spinlock)
>        : "memory");
> 
>   return ret;
> }
> 
> Andrew.
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]