Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hotspot/cpu/aarch64/assembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ class Assembler : public AbstractAssembler {
system(0b00, 0b011, 0b00011, SY, 0b110);
}

void sb() {
system(0b00, 0b011, 0b00011, 0b0000, 0b111);
}

void sys(int op1, int CRn, int CRm, int op2,
Register rt = as_Register(0b11111)) {
system(0b01, op1, CRn, CRm, op2, rt);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/globals_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
product(ccstr, OnSpinWaitInst, "yield", DIAGNOSTIC, \
"The instruction to use to implement " \
"java.lang.Thread.onSpinWait()." \
"Options: none, nop, isb, yield.") \
"Options: none, nop, isb, yield, sb.") \
product(uint, OnSpinWaitInstCount, 1, DIAGNOSTIC, \
"The number of OnSpinWaitInst instructions to generate." \
"It cannot be used with OnSpinWaitInst=none.") \
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6814,6 +6814,9 @@ void MacroAssembler::spin_wait() {
case SpinWait::YIELD:
yield();
break;
case SpinWait::SB:
sb();
break;
default:
ShouldNotReachHere();
}
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/cpu/aarch64/spin_wait_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class SpinWait {
NONE = -1,
NOP,
ISB,
YIELD
YIELD,
SB
};

private:
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ static SpinWait get_spin_wait_desc() {
return SpinWait(SpinWait::ISB, OnSpinWaitInstCount);
} else if (strcmp(OnSpinWaitInst, "yield") == 0) {
return SpinWait(SpinWait::YIELD, OnSpinWaitInstCount);
} else if (strcmp(OnSpinWaitInst, "sb") == 0) {
if (!VM_Version::supports_sb()) {
vm_exit_during_initialization("OnSpinWaitInst is SB but current CPU does not support SB instruction");
}
return SpinWait(SpinWait::SB, OnSpinWaitInstCount);
} else if (strcmp(OnSpinWaitInst, "none") != 0) {
vm_exit_during_initialization("The options for OnSpinWaitInst are nop, isb, yield, and none", OnSpinWaitInst);
vm_exit_during_initialization("The options for OnSpinWaitInst are nop, isb, yield, sb, and none", OnSpinWaitInst);
}

if (!FLAG_IS_DEFAULT(OnSpinWaitInstCount) && OnSpinWaitInstCount > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ enum Ampere_CPU_Model {
decl(SHA3, sha3, 17) \
decl(SHA512, sha512, 21) \
decl(SVE, sve, 22) \
decl(SB, sb, 29) \
decl(PACA, paca, 30) \
/* flags above must follow Linux HWCAP */ \
decl(SVEBITPERM, svebitperm, 27) \
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/os_cpu/bsd_aarch64/vm_version_bsd_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ void VM_Version::get_os_cpu_info() {
cpu_has("hw.optional.armv8_2_sha3")) {
_features |= CPU_SHA3;
}
if (cpu_has("hw.optional.arm.FEAT_SB")) {
_features |= CPU_SB;
}

int cache_line_size;
int hw_conf_cache_line[] = { CTL_HW, HW_CACHELINE };
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/os_cpu/linux_aarch64/vm_version_linux_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
#define HWCAP_SVE (1 << 22)
#endif

#ifndef HWCAP_SB
#define HWCAP_SB (1 << 29)
#endif

#ifndef HWCAP_PACA
#define HWCAP_PACA (1 << 30)
#endif
Expand Down Expand Up @@ -143,6 +147,7 @@ void VM_Version::get_os_cpu_info() {
HWCAP_SHA3 |
HWCAP_SHA512 |
HWCAP_SVE |
HWCAP_SB |
HWCAP_PACA |
HWCAP_FPHP |
HWCAP_ASIMDHP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public enum CPUFeature implements CPUFeatureName {
SHA3,
SHA512,
SVE,
SB,
PACA,
SVEBITPERM,
SVE2,
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/gtest/aarch64/aarch64-asmtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ def generate(kind, names):
generate (Op, ["nop", "yield", "wfe", "sev", "sevl",
"autia1716", "autiasp", "autiaz", "autib1716", "autibsp", "autibz",
"pacia1716", "paciasp", "paciaz", "pacib1716", "pacibsp", "pacibz",
"eret", "drps", "isb",])
"eret", "drps", "isb", "sb",])

# Ensure the "i" is not stripped off the end of the instruction
generate (PostfixExceptionOp, ["wfi", "xpaclri"])
Expand Down
583 changes: 292 additions & 291 deletions test/hotspot/gtest/aarch64/asmtest.out.h

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c2 nop 7
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c2 isb 3
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c2 yield 1
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c2 sb 1
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c1 nop 7
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c1 isb 3
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c1 yield
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c1 yield 1
* @run driver compiler.onSpinWait.TestOnSpinWaitAArch64 c1 sb 1
*/

package compiler.onSpinWait;
Expand All @@ -50,13 +52,12 @@ public class TestOnSpinWaitAArch64 {
public static void main(String[] args) throws Exception {
String compiler = args[0];
String spinWaitInst = args[1];
String spinWaitInstCount = (args.length == 3) ? args[2] : "1";
String spinWaitInstCount = args[2];
ArrayList<String> command = new ArrayList<String>();
command.add("-XX:+IgnoreUnrecognizedVMOptions");
command.add("-showversion");
command.add("-XX:-BackgroundCompilation");
command.add("-XX:+UnlockDiagnosticVMOptions");
command.add("-XX:+PrintAssembly");
if (compiler.equals("c2")) {
command.add("-XX:-TieredCompilation");
} else if (compiler.equals("c1")) {
Expand All @@ -69,12 +70,18 @@ public static void main(String[] args) throws Exception {
command.add("-XX:OnSpinWaitInst=" + spinWaitInst);
command.add("-XX:OnSpinWaitInstCount=" + spinWaitInstCount);
command.add("-XX:CompileCommand=compileonly," + Launcher.class.getName() + "::" + "test");
command.add("-XX:CompileCommand=print," + Launcher.class.getName() + "::" + "test");
command.add(Launcher.class.getName());

ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(command);

OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());

if ("sb".equals(spinWaitInst) && analyzer.contains("CPU does not support SB")) {
System.out.println("Skipping the test. The current CPU does not support SB instruction.");
return;
}

analyzer.shouldHaveExitValue(0);

System.out.println(analyzer.getOutput());
Expand All @@ -89,6 +96,8 @@ private static String getSpinWaitInstHex(String spinWaitInst) {
return "df3f 03d5";
} else if ("yield".equals(spinWaitInst)) {
return "3f20 03d5";
} else if ("sb".equals(spinWaitInst)) {
return "ff30 03d5";
} else {
throw new RuntimeException("Unknown spin wait instruction: " + spinWaitInst);
}
Expand Down