From 04ce59fdf014e3727e0724d71ef4db28b78fb39e Mon Sep 17 00:00:00 2001 From: Annabelle Huo Date: Sat, 26 Oct 2024 15:38:48 -0400 Subject: [PATCH] Do not trust nullable arrayclass type in VP Update isUnreliableSignatureType to check if the class is an array class, and if its component class is value type, and if the array class is not null-restricted array. If so, the type is not reliable because it can either be a nullable array class type or a null-restricted array type. Fixes: #19914 Signed-off-by: Annabelle Huo --- .../compiler/optimizer/J9ValuePropagation.cpp | 21 ++++++++++++++++++- test/functional/Valhalla/playlist.xml | 9 ++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/runtime/compiler/optimizer/J9ValuePropagation.cpp b/runtime/compiler/optimizer/J9ValuePropagation.cpp index fa63af75fdd..ea5aa34c743 100644 --- a/runtime/compiler/optimizer/J9ValuePropagation.cpp +++ b/runtime/compiler/optimizer/J9ValuePropagation.cpp @@ -3782,9 +3782,28 @@ bool J9::ValuePropagation::isUnreliableSignatureType( return false; int32_t numDims = 0; + TR_OpaqueClassBlock *originClass = klass; klass = comp()->fej9()->getBaseComponentClass(klass, numDims); + if (!TR::Compiler->cls.isInterfaceClass(comp(), klass)) - return false; + { + // If the original class is an array class and it is not a null-restricted array, + // we can not trust its type as a nullable array because it can either be a nullable + // array class type or a null-restricted array type. + // TODO-VALUETYPE: However, if in the future Value Propagation constraints are able + // to distinguish between nullable and null-restricted arrays, this test can change. + if (TR::Compiler->om.areFlattenableValueTypesEnabled() && + (numDims > 0) && + TR::Compiler->cls.isValueTypeClass(klass) && + !TR::Compiler->cls.isArrayNullRestricted(comp(), originClass)) + { + // Do nothing here and will be handled next like an interface array + } + else + { + return false; + } + } // Find the best array type that we can guarantee based on an // array-of-interface signature. diff --git a/test/functional/Valhalla/playlist.xml b/test/functional/Valhalla/playlist.xml index 3225144ba63..826266c96a7 100644 --- a/test/functional/Valhalla/playlist.xml +++ b/test/functional/Valhalla/playlist.xml @@ -339,8 +339,7 @@ -Xint -Xint -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -Xint -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening - - + -Xjit:count=1,disableAsyncCompilation -Xnocompressedrefs -Xgcpolicy:gencon - + -Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xnocompressedrefs -Xgcpolicy:gencon $(JAVA_COMMAND) $(JVM_OPTIONS) \ --enable-preview \