Summary
-------
Add new 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](https://developer.arm.com/documentation/ddi0596/2021-06/Base-Instructions/YIELD--YIELD-). 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 VM options to control which instruction and how many to use for `Thread.onSpinWait` intrinsic code on AArch64.
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`: use `nop` instruction for spin pauses.
- `isb`: use `isb` instruction for spin pauses.
- `yield`: use `yield` 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",
"Use instructions to implement java.lang.Thread.onSpinWait()."
"Options: none, nop, isb, yield.")
product(uint, OnSpinWaitInstCount, 1,
"Use a number of OnSpinWaitInst.")
range(1, 99)
```
See: https://github.com/openjdk/jdk/pull/5562/