JDK-8157296 : Remove fork to xxcodeArrayLoop() and xxcodeBufferLoop() in sun.nio.cs coders
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2016-05-18
  • Updated: 2023-12-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Description
A DESCRIPTION OF THE REQUEST :
Use same code on heap buffers and direct buffers.

JUSTIFICATION :
Since access to heap buffers and direct buffers is now optimized via Unsafe [1], there is no more need to separately optimize the code.
[1] https://bugs.openjdk.java.net/browse/JDK-8149469

ACTUAL -
        protected CoderResult decodeLoop(ByteBuffer src,
                                         CharBuffer dst)
        {
            if (src.hasArray() && dst.hasArray())
                return decodeArrayLoop(src, dst);
            else
                return decodeBufferLoop(src, dst);
        }



Comments
The performance issue could be solved by bug JDK-6509032. See also: https://bugs.openjdk.org/browse/JDK-8158695?focusedCommentId=14161141&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14161141
10-03-2023

I would not do this. Charset implementations are performance critical. It's true that there's a huge amount of errorprone code duplication in the parallel decodeArrayLoop and decodeBufferLoop methods, but that price has been paid and there's no ongoing maintenance cost, since nobody is introducing new Charsets. Anyone who takes this on should do lots of microbenchmarking with various JITs including C1.
06-03-2023