JDK-8295555 : Primitive wrapper caches could be `@Stable`
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,20,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2022-10-12
  • Updated: 2023-11-01
  • Resolved: 2023-06-13
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.
JDK 21 JDK 22
21.0.2Fixed 22 b02Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
The @jdk.internal.vm.annotation.Stable annotation indicates to the HotSpot vm that it can trust the contents of an array to be treated as constant. I think that primitive wrapper caches (such as Integer.IntegerCache.cache) could benefit from such optimization.

Please correct me if I'm wrong, I'd love to know if there's other, more powerful optimizations in place, or other reasons why this wouldn't be a good idea or could cause issues.



Comments
[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Clean backport to improve corner case performance around the primitives.
24-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/286 Date: 2023-10-23 17:18:31 +0000
23-10-2023

Changeset: f7de726b Author: Per Minborg <pminborg@openjdk.org> Date: 2023-06-13 08:39:00 +0000 URL: https://git.openjdk.org/jdk/commit/f7de726bd37a2f1fa6f63b601cd2dab1805234e8
13-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14418 Date: 2023-06-12 14:25:42 +0000
12-06-2023

> The JIT compilers seem to treat those fields as special already. See ciField::is_autobox_cache(). The special treatment is limited to LoadNode::eliminate_autobox() which tries to optimize away valueOf()/xxxValue() nested calls. In general, it's more powerful than just constant folding except the case when a boxed constant is requested (e.g., Integer.valueOf(5)). @Stable would allow to fold it into an Integer constant while LoadNode::eliminate_autobox()/ciField::is_autobox_cache() doesn't do anything about it.
25-10-2022

The JIT compilers seem to treat those fields as special already. See ciField::is_autobox_cache().
20-10-2022

Moving to compiler team as the @stable annotation relates to JIT optimisations - JDK-8001107
19-10-2022

This is an enhancement request, Moving it to dev team for analysis.
19-10-2022