diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index b12080c3ad2..d26b16941db 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -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 diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 5c72b64b629..f74ed8c8f81 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -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++; }