I am trying to understand how c2 compiler in hotspot jvm translate memory barriers for load/store of volatile variables to assembly code.
I understand that for x86 to add StoreLoad barrier, the interpreter will add lock; addl $0,0(%%esp) to the assembly code. So what about c2 compiler? I know c2 operates on Ideal Graph (IR), and adds appropriate barrier nodes before and after load/store nodes (for volatile variables). Do they use lock as in the interpreter mode, or use fence instructions (LFENCE, SFENCE and MFENCE)? Is the code for barriers emitted in compiler mode the same with interpreter mode? Can I refer to some translation rules or manually check them?