Skip to content

JProfiling fix to avoid too many internal pointers #21056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions runtime/compiler/optimizer/JProfilingValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,23 @@ void
TR_JProfilingValue::lowerCalls()
{
TR::TreeTop *cursor = comp()->getStartTree();
bool stopProfiling = false;
TR_BitVector *backwardAnalyzedAddressNodesToCheck = new (comp()->trStackMemory()) TR_BitVector();
while (cursor)
{
TR::Node * node = cursor->getNode();
TR::TreeTop *nextTreeTop = cursor->getNextTreeTop();
int32_t ipMax = comp()->maxInternalPointers()/2;
static const char * ipl = feGetEnv("TR_ProfilingIPLimit");
if (ipl)
{
static const int32_t ipLimit = atoi(ipl);
ipMax = ipLimit;
}

if (!stopProfiling && (comp()->getSymRefTab()->getNumInternalPointers() >= ipMax))
stopProfiling = true;

if (node->isProfilingCode() &&
node->getOpCodeValue() == TR::treetop &&
node->getFirstChild()->getOpCode().isCall() &&
Expand Down Expand Up @@ -354,15 +366,20 @@ TR_JProfilingValue::lowerCalls()
}

backwardAnalyzedAddressNodesToCheck->empty();
TR::Node *child = node->getFirstChild();
dumpOptDetails(comp(), "%s Replacing profiling placeholder n%dn with value profiling trees\n",
optDetailString(), child->getGlobalIndex());
// Extract the arguments and add the profiling trees
TR::Node *value = child->getFirstChild();
TR_AbstractHashTableProfilerInfo *table = (TR_AbstractHashTableProfilerInfo*) child->getSecondChild()->getAddress();
bool needNullTest = comp()->getSymRefTab()->isNonHelper(child->getSymbolReference(), TR::SymbolReferenceTable::jProfileValueWithNullCHKSymbol);
addProfilingTrees(comp(), cursor, value, table, needNullTest, true, trace());
// Remove the original trees and continue from the tree after the profiling

if (!stopProfiling)
{
TR::Node *child = node->getFirstChild();
dumpOptDetails(comp(), "%s Replacing profiling placeholder n%dn with value profiling trees\n",
optDetailString(), child->getGlobalIndex());
// Extract the arguments and add the profiling trees
TR::Node *value = child->getFirstChild();
TR_AbstractHashTableProfilerInfo *table = (TR_AbstractHashTableProfilerInfo*) child->getSecondChild()->getAddress();
bool needNullTest = comp()->getSymRefTab()->isNonHelper(child->getSymbolReference(), TR::SymbolReferenceTable::jProfileValueWithNullCHKSymbol);
addProfilingTrees(comp(), cursor, value, table, needNullTest, true, trace());
// Remove the original trees and continue from the tree after the profiling
}

TR::TransformUtil::removeTree(comp(), cursor);
if (trace())
comp()->dumpMethodTrees("After Adding Profiling Trees");
Expand Down