[lworld] RFR(XL): 8220716: [lworld] C2 support for LW2 arrays

Tobias Hartmann tobias.hartmann at oracle.com
Wed Apr 10 12:48:20 UTC 2019


Hi,

please review the following patch that adds C2 support for LW2 arrays:
https://bugs.openjdk.java.net/browse/JDK-8220716
http://cr.openjdk.java.net/~thartmann/8220716/webrev.00/

It's based on Mr. Simms' runtime patch:
http://cr.openjdk.java.net/~dsimms/valhalla/lw2_arrays/webrev5/

We now support the following three types of value type arrays:
- null-ok:              MyValue.box[] (ciObjArrayKlass "[LMyValue")
- null-free:            MyValue.val[] (ciObjArrayKlass "[QMyValue")
- null-free, flattened: MyValue.val[] (ciValueArrayKlass "[QMyValue")

GraphKit::new_array needs to emit code to compute the storage properties if the array type is not
statically known (i.e. for reflective array creation) and PhaseMacroExpand::initialize_object needs
to encode these properties into the klass pointer.

Typeflow analysis and C2's type system required some changes to take the array storage properties
into account when computing the meet between array types.

Complexity of loading/storing from/to an array didn't change compared to LW1. Also allocation of an
array with a known element type didn't change. Only unsafe/reflective array creation with an unknown
array type is a bit more complicated now because we need to compute the storage properties at
runtime. The array_copyOf and native_clone intrinsics now need to load the array element mirror.

This patch also includes the following changes:
- Intrinsification of Class::asBoxType/asValueType to fold MyValue.class.asBoxType()/asValueType()
- Fixed Class.cast intrinsic to check for null when casting to .val
- Minor refactoring and cleanups of related code
- Lots of additional tests that caught lots of bugs, also in the runtime :)

All compiler and runtime value type tests pass.

Thanks,
Tobias



More information about the valhalla-dev mailing list