RFR: 8368595: [leyden] Enhance CPU features check

Hamlin Li mli at openjdk.org
Thu Sep 25 08:57:21 UTC 2025


On Wed, 24 Sep 2025 20:34:53 GMT, Ashutosh Mehra <asmehra at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch?
>> 
>> Current implementation of CPU features check compare the whole buffer of cpu features. This could introduce a potential issue when CPU features accumulate.
>> 
>> Consider this example.
>> If at JDK version X there are 5 CPU features, they are a(0), b(1), c(2), d(3), e(4), the number inside () is the feature index assigned (it could be explicitly or implicitly, depends on the implementation of VM_Version). In the future at JDK version Y there could be another feature f added, but f could be added at the middle of features list (reason could be to group some features together or order all cpu features in alphabetical way, so now it looks like a(0), b(1), c(2), f(3), d(4), e(5).
>> So, cpu features buffer of the version X in an archive could be 111110000..., which means all 5 features (a/b/c/d/e) are supported, and this archive could be used by a runtime of version Y, and the local CPU supports a/b/c/f/d, but not e, in this situation, the cpu features are also 111110000..., which means buffer comparison result is equal, but indeed they are not equal.
>> 
>> The solution could be to just introduce an cpu_feature_number, before comparing the buffer, compare if the number is equal, if not just fail the cpu feature comparison.
>> This solution is based on the assumption that we only add but not remove CPU features.
>> 
>> Thanks!
>
> @Hamlin-Li while I don't disagree with adding a check for cpu features number as such, I think the scenario you mentioned is not a problem because AOTCache is tightly coupled to the JDK version. So an AOTCache built with a JDK version X that supports 5 features cannot be used with a JDK version Y with support for 6 features.

Ah, I see, I thought there could be such an restriction, but I did not check further. Thanks for confirmation! @ashu-mehra 

Then I'll close this PR later if it's not that useful.

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

PR Comment: https://git.openjdk.org/leyden/pull/100#issuecomment-3332953001


More information about the leyden-dev mailing list