8329823: RISC-V: Need to sync CPU features with related JVM flags

Reviewed-by: fyang, rehn
This commit is contained in:
Gui Cao 2024-04-09 10:41:28 +00:00 committed by Fei Yang
parent 71c5bbcec7
commit b9331cd25c
2 changed files with 27 additions and 11 deletions
src/hotspot

@ -61,6 +61,10 @@ class VM_Version : public Abstract_VM_Version {
_enabled = true;
_value = value;
}
void disable_feature() {
_enabled = false;
_value = -1;
}
const char* pretty() { return _pretty; }
uint64_t feature_bit() { return _feature_bit; }
bool feature_string() { return _feature_string; }
@ -69,16 +73,21 @@ class VM_Version : public Abstract_VM_Version {
virtual void update_flag() = 0;
};
#define UPDATE_DEFAULT(flag) \
void update_flag() { \
assert(enabled(), "Must be."); \
if (FLAG_IS_DEFAULT(flag)) { \
FLAG_SET_DEFAULT(flag, true); \
} \
} \
#define UPDATE_DEFAULT(flag) \
void update_flag() { \
assert(enabled(), "Must be."); \
if (FLAG_IS_DEFAULT(flag)) { \
FLAG_SET_DEFAULT(flag, true); \
} else { \
/* Sync CPU features with flags */ \
if (!flag) { \
disable_feature(); \
} \
} \
} \
#define NO_UPDATE_DEFAULT \
void update_flag() {} \
#define NO_UPDATE_DEFAULT \
void update_flag() {} \
// Frozen standard extensions
// I RV64I

@ -115,6 +115,15 @@ void VM_Version::setup_cpu_available_features() {
int i = 0;
while (_feature_list[i] != nullptr) {
if (_feature_list[i]->enabled()) {
// Change flag default
_feature_list[i]->update_flag();
// Feature will be disabled by update_flag() if flag
// is set to false by the user on the command line.
if (!_feature_list[i]->enabled()) {
continue;
}
log_debug(os, cpu)("Enabled RV64 feature \"%s\" (%ld)",
_feature_list[i]->pretty(),
_feature_list[i]->value());
@ -139,8 +148,6 @@ void VM_Version::setup_cpu_available_features() {
if (_feature_list[i]->feature_bit() != 0) {
_features |= _feature_list[i]->feature_bit();
}
// Change flag default
_feature_list[i]->update_flag();
}
i++;
}