Skip to content

Commit

Permalink
Check non-null constraint rather than isNonNull on node in VP
Browse files Browse the repository at this point in the history
When Value Propagation determines that a call to
<jitStoreFlattenableArrayElement> can be transformed due to constraints
associated with the value that is being stored, it should determine
whether the value is known to be non-null by checking the constraint
associated with the value rather than calling isNonNull() on the node.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
  • Loading branch information
hzongaro committed Oct 29, 2021
1 parent 923e871 commit 7f95a3b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions runtime/compiler/optimizer/J9ValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,19 @@ J9::ValuePropagation::constrainRecognizedMethod(TR::Node *node)

TR::Node *indexNode = node->getChild(elementIndexOpIndex);
TR::Node *arrayRefNode = node->getChild(arrayRefOpIndex);
TR::Node *storeValueNode = isStoreFlattenableArrayElement ? node->getChild(storeValueOpIndex) : NULL;
TR::VPConstraint *arrayConstraint = getConstraint(arrayRefNode, arrayRefGlobal);
TR_YesNoMaybe isCompTypeVT = isArrayCompTypeValueType(arrayConstraint);

TR_YesNoMaybe isStoreValueVT = isStoreFlattenableArrayElement ? isValue(getConstraint(storeValueNode, storeValueGlobal)) : TR_maybe;
TR::Node *storeValueNode = NULL;
TR::VPConstraint *storeValueConstraint = NULL;
TR_YesNoMaybe isStoreValueVT = TR_maybe;

if (isStoreFlattenableArrayElement)
{
storeValueNode = node->getChild(storeValueOpIndex);
storeValueConstraint = getConstraint(storeValueNode, storeValueGlobal);
isStoreValueVT = isValue(storeValueConstraint);
}

// If the array's component type is definitely not a value type, or if the value
// being assigned in an array store operation is definitely not a value type, add
Expand All @@ -789,12 +797,12 @@ J9::ValuePropagation::constrainRecognizedMethod(TR::Node *node)
if (isStoreFlattenableArrayElement && !owningMethodDoesNotContainStoreChecks(this, node))
{
// If storing to an array whose component type is or might be a value type
// and the value that's being assigned is or might null, both a run-time
// and the value that's being assigned is or might be null, both a run-time
// NULLCHK of the value is required (guarded by a check of whether the
// component type is a value type) and an ArrayStoreCHK are required;
// otherwise, only the ArrayStoreCHK is required.
//
if ((isCompTypeVT != TR_no) && !storeValueNode->isNonNull())
if ((isCompTypeVT != TR_no) && (storeValueConstraint == NULL || !storeValueConstraint->isNonNullObject()))
{
flagsForTransform.set(ValueTypesHelperCallTransform::RequiresStoreAndNullCheck);
}
Expand Down

0 comments on commit 7f95a3b

Please sign in to comment.