Skip to content

Commit

Permalink
Add a new symbol flag to mark addresses within method bounds
Browse files Browse the repository at this point in the history
A new flag StaticAddressWithinMethodBounds indicates that an address
stored in a static symbol is inside method bounds, and can be
accessed using RIP addressing during an out-of-process compilation.

Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
  • Loading branch information
dmitry-ten committed Nov 9, 2021
1 parent e47b38a commit f797475
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/compile/OMRSymbolReferenceTable.cpp
Expand Up @@ -1226,6 +1226,7 @@ OMR::SymbolReferenceTable::findOrCreateGCRPatchPointSymbolRef()
sym->setStaticAddress(0);
sym->setGCRPatchPoint(); // set the flag
sym->setNotDataAddress();
sym->setStaticAddressWithinMethodBounds();
element(gcrPatchPointSymbol) = new (trHeapMemory()) TR::SymbolReference(self(), gcrPatchPointSymbol, sym);
}
return element(gcrPatchPointSymbol);
Expand All @@ -1241,6 +1242,7 @@ OMR::SymbolReferenceTable::findOrCreateStartPCSymbolRef()
sym->setStaticAddress(0);
sym->setStartPC();
sym->setNotDataAddress();
sym->setStaticAddressWithinMethodBounds();
element(startPCSymbol) = new (trHeapMemory()) TR::SymbolReference(self(), startPCSymbol, sym);
}
return element(startPCSymbol);
Expand Down
4 changes: 4 additions & 0 deletions compiler/il/OMRSymbol.hpp
Expand Up @@ -353,6 +353,9 @@ class OMR_EXTENSIBLE Symbol
inline void setConstantPoolAddress();
inline bool isConstantPoolAddress();

inline void setStaticAddressWithinMethodBounds();
inline bool isStaticAddressWithinMethodBounds();

// flag methods specific to resolved
//
inline bool isJittedMethod();
Expand Down Expand Up @@ -516,6 +519,7 @@ class OMR_EXTENSIBLE Symbol
CountForRecompile = 0x02000000,
RecompilationCounter = 0x01000000,
GCRPatchPoint = 0x00400000,
StaticAddressWithinMethodBounds = 0x00800000, // Address is inside a method body and can be accessed with RIP addressing without relocations

//Only Used by Symbols for which isResolvedMethod is true;
IsJittedMethod = 0x80000000,
Expand Down
13 changes: 13 additions & 0 deletions compiler/il/OMRSymbol_inlines.hpp
Expand Up @@ -595,6 +595,19 @@ OMR::Symbol::setConstantPoolAddress()
_flags.set(ConstantPoolAddress);
}

bool
OMR::Symbol::isStaticAddressWithinMethodBounds()
{
return self()->isStatic() && _flags.testAny(StaticAddressWithinMethodBounds);
}

void
OMR::Symbol::setStaticAddressWithinMethodBounds()
{
TR_ASSERT(self()->isStatic(), "Symbol must be static");
_flags.set(StaticAddressWithinMethodBounds);
}

bool
OMR::Symbol::isConstMethodHandle()
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/x/amd64/codegen/OMRMemoryReference.cpp
Expand Up @@ -298,7 +298,7 @@ bool OMR::X86::AMD64::MemoryReference::needsAddressLoadInstruction(intptr_t next
return true; // If a class gets replaced, it may no longer fit in an immediate
else if (IS_32BIT_SIGNED(displacement))
return false;
else if (cg->comp()->isOutOfProcessCompilation() && sr.getSymbol() && sr.getSymbol()->isStatic() && !sr.getSymbol()->isNotDataAddress())
else if (cg->comp()->isOutOfProcessCompilation() && sr.getSymbol() && sr.getSymbol()->isStatic() && !sr.getSymbol()->isStaticAddressWithinMethodBounds())
return true;
else if (IS_32BIT_RIP(displacement, nextInstructionAddress))
return false;
Expand Down

0 comments on commit f797475

Please sign in to comment.