Skip to content

Commit 389628f

Browse files
Annabelle HuoAnnabelle Huo
authored andcommitted
Rename isArrayCompTypePrimitiveValueType
Rename isArrayCompTypePrimitiveValueType to isArrayNullRestricted. Whether or not an array is null restricted is no longer decided by array component type but by the J9ClassArrayIsNullRestricted flag in array class. Signed-off-by: Annabelle Huo <Annabelle.Huo@ibm.com>
1 parent b8179ee commit 389628f

3 files changed

Lines changed: 38 additions & 40 deletions

File tree

compiler/optimizer/OMRValuePropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ TR_YesNoMaybe OMR::ValuePropagation::isCastClassObject(TR::VPClassType *type)
16901690
}
16911691

16921692

1693-
TR_YesNoMaybe OMR::ValuePropagation::isArrayCompTypePrimitiveValueType(TR::VPConstraint *arrayConstraint)
1693+
TR_YesNoMaybe OMR::ValuePropagation::isArrayNullRestricted(TR::VPConstraint *arrayConstraint)
16941694
{
16951695
return TR::Compiler->om.areFlattenableValueTypesEnabled() ? TR_maybe : TR_no;
16961696
}

compiler/optimizer/OMRValuePropagation.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ class ValuePropagation : public TR::Optimization
367367
TR_YesNoMaybe isCastClassObject(TR::VPClassType *type);
368368

369369
/**
370-
* Determine whether the component type of an array is, or might be, a primitive value
371-
* type.
370+
* Determine whether the array is, or might be, null-restricted
371+
*
372372
* \param arrayConstraint The \ref TR::VPConstraint type constraint for the array reference
373-
* \returns \c TR_yes if the array's component type is definitely a primitive value type;\n
374-
* \c TR_no if it is definitely not a primitive value type; or\n
373+
* \returns \c TR_yes if the array is definitely a null-restricted array;\n
374+
* \c TR_no if it is definitely not a null-restricted array; or\n
375375
* \c TR_maybe otherwise.
376376
*/
377-
virtual TR_YesNoMaybe isArrayCompTypePrimitiveValueType(TR::VPConstraint *arrayConstraint);
377+
virtual TR_YesNoMaybe isArrayNullRestricted(TR::VPConstraint *arrayConstraint);
378378

379379
/**
380380
* \brief

compiler/optimizer/ValuePropagationCommon.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -977,10 +977,10 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
977977

978978
bool doRuntimeNullRestrictedTest = false;
979979
bool needRuntimeTestDstArray = true; // needRuntimeTestDstArray is used only if doRuntimeNullRestrictedTest is true
980-
bool areBothArraysFlattenedPrimitiveValueType = false;
980+
bool areBothArraysFlattenedNullRestrictedArray = false;
981981
bool isValueTypeArrayFlatteningEnabled = TR::Compiler->om.isValueTypeArrayFlatteningEnabled();
982-
TR_YesNoMaybe isDstArrayCompTypePrimitiveValueType = TR_no;
983-
TR_YesNoMaybe isSrcArrayCompTypePrimitiveValueType = TR_no;
982+
TR_YesNoMaybe isDstArrayNullRestricted = TR_no;
983+
TR_YesNoMaybe isSrcArrayNullRestricted = TR_no;
984984

985985
if (trace() && comp()->generateArraylets())
986986
traceMsg(comp(), "Detected arraylet arraycopy: %p\n", node);
@@ -1311,7 +1311,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
13111311

13121312
static char *disableNullRestrictedArrayCopyXForm = feGetEnv("TR_DisableNullRestrictedArraycopyXForm");
13131313

1314-
// JEP 401: If null restricted value type is enabled, we need to preform null check on the value being stored
1314+
// JEP 401: If null-restricted value type is enabled, we need to preform null check on the value being stored
13151315
// in order to throw a NullPointerException if the array is null-restricted and the value to write is null.
13161316
// If it is this case, System.arraycopy cannot be transformed into arraycopy instructions.
13171317
//
@@ -1324,23 +1324,23 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
13241324
!primitiveArray2 &&
13251325
(copyLen != _constantZeroConstraint)) // Not zero length copy
13261326
{
1327-
isDstArrayCompTypePrimitiveValueType = isArrayCompTypePrimitiveValueType(dstObject);
1328-
isSrcArrayCompTypePrimitiveValueType = isArrayCompTypePrimitiveValueType(srcObject);
1327+
isDstArrayNullRestricted = isArrayNullRestricted(dstObject);
1328+
isSrcArrayNullRestricted = isArrayNullRestricted(srcObject);
13291329

1330-
switch (isDstArrayCompTypePrimitiveValueType)
1330+
switch (isDstArrayNullRestricted)
13311331
{
13321332
case TR_yes:
13331333
{
1334-
if (isSrcArrayCompTypePrimitiveValueType == TR_yes)
1334+
if (isSrcArrayNullRestricted == TR_yes)
13351335
{
13361336
// Array flattening is not enabled
1337-
// - If both source and destination arrays are primitive VT, they don't contain
1337+
// - If both source and destination arrays are null-restricted, they don't contain
13381338
// NULL value. There is no need to check null store
13391339
// - Also because flattening is not enabled, we don't need to concern about copying
13401340
// between flattened arrays
13411341
//
13421342
// Array flattening is enabled
1343-
// - If both source and destination arrays are primitive VT
1343+
// - If both source and destination arrays are null-restricted
13441344
// - (1) Both arrays are not flattened, there is no need to do anything
13451345
// - (2) Both arrays are flattened, elementSize needs to be updated in order to
13461346
// use arraycopy instructions
@@ -1356,7 +1356,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
13561356
if ((isArrayElementFlattened(dstObject) == TR_yes) &&
13571357
(isArrayElementFlattened(srcObject) == TR_yes))
13581358
{
1359-
areBothArraysFlattenedPrimitiveValueType = true;
1359+
areBothArraysFlattenedNullRestrictedArray = true;
13601360
elementSize = TR::Compiler->cls.flattenedArrayElementSize(comp(), dstObject->getClass());
13611361

13621362
if (trace())
@@ -1369,27 +1369,27 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
13691369
}
13701370
}
13711371
}
1372-
else // isSrcArrayCompTypePrimitiveValueType == TR_no or TR_maybe
1372+
else // isSrcArrayNullRestricted == TR_no or TR_maybe
13731373
{
1374-
// The destination is primitive VT array and the source might or might not
1375-
// be primitive VT array, do not transform because we need to do null store check and
1374+
// The destination is null-restricted array and the source might or might not
1375+
// be null-restricted array, do not transform because we need to do null store check and
13761376
// consider if the arrays are flattened
13771377
transformTheCall = false;
13781378
}
13791379
break;
13801380
}
13811381
case TR_maybe:
13821382
{
1383-
// If the destination array might or might not be primitive VT array at compile time,
1383+
// If the destination array might or might not be null-restricted array at compile time,
13841384
// runtime tests are required regardless of the source array type.
13851385
doRuntimeNullRestrictedTest = true;
13861386
break;
13871387
}
1388-
default: // TR_no == isDstArrayCompTypePrimitiveValueType
1388+
default: // TR_no == isDstArrayNullRestricted
13891389
{
13901390
if (isValueTypeArrayFlatteningEnabled)
13911391
{
1392-
if (isSrcArrayCompTypePrimitiveValueType == TR_yes)
1392+
if (isSrcArrayNullRestricted == TR_yes)
13931393
{
13941394
if (isArrayElementFlattened(srcObject) == TR_yes)
13951395
{
@@ -1400,16 +1400,16 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
14001400
}
14011401
// else: As long as the source array is not flattened, no need to do anything here
14021402
}
1403-
else if (isSrcArrayCompTypePrimitiveValueType == TR_maybe)
1403+
else if (isSrcArrayNullRestricted == TR_maybe)
14041404
{
1405-
// The source might or might not be a primitive VT array. If it is primitive VT array that is flattened,
1405+
// The source might or might not be a null-restricted array. If it is null-restricted array that is flattened,
14061406
// the arraycopy instruction cannot handle copying from flattened array into non-flattened array since the
14071407
// destination array is identity type. Need to add runtime check here
14081408
doRuntimeNullRestrictedTest = true;
14091409
// We already know the destination array is identity type. No need to insert runtime test here
14101410
needRuntimeTestDstArray = false;
14111411
}
1412-
// else: isSrcArrayCompTypePrimitiveValueType == TR_no, both destination and source arrays are
1412+
// else: isSrcArrayNullRestricted == TR_no, both destination and source arrays are
14131413
// identity arrays. No need to do anything here
14141414
}
14151415
// else: As long as array flattening is not enabled, no need to do anything here
@@ -1419,8 +1419,8 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
14191419
}
14201420

14211421
if (trace())
1422-
traceMsg(comp(), "%s: n%dn %p transformTheCall %d isSrcArrayCompTypePrimitiveValueType %d isDstArrayCompTypePrimitiveValueType %d doRuntimeNullRestrictedTest %d\n", __FUNCTION__,
1423-
node->getGlobalIndex(), node, transformTheCall, isSrcArrayCompTypePrimitiveValueType, isDstArrayCompTypePrimitiveValueType, doRuntimeNullRestrictedTest);
1422+
traceMsg(comp(), "%s: n%dn %p transformTheCall %d isSrcArrayNullRestricted %d isDstArrayNullRestricted %d doRuntimeNullRestrictedTest %d\n", __FUNCTION__,
1423+
node->getGlobalIndex(), node, transformTheCall, isSrcArrayNullRestricted, isDstArrayNullRestricted, doRuntimeNullRestrictedTest);
14241424
}
14251425
#else
14261426
bool isStringCompressedArrayCopy = false;
@@ -1436,7 +1436,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
14361436
{
14371437
if (trace())
14381438
{
1439-
comp()->dumpMethodTrees("Trees before modifying for null restricted array check");
1439+
comp()->dumpMethodTrees("Trees before modifying for null-restricted array check");
14401440
comp()->getDebug()->print(comp()->getOutFile(), comp()->getFlowGraph());
14411441
}
14421442
/*
@@ -1551,7 +1551,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
15511551
needRuntimeTestDstArray));
15521552
if (trace())
15531553
{
1554-
comp()->dumpMethodTrees("Trees after modifying for null restricted array check");
1554+
comp()->dumpMethodTrees("Trees after modifying for null-restricted array check");
15551555
comp()->getDebug()->print(comp()->getOutFile(), comp()->getFlowGraph());
15561556
}
15571557
}
@@ -1731,7 +1731,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
17311731
else if (srcArrayInfo)
17321732
stride = srcArrayInfo->elementSize();
17331733

1734-
stride = areBothArraysFlattenedPrimitiveValueType ? elementSize : stride;
1734+
stride = areBothArraysFlattenedNullRestrictedArray ? elementSize : stride;
17351735

17361736
if (stride != 0)
17371737
srcArrayLength->setArrayStride(stride);
@@ -1746,7 +1746,7 @@ void OMR::ValuePropagation::transformArrayCopyCall(TR::Node *node)
17461746
else if (dstArrayInfo)
17471747
stride = dstArrayInfo->elementSize();
17481748

1749-
stride = areBothArraysFlattenedPrimitiveValueType ? elementSize : stride;
1749+
stride = areBothArraysFlattenedNullRestrictedArray ? elementSize : stride;
17501750

17511751
if (stride != 0)
17521752
dstArrayLength->setArrayStride(stride);
@@ -3644,8 +3644,7 @@ void OMR::ValuePropagation::transformNullRestrictedArrayCopy(TR_NeedRuntimeTestN
36443644
* Array Flattening Is NOT Enabled:
36453645
* ================================
36463646
*
3647-
* Is dstArray primitive VT?
3648-
* (null restricted)
3647+
* Is dstArray null-restricted?
36493648
* |
36503649
* +---------+---------+
36513650
* | |
@@ -3660,15 +3659,14 @@ void OMR::ValuePropagation::transformNullRestrictedArrayCopy(TR_NeedRuntimeTestN
36603659
* Array Flattening IS Enabled:
36613660
* ================================
36623661
*
3663-
* Is dstArray primitive VT?
3664-
* (null restricted)
3662+
* Is dstArray null-restricted?
36653663
* |
36663664
* +---------+---------+
36673665
* | |
36683666
* Yes No
36693667
* | |
36703668
* v v
3671-
* System.arrayCopy Is srcArray primitive VT?
3669+
* System.arrayCopy Is srcArray null-restricted?
36723670
* (slowBlock) (could be flattened)
36733671
* |
36743672
* +---------+---------+
@@ -3683,7 +3681,7 @@ void OMR::ValuePropagation::transformNullRestrictedArrayCopy(TR_NeedRuntimeTestN
36833681
* No need to check dstArray(needTestDstArray=false):
36843682
* ================================
36853683
*
3686-
* Is srcArray primitive VT?
3684+
* Is srcArray null-restricted?
36873685
* (could be flattened)
36883686
* |
36893687
* +---------+---------+
@@ -3881,8 +3879,8 @@ slowBlock-> n39n BBStart <block_10> (freq 0) (cold)
38813879
prevBlock->split(ifDstTree->getNextTreeTop(), cfg, true, true);
38823880
}
38833881

3884-
// If destination is not null restricted value type array and array flattening is enabled, we need to check
3885-
// the source array component type. If it is null restricted value type, the current arraycopy instructions
3882+
// If destination is not null-restricted value type array and array flattening is enabled, we need to check
3883+
// the source array component type. If it is null-restricted value type, the current arraycopy instructions
38863884
// can't handle copying between flattened and non-flattened arrays.
38873885
if (needTestSrcArray)
38883886
{

0 commit comments

Comments
 (0)