RFR: 8341415: Optimize RawBytecodeHelper::next
Shaojin Wen
swen at openjdk.org
Wed Oct 2 13:57:37 UTC 2024
On Wed, 2 Oct 2024 13:28:24 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java line 350:
>>
>>> 348: */
>>> 349: public boolean isWide() {
>>> 350: return (opcode & (WIDE << 8)) != 0;
>>
>> Suggestion:
>>
>> return (opcode >>> 8) == WIDE;
>
> WIDE is a constant, WIDE << 8 will do constant folding, your suggestion will be longer in bytecode.
public isWide()Z
L0
LINENUMBER 8 L0
ALOAD 0
GETFIELD internal/classfile/impl/RawBytecodeHelper.opcode : I
LDC 50176
IAND
IFEQ L1
ICONST_1
GOTO L2
L1
FRAME SAME
ICONST_0
L2
FRAME SAME1 I
IRETURN
L3
LOCALVARIABLE this Linternal/classfile/impl/RawBytecodeHelper; L0 L3 0
MAXSTACK = 2
MAXLOCALS = 1
}
public isWide1()Z
L0
LINENUMBER 12 L0
ALOAD 0
GETFIELD internal/classfile/impl/RawBytecodeHelper.opcode : I
BIPUSH 8
IUSHR
SIPUSH 196
IF_ICMPNE L1
ICONST_1
GOTO L2
L1
FRAME SAME
ICONST_0
L2
FRAME SAME1 I
IRETURN
L3
LOCALVARIABLE this Linternal/classfile/impl/RawBytecodeHelper; L0 L3 0
MAXSTACK = 2
MAXLOCALS = 1
}
The above are the bytecodes of the two implementations. It can be seen that the original implementation is more concise.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21300#discussion_r1784575918
More information about the core-libs-dev
mailing list