On Sat, 5 Oct 2024 16:33:50 GMT, Shaojin Wen <[email protected]> wrote:
>> Some DirectCodeBuilder related optimizations to improve startup and running
>> performance:
>> 1. Merge calls, merge writeU1 and writeU2 into writeU3
>> 2. Merge calls, merge writeU1 and writeIndex operations
>> 3. Directly use writeU1 instead of writeBytecode
>> 4. Rewrite the implementation of load and store
>
> Shaojin Wen has updated the pull request incrementally with one additional
> commit since the last revision:
>
> fix merge error
Everything else looks good.
src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java
line 78:
> 76: private static final LocalVariableType[]
> EMPTY_LOCAL_VARIABLE_TYPE_ARRAY = new LocalVariableType[0];
> 77: private static final AbstractPseudoInstruction.ExceptionCatchImpl[]
> EMPTY_HANDLER_ARRAY = new AbstractPseudoInstruction.ExceptionCatchImpl[0];
> 78: private static final DeferredLabel[] EMPTY_DEFERRED_LABEL_ARRAY = new
> DeferredLabel[0];
You used `{}` for conciseness in `DirectClassBuilder`. Maybe use `{}` here as
well?
src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java
line 507:
> 505: } else {
> 506: bytecodesBufWriter.writeU1U1U2(WIDE, bytecode, slot);
> 507: }
Can we do:
if ((slot & ~0xFF) == 0)
bytecodesBufWriter.writeU1U1(bytecode, slot);
else if ((slot & ~0xFFFF) == 0)
bytecodesBufWriter.writeU1U1U2(WIDE, bytecode, slot);
else
throw BytecodeHelpers.slotOutOfBounds(slot);
src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java
line 989:
> 987: @Override
> 988: public CodeBuilder aload(int slot) {
> 989: if (slot >= 0 && slot <= 3) {
Should we use `if ((slot & ~3) != 0)` for shorter bytecode? #21367
-------------
PR Review: https://git.openjdk.org/jdk/pull/21243#pullrequestreview-2352814559
PR Review Comment: https://git.openjdk.org/jdk/pull/21243#discussion_r1790792835
PR Review Comment: https://git.openjdk.org/jdk/pull/21243#discussion_r1790810567
PR Review Comment: https://git.openjdk.org/jdk/pull/21243#discussion_r1790804586