Skip to content

Commit

Permalink
Be more confident about single interface implementer profiled guards
Browse files Browse the repository at this point in the history
These guards used to be nop guards. They no longer are, but only because
certain kinds of bytecode are technically allowed to be loaded. Bytecode
that is problematic in this way should be exceedingly rare though, so
treat these guards more like the nop guards we used to have by marking
the taken side cold and by making sure to allow privatized argument
rematerialization.
  • Loading branch information
jdmpapin committed Aug 24, 2022
1 parent b647551 commit a628c77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -2847,7 +2847,7 @@ TR_MultipleCallTargetInliner::eliminateTailRecursion(
backEdge = TR::CFGEdge::createEdge(gotoBlock, branchDestination, trMemory());
callerCFG->addEdge(backEdge);
callerCFG->removeEdge(origEdge);
if (guard->_kind == TR_ProfiledGuard)
if (guard->_kind == TR_ProfiledGuard && !guard->_forceTakenSideCold)
{
if (block->getFrequency() < 0)
block2->setFrequency(block->getFrequency());
Expand Down Expand Up @@ -6784,7 +6784,11 @@ TR_J9InlinerPolicy::suitableForRemat(TR::Compilation *comp, TR::Node *callNode,

bool suitableForRemat = true;
TR_AddressInfo *valueInfo = static_cast<TR_AddressInfo*>(TR_ValueProfileInfoManager::getProfiledValueInfo(callNode, comp, AddressInfo));
if (guard->isHighProbablityProfiledGuard())
if (guard->_forceTakenSideCold)
{
// remat ok
}
else if (guard->isHighProbablityProfiledGuard())
{
if (comp->getMethodHotness() <= warm && comp->getPersistentInfo()->getJitState() == STARTUP_STATE)
{
Expand Down
14 changes: 14 additions & 0 deletions runtime/compiler/optimizer/J9Inliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,20 @@ bool TR_J9InterfaceCallSite::findCallSiteTargetImpl(TR_CallStack *callStack, TR_
new (comp()->trHeapMemory()) TR_VirtualGuardSelection(
kind, testType, thisClass);

if (kind == TR_ProfiledGuard)
{
// Almost all bytecode would pass type checking even including
// interface types. So even though this can't be a nop guard
// (because verification doesn't check interface types), treat it
// as much like a nop guard as possible. In particular, this will
// ensure that the block containing the cold call is actually
// marked cold, and ensure that priv. arg remat is allowed.
guard->_forceTakenSideCold = true;

// It is still a high-probability profiled guard...
guard->setIsHighProbablityProfiledGuard();
}

addTarget(
comp()->trMemory(),
inliner,
Expand Down

0 comments on commit a628c77

Please sign in to comment.