RFR: 8341141: Optimize DirectCodeBuilder [v24]

Chen Liang liach at openjdk.org
Tue Oct 8 22:35:06 UTC 2024


On Tue, 8 Oct 2024 09:34:42 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   suggestion from @liach
>
> src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java line 706:
> 
>> 704:     public void writeLoadConstant(Opcode opcode, LoadableConstantEntry value) {
>> 705:         // Make sure Long and Double have LDC2_W and
>> 706:         // rewrite to _W if index is > 256
> 
> Pre-existing.. 
> - Comment should say >= 256. 
> - As we're cloning from a pre-existing pool I assume there's a (perhaps unlikely) possibility we go from a wide to a lower index? In that case the opcode could profitably be "rewritten" to `Opcode.LDC` in an else clause. (I assume `LDC_W` with an index in the 0-255 range works fine functionally; it just wastes a byte.)

Indeed, the opcode here is pointless if we have a pool adaption; in that case we should just use `ldc(LoadableConstantEntry)`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21243#discussion_r1792580876


More information about the core-libs-dev mailing list