RFR: 8272160: Avoid using 32-bit counters in CDS code [v2]
Matias Saavedra Silva
matsaave at openjdk.org
Wed Nov 5 19:33:02 UTC 2025
On Tue, 4 Nov 2025 20:18:47 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
> You only changed `CountSharedSymbols::_count`. Please, adjust RFE's title accordingly.
>
> I am not actually convinced why it is necessary. Can you explain why? What benefits you get with this change.
It's preferable to use size_t for counters so we can avoid having negative counts or overflows. I didn't notice any bugs aside from the one listed in the description but I think it is a good defense in depth strategy to use size_t when possible. The number of oops can potentially be very large so any fields that count oops should be size_t. Other areas in the VM use size_t to could classes as well even though it is unlikely to have more than 2 billion classes.
Additionally, some fields track size should also be size_t as these are values that cannot be negative and could possibly be quite large.
I found more instances of int to change to size_t and added them to this PR.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28139#issuecomment-3492953494
More information about the hotspot-runtime-dev
mailing list