[14] RFR(S): 8234617: C1: Incorrect result of field load due to missing narrowing conversion

Doerr, Martin martin.doerr at sap.com
Mon Dec 2 10:14:23 UTC 2019


+1

Best regards,
Martin

> -----Original Message-----
> From: hotspot-compiler-dev <hotspot-compiler-dev-
> bounces at openjdk.java.net> On Behalf Of Tobias Hartmann
> Sent: Montag, 2. Dezember 2019 06:57
> To: Vladimir Ivanov <vladimir.x.ivanov at oracle.com>; hotspot compiler
> <hotspot-compiler-dev at openjdk.java.net>
> Subject: Re: [14] RFR(S): 8234617: C1: Incorrect result of field load due to
> missing narrowing conversion
> 
> Thanks Vladimir!
> 
> Best regards,
> Tobias
> 
> On 29.11.19 15:19, Vladimir Ivanov wrote:
> >
> >> http://cr.openjdk.java.net/~thartmann/8234617/webrev.00/
> >
> > Looks good.
> >
> > Best regards,
> > Vladimir Ivanov
> >
> >>
> >> Writing an (integer) value to a boolean, byte, char or short field includes
> an implicit narrowing
> >> conversion [1]. With -XX:+EliminateFieldAccess (default), C1 tries to omit
> field loads by caching
> >> and reusing the last written value. The problem is that this value is not
> necessarily converted to
> >> the field type and we end up using an incorrect value.
> >>
> >> For example, for the field store/load in testShort, C1 emits:
> >>    [...]
> >>    0x00007f0fc582bd6c:   mov    %dx,0x12(%rsi)
> >>    0x00007f0fc582bd70:   mov    %rdx,%rax
> >>    [...]
> >>
> >> The field load has been eliminated and the non-converted integer value
> (%rdx) is returned.
> >>
> >> The fix is to emit an explicit conversion to get the correct field value after
> the write:
> >>    [...]
> >>    0x00007ff07982bd6c:   mov    %dx,0x12(%rsi)
> >>    0x00007ff07982bd70:   movswl %dx,%edx
> >>    0x00007ff07982bd73:   mov    %rdx,%rax
> >>    [...]
> >>
> >> Thanks,
> >> Tobias
> >>
> >> [1] https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-
> 6.html#jvms-6.5.putfield
> >>


More information about the hotspot-compiler-dev mailing list