RFR: JDK-8299688: Adopt C++14 compatible std::bit_cast introduced in C++20 [v2]

Stefan Karlsson stefank at openjdk.org
Mon Jan 9 15:17:54 UTC 2023


On Thu, 5 Jan 2023 19:59:40 GMT, Justin King <jcking at openjdk.org> wrote:

>> Adopts a C++14 compatible implementation of [std::bit_cast](https://en.cppreference.com/w/cpp/numeric/bit_cast).
>> 
>> `PrimitiveConversions::cast` is refactored into `bit_cast` and extended to support all compatible types. Additionally it makes use of `__builtin_bit_cast` when available, which is strictly well defined compared to fallback approaches which are sometimes lurking in undefined behavior territory.
>> 
>> Lastly some legacy casting is updated to use `bit_cast` in `utilities/globalDefinitions.hpp`.
>
> Justin King has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Apple Clang thinks __builtin_bit_cast is present when its not
>   
>   Signed-off-by: Justin King <jcking at google.com>

Leaving this review for Kim ... but saw a few nits that could be fixed in the meantime.

src/hotspot/os_cpu/linux_ppc/atomic_linux_ppc.hpp line 35:

> 33: #include "orderAccess_linux_ppc.hpp"
> 34: #include "utilities/debug.hpp"
> 35: #include "utilities/bitCast.hpp"

Sort includes

src/hotspot/os_cpu/windows_aarch64/atomic_windows_aarch64.hpp line 63:

> 61:     return bit_cast<D>(                                 \
> 62:       IntrinsicName(reinterpret_cast<IntrinsicType volatile *>(dest),     \
> 63:                     bit_cast<IntrinsicType>(add_value))); \

Could you realign the `` characters? The same comment applies to other places in this patch.

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

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


More information about the hotspot-dev mailing list