Any instructions in jvm atomic?

I remember I read somewhere earlier, but I can’t find the official document now.

- all instructions in jvm are all atoms?

as:

iinc iload aload 

all atoms?

+2
jvm
source share
1 answer

The specified instruction bytecodes ( iinc , iload , aload , etc.) work with values ​​from the operand stack and local variables. These regions are local in the flow (see JVMS 2.5 , 2.6 ), i.e. speaking of atomicity is pointless here. That is, they are NOT implemented using atomic processor instructions such as lock xadd , but no one should care.

Bytecode commands that read or write fields and array elements ( getfield , putfiled , iastore , etc.) are atomic, except for long and double types (see JLS 17.7 ). A 32-bit JVM can implement (in fact, the JSM HotSpot implements) read and write 64-bit fields with two 32-bit loads or storages, unless the field is declared volatile .

0
source share

All Articles