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.

Signed-off-by: KONNO Kazuhiro <[email protected]>
  • Loading branch information
knn-k committed Nov 27, 2024
1 parent fc778d6 commit 5e8ada3
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 1,295 deletions.
4 changes: 0 additions & 4 deletions jcl/src/java.base/share/classes/com/ibm/jit/JITHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ private static JITHelpers jitHelpers() {
return helpers;
}

public native int transformedEncodeUTF16Big(long src, long dest, int num);

public native int transformedEncodeUTF16Little(long src, long dest, int num);

/*
* Constants for getSuperclass.
*/
Expand Down
1 change: 0 additions & 1 deletion runtime/compiler/build/files/host/p.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ JIT_PRODUCT_SOURCE_FILES+=\
compiler/p/runtime/J9PPCArrayTranslate.spp \
compiler/p/runtime/J9PPCCRC32.spp \
compiler/p/runtime/J9PPCCRC32_wrapper.c \
compiler/p/runtime/J9PPCEncodeUTF16.spp \
compiler/p/runtime/Math.spp \
compiler/p/runtime/PPCHWProfiler.cpp \
compiler/p/runtime/PPCRelocationTarget.cpp \
Expand Down
1 change: 0 additions & 1 deletion runtime/compiler/build/files/host/x.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ JIT_PRODUCT_SOURCE_FILES+=\
compiler/x/runtime/X86RelocationTarget.cpp \
compiler/x/runtime/X86ArrayTranslate.nasm \
compiler/x/runtime/X86Codert.nasm \
compiler/x/runtime/X86EncodeUTF16.nasm \
compiler/x/runtime/X86LockReservation.nasm \
compiler/x/runtime/X86PicBuilder.nasm \
compiler/x/runtime/X86Unresolveds.nasm
Expand Down
5 changes: 0 additions & 5 deletions runtime/compiler/codegen/J9RecognizedMethodsEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,6 @@
sun_nio_cs_UTF_8_Encoder_encodeUTF_8,
sun_nio_cs_ext_IBM1388_Encoder_encodeArrayLoop,

sun_nio_cs_UTF_16_Encoder_encodeUTF16Big,
sun_nio_cs_UTF_16_Encoder_encodeUTF16Little,
com_ibm_jit_JITHelpers_transformedEncodeUTF16Big,
com_ibm_jit_JITHelpers_transformedEncodeUTF16Little,

java_lang_Integer_bitCount,
java_lang_Integer_highestOneBit,
java_lang_Integer_lowestOneBit,
Expand Down
10 changes: 0 additions & 10 deletions runtime/compiler/compile/J9Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ J9::Compilation::isConverterMethod(TR::RecognizedMethod rm)
case TR::sun_nio_cs_ext_SBCS_Decoder_decodeSBCS:
case TR::sun_nio_cs_UTF_8_Encoder_encodeUTF_8:
case TR::sun_nio_cs_UTF_8_Decoder_decodeUTF_8:
case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big:
case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Little:
return true;
default:
return false;
Expand Down Expand Up @@ -497,14 +495,6 @@ J9::Compilation::canTransformConverterMethod(TR::RecognizedMethod rm)
case TR::sun_nio_cs_ext_SBCS_Decoder_decodeSBCS:
return genTRxx;

// devinmp: I'm not sure whether these could be transformed in AOT, but
// they haven't been so far.
case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Little:
return !aot && self()->cg()->getSupportsEncodeUtf16LittleWithSurrogateTest();

case TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big:
return !aot && self()->cg()->getSupportsEncodeUtf16BigWithSurrogateTest();

default:
return false;
}
Expand Down
5 changes: 0 additions & 5 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3192,8 +3192,6 @@ void TR_ResolvedJ9Method::construct()
{x(TR::com_ibm_jit_JITHelpers_getPackedDataSizeFromJ9Class64, "getPackedDataSizeFromJ9Class64", "(J)J")},
{x(TR::com_ibm_jit_JITHelpers_getComponentTypeFromJ9Class32, "getComponentTypeFromJ9Class32", "(I)I")},
{x(TR::com_ibm_jit_JITHelpers_getComponentTypeFromJ9Class64, "getComponentTypeFromJ9Class64", "(J)J")},
{x(TR::com_ibm_jit_JITHelpers_transformedEncodeUTF16Big, "transformedEncodeUTF16Big", "(JJI)I")},
{x(TR::com_ibm_jit_JITHelpers_transformedEncodeUTF16Little, "transformedEncodeUTF16Little", "(JJI)I")},
{x(TR::com_ibm_jit_JITHelpers_getIntFromObject, "getIntFromObject", "(Ljava/lang/Object;J)I")},
{x(TR::com_ibm_jit_JITHelpers_getIntFromObjectVolatile, "getIntFromObjectVolatile", "(Ljava/lang/Object;J)I")},
{x(TR::com_ibm_jit_JITHelpers_getLongFromObject, "getLongFromObject", "(Ljava/lang/Object;J)J")},
Expand Down Expand Up @@ -3781,8 +3779,6 @@ void TR_ResolvedJ9Method::construct()
{x(TR::sun_nio_cs_ext_SBCS_Decoder_decodeSBCS, "decodeSBCS", "([BII[CI[C)I")},
{x(TR::sun_nio_cs_UTF_8_Encoder_encodeUTF_8, "encodeUTF_8", "([CII[BI)I")},
{x(TR::sun_nio_cs_UTF_8_Decoder_decodeUTF_8, "decodeUTF_8", "([BII[CI)I")},
{x(TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Big, "encodeUTF16Big", "([CII[BI)I")},
{x(TR::sun_nio_cs_UTF_16_Encoder_encodeUTF16Little, "encodeUTF16Little", "([CII[BI)I")},
{ TR::unknownMethod}
};

Expand Down Expand Up @@ -4191,7 +4187,6 @@ void TR_ResolvedJ9Method::construct()
{ "java/lang/reflect/Method", MethodMethods },
{ "sun/nio/cs/UTF_8$Decoder", EncodeMethods },
{ "sun/nio/cs/UTF_8$Encoder", EncodeMethods },
{ "sun/nio/cs/UTF16_Encoder", EncodeMethods },
{ "jdk/internal/misc/Unsafe", UnsafeMethods },
{ 0 }
};
Expand Down
98 changes: 0 additions & 98 deletions runtime/compiler/p/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10597,95 +10597,6 @@ static TR::Register *inlineStringHashcode(TR::Node *node, TR::CodeGenerator *cg)
return hashReg;
}

static TR::Register *inlineEncodeUTF16(TR::Node *node, TR::CodeGenerator *cg)
{
// tree looks like:
// icall com.ibm.jit.JITHelpers.encodeUtf16{Big,Little}()
// input ptr
// output ptr
// input length (in elements)
// Number of elements converted returned

TR::MethodSymbol *symbol = node->getSymbol()->castToMethodSymbol();
bool bigEndian = symbol->getRecognizedMethod() == TR::com_ibm_jit_JITHelpers_transformedEncodeUTF16Big;

// Set up register dependencies
const int gprClobberCount = 5;
const int fprClobberCount = 4;
const int vrClobberCount = 6;
const int crClobberCount = 2;
const int totalDeps = crClobberCount + gprClobberCount + fprClobberCount + vrClobberCount + 3;
TR::RegisterDependencyConditions *deps = new (cg->trHeapMemory()) TR::RegisterDependencyConditions(1, totalDeps, cg->trMemory());

TR::Register *inputReg = cg->gprClobberEvaluate(node->getChild(0));
TR::Register *outputReg = cg->gprClobberEvaluate(node->getChild(1));
TR::Register *inputLenReg = cg->gprClobberEvaluate(node->getChild(2));
TR::Register *outputLenReg = cg->allocateRegister();

// Allocate clobbered registers
TR::Register *gprClobbers[gprClobberCount], *fprClobbers[fprClobberCount], *vrClobbers[vrClobberCount], *crClobbers[crClobberCount];
for (int i = 0; i < gprClobberCount; ++i) gprClobbers[i] = cg->allocateRegister(TR_GPR);
for (int i = 0; i < fprClobberCount; ++i) fprClobbers[i] = cg->allocateRegister(TR_FPR);
for (int i = 0; i < vrClobberCount; ++i) vrClobbers[i] = cg->allocateRegister(TR_VRF);
for (int i = 0; i < crClobberCount; ++i) crClobbers[i] = cg->allocateRegister(TR_CCR);

// Add the pre and post conditions
// Input and output registers
deps->addPreCondition(inputReg, TR::RealRegister::gr3);

deps->addPostCondition(outputLenReg, TR::RealRegister::gr3);
deps->addPostCondition(outputReg, TR::RealRegister::gr4);
deps->addPostCondition(inputLenReg, TR::RealRegister::gr5);

//CCR.
deps->addPostCondition(crClobbers[0], TR::RealRegister::cr0);
deps->addPostCondition(crClobbers[1], TR::RealRegister::cr6);

//GPRs + Trampoline
deps->addPostCondition(gprClobbers[0], TR::RealRegister::gr6);
deps->addPostCondition(gprClobbers[1], TR::RealRegister::gr7);
deps->addPostCondition(gprClobbers[2], TR::RealRegister::gr8);
deps->addPostCondition(gprClobbers[3], TR::RealRegister::gr9);
deps->addPostCondition(gprClobbers[4], TR::RealRegister::gr11);

//VR's
deps->addPostCondition(vrClobbers[0], TR::RealRegister::vr0);
deps->addPostCondition(vrClobbers[1], TR::RealRegister::vr1);
deps->addPostCondition(vrClobbers[2], TR::RealRegister::vr2);
deps->addPostCondition(vrClobbers[3], TR::RealRegister::vr3);
deps->addPostCondition(vrClobbers[4], TR::RealRegister::vr4);
deps->addPostCondition(vrClobbers[5], TR::RealRegister::vr5);

//FP/VSR
deps->addPostCondition(fprClobbers[0], TR::RealRegister::fp0);
deps->addPostCondition(fprClobbers[1], TR::RealRegister::fp1);
deps->addPostCondition(fprClobbers[2], TR::RealRegister::fp2);
deps->addPostCondition(fprClobbers[3], TR::RealRegister::fp3);

// Generate helper call
TR_RuntimeHelper helper;
helper = bigEndian ? TR_PPCencodeUTF16Big : TR_PPCencodeUTF16Little;
TR::SymbolReference *helperSym = cg->comp()->getSymRefTab()->findOrCreateRuntimeHelper(helper);
generateDepImmSymInstruction(cg, TR::InstOpCode::bl, node, (uintptr_t)helperSym->getMethodAddress(), deps, helperSym);

for (uint32_t i = 0; i < node->getNumChildren(); ++i) cg->decReferenceCount(node->getChild(i));

// Spill the clobbered registers
if (inputReg != node->getChild(0)->getRegister()) cg->stopUsingRegister(inputReg);
if (outputReg != node->getChild(1)->getRegister()) cg->stopUsingRegister(outputReg);
if (inputLenReg != node->getChild(2)->getRegister()) cg->stopUsingRegister(inputLenReg);
for (int i = 0; i < gprClobberCount; ++i) cg->stopUsingRegister(gprClobbers[i]);
for (int i = 0; i < vrClobberCount; ++i) cg->stopUsingRegister(vrClobbers[i]);
for (int i = 0; i < fprClobberCount; ++i) cg->stopUsingRegister(fprClobbers[i]);
for (int i = 0; i < crClobberCount; ++i) cg->stopUsingRegister(crClobbers[i]);

cg->machine()->setLinkRegisterKilled(true);
cg->setHasCall();
node->setRegister(outputLenReg);

return outputLenReg;
}

static TR::Register *inlineIntrinsicIndexOf_P10(TR::Node *node, TR::CodeGenerator *cg, bool isLatin1)
{
static bool disableIndexOfStringIntrinsic = feGetEnv("TR_DisableIndexOfStringIntrinsic") != NULL;
Expand Down Expand Up @@ -12125,15 +12036,6 @@ J9::Power::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result
}
break;

case TR::com_ibm_jit_JITHelpers_transformedEncodeUTF16Big:
case TR::com_ibm_jit_JITHelpers_transformedEncodeUTF16Little:
if (comp->target().cpu.isAtLeast(OMR_PROCESSOR_PPC_P7) && comp->target().cpu.supportsFeature(OMR_FEATURE_PPC_HAS_VSX))
{
resultReg = inlineEncodeUTF16(node, cg);
return true;
}
break;

case TR::java_lang_StringLatin1_indexOfChar:
case TR::java_lang_StringUTF16_indexOfCharUnsafe:
case TR::com_ibm_jit_JITHelpers_intrinsicIndexOfLatin1:
Expand Down
1 change: 0 additions & 1 deletion runtime/compiler/p/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ j9jit_files(
${omr_SOURCE_DIR}/compiler/p/runtime/OMRCodeCacheConfig.cpp
p/runtime/J9PPCArrayCopy.spp
p/runtime/J9PPCArrayTranslate.spp
p/runtime/J9PPCEncodeUTF16.spp
p/runtime/J9PPCCRC32.spp
p/runtime/J9PPCCRC32_wrapper.c
p/runtime/CodeSync.cpp
Expand Down
Loading

0 comments on commit 5e8ada3

Please sign in to comment.