Skip to content

Commit e2d1058

Browse files
committed
Fix inliner size scaling based on number of calls
When scaling the estimated size of a candidate for inlining based on frequency and the number of estimated calls nested in the candidate, the calculation inadvertently ignores the number of estimated calls and uses a value derived from the frequency twice. This doesn't appear to be the intention of the code at all. Signed-off-by: Younes Manton <ymanton@ca.ibm.com>
1 parent b396023 commit e2d1058

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

runtime/compiler/optimizer/InlinerTempForJ9.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,9 +4147,11 @@ int32_t TR_MultipleCallTargetInliner::scaleBasedOnFrequency(TR_CallTarget *callt
41474147
float factor = (float)(maxFrequency - frequency) / (float)maxFrequency;
41484148
factor = std::max(factor, 0.4f);
41494149

4150-
float avgMethodSize = (float)size / (float)ecs->getNumOfEstimatedCalls();
4150+
// getNumOfEstimatedCalls is 0 if the the call target doesn't have any nested calls and
4151+
// avgMethodSize should equal size in that case, so we add 1.
4152+
float avgMethodSize = (float)size / (float)(1 + ecs->getNumOfEstimatedCalls());
41514153
float numCallsFactor = (float)(avgMethodSize) / 110.0f;
4152-
numCallsFactor = std::max(factor, 0.1f);
4154+
numCallsFactor = std::max(numCallsFactor, 0.1f);
41534155

41544156
if (size > 100) {
41554157
size = (int)((float)size * factor * numCallsFactor);

0 commit comments

Comments
 (0)