I have a java code which looks like this:
private volatile boolean myWriteActionPending;
void startWrite() {
boolean prev = myWriteActionPending;
myWriteActionPending = true;
try {
// acquire write lock here + do some other stuff
} finally {
myWriteActionPending = prev;
}
}
C1 in java-11.0.14.1 generates following code for myWriteActionPending = true
:
mov eax,0x1
mov BYTE PTR [rsi+0x5a],al
lock add DWORD PTR [rsp-0x40],0x0
And this for myWriteActionPending = prev
:
mov edi,DWORD PTR [rsp+0xf8]
and edi,0x1
mov BYTE PTR [rsi+0x5a],dil
lock add DWORD PTR [rsp-0x40],0x0
C2 generates this for myWriteActionPending = prev
:
mov rbx,QWORD PTR [rsp+0x8]
mov BYTE PTR [rbx+0x5a],r12b
lock add DWORD PTR [rsp-0x40],0x0
Since I use compressed oops r12 contains the HeapBase. What is the meaning of mov BYTE PTR [rbx+0x5a],r12b
? How it restores the field to the original value?