RFR: 8311847: Fix -Wconversion for assembler.hpp emit_int8,16 callers

Dean Long dlong at openjdk.org
Tue Jul 11 02:14:15 UTC 2023


On Tue, 11 Jul 2023 01:26:44 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> Please review changes to fix -Wconversion warnings that come from assembler_<cpu>.cpp by adding narrow_casts to the emit_int8,16,24, and 32 functions.  And some other fixups with checked_cast.
> 
> Ran tier1 on Oracle platforms, and tier1-4 on linux-x64-debug, linux-aarch64-debug, windows-x64-debug.

src/hotspot/cpu/aarch64/assembler_aarch64.hpp line 224:

> 222:     unsigned target = *(unsigned *)a;
> 223:     target &= ~mask;
> 224:     target |= checked_cast<unsigned>(val);

Any value that doesn't fit in 32 bits is going to fail, so it's tempting to force the callers to pass 32-bit types, but that's a bigger change.  How about something like this:

static ALWAYSINLINE void patch(address a, int msb, int lsb, uint32_t val) {
/* original code, no additional checked_cast needed */
}

static ALWAYSINLINE void patch(address a, int msb, int lsb, uint64_t val) {
  patch(a, msb, lsb, checked_cast<unsigned>(val));
}

src/hotspot/cpu/aarch64/assembler_aarch64.hpp line 239:

> 237:     unsigned target = *(unsigned *)a;
> 238:     target &= ~mask;
> 239:     target |= checked_cast<unsigned>(uval);

Same suggestion as patch() above.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14822#discussion_r1259094106
PR Review Comment: https://git.openjdk.org/jdk/pull/14822#discussion_r1259094782


More information about the hotspot-compiler-dev mailing list