News for hackers. Stuff that matters.
Re:Java Memory Model Pragmatics by pron on Saturday July 12, 2014 @09:16AM (#8024453)
You are free to rely on the guarantees made by a particular hardware architecture. The JVM implementation doesn't "take them away" -- the spec merely doesn't guarantee them. But if you do, then you might lose portability.
Re:Java Memory Model Pragmatics by zmmmmm on Saturday July 12, 2014 @06:58PM (#8026037)
My impression is that by not guaranteeing them it does take them away, because the implementation is free to implement them in any way they choose including in the compiler. So it will not matter if your code is executing on a processor that does not reorder instructions, Javac may already have done it to the byte code.
Re:Java Memory Model Pragmatics by pron on Monday July 14, 2014 @04:19PM (#8032970)
Even a C compiler is allowed to reorder instructions. How is any compiler supposed to know if you prefer performance (and therefore reordering) or to to rely on a processor-specific feature? That's why any language that runs on more than one architecture needs to define a language-level memory model.