RFR(L): 8212190: [lworld] Support for nullable value types in C2

Tobias Hartmann tobias.hartmann at oracle.com
Fri Oct 19 12:40:05 UTC 2018


please review the following patch:

Since 8211772 we can disable scalarization of value types in C2. Building on top of that, this patch
implements support for nullable value types by only performing scalarization when the value type oop
is known to be non-null at compile time.

Because we don't yet have a way to declare nullable value types in Java (bytecodes), C2 treats all
value types as non-nullable by default. However, if -XX:+NullableValueTypes is set, all value types
are treated as nullable. Use sites of that flag define the places in the code where we later need
nullable information from the runtime (method arguments/returns, checkcast and getfield/putfield).

I've factored out all compiler tests that rely on being able to pass null for a value type into an
own test that sets the -XX:+NullableValueTypes flag. C2 will still attempt scalarization when it is
able to determine that a value type is never null. All tests pass with -XX:+NullableValueTypes and
-XX:-NullableValueTypes which means that even with nullable value types, we are still able to emit
optimal code for these tests (verified by IR matching).

To be able to propagate nullness information through ciTypeFlow, I've introduced a ciWrapper type
that is a subtype of ciType and wraps values types. The interfaces of ciTypeFlow and ciSignature use
that information and unwrap the type before it's passed on (to not confuse other code).

This patch also includes the following changes:
- Removed null-checking value type entry point (might re-add something similar for calling
convention optimization)
- Removed CheckCastPPNode optimizations that were used to optimize method handle calls in MVT (not
applicable to LWorld)
- Avoid having ValueTypeNodes with ValueTypePtrNodes as oop input (can happen with incremental inlining)


More information about the valhalla-dev mailing list