Skip to content

Commit

Permalink
Use entryPointFromCompiledMethod linkage API for recursive calls
Browse files Browse the repository at this point in the history
Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Oct 20, 2020
1 parent 72240e2 commit f9df260
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
8 changes: 3 additions & 5 deletions compiler/arm/codegen/ARMBinaryEncoding.cpp
Expand Up @@ -23,6 +23,7 @@
#include "codegen/CodeGenerator.hpp"
#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "codegen/Linkage.hpp"
#include "codegen/Relocation.hpp"
#include "codegen/Machine.hpp"
#include "arm/codegen/ARMInstruction.hpp"
Expand Down Expand Up @@ -267,11 +268,8 @@ uint8_t *TR::ARMImmSymInstruction::generateBinaryEncoding()

if (comp->isRecursiveMethodTarget(sym))
{
uint32_t jitTojitStart = (uintptr_t) cg()->getCodeStart();

// reach for how many interp->jit argument loads to skip
jitTojitStart += ((*(int32_t *)(jitTojitStart - 4)) >> 16) & 0xFFFF;
*(int32_t *) cursor = (*(int32_t *)cursor) | encodeBranchDistance((uintptr_t)cursor, jitTojitStart);
intptr_t jitToJitStart = cg()->getLinkage()->entryPointFromCompiledMethod();
*(int32_t *) cursor = (*(int32_t *)cursor) | encodeBranchDistance((uintptr_t)cursor, (uint32_t)jitToJitStart);
}
else if (label != NULL)
{
Expand Down
8 changes: 4 additions & 4 deletions compiler/compile/OMRCompilation.cpp
Expand Up @@ -34,6 +34,7 @@
#include "codegen/CodeGenerator.hpp"
#include "env/FrontEnd.hpp"
#include "codegen/Instruction.hpp"
#include "codegen/Linkage.hpp"
#include "codegen/RecognizedMethods.hpp"
#include "compile/Compilation.hpp"
#include "compile/Compilation_inlines.hpp"
Expand Down Expand Up @@ -1250,12 +1251,11 @@ int32_t OMR::Compilation::compile()
#if defined(AIXPPC) || defined(LINUXPPC)
if (self()->getOption(TR_DebugOnEntry))
{
intptr_t jitTojitStart = (intptr_t) self()->cg()->getCodeStart();
jitTojitStart += ((*(int32_t *)(jitTojitStart - 4)) >> 16) & 0x0000ffff;
intptr_t jitToJitStart = self()->cg()->getLinkage()->entryPointFromCompiledMethod();
#if defined(AIXPPC)
self()->getDebug()->setupDebugger((void *)jitTojitStart);
self()->getDebug()->setupDebugger((void *)jitToJitStart);
#else
self()->getDebug()->setupDebugger((void *)jitTojitStart, self()->cg()->getCodeEnd(), false);
self()->getDebug()->setupDebugger((void *)jitToJitStart, self()->cg()->getCodeEnd(), false);
#endif /* defined(AIXPPC) */
}
#elif defined(LINUX) || defined(J9ZOS390) || defined(OMR_OS_WINDOWS)
Expand Down
6 changes: 3 additions & 3 deletions compiler/p/codegen/OMRInstruction.cpp
Expand Up @@ -25,6 +25,7 @@
#include "env/FrontEnd.hpp"
#include "codegen/InstOpCode.hpp"
#include "codegen/Instruction.hpp"
#include "codegen/Linkage.hpp"
#include "codegen/MemoryReference.hpp"
#include "codegen/PPCInstruction.hpp"
#include "codegen/RegisterConstants.hpp"
Expand Down Expand Up @@ -196,9 +197,8 @@ uint8_t *TR::PPCDepImmSymInstruction::generateBinaryEncoding()
{
if (cg()->comp()->isRecursiveMethodTarget(getSymbolReference()->getSymbol()))
{
uint8_t *jitTojitStart = cg()->getCodeStart();
jitTojitStart += ((*(int32_t *)(jitTojitStart - 4)) >> 16) & 0x0000ffff;
distance = (intptr_t)(jitTojitStart - cursor);
intptr_t jitToJitStart = cg()->getLinkage()->entryPointFromCompiledMethod();
distance = jitToJitStart - reinterpret_cast<intptr_t>(cursor);
}
else
{
Expand Down
6 changes: 2 additions & 4 deletions compiler/p/codegen/PPCDebug.cpp
Expand Up @@ -31,6 +31,7 @@ int jitDebugPPC;
#include "codegen/GCRegisterMap.hpp"
#include "codegen/InstOpCode.hpp"
#include "codegen/Instruction.hpp"
#include "codegen/Linkage.hpp"
#include "codegen/Machine.hpp"
#include "codegen/MemoryReference.hpp"
#include "codegen/RealRegister.hpp"
Expand Down Expand Up @@ -419,10 +420,7 @@ TR_Debug::print(TR::FILE *pOutFile, TR::PPCDepImmSymInstruction * instr)
}
else if (targetAddress == 0)
{
uint8_t *jitTojitStart = _cg->getCodeStart();

jitTojitStart += ((*(int32_t *)(jitTojitStart - 4)) >> 16) & 0x0000ffff;
targetAddress = (intptr_t)jitTojitStart;
targetAddress = _cg->getLinkage()->entryPointFromCompiledMethod();
}
else if (_cg->directCallRequiresTrampoline(targetAddress, (intptr_t)cursor))
{
Expand Down
12 changes: 4 additions & 8 deletions compiler/z/codegen/S390Instruction.cpp
Expand Up @@ -2232,12 +2232,8 @@ TR::S390RILInstruction::generateBinaryEncoding()

if (comp->isRecursiveMethodTarget(getTargetSymbol()))
{
// call myself case
uint8_t * jitTojitStart = cg()->getCodeStart();

// Calculate jit-to-jit entry point
jitTojitStart += ((*(int32_t *) (jitTojitStart - 4)) >> 16) & 0x0000ffff;
*(int32_t *) (cursor + 2) = boi(((intptr_t) jitTojitStart - (intptr_t) cursor) / 2);
intptr_t jitToJitStart = cg()->getLinkage()->entryPointFromCompiledMethod();
*(int32_t *) (cursor + 2) = boi((jitToJitStart - (intptr_t) cursor) / 2);
}
else
{
Expand Down Expand Up @@ -5079,7 +5075,7 @@ TR::S390AlignmentNopInstruction::generateBinaryEncoding()
uint32_t nopsOfLength6ToAdd = (_alignment - currentMisalign) / 6;
uint32_t nopsOfLength4ToAdd = ((_alignment - currentMisalign) % 6) / 4;
uint32_t nopsOfLength2ToAdd = (((_alignment - currentMisalign) % 6) % 4) / 2;

if (trace)
traceMsg(cg()->comp(), "Expanding alignment nop %p into %u instructions: [ ", self(), nopsOfLength6ToAdd + nopsOfLength4ToAdd + nopsOfLength2ToAdd);

Expand All @@ -5098,7 +5094,7 @@ TR::S390AlignmentNopInstruction::generateBinaryEncoding()
if (trace)
traceMsg(cg()->comp(), "%p ", nop);
}

for (uint32_t i = 0; i < nopsOfLength6ToAdd; ++i)
{
TR::Instruction *nop = new (cg()->trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 6, getNode(), self(), cg());
Expand Down

0 comments on commit f9df260

Please sign in to comment.