JDK-8215520 : [lworld] Add Unsafe primitives to support updating values
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: repo-valhalla
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-12-17
  • Updated: 2018-12-17
  • Resolved: 2018-12-17
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
repo-valhallaFixed
Related Reports
Relates :  
Description
John outlined two ways to adjust the existing Unsafe.putX contract for values:  

1. Create two new Unsafe operations ���start buffer��� and ���finish buffer��� on values; ���start buffer��� creates a true object instance  (of undefined type) whose layout and contents is exactly the input value instance, and ���finish buffer��� reverses the process.  In between, Unsafe.putInt on the buffer will have predictable effects.  The JIT can easily EA away the buffer, especially since it will be an ���Unsafe party foul��� to do anything with the buffer other than finishing it and walking away with the resulting value. 

2. For every operation like Unsafe.putInt create a corresponding operation Unsafe.withInt which operates on a value instance and returns the new value.  (Remember that putInt returns void.)  This requires not two new Unsafe API points but about 10 (prims + ref + value).  Note that there is no need to worry about relaxed vs. volatile ordering; withInt can only have one ordering because the value instance is always local and unaliased.

John suggested to go with the ���magic buffer��� approach is more robust than the withfield APIs approach.  That is a different approach than the one discussed at valhalla offsite 2018.
Comments
Changeset: http://hg.openjdk.java.net/valhalla/valhalla/rev/127ed6c19242
17-12-2018