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


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]