RFR: 8358957: [ubsan]: The assert in layout_helper_boolean_diffbit() in klass.hpp needs UB to fail [v4]
Afshin Zafari
azafari at openjdk.org
Thu Nov 6 12:09:06 UTC 2025
On Tue, 4 Nov 2025 04:19:13 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> 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 514:
>
>> 512: }
>> 513:
>> 514: // Find the right-most non-zero (e.g., ...1000) bit of the diff of array-of-boolean and array-of-byte layout helpers.
>
> Callers don't care whether it's the rightmost bit, only that it's a single
> bit. (Some callers use log2_exact to get the bit position.) So a more
> pedantically correct description might be something like "Return a value
> containing a single set bit that is in the bitset difference between the
> layout helpers for array-of-boolean and array-of-byte."
Comment of the function is replaced with this one.
> 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");
>
> Use `power_of_2(result)`. For completeness, also consider checking other post-conditions - result is set
> in zlh and clear in blh.
Done.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27288#discussion_r2498695917
PR Review Comment: https://git.openjdk.org/jdk/pull/27288#discussion_r2498696841
More information about the hotspot-dev
mailing list