RFR: JDK-8205549 JDK-8205698 Support of flattened values in Unsafe
Paul Sandoz
paul.sandoz at oracle.com
Fri Jun 29 16:23:12 UTC 2018
View nice!
Comments for further iteration perhaps after committing:
- You may want to follow the same pattern for getType as for fieldOffset i.e. use a static method rather than a virtual method.
- We can remove the atomic add and bitwise ops from ValueFieldInstanceReadWrite.
- The Unsafe atomic accessors ValueVolatile/Acquire/Release/Opaque can use a global lock for the moment to ensure atomicity and ordering, the acquire/release can defer to the volatile accessors. Adding the others is also straightforward (weaker CAS and CAE can defer to the volatile CAS/CAE methods).
Happy to help with any of this with following patches.
Paul.
> On Jun 28, 2018, at 9:47 PM, mandy chung <mandy.chung at oracle.com> wrote:
>
> This patch introduces Unsafe::getValue and Unsafe::putValue API.
>
> http://cr.openjdk.java.net/~mchung/valhalla/webrevs/unsafe-flat-fields-webrev/
>
> A flattenable object field can be flattened. The decision to flatten
> an object field is made at class loading time in this implementation
> When an object field is accessed, we will query if the field is
> flattened or not. java.lang.reflect.Field and java.lang.invoke.MemberName
> are extended to indicate if it's flattened.
>
> A new MethodHandleTest and existing tests are updated to test value
> type and non-value type containing flat fields via MethodHandle,
> VarHandle, and core reflection. It also tests direct method handle
> of array element getter and setters. VarHandle support for value
> arrays depend on JDK-8205698. I will look into this next.
>
> - ValueFieldInstanceReadWrite and ValueFieldInstanceReadOnly are added
> specially for flat field. The implementation does not flatten static
> fields and hence I decide not to add unused ValueFieldStaticXXX class.
> I left the other VarHandle operations such as compareAndSet as is and
> look at them again.
>
> - I removed check_putfield_access in unsafe.cpp and move the check of
> non-null value to put on a flat field to java. We will go through
> over places that does not allow setting value field to null, as a
> separate task.
>
> - I keep the assert and logging in Unsafe_GetValue and Unsafe_PutValue
> for diagnosis. I will remove it when we add the VarHandle support for
> value arrays.
>
> I quite like this patch coming along.
>
> Thanks
> Mandy
More information about the valhalla-dev
mailing list