RFR: 8341415: Optimize RawBytecodeHelper::next

ExE Boss duke at openjdk.org
Wed Oct 2 13:49:11 UTC 2024


On Wed, 2 Oct 2024 07:53:44 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> A small optimization to the RawBytecodeHelper::next method
> * Remove `len <= 0` once
> * merge store opcode and isWide

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;

src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java line 449:

> 447:         }
> 448: 
> 449:         if ((nextBci += len) > end) {

This change makes it that `nextBci` will no longer monotonically increase in case of a malformed special instruction.

Suggestion:

        if (len <= 0 || (nextBci += len) > end) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21300#discussion_r1784315687
PR Review Comment: https://git.openjdk.org/jdk/pull/21300#discussion_r1784331432


More information about the core-libs-dev mailing list