Skip to content

Commit e3780b7

Browse files
authored
Merge pull request #21875 from r30shah/inlinerIncreaseCutoff
Increase the cutoff to inline interpreted targets
2 parents 8492e6f + d386800 commit e3780b7

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

runtime/compiler/optimizer/J9EstimateCodeSize.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const float TR_J9EstimateCodeSize::CONST_ARG_IN_CALLEE_ADJUSTMENT_FACTOR = 0.75f
5555

5656
#define DEFAULT_FREQ_CUTOFF 40
5757

58+
#define FREQ_CUTOFF_INTERPRETED_HOTANDABOVE 700
59+
60+
#define FREQ_CUTOFF_INTERPRETED_WARM 50
61+
5862
#define DEFAULT_GRACE_INLINING_THRESHOLD 100
5963

6064
#define DEFAULT_ANALYZED_ALLOWANCE_FACTOR 2
@@ -1730,10 +1734,39 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
17301734
}
17311735
else
17321736
{
1737+
// Now check the invocation count for the callee if interpreted.
1738+
bool isInterpretedCallWithLowFrequency = false;
1739+
static bool shouldNotInlineInterpretedMethods = feGetEnv("TR_DisableSkippingInliningOfColdInterpretedMethods") == NULL;
1740+
if (shouldNotInlineInterpretedMethods)
1741+
{
1742+
static bool includeWarmCompilationsAsWell = feGetEnv("TR_EnableSkippingInliningOfColdInterpretedMethodsInWarm") != NULL;
1743+
if (targetCallee->_calleeMethod->isInterpretedForHeuristics() && !comp()->fej9()->compiledAsDLTBefore(targetCallee->_calleeMethod))
1744+
{
1745+
if (comp()->getMethodHotness() > warm)
1746+
{
1747+
static const char *cutOffHotAndAbove = feGetEnv("TR_FreqCutOffForInterpretedCalleeInHotAndAbove");
1748+
static const int32_t cutOffFreqForHotAndAbove = cutOffHotAndAbove ? atoi(cutOffHotAndAbove) : FREQ_CUTOFF_INTERPRETED_HOTANDABOVE;
1749+
isInterpretedCallWithLowFrequency = currentBlock->getFrequency() < cutOffFreqForHotAndAbove;
1750+
}
1751+
else if (includeWarmCompilationsAsWell && comp()->getMethodHotness() == warm)
1752+
{
1753+
static const char *cutOffForWarm = feGetEnv("TR_FreqCutOffForInterpretedCalleeInWarm");
1754+
static const int32_t cutOffFreqForWarm = cutOffForWarm ? atoi(cutOffForWarm) : FREQ_CUTOFF_INTERPRETED_WARM;
1755+
isInterpretedCallWithLowFrequency = currentBlock->getFrequency() < cutOffFreqForWarm;
1756+
}
1757+
heuristicTrace(tracer(),"Depth %d: callee %s is interpreted and isInterpretedCallWithLowFrequency = %s.",_recursionDepth,calleeName,isInterpretedCallWithLowFrequency ? "true" : "false");
1758+
}
1759+
}
1760+
17331761
static const char *fc = feGetEnv("TR_FrequencyCutoff");
17341762
static const int32_t freqCutoff = fc ? atoi(fc) : DEFAULT_FREQ_CUTOFF;
17351763

1736-
bool isColdCall = (((comp()->getMethodHotness() <= warm) && profileManager->isColdCall(targetCallee->_calleeMethod->getPersistentIdentifier(), calltarget->_calleeMethod->getPersistentIdentifier(), i, comp())) || (currentBlock->getFrequency() < freqCutoff)) && !_inliner->alwaysWorthInlining(targetCallee->_calleeMethod, NULL);
1764+
bool isColdCall = ((comp()->getMethodHotness() <= warm \
1765+
&& profileManager->isColdCall(targetCallee->_calleeMethod->getPersistentIdentifier(),
1766+
calltarget->_calleeMethod->getPersistentIdentifier(), i, comp())) \
1767+
|| currentBlock->getFrequency() < freqCutoff \
1768+
|| isInterpretedCallWithLowFrequency) \
1769+
&& !(_inliner->alwaysWorthInlining(targetCallee->_calleeMethod, NULL));
17371770

17381771
if (coldCallInfoIsReliable && isColdCall)
17391772
{

0 commit comments

Comments
 (0)