diff --git a/runtime/compiler/optimizer/FearPointAnalysis.cpp b/runtime/compiler/optimizer/FearPointAnalysis.cpp index 7b3935713f9..fb9e389a6de 100644 --- a/runtime/compiler/optimizer/FearPointAnalysis.cpp +++ b/runtime/compiler/optimizer/FearPointAnalysis.cpp @@ -34,10 +34,31 @@ #include "infra/BitVector.hpp" #include "infra/Checklist.hpp" -bool TR_FearPointAnalysis::virtualGuardsKillFear(TR::Compilation *comp) + +bool TR_FearPointAnalysis::virtualGuardKillsFear(TR::Compilation *comp, TR::Node *virtualGuardNode) { - static bool kill = (feGetEnv("TR_FPAnalaysisGuardsDoNotKillFear") == NULL); - return kill && !(!comp->getOption(TR_DisableVectorAPIExpansion) && comp->getMethodSymbol()->hasVectorAPI()); + if (!comp->cg()->supportsMergingGuards()) + return false; + + static bool kill = (feGetEnv("TR_FPAnalaysisGuardsDoNotKillFear")) == NULL; + + if (kill && !comp->getOption(TR_DisableVectorAPIExpansion) && comp->getMethodSymbol()->hasVectorAPI()) + { + TR_VirtualGuard *guardInfo = comp->findVirtualGuardInfo(virtualGuardNode); + if (guardInfo->isInlineGuard()) + { + TR::Method *guardedMethod = guardInfo->getSymbolReference()->getSymbol()->castToMethodSymbol()->getMethod(); + uint32_t classNameLength = guardedMethod->classNameLength(); + char* className = guardedMethod->classNameChars(); + // Set Virtual guard to not kill fear if it is guarding calls to method in two VectorJEP packages. + if ((classNameLength >= 20 && strncmp("jdk/incubator/vector", className, 20) == 0) + || (classNameLength >= 22 && strncmp("jdk/internal/vm/vector", className, 22) == 0)) + { + return false; + } + } + } + return kill; } int32_t TR_FearPointAnalysis::getNumberOfBits() { return 1; } @@ -246,9 +267,8 @@ void TR_FearPointAnalysis::initializeGenAndKillSetInfo() } // kill any fear originating from inside - if (virtualGuardsKillFear(comp()) - && treeTop->getNode()->isTheVirtualGuardForAGuardedInlinedCall() - && comp()->cg()->supportsMergingGuards()) + if (treeTop->getNode()->isTheVirtualGuardForAGuardedInlinedCall() + && virtualGuardKillsFear(comp(), treeTop->getNode())) { _regularKillSetInfo[currentBlock->getNumber()]->setAll(getNumberOfBits()); _exceptionKillSetInfo[currentBlock->getNumber()]->setAll(getNumberOfBits()); diff --git a/runtime/compiler/optimizer/FearPointAnalysis.hpp b/runtime/compiler/optimizer/FearPointAnalysis.hpp index cf080000009..3eb66f1cb80 100644 --- a/runtime/compiler/optimizer/FearPointAnalysis.hpp +++ b/runtime/compiler/optimizer/FearPointAnalysis.hpp @@ -41,7 +41,7 @@ class TR_FearPointAnalysis : public TR_BackwardUnionSingleBitContainerAnalysis virtual bool postInitializationProcessing(); TR_SingleBitContainer *generatedFear(TR::Node *node); - static bool virtualGuardsKillFear(TR::Compilation *comp); + static bool virtualGuardKillsFear(TR::Compilation *comp, TR::Node *virtualGuardNode); private: void computeFear(TR::Compilation *comp, TR::Node *node, TR::NodeChecklist &checklist); diff --git a/runtime/compiler/optimizer/HCRGuardAnalysis.cpp b/runtime/compiler/optimizer/HCRGuardAnalysis.cpp index e1310e3a980..f25f594d6e7 100644 --- a/runtime/compiler/optimizer/HCRGuardAnalysis.cpp +++ b/runtime/compiler/optimizer/HCRGuardAnalysis.cpp @@ -190,12 +190,10 @@ void TR_HCRGuardAnalysis::initializeGenAndKillSetInfo() isKill = false; } } - else if (ttNode->isTheVirtualGuardForAGuardedInlinedCall() - && TR_FearPointAnalysis::virtualGuardsKillFear(comp()) - && comp()->cg()->supportsMergingGuards()) + else if (ttNode->isTheVirtualGuardForAGuardedInlinedCall()) { TR_VirtualGuard *guardInfo = comp()->findVirtualGuardInfo(ttNode); - if (guardInfo->getKind() != TR_HCRGuard) + if (guardInfo->getKind() != TR_HCRGuard && TR_FearPointAnalysis::virtualGuardKillsFear(comp(), ttNode)) { // Theoretically, the guard should only kill its inlined path. However, making it right require adding // complications to the data flow and/or optimizations using the result of the analysis. Based on the diff --git a/runtime/compiler/optimizer/OSRGuardInsertion.cpp b/runtime/compiler/optimizer/OSRGuardInsertion.cpp index 450248c7d9b..d92bd907c85 100644 --- a/runtime/compiler/optimizer/OSRGuardInsertion.cpp +++ b/runtime/compiler/optimizer/OSRGuardInsertion.cpp @@ -386,9 +386,8 @@ void TR_OSRGuardInsertion::removeHCRGuards(TR_BitVector &fearGeneratingNodes, TR // if virtual guards kill fear we can short cut additional analysis if the method still has a guard // we can mark that guard as an OSR guard and continue without needing a data flow analysis - if (TR_FearPointAnalysis::virtualGuardsKillFear(comp()) - && additionalVirtualGuard - && comp()->cg()->supportsMergingGuards()) + if (additionalVirtualGuard + && TR_FearPointAnalysis::virtualGuardKillsFear(comp(), potentialGuard)) { TR_VirtualGuard *additionalGuardInfo = comp()->findVirtualGuardInfo(potentialGuard); TR_ASSERT(additionalGuardInfo, "guard info should exist for a virtual guard"); @@ -412,7 +411,7 @@ void TR_OSRGuardInsertion::removeHCRGuards(TR_BitVector &fearGeneratingNodes, TR { comp()->addClassForOSRRedefinition(guardInfo->getThisClass()); guardInfo->setMergedWithHCRGuard(false); - if (TR_FearPointAnalysis::virtualGuardsKillFear(comp())) + if (TR_FearPointAnalysis::virtualGuardKillsFear(comp(), node)) guardInfo->setMergedWithOSRGuard(); else { @@ -475,9 +474,8 @@ int32_t TR_OSRGuardInsertion::insertOSRGuards(TR_BitVector &fearGeneratingNodes) continue; } - if (TR_FearPointAnalysis::virtualGuardsKillFear(comp()) - && cursor->getNode()->isTheVirtualGuardForAGuardedInlinedCall() - && comp()->cg()->supportsMergingGuards()) + if (cursor->getNode()->isTheVirtualGuardForAGuardedInlinedCall() + && TR_FearPointAnalysis::virtualGuardKillsFear(comp(), cursor->getNode())) { TR::DebugCounter::prependDebugCounter(comp(), TR::DebugCounter::debugCounterName(comp(), "osrGuardSummary/patch/vguard/%s/=%d", comp()->getHotnessName(comp()->getMethodHotness()), block->getFrequency()), cursor); TR::DebugCounter::prependDebugCounter(comp(), TR::DebugCounter::debugCounterName(comp(), "osrGuardVGLocation/%s/(%s)/block_%d@%d", comp()->getHotnessName(comp()->getMethodHotness()), comp()->signature(), block->getNumber(), block->getFrequency()), cursor);