Compatibility Risk Description:A pure addition, and can be ignored by the JVM, so no compatibility risk. `Thread.onSpinWait` is a hint to the JVM without any guarantee that the JVM will use it.
Interface Kind:add/remove/modify command line option
Add new diagnostic VM options
OnSpinWaitInstCount to control the code generated for JVM's
Thread.onSpinWait intrinsic on AArch64.
AArch64 ISA provides the
YIELD instruction. According to the specification the instruction can be used to implement spin pauses including
Thread.onSpinWait intrinsic. However most known hardware implementations of AArch64 ISA treat the instruction as
NOP. As a result no pauses happen.
Experiments with sequences of the
NOP instructions or the
ISB instructions have shown they can be used to implement spin pauses:
The problem is that for some AArch64 microarchitectures
NOPs should be used, for other AArch64 microarchitectures -
ISBs. Also a number of instructions can depend on a microarchitecture. Future microarchitectures may have the proper implementation of the
Add diagnostic VM options to control which instruction and how many to use for
Thread.onSpinWait intrinsic code on AArch64. Performance engineers can use the options to find the best instruction and its count for a AArch64 microarchitecture which can be set as default for that microarchitecture. In rare cases the default can be changed with options but this would be either to disable the functionality or to change instruction count.
VM option to specify an instruction:
inst can be, for AArch64,
none: no implementation for spin pauses. This is the default value.
nopinstruction for spin pauses.
isbinstruction for spin pauses.
yieldinstruction for spin pauses.
VM option to specify a number of instructions:
count specifies a number of
OnSpinWaitInst and can be in
It is an error to use
product(ccstr, OnSpinWaitInst, "none", DIAGNOSTIC, "The instruction to use to implement java.lang.Thread.onSpinWait()." "Options: none, nop, isb, yield.") product(uint, OnSpinWaitInstCount, 1, DIAGNOSTIC, "The number of OnSpinWaitInst instructions to generate." "It cannot be used with OnSpinWaitInst=none.") range(1, 99)