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

Remi Forax forax at univ-mlv.fr
Fri Oct 19 21:26:52 UTC 2018

----- Mail original -----
> De: "Tobias Hartmann" <tobias.hartmann at oracle.com>
> À: "valhalla-dev" <valhalla-dev at openjdk.java.net>
> Envoyé: Vendredi 19 Octobre 2018 14:40:05
> Objet: RFR(L): 8212190: [lworld] Support for nullable value types in C2

> Hi,
> please review the following patch:
> https://bugs.openjdk.java.net/browse/JDK-8212190
> http://cr.openjdk.java.net/~thartmann/8212190/webrev.00/
> 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).

I suppose that c2 if only able to determine if a value type is never null only for local variables not for fields.

> 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)
> Thanks,
> Tobias


More information about the valhalla-dev mailing list