harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Egor Pasko <egor.pa...@gmail.com>
Subject Re: [jira] Updated: (HARMONY-2092) [drlvm][jit] Harmony works with volatile variables incorrectly
Date Wed, 30 May 2007 20:52:00 GMT
On the 0x2E6 day of Apache Harmony Xiao-Feng Li wrote:
> On 5/30/07, George Timoshenko <george.timoshenko@gmail.com> wrote:
> >
> > > I had a question in the JIRA about this issue: why don't we use "lock"
> > > prefix for the atomic access?
> >
> > well...
> >
> > Originally we split all 64-bit memory access into 2 ones of 32-bit.
> > It does not have sense to set #LOCK prefix for them. (there is a gap
> > between)
> >
> > We can only set #LOCK to some instruction that reads/writes whole 64 bits.
> >
> > The bad thing is the only instruction (according to IA32 spec) we can
> > set #LOCK to is CMPXCHG8B (MOVQ, MOVSD and any others can not be used
> > with #LOCK)
> >
> > This monster (CMPXCHG8B) requires 4 registers:
> >
> > EAX
> > EBX
> > ECX
> > EDX
> >
> > and (FLAGS) also.
> >
> > I am not sure CMPXCHG8B usage will be faster than making volatile fields
> >    always synchronized (artificially)
> 
> George, I believe it should be much faster than synchronized block,
> since it is non-blocking with contended locks. To use compxchg, you
> need a loop to check the return result till it succeeds. With
> synchronized block, the thread will go to sleep till being waken up by
> the releasing thread.

hm, if I am not mistaken most of the time that would be a spin lock
with the current thread manager. So, I cannot not bet which way is
faster. Maybe, some expert in TM can tell for sure?

Anyway, both implementations do not seem to be very hard, we could try
both ways...

-- 
Egor Pasko


Mime
View raw message