-
CSR
-
Resolution: Withdrawn
-
P4
-
None
-
behavioral
-
minimal
-
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.
-
add/remove/modify command line option
-
Implementation
Summary
Add new diagnostic VM options OnSpinWaitInst
and OnSpinWaitInstCount
to control the code generated for JVM's Thread.onSpinWait
intrinsic on AArch64.
Problem
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:
- http://mail.openjdk.java.net/pipermail/aarch64-port-dev/2017-August/004870.html
- https://mail.openjdk.java.net/pipermail/hotspot-dev/2021-August/054033.html
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 YIELD
instruction.
Solution
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.
Specification
VM option to specify an instruction: OnSpinWaitInst=inst
, where inst
can be, for AArch64,
none
: no implementation for spin pauses. This is the default value.nop
: usenop
instruction for spin pauses.isb
: useisb
instruction for spin pauses.yield
: useyield
instruction for spin pauses.
VM option to specify a number of instructions: OnSpinWaitInstCount=count
, where count
specifies a number of OnSpinWaitInst
and can be in 1..99
range.
It is an error to use OnSpinWaitInstCount
when OnSpinWaitInst
is none
.
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)
- csr of
-
JDK-8186670 Implement _onSpinWait() intrinsic for AArch64
-
- Resolved
-