Skip to content

Commit

Permalink
Replace calls to indexedTrampolineLookup with findHelperTrampoline
Browse files Browse the repository at this point in the history
Ask the CodeCacheManager directly for the helper trampoline address.

Change the return type of `CodeCacheManager::findHelperTrampoline` to an `intptrj_t`.

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Feb 16, 2019
1 parent 6e7568d commit 1609a0b
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion compiler/arm/codegen/ARMBinaryEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "env/CHTable.hpp"
#endif
#include "env/CompilerEnv.hpp"
#include "runtime/CodeCacheManager.hpp"

void OMR::ARM::Instruction::generateConditionBinaryEncoding(uint8_t *instructionStart)
{
Expand Down Expand Up @@ -73,7 +74,7 @@ uint32_t encodeHelperBranch(bool isBranchAndLink, TR::SymbolReference *symRef, u

if (cg->directCallRequiresTrampoline(target, (intptrj_t)cursor))
{
target = cg->fe()->indexedTrampolineLookup(symRef->getReferenceNumber(), (void *)cursor);
target = TR::CodeCacheManager::instance()->findHelperTrampoline(symRef->getReferenceNumber(), (void *)cursor);

TR_ASSERT_FATAL(TR::Compiler->target.cpu.isTargetWithinBranchImmediateRange(target, (intptrj_t)cursor),
"Target address is out of range");
Expand Down
3 changes: 2 additions & 1 deletion compiler/arm/codegen/ARMDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int jitDebugARM;
#include "env/jittypes.h"
#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "runtime/CodeCacheManager.hpp"

#ifdef J9_PROJECT_SPECIFIC
#include "arm/codegen/ARMHelperCallSnippet.hpp"
Expand Down Expand Up @@ -830,7 +831,7 @@ TR_Debug::printARMHelperBranch(TR::SymbolReference *symRef, uint8_t *bufferPos,
int32_t refNum = symRef->getReferenceNumber();
if (refNum < TR_ARMnumRuntimeHelpers)
{
target = _comp->fe()->indexedTrampolineLookup(refNum, (void *)bufferPos);
target = TR::CodeCacheManager::instance()->findHelperTrampoline(refNum, (void *)bufferPos);
info = " through trampoline";
}
else if (*((uintptr_t*)bufferPos) == 0xe28fe004) // This is a JNI method
Expand Down
3 changes: 2 additions & 1 deletion compiler/p/codegen/OMRInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "il/Block.hpp"
#include "il/ILOpCodes.hpp"
#include "il/Node.hpp"
#include "runtime/CodeCacheManager.hpp"

namespace TR { class PPCConditionalBranchInstruction; }
namespace TR { class PPCDepImmInstruction; }
Expand Down Expand Up @@ -247,7 +248,7 @@ uint8_t *TR::PPCDepImmSymInstruction::generateBinaryEncoding()
int32_t refNum = getSymbolReference()->getReferenceNumber();
if (refNum < TR_PPCnumRuntimeHelpers)
{
targetAddress = cg()->fe()->indexedTrampolineLookup(refNum, (void *)cursor);
targetAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(refNum, (void *)cursor);
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions compiler/p/codegen/PPCDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int jitDebugPPC;
#include "p/codegen/PPCOutOfLineCodeSection.hpp"
#include "codegen/Snippet.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"

#ifdef J9_PROJECT_SPECIFIC
Expand Down Expand Up @@ -394,7 +395,7 @@ TR_Debug::isBranchToTrampoline(TR::SymbolReference *symRef, uint8_t *cursor, int

if (_cg->directCallRequiresTrampoline(methodAddress, (intptrj_t)cursor))
{
methodAddress = _comp->fe()->indexedTrampolineLookup(symRef->getReferenceNumber(), (void *)cursor);
methodAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(symRef->getReferenceNumber(), (void *)cursor);
requiresTrampoline = true;
}

Expand Down Expand Up @@ -430,7 +431,7 @@ TR_Debug::print(TR::FILE *pOutFile, TR::PPCDepImmSymInstruction * instr)
int32_t refNum = instr->getSymbolReference()->getReferenceNumber();
if (refNum < TR_PPCnumRuntimeHelpers)
{
targetAddress = _comp->fe()->indexedTrampolineLookup(refNum, (void *)cursor);
targetAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(refNum, (void *)cursor);
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion compiler/p/codegen/PPCHelperCallSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "il/symbol/MethodSymbol.hpp"
#include "infra/Assert.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"

uint8_t *TR::PPCHelperCallSnippet::emitSnippetBody()
Expand Down Expand Up @@ -104,7 +105,7 @@ uint8_t *TR::PPCHelperCallSnippet::genHelperCall(uint8_t *buffer)

if (cg()->directCallRequiresTrampoline(helperAddress, (intptrj_t)buffer))
{
helperAddress = cg()->comp()->fe()->indexedTrampolineLookup(getDestination()->getReferenceNumber(), (void *)buffer);
helperAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(getDestination()->getReferenceNumber(), (void *)buffer);

TR_ASSERT_FATAL(TR::Compiler->target.cpu.isTargetWithinIFormBranchRange(helperAddress, (intptrj_t)buffer),
"Helper address is out of range");
Expand Down
3 changes: 2 additions & 1 deletion compiler/x/codegen/HelperCallSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "il/symbol/StaticSymbol.hpp"
#include "infra/Assert.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "x/codegen/RestartSnippet.hpp"
#include "env/IO.hpp"
Expand Down Expand Up @@ -491,7 +492,7 @@ int32_t TR::X86HelperCallSnippet::branchDisplacementToHelper(

if (cg->directCallRequiresTrampoline(helperAddress, (intptrj_t)callInstructionAddress))
{
helperAddress = cg->fe()->indexedTrampolineLookup(helper->getReferenceNumber(), (void *)(callInstructionAddress+1));
helperAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(helper->getReferenceNumber(), (void *)(callInstructionAddress+1));

TR_ASSERT_FATAL(TR::Compiler->target.cpu.isTargetWithinRIPRange(helperAddress, nextInstructionAddress),
"Local helper trampoline should be reachable directly");
Expand Down
3 changes: 2 additions & 1 deletion compiler/x/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "optimizer/RegisterCandidate.hpp"
#include "ras/Debug.hpp"
#include "ras/DebugCounter.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "x/codegen/DataSnippet.hpp"
#include "x/codegen/OutlinedInstructions.hpp"
#include "x/codegen/FPTreeEvaluator.hpp"
Expand Down Expand Up @@ -2334,7 +2335,7 @@ int32_t OMR::X86::CodeGenerator::branchDisplacementToHelperOrTrampoline(

if (self()->directCallRequiresTrampoline(helperAddress, (intptrj_t)nextInstructionAddress))
{
helperAddress = self()->fe()->indexedTrampolineLookup(helper->getReferenceNumber(), (void *)(nextInstructionAddress-4));
helperAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(helper->getReferenceNumber(), (void *)(nextInstructionAddress-4));

TR_ASSERT_FATAL(TR::Compiler->target.cpu.isTargetWithinRIPRange(helperAddress, (intptrj_t)nextInstructionAddress),
"Local helper trampoline should be reachable directly");
Expand Down
3 changes: 2 additions & 1 deletion compiler/x/codegen/X86BinaryEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "infra/List.hpp"
#include "ras/Debug.hpp"
#include "ras/DebugCounter.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "x/codegen/X86Instruction.hpp"
#include "x/codegen/X86Ops.hpp"
Expand Down Expand Up @@ -1304,7 +1305,7 @@ uint8_t* TR::X86ImmSymInstruction::generateOperand(uint8_t* cursor)
if (isTrampolineRequired)
{
// TODO:AMD64: Consider AOT ramifications
targetAddress = cg()->fe()->indexedTrampolineLookup(getSymbolReference()->getReferenceNumber(), (void *)cursor);
targetAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(getSymbolReference()->getReferenceNumber(), (void *)cursor);
}
}
else if (methodSym && methodSym->isJNI() && getNode() && getNode()->isPreparedForDirectJNI())
Expand Down
3 changes: 2 additions & 1 deletion compiler/x/codegen/X86FPConversionSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "il/symbol/LabelSymbol.hpp"
#include "infra/Assert.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "x/codegen/X86Instruction.hpp"

Expand All @@ -63,7 +64,7 @@ uint8_t *TR::X86FPConversionSnippet::emitCallToConversionHelper(uint8_t *buffer)
intptrj_t helperAddress = (intptrj_t)getHelperSymRef()->getMethodAddress();
if (cg()->directCallRequiresTrampoline(helperAddress, callInstructionAddress))
{
helperAddress = cg()->fe()->indexedTrampolineLookup(getHelperSymRef()->getReferenceNumber(), (void *)buffer);
helperAddress = TR::CodeCacheManager::instance()->findHelperTrampoline(getHelperSymRef()->getReferenceNumber(), (void *)buffer);

TR_ASSERT_FATAL(TR::Compiler->target.cpu.isTargetWithinRIPRange(helperAddress, nextInstructionAddress),
"Local helper trampoline must be reachable directly");
Expand Down
3 changes: 2 additions & 1 deletion compiler/z/codegen/OMRSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "il/symbol/MethodSymbol.hpp"
#include "infra/Assert.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "z/codegen/CallSnippet.hpp"
#include "z/codegen/S390HelperCallSnippet.hpp"
Expand Down Expand Up @@ -144,7 +145,7 @@ OMR::Z::Snippet::generatePICBinary(TR::CodeGenerator * cg, uint8_t * cursor, TR:
{
// Destination is beyond our reachable jump distance, we'll find the
// trampoline.
destAddr = cg->fe()->indexedTrampolineLookup(glueRef->getReferenceNumber(), (void *)cursor);
destAddr = TR::CodeCacheManager::instance()->findHelperTrampoline(glueRef->getReferenceNumber(), (void *)cursor);
self()->setUsedTrampoline(true);
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/z/codegen/S390HelperCallSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "il/symbol/MethodSymbol.hpp"
#include "infra/Assert.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "z/codegen/CallSnippet.hpp"

Expand Down Expand Up @@ -116,7 +117,7 @@ TR::S390HelperCallSnippet::emitSnippetBody()
{
if (cg()->directCallRequiresTrampoline(destAddr, branchInstructionStartAddress))
{
destAddr = cg()->fe()->indexedTrampolineLookup(helperSymRef->getReferenceNumber(), (void *)cursor);
destAddr = TR::CodeCacheManager::instance()->findHelperTrampoline(helperSymRef->getReferenceNumber(), (void *)cursor);
this->setUsedTrampoline(true);

// We clobber rEP if we take a trampoline. Update our register map if necessary.
Expand Down
3 changes: 2 additions & 1 deletion compiler/z/codegen/S390Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "infra/CfgEdge.hpp"
#include "optimizer/Structure.hpp"
#include "ras/Debug.hpp"
#include "runtime/CodeCacheManager.hpp"
#include "runtime/Runtime.hpp"
#include "z/codegen/EndianConversion.hpp"
#include "z/codegen/S390GenerateInstructions.hpp"
Expand Down Expand Up @@ -1977,7 +1978,7 @@ TR::S390RILInstruction::adjustCallOffsetWithTrampoline(int32_t offset, uint8_t *
printf("Target: %p, Cursor: %p, Our Reference # is: %d\n",getTargetPtr(),(uintptrj_t)currentInst,getSymbolReference()->getReferenceNumber());
#endif
if (getSymbolReference()->getReferenceNumber() < TR_S390numRuntimeHelpers)
targetAddr = cg()->fe()->indexedTrampolineLookup(getSymbolReference()->getReferenceNumber(), (void *)currentInst);
targetAddr = TR::CodeCacheManager::instance()->findHelperTrampoline(getSymbolReference()->getReferenceNumber(), (void *)currentInst);
else
targetAddr = cg()->fe()->methodTrampolineLookup(cg()->comp(), getSymbolReference(), (void *)currentInst);

Expand Down

0 comments on commit 1609a0b

Please sign in to comment.