RFR: 8358957: [ubsan]: The assert in layout_helper_boolean_diffbit() in klass.hpp needs UB to fail [v4]
Dean Long
dlong at openjdk.org
Tue Nov 4 23:50:40 UTC 2025
On Mon, 3 Nov 2025 09:29:28 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
>> Avoid using loop and UB in left-shift operation as suggested by Kim's comment in the JBS-issue.
>>
>> Tests:
>> mach5 tiers 1-5 {macosx-aarch64, linux-x64, windows-x64} x {debug, product}
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>
> comments and post-cond
src/hotspot/share/oops/klass.hpp line 525:
> 523: // So use alternate form of negation to avoid warning.
> 524: uint result = candidates & (~candidates + 1);
> 525: assert(((result - 1) & result) == 0, "post-condition");
Maybe use "must be power of 2" instead of "post-condition". Also, this value is never going to change. Can we make the function `constexpr`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27288#discussion_r2492344606
More information about the hotspot-dev
mailing list