Skip to content

Commit

Permalink
Merge pull request #4040 from 0xdaryl/noelementprivatization
Browse files Browse the repository at this point in the history
Remove deprecated element privatization from FieldPrivatizer
  • Loading branch information
vijaysun-omr authored Jun 21, 2019
2 parents 7c87422 + c5cd5a5 commit 52ffab0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 282 deletions.
8 changes: 0 additions & 8 deletions compiler/compile/OMRSymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1780,14 +1780,6 @@ OMR::SymbolReferenceTable::findOrCreateTemporaryWithKnowObjectIndex(TR::Resolved
knownObjectIndex);
}

TR::SymbolReference *
OMR::SymbolReferenceTable::createCoDependentTemporary(TR::ResolvedMethodSymbol *owningMethodSymbol, TR::DataType type, bool isInternalPointer, size_t size, TR::Symbol *coDependent, int32_t offset)
{
TR::SymbolReference *tempSymRef = findOrCreateAutoSymbol(owningMethodSymbol, offset, type, true, isInternalPointer, false, false, size);
return tempSymRef;
}


TR::SymbolReference *
OMR::SymbolReferenceTable::findOrCreatePendingPushTemporary(
TR::ResolvedMethodSymbol * owningMethodSymbol, int32_t slot, TR::DataType type, size_t size)
Expand Down
2 changes: 0 additions & 2 deletions compiler/compile/OMRSymbolReferenceTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ class SymbolReferenceTable
TR::SymbolReference * findOrCreateAutoSymbol(TR::ResolvedMethodSymbol * owningMethodSymbol, int32_t slot, TR::DataType, bool isReference = true,
bool isInternalPointer = false, bool reuseAuto = true, bool isAdjunct = false, size_t size = 0);
TR::SymbolReference * createTemporary(TR::ResolvedMethodSymbol * owningMethodSymbol, TR::DataType, bool isInternalPointer = false, size_t size = 0);
TR::SymbolReference * createCoDependentTemporary(TR::ResolvedMethodSymbol * owningMethodSymbol, TR::DataType, bool isInternalPointer, size_t size,
TR::Symbol *coDependent, int32_t offset);
TR::SymbolReference * findStaticSymbol(TR_ResolvedMethod * owningMethod, int32_t cpIndex, TR::DataType);

// --------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"enableDynamicSamplingWindow", "M\t", RESET_OPTION_BIT(TR_DisableDynamicSamplingWindow), "F", NOT_IN_SUBSET},
{"enableEarlyCompilationDuringIdleCpu","M\t", SET_OPTION_BIT(TR_EnableEarlyCompilationDuringIdleCpu), "F", NOT_IN_SUBSET},
{"enableEBBCCInfo", "C\tenable tracking CCInfo in Extended Basic Block scope", SET_OPTION_BIT(TR_EnableEBBCCInfo), "F"},
{"enableElementPrivatization", "O\tenable privatization of stack declared elements accessed by const indices\n", SET_OPTION_BIT(TR_EnableElementPrivatization), "F"},
{"enableExecutableELFGeneration", "I\tenable the generation of executable ELF files", SET_OPTION_BIT(TR_EmitExecutableELFFile), "F", NOT_IN_SUBSET},
{"enableExpensiveOptsAtWarm", "O\tenable store sinking and OSR at warm and below", SET_OPTION_BIT(TR_EnableExpensiveOptsAtWarm), "F" },
{"enableFastHotRecompilation", "R\ttry to recompile at hot sooner", SET_OPTION_BIT(TR_EnableFastHotRecompilation), "F"},
Expand Down
2 changes: 1 addition & 1 deletion compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ enum TR_CompilationOptions
// Option word 6
//
TR_EnableAggressiveLoopVersioning = 0x00000020 + 6,
TR_EnableElementPrivatization = 0x00000040 + 6,
// Available = 0x00000040 + 6,
TR_CompileBit = 0x00000080 + 6,
TR_WaitBit = 0x00000100 + 6,
TR_DisableZ14 = 0x00000200 + 6,
Expand Down
198 changes: 1 addition & 197 deletions compiler/optimizer/FieldPrivatizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#include "compile/SymbolReferenceTable.hpp"
#include "control/Options.hpp"
#include "control/Options_inlines.hpp"
#include "cs2/allocator.h"
#include "cs2/bitvectr.h"
#include "cs2/hashtab.h"
#include "cs2/sparsrbit.h"
#include "env/StackMemoryRegion.hpp"
#include "env/TRMemory.hpp"
#include "il/AliasSetInterface.hpp"
Expand Down Expand Up @@ -76,9 +72,7 @@ TR_FieldPrivatizer::TR_FieldPrivatizer(TR::OptimizationManager *manager)
_privatizedFieldSymRefs(manager->trMemory(), stackAlloc),
_privatizedRegCandidates(manager->trMemory()),
_appendCalls(manager->trMemory()),
_privatizedFieldNodes(manager->trMemory()),
_epCandidates(getTypedAllocator<EPCandidate>(manager->allocator())),
_epValueNumbers(manager->allocator())
_privatizedFieldNodes(manager->trMemory())
{
}

Expand Down Expand Up @@ -111,10 +105,6 @@ int32_t TR_FieldPrivatizer::perform()
#endif
}


if(comp()->getOption(TR_EnableElementPrivatization))
elementPrivatization();

return 1;
}

Expand Down Expand Up @@ -1477,192 +1467,6 @@ void TR_FieldPrivatizer::cleanupStringPeephole()
#endif
}


void TR_FieldPrivatizer::elementPrivatization()
{
setVisitCount(comp()->incOrResetVisitCount());

if (!optimizer()->getValueNumberInfo())
{
dumpOptDetails(comp(), "Can't do element Privatization - no value numbers for %s\n", comp()->signature());
return;
}

_valueNumberInfo = optimizer()->getValueNumberInfo();


findElementCandidates();
privatizeElementCandidates();

}

void TR_FieldPrivatizer::findElementCandidates()
{
for ( TR::TreeTop *tt = comp()->getMethodSymbol()->getFirstTreeTop() ; tt ; tt = tt->getNextTreeTop())
{
TR::Node *loadOrStoreNode = walkTreeForLoadOrStoreNode(tt->getNode());

if (loadOrStoreNode && isNodeInCorrectForm(loadOrStoreNode))
{
traceMsg(comp(), "Adding node %p tt %p with vn %d to list of candidates to privatize\n",loadOrStoreNode,tt,_valueNumberInfo->getValueNumber(loadOrStoreNode->getFirstChild()));

EPCandidate newCand(loadOrStoreNode,tt,_valueNumberInfo->getValueNumber(loadOrStoreNode->getFirstChild()));
_epCandidates.push_back(newCand);
_epValueNumbers[_valueNumberInfo->getValueNumber(loadOrStoreNode->getFirstChild())] = 1;
}
}
}

void TR_FieldPrivatizer::privatizeElementCandidates()
{
CS2::HashTable<int32_t, TR::SymbolReference*, TR::Allocator> tempMap(comp()->allocator());
TR::list<EPCandidate> difficultCandidates(getTypedAllocator<EPCandidate>(comp()->allocator()));
for (auto cursor = _epCandidates.begin(); cursor != _epCandidates.end(); ++cursor)
{
TR::SymbolReference *tempSymRef = 0;

EPCandidate &candidate = *cursor;
CS2::HashIndex index;
if (tempMap.Locate(candidate.valueNum,index))
{
tempSymRef = tempMap[index];
}
else
{
TR_ASSERT(candidate.node->getOpCode().hasSymbolReference(), "Candidate node %p does not have a symbol reference!\n",candidate.node);

TR::Node *addressNode = candidate.node->getFirstChild();

int64_t offset = getOffSetFromAddressNode(addressNode);

if (offset < 0) //This means that candidate has a value number and some other node will have the addr calculation, we just have to wait till it gets added to the hashtable
{
difficultCandidates.push_back(candidate);
continue;
}

tempSymRef = comp()->getSymRefTab()->createCoDependentTemporary(comp()->getMethodSymbol(),candidate.node->getDataType(),false,candidate.node->getSize(),candidate.node->getSymbol(),0);

tempMap.Add(candidate.valueNum,tempSymRef);
}

TR::DataType storedt = candidate.node->getDataType();

// step 1, anchor the original store address calculation child

TR::TreeTop *anchorTT = TR::TreeTop::create(comp(),TR::Node::create(TR::treetop, 1,candidate.node->getFirstChild()));
candidate.rootTT->insertBefore(anchorTT);

// step 2, convert the indirect store in to a direct store.

TR_ASSERT(candidate.node->getReferenceCount() == 1, "Candidate store node %p has refcount > 1... How is this possible?\n",candidate.node);

TR::Node::recreate(candidate.node, comp()->il.opCodeForDirectStore(storedt));
candidate.node->setSymbolReference(tempSymRef);
candidate.node->setFirst(candidate.node->getSecondChild());
candidate.node->setNumChildren(1);
}


// Process the difficult candidates.
for (auto difficult_cursor = difficultCandidates.begin(); difficult_cursor != difficultCandidates.end(); ++difficult_cursor)
{
TR::SymbolReference *tempSymRef = 0;

EPCandidate &candidate = *difficult_cursor;
CS2::HashIndex index;
if (tempMap.Locate(candidate.valueNum,index))
{
tempSymRef = tempMap[index];
}
else
{
TR_ASSERT(0, "Unable to process Candidate node %p!\n",candidate.node);
}
}


}

int64_t TR_FieldPrivatizer::getOffSetFromAddressNode(TR::Node *addressNode)
{
if (addressNode->getOpCodeValue() == TR::loadaddr)
{
return 0;
}

else if (addressNode->getOpCode().isAdd())
{
if (addressNode->getFirstChild()->getOpCode().isLoadConst())
{
//TR_ASSERT(addressNode->getFirst)
return addressNode->getFirstChild()->getLongInt();
}
else if (addressNode->getSecondChild()->getOpCode().isLoadConst())
{
return addressNode->getSecondChild()->getLongInt();
}

}

return -1;

}


bool TR_FieldPrivatizer::isNodeInCorrectForm(TR::Node *node)
{

TR_ASSERT(node->getOpCode().isStoreIndirect() || node->getOpCode().isLoadIndirect(), "Node is not an indirect store or load!\n");

if(node->getFirstChild()->getOpCodeValue() == TR::loadaddr)
{
return true;
}
else if( node->getFirstChild()->getOpCode().isAdd() && ((node->getFirstChild()->getFirstChild()->getOpCodeValue() == TR::loadaddr && node->getFirstChild()->getSecondChild()->getOpCode().isLoadConst() ) ||
(node->getFirstChild()->getFirstChild()->getOpCode().isLoadConst() && node->getFirstChild()->getSecondChild()->getOpCodeValue() == TR::loadaddr)
)
)
{

int64_t offset = getOffSetFromAddressNode(node->getFirstChild());

if (offset < 0 || offset > 20) // a basic heuristic to not do this for massively huge arrays. Maybe I don't need this.
return false;

return true;
}
else
{
int32_t vn = _valueNumberInfo->getValueNumber(node->getFirstChild());

if(_epValueNumbers.ValueAt(vn))
{
return true;
}
}

return false;
}

TR::Node * TR_FieldPrivatizer::walkTreeForLoadOrStoreNode(TR::Node *node)
{
if (node->getVisitCount() >= _visitCount)
return 0;

node->setVisitCount(_visitCount);

if (node->getOpCode().isStoreIndirect() || node->getOpCode().isLoadIndirect())
return node;

for(int32_t i = 0 ; i < node->getNumChildren() ; ++i)
{
walkTreeForLoadOrStoreNode(node->getChild(i));
}

return 0;
}

const char *
TR_FieldPrivatizer::optDetailString() const throw()
{
Expand Down
Loading

0 comments on commit 52ffab0

Please sign in to comment.