Skip to content

Commit

Permalink
Merge pull request #7763 from zl-wang/master
Browse files Browse the repository at this point in the history
Fix JNI performance regression
  • Loading branch information
0xdaryl authored Nov 20, 2019
2 parents 4001eaa + 74ada59 commit 240b236
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
17 changes: 17 additions & 0 deletions runtime/compiler/p/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,20 @@ J9::Power::CodeGenerator::insertPrefetchIfNecessary(TR::Node *node, TR::Register
}
}

TR::Linkage *
J9::Power::CodeGenerator::deriveCallingLinkage(TR::Node *node, bool isIndirect)
{
TR::SymbolReference *symRef = node->getSymbolReference();
TR::MethodSymbol *callee = symRef->getSymbol()->castToMethodSymbol();
TR_J9VMBase *fej9 = (TR_J9VMBase *)(self()->fe());

static char * disableDirectNativeCall = feGetEnv("TR_DisableDirectNativeCall");

// Clean-up: the fej9 checking seemed unnecessary
if (!isIndirect && callee->isJNI() && fej9->canRelocateDirectNativeCalls() &&
(node->isPreparedForDirectJNI() ||
(disableDirectNativeCall == NULL && callee->getResolvedMethodSymbol()->canDirectNativeCall())))
return self()->getLinkage(TR_J9JNILinkage);

return self()->getLinkage(callee->getLinkageConvention());
}
2 changes: 2 additions & 0 deletions runtime/compiler/p/codegen/J9CodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class OMR_EXTENSIBLE CodeGenerator : public J9::CodeGenerator

bool inlineDirectCall(TR::Node *node, TR::Register *&resultReg);

TR::Linkage *deriveCallingLinkage(TR::Node *node, bool isIndirect);

bool suppressInliningOfRecognizedMethod(TR::RecognizedMethod method);

bool enableAESInHardwareTransformations();
Expand Down
21 changes: 1 addition & 20 deletions runtime/compiler/p/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13318,25 +13318,9 @@ TR::Register *J9::Power::TreeEvaluator::directCallEvaluator(TR::Node *node, TR::
TR::MethodSymbol *callee = symRef->getSymbol()->castToMethodSymbol();
TR::Linkage *linkage;
TR::Register *returnRegister;
bool doJNIDirectDispatch = false;

TR_J9VMBase *fej9 = (TR_J9VMBase *)(cg->fe());

if(callee->isJNI() && callee->getLinkageConvention() != TR_J9JNILinkage)
{
//This needs a cleanup, canRelocateDirectNativeCalls() might go away soon.
//Too many checks here, can we simplify this?

static char * disableDirectNativeCall = feGetEnv("TR_DisableDirectNativeCall");
doJNIDirectDispatch = fej9->canRelocateDirectNativeCalls() &&
(node->isPreparedForDirectJNI() ||
(disableDirectNativeCall == NULL && callee->getResolvedMethodSymbol()->canDirectNativeCall()));

}

if (!cg->inlineDirectCall(node, returnRegister))
{
TR::SymbolReference *symRef = node->getSymbolReference();
TR::SymbolReferenceTable *symRefTab = cg->comp()->getSymRefTab();

// Non-helpers supported by code gen. are expected to be inlined
Expand All @@ -13347,10 +13331,7 @@ TR::Register *J9::Power::TreeEvaluator::directCallEvaluator(TR::Node *node, TR::
symRefTab->getNonHelperSymbol(symRef));
}

if(doJNIDirectDispatch)
linkage = cg->getLinkage(TR_J9JNILinkage);
else
linkage = cg->getLinkage(callee->getLinkageConvention());
linkage = cg->deriveCallingLinkage(node, false);
returnRegister = linkage->buildDirectDispatch(node);
}

Expand Down

0 comments on commit 240b236

Please sign in to comment.