Why is the JIT not allowed to do this? (Assuming publishing isn't volatile)
The reordering could also be caused by the CPU, not only by the JIT.
If the JIT isn't allowed to reorder, we also need to prevent the CPU from reordering.
Otherwise it doesn't make sense to restrict the JIT from reordering if the CPU could still reorder later.
We would need to emit memory barriers for non-volatile loads & stores to prevent reordering on architectures like ARM.
This sounds quite expensive.
This doesn't make sense to me. Am I thinking wrong? Can you point me to documentation/reference that states that the JIT isn't allowed to do this?