Skip to content

Commit

Permalink
Stop recognizing UTF_16.encodeUTF16 methods
Browse files Browse the repository at this point in the history
This commit removes the code for encodeUTF16Big() and encodeUTF16Little()
methods in sun.nio.cs.UTF_16$Encoder from method recognition, and removes
related helper functions.
  • Loading branch information
knn-k committed Nov 18, 2024
1 parent 52b4dd4 commit a9445ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 78 deletions.
59 changes: 6 additions & 53 deletions compiler/optimizer/ValuePropagationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,8 +2407,6 @@ void OMR::ValuePropagation::generateArrayTranslateNode(TR::TreeTop *callTree,TR:
bool isISO88591Decoder = (rm == TR::sun_nio_cs_ISO_8859_1_Decoder_decodeISO8859_1);
bool isSBCSEncoder = (rm == TR::sun_nio_cs_ext_SBCS_Encoder_encodeSBCS)? true:false;
bool isSBCSDecoder = (rm == TR::sun_nio_cs_ext_SBCS_Decoder_decodeSBCS)? true:false;
bool isEncodeUtf16 = (rm == TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big || rm == TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Little);


int32_t childId = callNode->getFirstArgumentIndex();
if (callNode->getChild(childId)->getType().isAddress() && callNode->getChild(childId+1)->getType().isAddress())
Expand Down Expand Up @@ -2471,7 +2469,7 @@ void OMR::ValuePropagation::generateArrayTranslateNode(TR::TreeTop *callTree,TR:
else
strideNode = TR::Node::create(callNode, TR::iconst, 0, 2);

if ( isISO88591Encoder || isAsciiEncoder || isSBCSEncoder || isEncodeUtf16 ||
if ( isISO88591Encoder || isAsciiEncoder || isSBCSEncoder ||
(rm == TR::sun_nio_cs_US_ASCII_Encoder_encodeASCII) ||
(rm == TR::sun_nio_cs_UTF_8_Encoder_encodeUTF_8))
encode = true;
Expand Down Expand Up @@ -2626,36 +2624,12 @@ void OMR::ValuePropagation::generateArrayTranslateNode(TR::TreeTop *callTree,TR:

stoppingNode = TR::Node::create(callNode,TR::iconst, 0, stopIndex);

if (isEncodeUtf16)
{
TR::SymbolReference* transformedCallSymRef =
comp()->getSymRefTab()->methodSymRefFromName(
comp()->getMethodSymbol(),
"com/ibm/jit/JITHelpers",
TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big == rm ?
"transformedEncodeUTF16Big" :
"transformedEncodeUTF16Little",
"(JJI)I",
TR::MethodSymbol::Static
);

arrayTranslateNode = TR::Node::createWithSymRef(callNode, callNode->getOpCodeValue(), 3, transformedCallSymRef);
}

arrayTranslateNode->setAndIncChild(0, src);
arrayTranslateNode->setAndIncChild(1, dst);

if (isEncodeUtf16)
{
arrayTranslateNode->setAndIncChild(2, len);
}
else
{
arrayTranslateNode->setAndIncChild(2, tableNode);
arrayTranslateNode->setAndIncChild(3, termCharNode);
arrayTranslateNode->setAndIncChild(4, len);
arrayTranslateNode->setAndIncChild(5, stoppingNode);
}
arrayTranslateNode->setAndIncChild(2, tableNode);
arrayTranslateNode->setAndIncChild(3, termCharNode);
arrayTranslateNode->setAndIncChild(4, len);
arrayTranslateNode->setAndIncChild(5, stoppingNode);

//arrayTranslateNode->setChild(5, NULL);//* do I need this? what if there are more children?*/

Expand Down Expand Up @@ -3936,29 +3910,8 @@ slowBlock-> n39n BBStart <block_10> (freq 0) (cold)
cfg->addEdge(TR::CFGEdge::createEdge(prevBlock, slowBlock, trMemory()));
cfg->addEdge(TR::CFGEdge::createEdge(slowBlock, nextBlock, trMemory()));
}
#endif

static
const char* transformedTargetName (TR::RecognizedMethod rm)
{
#ifdef J9_PROJECT_SPECIFIC
switch ( rm )
{
case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big:
return "icall com/ibm/jit/JITHelpers.transformedEncodeUTF16Big(JJI)I";

case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Little:
return "icall com/ibm/jit/JITHelpers.transformedEncodeUTF16Little(JJI)I" ;

default:
return "arraytranslate";
}
#else
return "arraytranslate";
#endif
}

#ifdef J9_PROJECT_SPECIFIC
/**
* Can be called from doDelayedTransformations when nodes may have been removed from the tree. Issue 6623
* https://github.com/eclipse-omr/omr/issues/6623
Expand Down Expand Up @@ -4243,7 +4196,7 @@ void OMR::ValuePropagation::transformConverterCall(TR::TreeTop *callTree)



if (!performTransformation(comp(), "%sChanging call %s [%p] to %s \n", OPT_DETAILS, callNode->getOpCode().getName(), callNode, transformedTargetName(rm)))
if (!performTransformation(comp(), "%sChanging call %s [%p] to %s \n", OPT_DETAILS, callNode->getOpCode().getName(), callNode, "arraytranslate"))
return;

TR::CFG *cfg = comp()->getFlowGraph();
Expand Down
3 changes: 0 additions & 3 deletions compiler/ras/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3942,9 +3942,6 @@ TR_Debug::getRuntimeHelperName(int32_t index)
case TR_PPCP256addNoMod: return "ECP256addNoMod_PPC";
case TR_PPCP256subNoMod: return "ECP256subNoMod_PPC";

case TR_PPCencodeUTF16Big: return "__encodeUTF16Big";
case TR_PPCencodeUTF16Little: return "__encodeUTF16Little";

case TR_PPCreferenceArrayCopy: return "__referenceArrayCopy";
case TR_PPCgeneralArrayCopy: return "__generalArrayCopy";
case TR_PPCsamplingRecompileMethod: return "__samplingRecompileMethod";
Expand Down
38 changes: 16 additions & 22 deletions compiler/runtime/Helpers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ SETVAL(TR_IA32JitMethodMonitorExitReserved,TR_LXRH+28)
SETVAL(TR_IA32arrayTranslateTRTO, TR_LXRH+29)
SETVAL(TR_IA32arrayTranslateTROTNoBreak, TR_LXRH+30)
SETVAL(TR_IA32arrayTranslateTROT, TR_LXRH+31)
SETVAL(TR_IA32encodeUTF16Big,TR_LXRH+32)
SETVAL(TR_IA32encodeUTF16Little,TR_LXRH+33)
SETVAL(TR_IA32numRuntimeHelpers,TR_LXRH+34)
SETVAL(TR_IA32numRuntimeHelpers,TR_LXRH+32)

SETVAL(TR_AMD64floatRemainder,TR_LXRH+0)
SETVAL(TR_AMD64doubleRemainder,TR_LXRH+1)
Expand Down Expand Up @@ -236,12 +234,10 @@ SETVAL(TR_AMD64clockGetTime,TR_LXRH+26)
SETVAL(TR_AMD64arrayTranslateTRTO, TR_LXRH+27)
SETVAL(TR_AMD64arrayTranslateTROTNoBreak, TR_LXRH+28)
SETVAL(TR_AMD64arrayTranslateTROT, TR_LXRH+29)
SETVAL(TR_AMD64encodeUTF16Big,TR_LXRH+30)
SETVAL(TR_AMD64encodeUTF16Little,TR_LXRH+31)
SETVAL(TR_AMD64doAESENCEncrypt,TR_LXRH+32)
SETVAL(TR_AMD64doAESENCDecrypt,TR_LXRH+33)
SETVAL(TR_AMD64java_util_zip_CRC32C_updateBytes,TR_LXRH+34)
SETVAL(TR_AMD64numRuntimeHelpers,TR_LXRH+35)
SETVAL(TR_AMD64doAESENCEncrypt,TR_LXRH+30)
SETVAL(TR_AMD64doAESENCDecrypt,TR_LXRH+31)
SETVAL(TR_AMD64java_util_zip_CRC32C_updateBytes,TR_LXRH+32)
SETVAL(TR_AMD64numRuntimeHelpers,TR_LXRH+33)

SETVAL(TR_PPClongDivide,TR_FSRH)
SETVAL(TR_PPCnativeStaticHelper,TR_FSRH+1)
Expand Down Expand Up @@ -324,19 +320,17 @@ SETVAL(TR_PPCquadWordArrayCopy_vsx, TR_FSRH+77)
SETVAL(TR_PPCforwardQuadWordArrayCopy_vsx, TR_FSRH+78)
SETVAL(TR_PPCpostP10ForwardCopy, TR_FSRH+79)
SETVAL(TR_PPCpostP10GenericCopy, TR_FSRH+80)
SETVAL(TR_PPCencodeUTF16Big, TR_FSRH+81)
SETVAL(TR_PPCencodeUTF16Little, TR_FSRH+82)
SETVAL(TR_PPCP256Multiply, TR_FSRH+83)
SETVAL(TR_PPCP256Mod, TR_FSRH+84)
SETVAL(TR_PPCP256addNoMod, TR_FSRH+85)
SETVAL(TR_PPCP256subNoMod, TR_FSRH+86)
SETVAL(TR_PPCAESCBCDecrypt, TR_FSRH+87)
SETVAL(TR_PPCAESCBCEncrypt, TR_FSRH+88)
SETVAL(TR_PPCinterpreterUnresolvedConstantDynamicGlue, TR_FSRH+89)
SETVAL(TR_PPCcrc32_vpmsum, TR_FSRH+90)
SETVAL(TR_PPCcrc32_no_vpmsum, TR_FSRH+91)
SETVAL(TR_PPCcrc32_oneByte, TR_FSRH+92)
SETVAL(TR_PPCnumRuntimeHelpers,TR_FSRH+93)
SETVAL(TR_PPCP256Multiply, TR_FSRH+81)
SETVAL(TR_PPCP256Mod, TR_FSRH+82)
SETVAL(TR_PPCP256addNoMod, TR_FSRH+83)
SETVAL(TR_PPCP256subNoMod, TR_FSRH+84)
SETVAL(TR_PPCAESCBCDecrypt, TR_FSRH+85)
SETVAL(TR_PPCAESCBCEncrypt, TR_FSRH+86)
SETVAL(TR_PPCinterpreterUnresolvedConstantDynamicGlue, TR_FSRH+87)
SETVAL(TR_PPCcrc32_vpmsum, TR_FSRH+88)
SETVAL(TR_PPCcrc32_no_vpmsum, TR_FSRH+89)
SETVAL(TR_PPCcrc32_oneByte, TR_FSRH+90)
SETVAL(TR_PPCnumRuntimeHelpers,TR_FSRH+91)

SETVAL(TR_ARMdouble2Long,TR_FSRH)
SETVAL(TR_ARMdoubleRemainder,TR_FSRH+1)
Expand Down

0 comments on commit a9445ba

Please sign in to comment.