RFR: 8281213: Unsafe uses of long and size_t in MemReporterBase::diff_in_current_scale [v2]

Evgeny Astigeevich eastigeevich at openjdk.org
Fri Dec 16 13:33:54 UTC 2022


On Thu, 15 Dec 2022 19:50:36 GMT, Afshin Zafari <duke at openjdk.org> wrote:

> Thank you for your help. I liked the references you sent me, and I learned a lot.
> Can you also help me in replacing SSIZE_MAX with something portable to windows? I got errors on windows-x64-*debug builds on mach5.

IMHO, we can use `INT64_MAX`. When `sizeof(int64_t) == sizeof(size_t)` this `SSIZE_MAX <= INT64_MAX` should be true. So we can rewrite the assert into:

assert(sizeof(size_t) < sizeof(int64_t)
            || (sizeof(size_t) == sizeof(int64_t) && amount <= INT64_MAX),
            "cannot fit scaled diff into int64_t");

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

PR: https://git.openjdk.org/jdk/pull/11514


More information about the hotspot-runtime-dev mailing list