Skip to content

Commit 7bed029

Browse files
authored
Merge pull request #21913 from nbhuiyan/nph-param-load
Enable peeking ILGen for param loads using NeedsPeekingHeuristic
2 parents 19435ca + 325f501 commit 7bed029

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

runtime/compiler/optimizer/InlinerTempForJ9.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6846,9 +6846,17 @@ static bool treeMatchesCallSite(TR::TreeTop* tt, TR::ResolvedMethodSymbol* calle
68466846

68476847

68486848

6849-
//make sure classes are compatible
6849+
// Make sure classes are compatible, but only for non-LambdaForm generated methods, as the class lookup
6850+
// for LF generated methods would result in failure to obtain the classes, and therefore, can't be checked
6851+
// for compatibility. It is safe to skip this check for LF methods, as the name and signature matching performed
6852+
// below would return false if call node and call site LF method classes do not match.
6853+
//
6854+
bool isLFMethod = false;
6855+
if (callsite->_initialCalleeMethod
6856+
&& TR::comp()->fej9()->isLambdaFormGeneratedMethod(callsite->_initialCalleeMethod))
6857+
isLFMethod = true;
68506858

6851-
if (!callNodeClass || !callSiteClass || callerSymbol->getResolvedMethod()->fe()->isInstanceOf (callNodeClass, callSiteClass, true, true, true) != TR_yes)
6859+
if (!isLFMethod && (!callNodeClass || !callSiteClass || callerSymbol->getResolvedMethod()->fe()->isInstanceOf (callNodeClass, callSiteClass, true, true, true) != TR_yes))
68526860
{
68536861
if (tracer->heuristicLevel())
68546862
{

runtime/compiler/optimizer/J9EstimateCodeSize.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ class NeedsPeekingHeuristic
172172
{
173173
if (_bci.bcIndex() - _loadIndices[i] <= _distance)
174174
{
175-
heuristicTraceIfTracerIsNotNull(_tracer, "there is a parm load at %d which is within %d of a call at %d", _loadIndices[i], _distance, _bci.bcIndex());
175+
heuristicTraceIfTracerIsNotNull(_tracer, "There is a parm load at %d which is within %d of a call at %d. Setting needs peeking to true and skipping any further param load check.", _loadIndices[i], _distance, _bci.bcIndex());
176+
setNeedsPeekingToTrue();
177+
break;
176178
}
177179
}
178180
};
@@ -184,7 +186,8 @@ class NeedsPeekingHeuristic
184186

185187
void processByteCode()
186188
{
187-
if (!_hasArgumentsInfo)
189+
static const bool disableNPH = feGetEnv("TR_disableNPH") != NULL;
190+
if (disableNPH || !_hasArgumentsInfo || doPeeking())
188191
return;
189192
TR_J9ByteCode bc = _bci.current();
190193
int slotIndex = -1;
@@ -1380,8 +1383,8 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
13801383
const static bool debugMHInlineWithOutPeeking = feGetEnv("TR_DebugMHInlineWithOutPeeking") ? true: false;
13811384
bool mhInlineWithPeeking = comp()->getOption(TR_DisableMHInlineWithoutPeeking);
13821385
const static bool disableMethodHandleInliningAfterFirstPass = feGetEnv("TR_DisableMethodHandleInliningAfterFirstPass") ? true: false;
1383-
bool inlineArchetypeSpecimen = calltarget->_calleeMethod->convertToMethod()->isArchetypeSpecimen() &&
1384-
(!disableMethodHandleInliningAfterFirstPass || _inliner->firstPass());
1386+
bool isArchetypeSpecimen = calltarget->_calleeMethod->convertToMethod()->isArchetypeSpecimen();
1387+
bool inlineArchetypeSpecimen = isArchetypeSpecimen && (!disableMethodHandleInliningAfterFirstPass || _inliner->firstPass());
13851388
bool inlineLambdaFormGeneratedMethod = comp()->fej9()->isLambdaFormGeneratedMethod(calltarget->_calleeMethod) &&
13861389
(!disableMethodHandleInliningAfterFirstPass || _inliner->firstPass());
13871390

@@ -1392,11 +1395,11 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
13921395

13931396
TR::CFG &cfg = processBytecodeAndGenerateCFG(calltarget, cfgRegion, bci, nph, blocks, flags);
13941397

1395-
// No need to peek LF methods, as we'll always interprete the method with state in order to propagate object info
1396-
// through bytecodes to find call targets
1398+
// No need to peek LF methods, as we'll always interpret the method with state in order to propagate object info
1399+
// through bytecodes to find call targets.
13971400
if (!inlineLambdaFormGeneratedMethod &&
1398-
((nph.doPeeking() && recurseDown) ||
1399-
(inlineArchetypeSpecimen && mhInlineWithPeeking)))
1401+
((nph.doPeeking() && !isArchetypeSpecimen && recurseDown) ||
1402+
(inlineArchetypeSpecimen && mhInlineWithPeeking)))
14001403
{
14011404

14021405
heuristicTrace(tracer(), "*** Depth %d: ECS CSI -- needsPeeking is true for calltarget %p",

0 commit comments

Comments
 (0)