Skip to content

Commit

Permalink
8329823: RISC-V: Need to sync CPU features with related JVM flags
Browse files Browse the repository at this point in the history
Reviewed-by: fyang, rehn
  • Loading branch information
zifeihan authored and RealFYang committed Apr 9, 2024
1 parent 71c5bbc commit b9331cd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/hotspot/cpu/riscv/vm_version_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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 NO_UPDATE_DEFAULT \
void update_flag() {} \
#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() {} \

// Frozen standard extensions
// I RV64I
Expand Down
11 changes: 9 additions & 2 deletions src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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++;
}
Expand Down

1 comment on commit b9331cd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.