RFR: 8318837: javac generates wrong ldc instruction for dynamic constant loads [v2]

Jan Lahoda jlahoda at openjdk.org
Thu Oct 26 12:32:33 UTC 2023


On Thu, 26 Oct 2023 10:14:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This PR fixes how javac loads dynamic variable symbols in `Gen` - currently, either a `ldc` or `ldc_w` is emitted. This is problematic, as, depending on the type of the dynamic constant, in some cases `ldc2_w` might be required (e.g. if the type of the constant is either `long` or `double`).
>> 
>> I've updated the existing compiler condy test to check which `ldc` opcode is emitted for the various constants. I've also verified that the updated test fails w/o the changes in this patch.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address review comments
>   Simplify code

Looks good to me.

I wonder if we should also simplify `Items.ImmediateItem.ldc`, since now `Code.emitLdc` handles the long/double on its own?

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

Marked as reviewed by jlahoda (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16367#pullrequestreview-1699506876


More information about the compiler-dev mailing list