RFR: 8339196: Optimize BufWriterImpl#writeU1/U2/Int/Long

Chen Liang liach at openjdk.org
Wed Aug 28 20:05:50 UTC 2024


On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more C2-friendly and improves performance.

src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java line 124:

> 122:     public void writeLong(long x) {
> 123:         reserveSpace(8);
> 124:         elems[offset    ] = (byte) (x >> 56);

Since elems is mutable, should we pull it to a local variable and write instead? Does C2 optimize this current code in compile logs?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20748#discussion_r1734740549


More information about the core-libs-dev mailing list