JDK-8150921 : Update Unsafe getters/setters to use double-register variants
  • Type: Enhancement
  • Component: core-libs
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-03-01
  • Updated: 2025-06-03
  • Resolved: 2016-05-07
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 9
9 b120Fixed
Related Reports
Causes :  
Relates :  
Relates :  
Description
There are two major versions of the s.m.Unsafe/j.i.m.Unsafe getters/setters. The "legacy" version which takes a single long address argument, and the newer double-register addressing versions which take an Object (which may be null) and an offset.

The legacy versions should be re-implemented to use the corresponding double-register methods, after which the VM implementation of the legacy methods can be removed.

For example, s.m.Unsafe.getFloat(long address) should call j.i.m.Unsafe.getFloat(null, address). j.i.m.Unsafe.getFloat(long) can be removed all-together (any user of it would simply have to be updated to use the double-register equivalent). Once that's done the DECLARE_GETPUTNATIVE related logic in unsafe.cpp can be removed.
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/60b331a4d392 User: lana Date: 2016-05-25 17:36:48 +0000
25-05-2016

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/b1c3c979ef6e User: lana Date: 2016-05-25 17:36:43 +0000
25-05-2016

URL: http://hg.openjdk.java.net/jdk9/hs/jdk/rev/b1c3c979ef6e User: mikael Date: 2016-05-07 01:40:48 +0000
07-05-2016

URL: http://hg.openjdk.java.net/jdk9/hs/hotspot/rev/60b331a4d392 User: mikael Date: 2016-05-07 01:40:46 +0000
07-05-2016

C2 is fine with replacing U.{get|put}X(address) with U.{get|put}X(null, offset). C1 might use a slightly better codegen: http://cr.openjdk.java.net/~shade/8150921/notes.txt Since C2 is fine, we can go on with this cleanup, and amend C1 concurrently.
02-03-2016

We need to additionally check that compilers (both C1 and C2) are able to fold double-register variants to the same generated code we have with single-register variants. I remember seeing some oddities about that.
01-03-2016