Skip to content

Commit

Permalink
Disable PPC TOC if TR_DisableTOC option is set
Browse files Browse the repository at this point in the history
This commit makes the allocateChunk and lookup methods
inside the TR_PPCTableOfConstants class return PTOC_FULL_INDEX
if the TR_DisableTOC compiler option is set. Doing so will
prevent the power code generator from ever generating
code that uses the TOC, effectively disabling the TOC. Adding this
option here allows downstream projects to easily disable TOC when
needed.

Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
  • Loading branch information
dchopra001 committed Dec 3, 2019
1 parent 7ea1fec commit 78dfb26
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions compiler/p/codegen/OMRConstantDataSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int32_t OMR::ConstantDataSnippet::addConstantRequest(void *v,
{
fcursor = new (_cg->trHeapMemory()) PPCConstant<float>(_cg, fin.fvalue);
_floatConstants.add(fcursor);
if (TR::Compiler->target.is64Bit() && !comp->getOption(TR_DisableTOC))
if (TR::Compiler->target.is64Bit())
{
ret = TR_PPCTableOfConstants::lookUp(fin.fvalue, _cg);
}
Expand Down Expand Up @@ -110,7 +110,7 @@ int32_t OMR::ConstantDataSnippet::addConstantRequest(void *v,
{
dcursor = new (_cg->trHeapMemory()) PPCConstant<double>(_cg, din.dvalue);
_doubleConstants.add(dcursor);
if (TR::Compiler->target.is64Bit() && !comp->getOption(TR_DisableTOC))
if (TR::Compiler->target.is64Bit())
{
ret = TR_PPCTableOfConstants::lookUp(din.dvalue, _cg);
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/p/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ TR::Instruction *loadConstant(TR::CodeGenerator *cg, TR::Node * node, int64_t va

int32_t offset = PTOC_FULL_INDEX;

bool canUseTOC = (!TR::isJ9() || !isPicSite) &&
!comp->getOption(TR_DisableTOC);
bool canUseTOC = (!TR::isJ9() || !isPicSite);
if (canUseTOC && useTOC)
offset = TR_PPCTableOfConstants::lookUp((int8_t *)&value, sizeof(int64_t), true, 0, cg);

Expand Down
15 changes: 12 additions & 3 deletions compiler/p/codegen/PPCTableOfConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ TR_PPCTableOfConstants::lookUp(int32_t val, struct TR_tocHashEntry *tmplate, int
{
TR::Compilation *comp = cg->comp();

if (comp->compileRelocatableCode() || (comp->getOption(TR_EnableHCR) && comp->getOption(TR_HCRPatchClassPointers)) || comp->getOption(TR_MimicInterpreterFrameShape))
if (comp->compileRelocatableCode() || comp->getOption(TR_DisableTOC) || (comp->getOption(TR_EnableHCR) && comp->getOption(TR_HCRPatchClassPointers)) || comp->getOption(TR_MimicInterpreterFrameShape))
return PTOC_FULL_INDEX;

if (comp->isOptServer())
Expand Down Expand Up @@ -391,7 +391,7 @@ int32_t TR_PPCTableOfConstants::lookUp(int8_t *name, int32_t len, bool isAddr, i
struct TR_tocHashEntry localEntry;
int32_t val, offsetInSlot;

if (comp->compileRelocatableCode() || (comp->getOption(TR_EnableHCR) && comp->getOption(TR_HCRPatchClassPointers)))
if (comp->compileRelocatableCode() || comp->getOption(TR_DisableTOC) || (comp->getOption(TR_EnableHCR) && comp->getOption(TR_HCRPatchClassPointers)))
return PTOC_FULL_INDEX;

if (comp->isOptServer())
Expand Down Expand Up @@ -430,6 +430,9 @@ int32_t TR_PPCTableOfConstants::lookUp(double dvalue, TR::CodeGenerator *cg)
return PTOC_FULL_INDEX;
}

if (comp->getOption(TR_DisableTOC))
return PTOC_FULL_INDEX;

struct TR_tocHashEntry localEntry;
int32_t offsetInSlot, val, tindex;
int8_t seed[8] = {'U', 'p', 'E', 'd', 'G', 'a', 'M', 'e'};
Expand All @@ -456,6 +459,9 @@ int32_t TR_PPCTableOfConstants::lookUp(float fvalue, TR::CodeGenerator *cg)
return PTOC_FULL_INDEX;
}

if (comp->getOption(TR_DisableTOC))
return PTOC_FULL_INDEX;

struct TR_tocHashEntry localEntry;
intptrj_t entryVal = 0;
int32_t offsetInSlot, val, tindex;
Expand Down Expand Up @@ -484,6 +490,9 @@ int32_t TR_PPCTableOfConstants::lookUp(TR::SymbolReference *symRef, TR::CodeGene
return PTOC_FULL_INDEX;
}

if (comp->getOption(TR_DisableTOC))
return PTOC_FULL_INDEX;

TR::StaticSymbol *sym = symRef->getSymbol()->castToStaticSymbol();
intptrj_t addr = (intptrj_t)sym->getStaticAddress();
int32_t nlen, tindex;
Expand Down Expand Up @@ -559,7 +568,7 @@ int32_t TR_PPCTableOfConstants::allocateChunk(uint32_t numEntries, TR::CodeGener
{
TR_PPCTableOfConstants *tocManagement = toPPCTableOfConstants(TR_PersistentMemory::getNonThreadSafePersistentInfo()->getPersistentTOC());

if (tocManagement == NULL || cg->comp()->compileRelocatableCode() || (cg->comp()->getOption(TR_EnableHCR) && cg->comp()->getOption(TR_HCRPatchClassPointers)))
if (tocManagement == NULL || cg->comp()->getOption(TR_DisableTOC) || cg->comp()->compileRelocatableCode() || (cg->comp()->getOption(TR_EnableHCR) && cg->comp()->getOption(TR_HCRPatchClassPointers)))
return PTOC_FULL_INDEX;

if (grabMonitor)
Expand Down

0 comments on commit 78dfb26

Please sign in to comment.