views:

50

answers:

1

Java specification allows the compiler and the VM to reorder memory writes in the interest of efficiency. Does the Dalvik VM take concrete advantage of this ?

Disclaimer : I have no intention of relying on order even if Dalvik does not do it (besides the compiler may do it too), but it would be nice to know.

+1  A: 

The Dalvik interpreter does not reorder anything. The JIT compiler might.

Where things really get wacky is on devices with multiple CPUs, because the ARM memory consistency model is pretty weak. In such an environment you could observe out-of-order memory accesses even with just the interpreter.

If the JSR-133 (JMM) docs say you can't rely on something, don't rely on it. :-)

fadden