4 ms·
The section with the "ugly" examples demonstrates some unintended consequences of the memory model. In particular it demonstrates a counterexample to the first
by avz 10y ago
The section with the "ugly" examples demonstrates some unintended consequences of the memory model. In particular it demonstrates a counterexample to the first theorem of the original JMM paper [1] which sought to establish that independent statements can be reordered without changing program behavior under the memory model. This got me worried since the theorem provides justification for some of the optimizations actually employed by the JVM.
I dug a bit deeper and found a pending JEP that calls for the update to the JMM to fix these issues: JPE-188 [2]. This links directly to the "Good, Bad and Ugly" paper.
I also found a presentation from one of the authors of "Good, Bad and Ugly" that may make some of this more accessible: [3].
[1] http://rsim.cs.uiuc.edu/Pubs/popl05.pdf http://rsim.cs.uiuc.edu/Pubs/popl05.pdf
[2] http://openjdk.java.net/jeps/188 http://openjdk.java.net/jeps/188
[3] http://pan.vmars.tuwien.ac.at/jtres2009/slides/jmm2.pdf http://pan.vmars.tuwien.ac.at/jtres2009/slides/jmm2.pdf