RFR: 8305056: Avoid unaligned access in emit_intX methods if not enabled [v4]

Andrew Haley aph at openjdk.org
Tue Apr 18 09:41:46 UTC 2023


On Mon, 17 Apr 2023 14:19:36 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:

>> Please review this change which attempts to eliminate unaligned memory stores generated by emit_int16/32/64 methods on some platforms.
>> 
>> Primary aim is risc-v platform. But I had to change some code in ppc/arm32/x86 to prevent possible perf degradation.
>
> Vladimir Kempik has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rework the fix to use memcpy in codeBuffer.hpp

src/hotspot/share/asm/codeBuffer.hpp line 42:

> 40:     assert(p != nullptr, "null pointer");
> 41: 
> 42:     memcpy((void*)p, &x, sizeof(T));

Suggestion:

    memcpy((void*)p, &x, sizeof x);

src/hotspot/share/asm/codeBuffer.hpp line 228:

> 226:   }
> 227: 
> 228:   void emit_int16(uint16_t x) { put_native(end(), x); set_end(end() + sizeof(uint16_t)); }

Suggestion:

  void emit_int16(uint16_t x) { put_native(end(), x); set_end(end() + sizeof x; }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13227#discussion_r1169763187
PR Review Comment: https://git.openjdk.org/jdk/pull/13227#discussion_r1169761777


More information about the hotspot-compiler-dev mailing list