RFR: 8367103: RISC-V: store cpu features in a bitmap [v6]

Ludovic Henry luhenry at openjdk.org
Wed Sep 24 12:17:35 UTC 2025


On Wed, 24 Sep 2025 10:51:50 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch?
>> 
>> Currently, the cpu features of riscv are stored in separate RVFeature subclasses.
>> But to support the store/restore CPU features for aot in the future, we need to store the cpu features in a continuous memory.
>> As the riscv extensions are introduced continuously, I think it's better to do it via an simple bitmap at the beginning.
>> Currently, just suppose the non-extension features will not be stored in aot image, so I also split the extension and non-extenion features. When we implement the related aot feature in the short future, we can revisit the way of splitting the features. Currently, just change the storage way of cpu features, lay the foundation for future aot.
>> 
>> Thanks
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
> 
>   refine

src/hotspot/cpu/riscv/vm_version_riscv.cpp line 39:

> 37: 
> 38: #define DEF_RV_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING, FLAGF)                 \
> 39: VM_Version::NAME##RVExtFeatureValue VM_Version::NAME(#PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING);

Why do you need to pass the parameters to this constructor, when you are also using `RV_EXT_FEATURE_FLAGS` to generate the body of the constructor at https://github.com/openjdk/jdk/pull/27152/files#diff-d8b70800fb68e0478dd0936c7f4a08b1bb59ce7a276ad1140355933c246372caR242-R243.

Can't we simply have the following here:

#define DEF_RV_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING, FLAGF)                 \
VM_Version::NAME##RVExtFeatureValue VM_Version::NAME(
RV_EXT_FEATURE_FLAGS(DEF_RV_EXT_FEATURE)
#undef DEF_RV_EXT_FEATURE


With the constructor defined as:

  #define DECLARE_RV_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING, FLAGF)                   \
  struct NAME##RVExtFeatureValue : public RVExtFeatureValue {                                                  \
    NAME##RVExtFeatureValue() : \
      RVExtFeatureValue(#PRETTY, LINUX_BIT, CPU_FEATURE_INDEX, FSTRING) {}                                  \
    FLAGF;                                                                                                     \
  };                                                                                                           \
  static NAME##RVExtFeatureValue NAME;                                                                         \
  RV_EXT_FEATURE_FLAGS(DECLARE_RV_EXT_FEATURE)

src/hotspot/cpu/riscv/vm_version_riscv.cpp line 44:

> 42: 
> 43: #define DEF_RV_NON_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, FSTRING, FLAGF)                 \
> 44: VM_Version::NAME##RVNonExtFeatureValue VM_Version::NAME(#PRETTY, LINUX_BIT, FSTRING);

Same as https://github.com/openjdk/jdk/pull/27152/files#r2375581724, can't we have the following:

#define DEF_RV_NON_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, FSTRING, FLAGF)                 \
VM_Version::NAME##RVNonExtFeatureValue VM_Version::NAME();
RV_NON_EXT_FEATURE_FLAGS(DEF_RV_NON_EXT_FEATURE)
#undef DEF_RV_NON_EXT_FEATURE


With the constructor defined as:

  #define DECLARE_RV_NON_EXT_FEATURE(NAME, PRETTY, LINUX_BIT, FSTRING, FLAGF)                  \
  struct NAME##RVNonExtFeatureValue : public RVNonExtFeatureValue {                            \
    NAME##RVNonExtFeatureValue() :          \
      RVNonExtFeatureValue(#PRETTY, LINUX_BIT, FSTRING) {}                                  \
    FLAGF;                                                                                     \
  };                                                                                           \
  static NAME##RVNonExtFeatureValue NAME;                                                      \

  RV_NON_EXT_FEATURE_FLAGS(DECLARE_RV_NON_EXT_FEATURE)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27152#discussion_r2375581724
PR Review Comment: https://git.openjdk.org/jdk/pull/27152#discussion_r2375586058


More information about the hotspot-dev mailing list