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

2024-08-29 Thread duke
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. @wenshao Your change (at version cd1140c1782255a5a1fcaaac89a37d21bf32582b) is now ready to be sponsored by a Committer. -

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

2024-08-29 Thread Claes Redestad
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. Ok, I did some adhoc testing to convince me that these are equivalent for these cases. Masking in line with intended semant

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

2024-08-29 Thread Shaojin Wen
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. The general way of writing should be like this: elems[offset++] = (byte) (intValue >>> 8 * (intSize - i - 1)); ``` * now

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

2024-08-29 Thread Chen Liang
On Wed, 28 Aug 2024 18:38:40 GMT, Claes Redestad wrote: >> A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more >> C2-friendly and improves performance. > > I made an off-list suggestion along this line some time before integration. > IIRC it was a decent win back then, a

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

2024-08-29 Thread Claes Redestad
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. Needs to mask with `& 0xFF` in these places, otherwise you're changing semantics. - Changes requested by rede

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

2024-08-28 Thread Chen Liang
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. Marked as reviewed by liach (Reviewer). - PR Review: https://git.openjdk.org/jdk/pull/20748#pullrequestreview-

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

2024-08-28 Thread Chen Liang
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen 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

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

2024-08-28 Thread Claes Redestad
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. I made an off-list suggestion along this line some time before integration. IIRC it was a decent win back then, and with th

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

2024-08-28 Thread Shaojin Wen
On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen wrote: > A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more > C2-friendly and improves performance. @liach Is this what you want to see? ## baseline @ 29 jdk.internal.classfile.impl.BufWriterImpl::writeU1 (8 bytes) in