Skip to content

Commit 3b587c8

Browse files
committed
JProfiling fix to avoid too many internal pointers
Jprofiling adds control flow to the IL as part of the lowering of the calls to profile values. This control flow splits blocks, and in the process creates temps for values commoned across the split point. If there are enough internal pointers commoned in the method, the lower may end up creating more than the max number of internal pointers allowed, thus causing the compile to fail. This commit keeps track of how many internal pointers are created and avoids lowering any more calls once we have reached a certain threshold. Also added an env var to control this threshold for experimenting in the future. Signed-off-by: Vijay Sundaresan <[email protected]>
1 parent 24f5138 commit 3b587c8

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

runtime/compiler/optimizer/JProfilingValue.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,24 @@ void
317317
TR_JProfilingValue::lowerCalls()
318318
{
319319
TR::TreeTop *cursor = comp()->getStartTree();
320+
bool stopProfiling = false;
320321
TR_BitVector *backwardAnalyzedAddressNodesToCheck = new (comp()->trStackMemory()) TR_BitVector();
321322
while (cursor)
322323
{
323324
TR::Node * node = cursor->getNode();
324325
TR::TreeTop *nextTreeTop = cursor->getNextTreeTop();
326+
327+
int32_t ipMax = comp()->maxInternalPointers()/2;
328+
static const char * ipl = feGetEnv("TR_ProfilingIPLimit");
329+
if (ipl)
330+
{
331+
static const int32_t ipLimit = atoi(ipl);
332+
ipMax = ipLimit;
333+
}
334+
335+
if (!stopProfiling && (comp()->getSymRefTab()->getNumInternalPointers() >= ipMax))
336+
stopProfiling = true;
337+
325338
if (node->isProfilingCode() &&
326339
node->getOpCodeValue() == TR::treetop &&
327340
node->getFirstChild()->getOpCode().isCall() &&
@@ -354,15 +367,20 @@ TR_JProfilingValue::lowerCalls()
354367
}
355368

356369
backwardAnalyzedAddressNodesToCheck->empty();
357-
TR::Node *child = node->getFirstChild();
358-
dumpOptDetails(comp(), "%s Replacing profiling placeholder n%dn with value profiling trees\n",
359-
optDetailString(), child->getGlobalIndex());
360-
// Extract the arguments and add the profiling trees
361-
TR::Node *value = child->getFirstChild();
362-
TR_AbstractHashTableProfilerInfo *table = (TR_AbstractHashTableProfilerInfo*) child->getSecondChild()->getAddress();
363-
bool needNullTest = comp()->getSymRefTab()->isNonHelper(child->getSymbolReference(), TR::SymbolReferenceTable::jProfileValueWithNullCHKSymbol);
364-
addProfilingTrees(comp(), cursor, value, table, needNullTest, true, trace());
365-
// Remove the original trees and continue from the tree after the profiling
370+
371+
if (!stopProfiling)
372+
{
373+
TR::Node *child = node->getFirstChild();
374+
dumpOptDetails(comp(), "%s Replacing profiling placeholder n%dn with value profiling trees\n",
375+
optDetailString(), child->getGlobalIndex());
376+
// Extract the arguments and add the profiling trees
377+
TR::Node *value = child->getFirstChild();
378+
TR_AbstractHashTableProfilerInfo *table = (TR_AbstractHashTableProfilerInfo*) child->getSecondChild()->getAddress();
379+
bool needNullTest = comp()->getSymRefTab()->isNonHelper(child->getSymbolReference(), TR::SymbolReferenceTable::jProfileValueWithNullCHKSymbol);
380+
addProfilingTrees(comp(), cursor, value, table, needNullTest, true, trace());
381+
// Remove the original trees and continue from the tree after the profiling
382+
}
383+
366384
TR::TransformUtil::removeTree(comp(), cursor);
367385
if (trace())
368386
comp()->dumpMethodTrees("After Adding Profiling Trees");

0 commit comments

Comments
 (0)