Skip to content

Commit

Permalink
Reformat performProcessRelocationsPhase function
Browse files Browse the repository at this point in the history
The indentation in it's current state is very confusing [1], and at
first sight one may think the:

```
     if (comp->getCurrentMethod() == NULL)
        {
        comp->getMethodSymbol()->setMethodAddress(cg->getBinaryBufferStart());
        }
```

piece of code is guarded by the `if (cg->getAheadOfTimeCompile() &&`
check, which is what I first thought, but upon a more careful
inspection the indentation was hiding this is not the case.

[1] https://github.com/eclipse/omr/blob/31db81f3d84a431736ac7a9ff1b3980158fae258/compiler/codegen/OMRCodeGenPhase.cpp#L182-L202

Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
  • Loading branch information
fjeremic committed Mar 6, 2020
1 parent 6e902d5 commit 27349e8
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions compiler/codegen/OMRCodeGenPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,43 +180,44 @@ OMR::CodeGenPhase::performProcessRelocationsPhase(TR::CodeGenerator * cg, TR::Co
}

if (cg->getAheadOfTimeCompile() && (comp->getOption(TR_TraceRelocatableDataCG) || comp->getOption(TR_TraceRelocatableDataDetailsCG) || comp->getOption(TR_TraceReloCG)))
{
traceMsg(comp, "\n<relocatableDataCG>\n");
if (comp->getOption(TR_TraceRelocatableDataDetailsCG)) // verbose output
{
uint8_t * relocatableMethodCodeStart = (uint8_t *)comp->getRelocatableMethodCodeStart();
traceMsg(comp, "Code start = %8x, Method start pc = %x, Method start pc offset = 0x%x\n", relocatableMethodCodeStart, cg->getCodeStart(), cg->getCodeStart() - relocatableMethodCodeStart);
}
cg->getAheadOfTimeCompile()->dumpRelocationData();
traceMsg(comp, "</relocatableDataCG>\n");
}
{
traceMsg(comp, "\n<relocatableDataCG>\n");
if (comp->getOption(TR_TraceRelocatableDataDetailsCG)) // verbose output
{
uint8_t * relocatableMethodCodeStart = (uint8_t *)comp->getRelocatableMethodCodeStart();
traceMsg(comp, "Code start = %8x, Method start pc = %x, Method start pc offset = 0x%x\n", relocatableMethodCodeStart, cg->getCodeStart(), cg->getCodeStart() - relocatableMethodCodeStart);
}
cg->getAheadOfTimeCompile()->dumpRelocationData();
traceMsg(comp, "</relocatableDataCG>\n");
}

if (debug("dumpCodeSizes"))
{
diagnostic("%08d %s\n", cg->getCodeLength(), comp->signature());
}
if (debug("dumpCodeSizes"))
{
diagnostic("%08d %s\n", cg->getCodeLength(), comp->signature());
}

TR_ASSERT(cg->getCodeLength() <= cg->getEstimatedCodeLength(),
"Method length estimate must be conservatively large\n"
" codeLength = %d, estimatedCodeLength = %d \n",
cg->getCodeLength(), cg->getEstimatedCodeLength()
);
TR_ASSERT(cg->getCodeLength() <= cg->getEstimatedCodeLength(),
"Method length estimate must be conservatively large\n"
" codeLength = %d, estimatedCodeLength = %d \n",
cg->getCodeLength(), cg->getEstimatedCodeLength()
);

// also trace the interal stack atlas
cg->getStackAtlas()->close(cg);
// also trace the interal stack atlas
cg->getStackAtlas()->close(cg);

TR::SimpleRegex * regex = comp->getOptions()->getSlipTrap();
if (regex && TR::SimpleRegex::match(regex, comp->getCurrentMethod()))
{
if (cg->comp()->target().is64Bit())
{
setDllSlip((char*)cg->getCodeStart(), (char*)cg->getCodeStart() + cg->getCodeLength(), "SLIPDLL64", comp);
}
else
{
setDllSlip((char*)cg->getCodeStart(), (char*)cg->getCodeStart() + cg->getCodeLength(), "SLIPDLL31", comp);
}
}

TR::SimpleRegex * regex = comp->getOptions()->getSlipTrap();
if (regex && TR::SimpleRegex::match(regex, comp->getCurrentMethod()))
{
if (cg->comp()->target().is64Bit())
{
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getCodeLength(),"SLIPDLL64", comp);
}
else
{
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getCodeLength(),"SLIPDLL31", comp);
}
}
if (comp->getOption(TR_TraceCG) || comp->getOptions()->getTraceCGOption(TR_TraceCGPostBinaryEncoding))
{
const char * title = "Post Relocation Instructions";
Expand Down

0 comments on commit 27349e8

Please sign in to comment.