8337237: Use FFM instead of Unsafe for Java 2D RenderBuffer class#20339
8337237: Use FFM instead of Unsafe for Java 2D RenderBuffer class#20339prrace wants to merge 3 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back prr! A progress list of the required criteria for merging this PR into |
|
@prrace This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 223 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
|
Most put operations require that the item is properly aligned now that the FFM API is used in conjunction with the aligned |
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java
Outdated
Show resolved
Hide resolved
Yes, we have pre-existing comments saying the caller has to make sure to properly align variables. |
|
Could this class use // putShort(short)
curOffset += Short.BYTES;
// put(short[], ...)
position(position() + length * Short.BYTES); |
Note that this code was written about a decade before that field was added to JDK, so it I don't think you can criticise the author not using it. |
JornVernee
left a comment
There was a problem hiding this comment.
Latest version looks good to me.
Wow. I did not realize that. Everything looks good. |
jayathirthrao
left a comment
There was a problem hiding this comment.
There are no alignment issues while reading/writing into RenderBuffer, verified that by taking a look at individual Metal/OpenGL/D3D calls.
Also as captured we should not worry about performance impact of these calls as these are minute computations compared to actual rendering logic.
Latest change looks good to me.
|
/integrate |
|
Going to push as commit c0384b6.
Your commit was automatically rebased without conflicts. |
Migrate from using Unsafe to FFM's MemorySegment API for allocating and setting native memory.
This code is used by Metal, OpenGL and D3D, so I manually tested SwingSet2 and J2Demo as well as running all the usual tests.
I also did some micro-benchmarking on the performance of Unsafe vs MemorySegment.
The performance of either is more than sufficient for us .. ie they could be 10x slower and we wouldn't even notice.
But they are in the same ballpark, and if one or the other is clearly faster it is the new FFM code.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20339/head:pull/20339$ git checkout pull/20339Update a local copy of the PR:
$ git checkout pull/20339$ git pull https://git.openjdk.org/jdk.git pull/20339/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20339View PR using the GUI difftool:
$ git pr show -t 20339Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20339.diff
Webrev
Link to Webrev Comment