RFR: 8367253: RISC-V: refactor dependent cpu extensions [v4]

Ludovic Henry luhenry at openjdk.org
Thu Sep 25 17:20:12 UTC 2025


On Thu, 25 Sep 2025 13:03:19 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch?
>> 
>> Dependent extensions could be improved in several ways.
>> 
>> Currently, the dependent cpu extensions are processed in 2 separate places:
>> 1. update_flag() when calling VM_Version::setup_cpu_available_features()
>> 2. at the end of VM_Version::common_initialize().
>> 
>> And, dependency relationship can only be expressed in (1:1) way, can not be expressed (1:N) way, but in fact some extensions can depend on several different other extensions, for example, zvfh depends on zvf and rvv. It's would be better to support this (1:N) relationship.
>> 
>> So, this PR brings several benefits:
>> 1. VM options directly related to CPU extensions are automatically set, and they are all set in one place.
>> 2. keep synchronization between CPU extensions (information in RVFeatureValue) and and VM options. Previously, code in common_initialize wont' sync to RVFeatureValue, unless do it manually, which is error-prone.
>> 3. support to express (1:N) dependency relationship among cpu extensions and related vm options.
>> 
>> Thanks!
>> 
>> 
>> ## Test
>> 
>> 
>> $TEST_JDK/bin/java -XX:+UnlockExperimentalVMOptions -XX:-UseRVV -XX:+PrintFlagsFinal -version | grep -e UseRVV -e UseZvbc -e UseZvfh -e UseZvkn
>> OpenJDK 64-Bit Server VM warning: Cannot enable UseZvbb on cpu without any of the supports: v (disabled)
>> OpenJDK 64-Bit Server VM warning: Cannot enable UseZvbc on cpu without any of the supports: v (disabled)
>> OpenJDK 64-Bit Server VM warning: Cannot enable UseZvfh on cpu without any of the supports: v (disabled), Zfh (enabled)
>>      bool UseRVV                                   = false                             {ARCH diagnostic} {command line}
>>      bool UseZvbc                                  = false                           {ARCH experimental} {default}
>>      bool UseZvfh                                  = false                             {ARCH diagnostic} {default}
>>      bool UseZvkn                                  = false                           {ARCH experimental} {default}
>> 
>> 
>> 
>> $TEST_JDK/bin/java -XX:+UnlockExperimentalVMOptions -XX:-UseZfh -XX:+PrintFlagsFinal -version | grep -e UseRVV -e UseZvbc -e UseZvfh -e UseZvkn
>> OpenJDK 64-Bit Server VM warning: Cannot enable UseZvfh on cpu without any of the supports: v (enabled), Zfh (disabled)
>>      bool UseRVV                                   = true                              {ARCH diagnostic} {default}
>>      bool UseZvbc                                  = true  ...
>
> Hamlin Li has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 13 commits:
> 
>  - merge master
>  - Merge branch 'openjdk:master' into master
>  - Merge branch 'openjdk:master' into master
>  - Merge branch 'openjdk:master' into master
>  - Merge branch 'openjdk:master' into master
>  - Merge branch 'openjdk:master' into master
>  - Merge branch 'master' into refactor-dependent-cpu-extensions
>  - Merge branch 'openjdk:master' into master
>  - initial commit
>  - add includes
>  - ... and 3 more: https://git.openjdk.org/jdk/compare/d1ea6ea2...20598b77

Changes requested by luhenry (Committer).

src/hotspot/cpu/riscv/vm_version_riscv.hpp line 141:

> 139:           stringStream ss;                                                                                  \
> 140:           deps_string(ss, dep0, ##__VA_ARGS__);                                                             \
> 141:           warning("Cannot enable " #flag " on cpu without any of the supports: %s", ss.as_string(true));    \

Suggestion:

          warning("Cannot enable " #flag ", it's missing dependent extension(s) %s", ss.as_string(true));    \

-------------

PR Review: https://git.openjdk.org/jdk/pull/27171#pullrequestreview-3268751253
PR Review Comment: https://git.openjdk.org/jdk/pull/27171#discussion_r2379820859


More information about the hotspot-dev mailing list