Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit bcf0d25

Browse files
zifeihanRealFYang
authored andcommitted
8329823: RISC-V: Need to sync CPU features with related JVM flags
Backport-of: b9331cd25ca88b07ce079405f5e3031cf8c13ea6
1 parent dbaca7a commit bcf0d25

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

src/hotspot/cpu/riscv/vm_version_riscv.hpp

+19-10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class VM_Version : public Abstract_VM_Version {
6161
_enabled = true;
6262
_value = value;
6363
}
64+
void disable_feature() {
65+
_enabled = false;
66+
_value = -1;
67+
}
6468
const char* pretty() { return _pretty; }
6569
uint64_t feature_bit() { return _feature_bit; }
6670
bool feature_string() { return _feature_string; }
@@ -69,16 +73,21 @@ class VM_Version : public Abstract_VM_Version {
6973
virtual void update_flag() = 0;
7074
};
7175

72-
#define UPDATE_DEFAULT(flag) \
73-
void update_flag() { \
74-
assert(enabled(), "Must be."); \
75-
if (FLAG_IS_DEFAULT(flag)) { \
76-
FLAG_SET_DEFAULT(flag, true); \
77-
} \
78-
} \
79-
80-
#define NO_UPDATE_DEFAULT \
81-
void update_flag() {} \
76+
#define UPDATE_DEFAULT(flag) \
77+
void update_flag() { \
78+
assert(enabled(), "Must be."); \
79+
if (FLAG_IS_DEFAULT(flag)) { \
80+
FLAG_SET_DEFAULT(flag, true); \
81+
} else { \
82+
/* Sync CPU features with flags */ \
83+
if (!flag) { \
84+
disable_feature(); \
85+
} \
86+
} \
87+
} \
88+
89+
#define NO_UPDATE_DEFAULT \
90+
void update_flag() {} \
8291

8392
// Frozen standard extensions
8493
// I RV64I

src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ void VM_Version::setup_cpu_available_features() {
115115
int i = 0;
116116
while (_feature_list[i] != nullptr) {
117117
if (_feature_list[i]->enabled()) {
118+
// Change flag default
119+
_feature_list[i]->update_flag();
120+
121+
// Feature will be disabled by update_flag() if flag
122+
// is set to false by the user on the command line.
123+
if (!_feature_list[i]->enabled()) {
124+
continue;
125+
}
126+
118127
log_debug(os, cpu)("Enabled RV64 feature \"%s\" (%ld)",
119128
_feature_list[i]->pretty(),
120129
_feature_list[i]->value());
@@ -139,8 +148,6 @@ void VM_Version::setup_cpu_available_features() {
139148
if (_feature_list[i]->feature_bit() != 0) {
140149
_features |= _feature_list[i]->feature_bit();
141150
}
142-
// Change flag default
143-
_feature_list[i]->update_flag();
144151
}
145152
i++;
146153
}

0 commit comments

Comments
 (0)