-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8362376: Use @Stable annotation in Java FDLIBM implementation #26341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back darcy! A progress list of the required criteria for merging this PR into |
@jddarcy This change is no longer ready for integration - check the PR body for details. |
Some small refactorings could be used to make a few non-static arrays static. |
Webrevs
|
The effect of this PR is to make the affected array elements eligible for constant-folding by the JIT. The contract of If we had a frozen (immutable) array feature in the JVM this PR could be formulated using frozen array constants. But we are not there yet. |
Yes; my intention was to allow HotSpot greater leeway to optimize the FDLIBM code. Under my limited performance testing, the change seemed to be performance neutral, but if it shouldn't cause a regression, I'd be comfortable pushing the change. |
The methods directly affected by this update are atan, exp, and sin, cos, tan. The sin, cos, and tan method are affected by the updates to KernelRemPio2 and tan is also directly affected by its own updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arrays at L.2257-2262 could be declared static
and @Stable
as well, and moved outside the method.
@@ -809,6 +814,7 @@ static final class KernelRemPio2 { | |||
|
|||
private static final int init_jk[] = {2, 3, 4, 6}; // initial value for jk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final int init_jk[] = {2, 3, 4, 6}; // initial value for jk | |
@Stable private static final int init_jk[] = {2, 3, 4, 6}; // initial value for jk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final int init_jk[] = {2, 3, 4, 6}; // initial value for jk | |
@Stable | |
private static final int[] init_jk = {2, 3, 4, 6}; // initial value for jk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that array on my edit; will add. Thanks.
@@ -451,7 +453,8 @@ static double compute(double x) { | |||
*/ | |||
private static final double | |||
pio4 = 0x1.921fb54442d18p-1, // 7.85398163397448278999e-01 | |||
pio4lo= 0x1.1a62633145c07p-55, // 3.06161699786838301793e-17 | |||
pio4lo= 0x1.1a62633145c07p-55; // 3.06161699786838301793e-17 | |||
@Stable private static final double |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stable private static final double | |
@Stable | |
private static final double |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These additions look reasonable.
@jddarcy What about the local arrays mentioned in my comment above
|
I think local arrays require more structural changes to the code, which might be why this patch did not include that change. However, note as said in #26355, such conversions are meaningful and would potentially allow performance boosts. |
Right; those were the ones I was referring to when I wrote "Some small refactorings could be used to make a few non-static arrays static." :-) I wanted to just start with the static final arrays, but I could pull those out too in this PR. |
Okay; I took a look at what the code was actually doing and wrote something that avoiding using arrays entirely. |
Add
@Stable
to the static final arrays used in the Java port of FDLIBM.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26341/head:pull/26341
$ git checkout pull/26341
Update a local copy of the PR:
$ git checkout pull/26341
$ git pull https://git.openjdk.org/jdk.git pull/26341/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26341
View PR using the GUI difftool:
$ git pr show -t 26341
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26341.diff
Using Webrev
Link to Webrev Comment