There are currently some issues with our handling of "load constant" 
instructions: namely, there is some problem with writing unbounded/external 
constants and handling of entry index changes, that we currently generate 
invalid bytecode for condy loading double/long that has index over 255.

This patch propose the following solution:
1. We write the instruction as-is, without changes, if we are writing a 
compatible constant pool entry, such as from shared-CP transformation or 
explicitly using CodeBuilder's constant pool + instruction factory.
2. Otherwise, we convert the instruction from/to ldc/ldc_w depends on if the 
instruction is encodable with ldc. ldc2_w can always be preserved by this rule.

Test changes verify the fix for the said condy issue and the intended adaption 
behaviors.

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

Commit messages:
 - Formatting
 - 8342458: More consistent constant instruction handling
 - Test for ldc

Changes: https://git.openjdk.org/jdk/pull/21743/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21743&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8342458
  Stats: 154 lines in 3 files changed: 79 ins; 9 del; 66 mod
  Patch: https://git.openjdk.org/jdk/pull/21743.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21743/head:pull/21743

PR: https://git.openjdk.org/jdk/pull/21743

Reply via email to