Skip to content

Commit

Permalink
Stop recognizing UTF16_Encoder.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.UTF16_Encoder from method recognition, and removes
related helper functions.
  • Loading branch information
knn-k committed Nov 27, 2024
1 parent f92a3f0 commit 613a8de
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 134 deletions.
3 changes: 0 additions & 3 deletions compiler/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,9 +1685,6 @@ class OMR_EXTENSIBLE CodeGenerator
bool getSupportsArrayTranslateTROT() {return _flags4.testAny(SupportsArrayTranslateTROT);}
void setSupportsArrayTranslateTROT() {_flags4.set(SupportsArrayTranslateTROT);}

bool getSupportsEncodeUtf16LittleWithSurrogateTest() { return false; }
bool getSupportsEncodeUtf16BigWithSurrogateTest() { return false; }

bool getSupportsArraySet() {return _flags1.testAny(SupportsArraySet);}
void setSupportsArraySet() {_flags1.set(SupportsArraySet);}

Expand Down
1 change: 0 additions & 1 deletion compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"disableUpgradingColdCompilations", "R\tdisable upgrading to warm those methods compiled at cold due to classLoadPhase", SET_OPTION_BIT(TR_DisableUpgradingColdCompilations), "F", NOT_IN_SUBSET},
{"disableUseDefForShadows", "I\ttemporary, disables usedef for shadows.", SET_OPTION_BIT(TR_DisableUseDefForShadows),"F"},
{"disableUseRIOnlyForLargeQSZ", "M\t", RESET_OPTION_BIT(TR_UseRIOnlyForLargeQSZ), "F", NOT_IN_SUBSET },
{"disableUTF16BEEncoder", "M\tdisable inlining of UTF16 Big Endian encoder", SET_OPTION_BIT(TR_DisableUTF16BEEncoder), "F"},
{"disableValueProfiling", "O\tdisable value profiling", SET_OPTION_BIT(TR_DisableValueProfiling), "F"},
{"disableVariablePrecisionDAA", "O\tdisable variable precision DAA optimizations", SET_OPTION_BIT(TR_DisableVariablePrecisionDAA), "F"},
{"disableVectorAPIExpansion", "M\tdisable expansion of Vector API", SET_OPTION_BIT(TR_DisableVectorAPIExpansion), "F"},
Expand Down
2 changes: 1 addition & 1 deletion compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ enum TR_CompilationOptions
TR_DisableInvariantCodeMotion = 0x00008000 + 28,
TR_EnableSelfTuningScratchMemoryUsageBeforeCompile = 0x00010000 + 28,
TR_EnableSelfTuningScratchMemoryUsageInTrMemory = 0x00020000 + 28,
TR_DisableUTF16BEEncoder = 0x00040000 + 28,
// Available = 0x00040000 + 28,
// Available = 0x00080000 + 28,
TR_DisableDAATrailingZero = 0x00100000 + 28,
TR_DisableDynamicRIBufferProcessing = 0x00200000 + 28,
Expand Down
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
14 changes: 0 additions & 14 deletions compiler/p/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,20 +1934,6 @@ bool OMR::Power::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode
return TR::CodeGenerator::getSupportsOpCodeForAutoSIMD(&self()->comp()->target().cpu, opcode);
}

bool
OMR::Power::CodeGenerator::getSupportsEncodeUtf16LittleWithSurrogateTest()
{
return self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_PPC_HAS_VSX) &&
!self()->comp()->getOption(TR_DisableSIMDUTF16LEEncoder);
}

bool
OMR::Power::CodeGenerator::getSupportsEncodeUtf16BigWithSurrogateTest()
{
return self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_PPC_HAS_VSX) &&
!self()->comp()->getOption(TR_DisableSIMDUTF16BEEncoder);
}


void
OMR::Power::CodeGenerator::addMetaDataForLoadAddressConstantFixed(
Expand Down
4 changes: 0 additions & 4 deletions compiler/p/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator
static bool getSupportsOpCodeForAutoSIMD(TR::CPU *cpu, TR::ILOpCode opcode);
bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode);

bool getSupportsEncodeUtf16LittleWithSurrogateTest();

bool getSupportsEncodeUtf16BigWithSurrogateTest();

int32_t arrayInitMinimumNumberOfBytes() {return 32;}

TR::SymbolReference &getDouble2LongSymbolReference() { return *_symRefTab->findOrCreateRuntimeHelper(TR_PPCdouble2Long); }
Expand Down
3 changes: 0 additions & 3 deletions compiler/ras/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3830,9 +3830,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
16 changes: 0 additions & 16 deletions compiler/x/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,22 +1189,6 @@ OMR::X86::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode)
return TR::CodeGenerator::getSupportsOpCodeForAutoSIMD(&self()->comp()->target().cpu, opcode);
}

bool
OMR::X86::CodeGenerator::getSupportsEncodeUtf16LittleWithSurrogateTest()
{
TR_ASSERT_FATAL(self()->comp()->compileRelocatableCode() || self()->comp()->isOutOfProcessCompilation() || self()->comp()->compilePortableCode() || self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_X86_SSE4_1) == TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_1(), "supportsSSE4_1()");
return self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_X86_SSE4_1) &&
!self()->comp()->getOption(TR_DisableSIMDUTF16LEEncoder);
}

bool
OMR::X86::CodeGenerator::getSupportsEncodeUtf16BigWithSurrogateTest()
{
TR_ASSERT_FATAL(self()->comp()->compileRelocatableCode() || self()->comp()->isOutOfProcessCompilation() || self()->comp()->compilePortableCode() || self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_X86_SSE4_1) == TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_1(), "supportsSSE4_1()");
return self()->comp()->target().cpu.supportsFeature(OMR_FEATURE_X86_SSE4_1) &&
!self()->comp()->getOption(TR_DisableSIMDUTF16BEEncoder);
}

bool
OMR::X86::CodeGenerator::getSupportsBitPermute()
{
Expand Down
3 changes: 0 additions & 3 deletions compiler/x/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator
static bool getSupportsOpCodeForAutoSIMD(TR::CPU *cpu, TR::ILOpCode opcode);
bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode);

bool getSupportsEncodeUtf16LittleWithSurrogateTest();
bool getSupportsEncodeUtf16BigWithSurrogateTest();

virtual bool getSupportsBitPermute();

bool supportsNonHelper(TR::SymbolReferenceTable::CommonNonhelperSymbol symbol);
Expand Down
12 changes: 0 additions & 12 deletions compiler/z/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,18 +1934,6 @@ OMR::Z::CodeGenerator::anyLitPoolSnippets()
return false;
}

bool
OMR::Z::CodeGenerator::getSupportsEncodeUtf16BigWithSurrogateTest()
{
if (self()->comp()->target().cpu.isAtLeast(OMR_PROCESSOR_S390_Z196))
{
return (!self()->comp()->getOption(TR_DisableUTF16BEEncoder) ||
(self()->getSupportsVectorRegisters() && !self()->comp()->getOption(TR_DisableSIMDUTF16BEEncoder)));
}

return false;
}

TR_S390ScratchRegisterManager*
OMR::Z::CodeGenerator::generateScratchRegisterManager(int32_t capacity)
{
Expand Down
2 changes: 0 additions & 2 deletions compiler/z/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator
bool anyNonConstantSnippets();
bool anyLitPoolSnippets();

bool getSupportsEncodeUtf16BigWithSurrogateTest();

TR_S390ScratchRegisterManager* generateScratchRegisterManager(int32_t capacity = 8);

bool canTransformUnsafeCopyToArrayCopy();
Expand Down

0 comments on commit 613a8de

Please sign in to comment.