Skip to content

Commit

Permalink
Merge pull request #4944 from jdmpapin/final-invokevirtual-concurrent…
Browse files Browse the repository at this point in the history
…-resolve-v0.13.0

Ensure resolved final methods are called directly
  • Loading branch information
pshipton committed Mar 1, 2019
2 parents d44db0f + d15048c commit 481af61
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions runtime/compiler/ilgen/Walker.cpp
Expand Up @@ -3917,14 +3917,24 @@ TR_J9ByteCodeIlGenerator::genInvokeVirtual(int32_t cpIndex)
else
{
symRef = symRefTab()->findOrCreateVirtualMethodSymbol(_methodSymbol, cpIndex);

// Update method in case getResolvedPossiblyPrivateVirtualMethod()
// returned null originally, but then findOrCreateVirtualMethodSymbol()
// later found the method.
//
// Without doing this, we can fail to set isDirectCall for recognized
// final methods (e.g. Unsafe and JITHelpers methods) where the compiler
// assumes calls are direct.
//
if (!symRef->isUnresolved())
method = symRef->getSymbol()->castToResolvedMethodSymbol()->getResolvedMethod();
}

TR::Symbol * sym = symRef->getSymbol();
bool isDirectCall = false;
if (method != NULL)
{
isDirectCall =
sym->isFinal() ||
symRef->getSymbol()->isFinal() ||
method->isPrivate() ||
(debug("omitVirtualGuard") && !method->virtualMethodIsOverridden());
}
Expand Down

0 comments on commit 481af61

Please sign in to comment.