Skip to content

Commit

Permalink
Merge pull request #20420 from a7ehuo/valuetype-fix-null-restricted-a…
Browse files Browse the repository at this point in the history
…rray-type-vp

Do not trust nullable arrayclass type in VP
  • Loading branch information
hzongaro authored Oct 30, 2024
2 parents e577d65 + 04ce59f commit 3974d87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
21 changes: 20 additions & 1 deletion runtime/compiler/optimizer/J9ValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions test/functional/Valhalla/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@
<variation>-Xint</variation>
<variation>-Xint -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999</variation>
<variation>-Xint -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<!-- https://github.com/eclipse-openj9/openj9/issues/19914 -->
<!--<variation>-Xjit:count=0</variation>
<variation>-Xjit:count=0</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xgcpolicy:optthruput</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:-EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
Expand All @@ -349,17 +348,17 @@
<variation>-Xjit:count=1,disableAsyncCompilation -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xnocompressedrefs -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xnocompressedrefs -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation -Xnocompressedrefs -Xgcpolicy:gencon</variation>-->
<variation>-Xjit:count=1,disableAsyncCompilation -Xnocompressedrefs -Xgcpolicy:gencon</variation>
<!-- Test the above options with initialOptLevel=warm -->
<!--<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:optthruput</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:optthruput</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:-EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=12 -XX:-EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=99999 -XX:-EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xnocompressedrefs -Xgcpolicy:optthruput -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xnocompressedrefs -Xgcpolicy:gencon -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening</variation>
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xnocompressedrefs -Xgcpolicy:gencon</variation>-->
<variation>-Xjit:count=1,disableAsyncCompilation,initialOptLevel=warm -Xnocompressedrefs -Xgcpolicy:gencon</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
--enable-preview \
Expand Down

0 comments on commit 3974d87

Please sign in to comment.