[PATCH] openjdk/zero: only use FPU opcodes if FPU is available

Andrew Haley aph at redhat.com
Wed Jun 23 08:21:21 PDT 2010


On 06/23/2010 03:51 PM, Sebastian Andrzej Siewior wrote:
> * Andrew Haley | 2010-06-23 13:32:07 [+0100]:
> 
>>> Basically, if you just want to run stuff then it's ok to bypass
>>> that piece of assembler, but if you want to certify the builds
>>> for whatever reason then you will need to figure out some other
>>> way to do a 64-bit atomic copy.
>>
>> Which is pretty easy:
>>
>> static void atomic_copy64(volatile void *src, volatile void *dst) {
>>  pthread_mutex_lock(&the_mutex);
>>  *dst = *src;
>>  pthread_mutex_unlock(&the_mutex);
>> }
>>
>> ... assuming that's the only place volatile doubles are ever touched.
> 
> I though about that. With this you need to grab the same mutex in every
> read section.

Mmm, but it is correct!  :-)

But this is fixable, if you really care about volatile long performance.

Answer below...

Andrew.
























































































pthread_mutex_t mutexes[SIZE];

static void atomic_copy64(volatile void *src, volatile void *dst) {

  uintptr_t a1 = (uintptr_t)src;
  uintptr_t a2 = (uintptr_t)dst;

  a1 %= SIZE;
  a2 %= SIZE;

  if (a1 > a2) {
    // swap a1 and a2;
  }

 retry:
  pthread_mutex_lock(mutexes[a1]);

  if (pthread_mutex_trylock(mutexes[a2]))
    {
      pthread_mutex_unlock(mutexes[a1]);
      goto retry;
    }
  else
    {
      *dst = *src;
    }

  pthread_mutex_unlock(mutexes[a2]);
  pthread_mutex_unlock(mutexes[a1]);
}




More information about the jdk6-dev mailing list