From 233cf247740abef18e1653b7df55ed31afdf0edf Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Mon, 10 Feb 2025 11:36:03 -0800 Subject: [PATCH] disable inlining of countPositives unless its caller is hasNegatives --- runtime/compiler/optimizer/InlinerTempForJ9.cpp | 12 ++++++++++++ runtime/compiler/x/codegen/J9CodeGenerator.cpp | 2 +- runtime/compiler/x/codegen/J9TreeEvaluator.cpp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/optimizer/InlinerTempForJ9.cpp b/runtime/compiler/optimizer/InlinerTempForJ9.cpp index 28d84b43fdf..1783780b228 100644 --- a/runtime/compiler/optimizer/InlinerTempForJ9.cpp +++ b/runtime/compiler/optimizer/InlinerTempForJ9.cpp @@ -5980,6 +5980,18 @@ TR_InlinerFailureReason return Recognized_Callee; } + if (rm == TR::java_lang_StringCoding_countPositives) + { + if (callsite->_callerResolvedMethod->getRecognizedMethod() == TR::java_lang_StringCoding_hasNegatives) + { + return InlineableTarget; + } + else + { + return DontInline_Callee; + } + } + return InlineableTarget; } diff --git a/runtime/compiler/x/codegen/J9CodeGenerator.cpp b/runtime/compiler/x/codegen/J9CodeGenerator.cpp index 575052a6889..44a5be07c03 100644 --- a/runtime/compiler/x/codegen/J9CodeGenerator.cpp +++ b/runtime/compiler/x/codegen/J9CodeGenerator.cpp @@ -154,7 +154,7 @@ J9::X86::CodeGenerator::initialize() { cg->setSupportsInlineStringCodingCountPositives(); } -#endif +#endif /* JAVA_SPEC_VERSION < 19 */ static bool disableInlineVectorizedMismatch = feGetEnv("TR_disableInlineVectorizedMismatch") != NULL; if (cg->getSupportsArrayCmpLen() && diff --git a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp index 10e9764283c..4c676b2d6d5 100644 --- a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp @@ -12597,7 +12597,7 @@ J9::X86::TreeEvaluator::directCallEvaluator(TR::Node *node, TR::CodeGenerator *c } } break; -#endif +#endif /* JAVA_SPEC_VERSION < 19 */ case TR::java_nio_Bits_keepAlive: case TR::java_lang_ref_Reference_reachabilityFence: {