RFR: JDK-8205549 JDK-8205698 Support of flattened values in Unsafe
Paul Sandoz
paul.sandoz at oracle.com
Wed Jun 27 22:11:40 UTC 2018
Hi Frederic,
Code looks good, but I have some concerns that modifying the existing non-intrinsic native implementations is the best direction to take. It may be better progress-wise for now to create new Unsafe methods for plain flat access:
- we don’t peturb existing behavior and usages of unsafe accessors and deviate from C1/C2 behavior.
- we can provide flat atomic accessors in Java by leveraging the plain accessors with locks thereby crudely supporting VarHandles until we can do something better.
- its not clear to me that the existing Unsafe plain access signatures are the right approach for flat access, nor is it clear to me the degree of checks that should be performed, after all this is Unsafe where checks are commonly performed before making unsafe calls with appropriately vetted arguments allowing for efficient code to be generated. Input from C2 experts will i think help with regards to the signature and required checks if any.
—
I was hacking around with an alternative based on your code that creates separate methods (with lighter checks pushed to asserts, but i almost removed ‘em):
http://cr.openjdk.java.net/~psandoz/valhalla/unsafe-flat-value-access/webrev/ <http://cr.openjdk.java.net/~psandoz/valhalla/unsafe-flat-value-access/webrev/>
The general idea being one could write or read a value to or from an area of memory, it's up to the caller to pass in the correct arguments. So that in principle works for flat fields, flat arrays, or off-heap. However, i don’t understand the the value type code in detail so perhaps such an approach is misguided?
Paul.
> On Jun 27, 2018, at 2:17 PM, Frederic Parain <frederic.parain at oracle.com> wrote:
>
> Please review this changeset which adds support for flattened values to the Unsafe API.
>
> http://cr.openjdk.java.net/~fparain/Unsafe/webrev.02/index.html
>
> This changeset addresses the following issues:
> - reading from /writing to a flattenable/flattened field with Unsafe
> - null-check when writing to a flattenable field
> - initialization barrier when reading an uninitialized static value field with Unsafe
> - enforcing values immutability even when using Unsafe
> - reading from /writing to a value array with Unsafe
> - null-check when writing to a value array with Unsafe
>
> Thanks,
>
> Fred
>
More information about the valhalla-dev
mailing list