[pr/110] RFR: 8317812: [Lilliput] Make C2 LoadNKlassCompactHeader more robust

Aleksey Shipilev shade at openjdk.org
Tue Oct 10 20:31:59 UTC 2023


On Tue, 10 Oct 2023 16:35:53 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> Lilliput's C2 code for generating LoadNKlass currently assumes that the disp of the incoming address is klass_offset_in_bytes. It then extracts the base register and loads from the mark_offset_in_bytes instead.
> Sometimes (apparently very rarely) it happens that C2 emits code that pre-adds obj+klass_offset into a register, and uses that as base, but with offset 0. In this case we would trip the assert or crash in release builds.
> 
> - [x] specjvm derby (which triggered the bug)
> - [x] tier1 x86_64 +UCOH
> - [x] tier1 aarch64 +UCOH

src/hotspot/cpu/x86/x86_64.ad line 5336:

> 5334:   format %{ "movl    $dst, $mem\t# compressed klass ptr" %}
> 5335:   ins_encode %{
> 5336:     Register index = $mem$$index != 4 ? $mem$$index$$Register : noreg;

I don't understand what`$mem$$index != 4` is supposed to check. Can't we just pass the whole register to `load_nklass_compact_c2`? Is it already `noreg` when index is not set?

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

PR Review Comment: https://git.openjdk.org/lilliput/pull/111#discussion_r1353194927


More information about the lilliput-dev mailing list