JDK-4067775 : Atomic double and long assignment not enforced for volatiles
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: generic
  • Submitted: 1997-07-28
  • Updated: 1997-07-30
  • Resolved: 1997-07-30
Related Reports
Duplicate :  
Description
The JLS section 17.4 describes that doubles and longs may be observed
to be assigned as two 32 bit pieces, except if the variable in question
is volatile.  The VM does not align data items and use single instructions
to make sure that assignments to volatile variables are atomic.  Ideally,
all such assignments could be atomic, not just variables declared
volatile.  Such a VM would pave the way for eventual removal of section
17.4, which is a canker on the language.

Comments
WORK AROUND Use explicit synchronization instead of the volatile keyword.
11-06-2004

EVALUATION This has been confirmed and partially evaluated by never. It looks like you could modify the sparc version of the vm to use atomic operations in the general case without impacting performance at all, though objects will be a bit larger because of alignment. I've actually done it and tested it. I'm pretty convinced though that there's no efficient way to do it on intel though, besides using the spin lock trickery. They don't seem to have a 64-bit atomic transfer instruction except as part of MMX. If someone decides to actually fix this it would probably be best to just do a general spin-lock solution instead of special casing for sparc. Also as dean noted, this is a problem for all versions of the current VM. tom.rodriguez@Eng 1997-07-29
29-07-1997