RFR: 8344026: Ubsan: prevent potential integer overflow in c1_LIRGenerator_<arch>.cpp file [v8]

Emanuel Peter epeter at openjdk.org
Wed Dec 4 08:34:44 UTC 2024


On Mon, 25 Nov 2024 13:44:03 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

>> This PR converts datatype from `jint` to `juint` for contstant `c` check in c1_LIRGenerator_<arch>.cpp. Please look JBS for more info.
>
> Amit Kumar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   unsigned int -> juint

src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp line 281:

> 279: bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
> 280:   juint u_value = (juint)c;
> 281:   if (is_power_of_2(u_value - 1)) {

What happens if this underflows? Is this not undefined behaviour? Could we use `java_add`?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22144#discussion_r1868951272


More information about the hotspot-compiler-dev mailing list