Skip to content

Commit

Permalink
Fix incorrect usage of TR::Options
Browse files Browse the repository at this point in the history
- during compilation, the per-method TR::Options should be used instead of the global one
- mostly happens at the Optimizer and Code Generation stage
- simplify comp()->getOptions()->getOption(TR_XXX) to comp()->getOptions(TR_XXX), they are equivalent
- switch _options usage to options in OMRCompilation ctor

Signed-off-by: Harry Yu <harryyu1994@gmail.com>
  • Loading branch information
harryyu1994 committed Jun 29, 2018
1 parent 6b22dda commit 2640976
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 81 deletions.
4 changes: 2 additions & 2 deletions compiler/arm/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ OMR::ARM::CodeGenerator::CodeGenerator()
// wrapping-around.
_maxObjectSizeGuaranteedNotToOverflow = 0x10000000;
self()->setSupportsDivCheck();
if (!self()->comp()->getOptions()->getOption(TR_DisableTraps))
if (!self()->comp()->getOption(TR_DisableTraps))
self()->setHasResumableTrapHandler();
}
else
Expand Down Expand Up @@ -691,7 +691,7 @@ TR_GlobalRegisterNumber OMR::ARM::CodeGenerator::pickRegister(TR_RegisterCandida
{
// Tactical GRA
// We delegate the decision to use register pressure simulation to common code.
// if (!comp()->getOptions()->getOption(TR_DisableRegisterPressureSimulation))
// if (!comp()->getOption(TR_DisableRegisterPressureSimulation))
return OMR::CodeGenerator::pickRegister(regCan, barr, availRegs, highRegisterNumber, candidates);
// }
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ OMR::CodeGenerator::CodeGenerator() :
_machine = new (self()->trHeapMemory()) TR::Machine(self());
_disableInternalPointers = self()->comp()->getOption(TR_MimicInterpreterFrameShape) ||
self()->comp()->getOptions()->realTimeGC() ||
self()->comp()->getOptions()->getOption(TR_DisableInternalPointers);
self()->comp()->getOption(TR_DisableInternalPointers);

uintptrj_t maxSize = TR::Compiler->vm.getOverflowSafeAllocSize(self()->comp());
int32_t i;
Expand Down Expand Up @@ -862,8 +862,8 @@ OMR::CodeGenerator::use64BitRegsOn32Bit()
return false;
else
{
bool longReg = self()->comp()->getOptions()->getOption(TR_Enable64BitRegsOn32Bit);
bool longRegHeur = self()->comp()->getOptions()->getOption(TR_Enable64BitRegsOn32BitHeuristic);
bool longReg = self()->comp()->getOption(TR_Enable64BitRegsOn32Bit);
bool longRegHeur = self()->comp()->getOption(TR_Enable64BitRegsOn32BitHeuristic);
bool use64BitRegs = (longReg && !longRegHeur && self()->comp()->getJittedMethodSymbol()->mayHaveLongOps()) ||
(longReg && longRegHeur && self()->comp()->useLongRegAllocation());
return use64BitRegs;
Expand Down Expand Up @@ -1969,7 +1969,7 @@ OMR::CodeGenerator::convertMultiplyToShift(TR::Node * node)
bool
OMR::CodeGenerator::isMemoryUpdate(TR::Node *node)
{
if (self()->comp()->getOptions()->getOption(TR_DisableDirectMemoryOps))
if (self()->comp()->getOption(TR_DisableDirectMemoryOps))
return false;

// See if the given store node can be represented by a direct operation on the
Expand Down Expand Up @@ -2950,7 +2950,7 @@ OMR::CodeGenerator::canNullChkBeImplicit(TR::Node *node)
bool
OMR::CodeGenerator::canNullChkBeImplicit(TR::Node *node, bool doChecks)
{
if (self()->comp()->getOptions()->getOption(TR_DisableTraps))
if (self()->comp()->getOption(TR_DisableTraps))
return false;

if (!doChecks)
Expand Down
32 changes: 16 additions & 16 deletions compiler/compile/OMRCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ OMR::Compilation::Compilation(
// while the PersistentMethodInfo is allocated during codegen creation
// Access to this list must be performed with assumptionTableMutex in hand
//
if (!TR::Options::getCmdLineOptions()->getOption(TR_DisableFastAssumptionReclamation))
if (!options.getOption(TR_DisableFastAssumptionReclamation))
_metadataAssumptionList = new (m->trPersistentMemory()) TR::SentinelRuntimeAssumption();
#endif

//Random fields must be set before allocating codegen
_primaryRandom = new (m->trHeapMemory()) TR_RandomGenerator(options.getRandomSeed());
_adhocRandom = new (m->trHeapMemory()) TR_RandomGenerator(options.getRandomSeed());
if (_options->getOption(TR_RandomSeedSignatureHash))
if (options.getOption(TR_RandomSeedSignatureHash))
{
int32_t hash = 0;
for (const char *c = self()->signature(); *c; c++)
Expand All @@ -347,7 +347,7 @@ OMR::Compilation::Compilation(
if (ilGenRequest.details().isMethodInProgress())
{
_flags.set(IsDLTCompile);
_options->setAllowRecompilation(false);
options.setAllowRecompilation(false);
}

if (optimizationPlan)
Expand All @@ -364,13 +364,13 @@ OMR::Compilation::Compilation(
}

// if we are not in the selective NoOptServer mode
_isOptServer = (!_options->getOption(TR_NoOptServer)) &&
( _options->getOption(TR_Server)
_isOptServer = (!options.getOption(TR_NoOptServer)) &&
( options.getOption(TR_Server)
#ifdef J9_PROJECT_SPECIFIC
|| (self()->getPersistentInfo()->getNumLoadedClasses() >= TR::Options::_bigAppThreshold)
#endif
);
_isServerInlining = !_options->getOption(TR_NoOptServer);
_isServerInlining = !options.getOption(TR_NoOptServer);

//_methodSymbol must be done after symRefTab, but before codegen
// _methodSymbol must be initialized here because creating a jitted method symbol
Expand All @@ -393,7 +393,7 @@ OMR::Compilation::Compilation(
_globalRegisterCandidates = new (self()->trHeapMemory()) TR_RegisterCandidates(self());

#ifdef J9_PROJECT_SPECIFIC
if (_recompilationInfo && _options->getOptLevelDowngraded())
if (_recompilationInfo && options.getOptLevelDowngraded())
_recompilationInfo->getMethodInfo()->setOptLevelDowngraded(true);
#endif

Expand Down Expand Up @@ -433,15 +433,15 @@ OMR::Compilation::Compilation(
_options->setOption(TR_EnableOSROnGuardFailure, false);
}

if (_options->getOption(TR_EnableOSR))
if (options.getOption(TR_EnableOSR))
{
// Current implementation of partial inlining will break OSR
self()->setOption(TR_DisablePartialInlining);

//TODO: investigate the memory footprint of this allocation
_osrCompilationData = new (self()->trHeapMemory()) TR_OSRCompilationData(self());

if (((self()->getMethodHotness() < warm) || self()->compileRelocatableCode() || self()->isProfilingCompilation()) && !enableOSRAtAllOptLevels && !_options->getOption(TR_FullSpeedDebug)) // Off for two reasons : 1) not sure if we can afford the increase in compile time due to the extra OSR control flow at cold and 2) not sure at this stage in 727 whether OSR can work with AOT (will try to find out soon) but disabling till I do find out
if (((self()->getMethodHotness() < warm) || self()->compileRelocatableCode() || self()->isProfilingCompilation()) && !enableOSRAtAllOptLevels && !options.getOption(TR_FullSpeedDebug)) // Off for two reasons : 1) not sure if we can afford the increase in compile time due to the extra OSR control flow at cold and 2) not sure at this stage in 727 whether OSR can work with AOT (will try to find out soon) but disabling till I do find out
_canAffordOSRControlFlow = false;
}
else
Expand Down Expand Up @@ -916,15 +916,15 @@ int32_t OMR::Compilation::compile()
if (!self()->getOption(TR_DisableSupportForCpuSpentInCompilation))
_cpuTimeAtStartOfCompilation = TR::Compiler->vm.cpuTimeSpentInCompilationThread(self());

bool printCodegenTime = TR::Options::getCmdLineOptions()->getOption(TR_CummTiming);
bool printCodegenTime = self()->getOption(TR_CummTiming);

if (self()->isOptServer())
{
// Temporarily exclude PPC due to perf regression
if( (self()->getMethodHotness() <= warm))
{
if (!TR::Compiler->target.cpu.isPower())
TR::Options::getCmdLineOptions()->setOption(TR_DisableInternalPointers);
self()->getOptions()->setOption(TR_DisableInternalPointers);
}
self()->getOptions()->setOption(TR_DisablePartialInlining);
}
Expand Down Expand Up @@ -1841,7 +1841,7 @@ void OMR::Compilation::resetVisitCounts(vcount_t count, TR::TreeTop *start)
void OMR::Compilation::reportFailure(const char *reason)
{
traceMsg(self(), "Compilation Failed Because: %s\n", reason);
if (TR::Options::getCmdLineOptions()->getOption(TR_PrintErrorInfoOnCompFailure))
if (self()->getOption(TR_PrintErrorInfoOnCompFailure))
fprintf(stderr, "Compilation Failed Because: %s\n", reason);
}

Expand Down Expand Up @@ -1950,7 +1950,7 @@ void OMR::Compilation::dumpMethodTrees(char *title, TR::ResolvedMethodSymbol * m

self()->getDebug()->printIRTrees(self()->getOutFile(), title, methodSymbol);

if (!self()->getOptions()->getOption(TR_DisableDumpFlowGraph))
if (!self()->getOption(TR_DisableDumpFlowGraph))
self()->dumpFlowGraph(methodSymbol->getFlowGraph());

if (self()->isOutermostMethod() && self()->getKnownObjectTable()) // This is pretty verbose. Let's just dump it when we're dumping the whole method.
Expand Down Expand Up @@ -2039,7 +2039,7 @@ void OMR::Compilation::validateIL(TR::ILValidationContext ilValidationContext)

void OMR::Compilation::verifyTrees(TR::ResolvedMethodSymbol *methodSymbol)
{
if (self()->getDebug() && !self()->getOptions()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
if (self()->getDebug() && !self()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
{
if (!methodSymbol)
methodSymbol = _methodSymbol;
Expand All @@ -2049,7 +2049,7 @@ void OMR::Compilation::verifyTrees(TR::ResolvedMethodSymbol *methodSymbol)

void OMR::Compilation::verifyBlocks(TR::ResolvedMethodSymbol *methodSymbol)
{
if (self()->getDebug() && !self()->getOptions()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
if (self()->getDebug() && !self()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
{
if (!methodSymbol)
methodSymbol = _methodSymbol;
Expand All @@ -2059,7 +2059,7 @@ void OMR::Compilation::verifyBlocks(TR::ResolvedMethodSymbol *methodSymbol)

void OMR::Compilation::verifyCFG(TR::ResolvedMethodSymbol *methodSymbol)
{
if (self()->getDebug() && !self()->getOptions()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
if (self()->getDebug() && !self()->getOption(TR_DisableVerification) && !self()->isPeekingMethod())
{
if (!methodSymbol)
methodSymbol = _methodSymbol;
Expand Down
10 changes: 5 additions & 5 deletions compiler/control/CompileMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,23 +401,23 @@ compileMethodFromDetails(
}

if (
TR::Options::getCmdLineOptions()->getOption(TR_PerfTool)
|| TR::Options::getCmdLineOptions()->getOption(TR_EmitExecutableELFFile)
|| TR::Options::getCmdLineOptions()->getOption(TR_EmitRelocatableELFFile)
compiler.getOption(TR_PerfTool)
|| compiler.getOption(TR_EmitExecutableELFFile)
|| compiler.getOption(TR_EmitRelocatableELFFile)
)
{
TR::CodeCacheManager &codeCacheManager(fe.codeCacheManager());
TR::CodeGenerator &codeGenerator(*compiler.cg());
codeCacheManager.registerCompiledMethod(compiler.externalName(), startPC, codeGenerator.getCodeLength());
if (TR::Options::getCmdLineOptions()->getOption(TR_EmitRelocatableELFFile))
if (compiler.getOption(TR_EmitRelocatableELFFile))
{
auto &relocations = codeGenerator.getStaticRelocations();
for (auto it = relocations.begin(); it != relocations.end(); ++it)
{
codeCacheManager.registerStaticRelocation(*it);
}
}
if (TR::Options::getCmdLineOptions()->getOption(TR_PerfTool))
if (compiler.getOption(TR_PerfTool))
{
generatePerfToolEntry(startPC, codeGenerator.getCodeEnd(), compiler.signature(), compiler.getHotnessName(compiler.getMethodHotness()));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/il/Aliases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ OMR::SymbolReference::getUseonlyAliasesBV(TR::SymbolReferenceTable * symRefTab)
case TR::Symbol::IsResolvedMethod:
{
TR::ResolvedMethodSymbol * resolvedMethodSymbol = _symbol->castToResolvedMethodSymbol();
if (!TR::Options::getCmdLineOptions()->getOption(TR_EnableHCR))
if (!TR::comp()->getOption(TR_EnableHCR))
{
switch (resolvedMethodSymbol->getRecognizedMethod())
{
Expand Down Expand Up @@ -352,7 +352,7 @@ OMR::SymbolReference::getUseDefAliasesBV(bool isDirectCall, bool includeGCSafePo
{
TR::ResolvedMethodSymbol * resolvedMethodSymbol = _symbol->castToResolvedMethodSymbol();

if (!TR::Options::getCmdLineOptions()->getOption(TR_EnableHCR))
if (!comp->getOption(TR_EnableHCR))
{
switch (resolvedMethodSymbol->getRecognizedMethod())
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/optimizer/GlobalRegisterAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3687,7 +3687,7 @@ TR_GlobalRegisterAllocator::findLoopsAndCorrespondingAutos(TR_StructureSubGraphN
TR_BitVector *symsThatShouldBeAssignedInCurrentLoop = NULL;

bool excludeInvariantsEnabled = comp()->cg()->excludeInvariantsFromGRAEnabled() &&
(!comp()->getOptions()->getOption(TR_DisableRXusage));
(!comp()->getOption(TR_DisableRXusage));

if (excludeInvariantsEnabled)
{
Expand Down Expand Up @@ -4817,7 +4817,7 @@ TR_LiveRangeSplitter::TR_LiveRangeSplitter(TR::OptimizationManager *manager)

int32_t TR_LiveRangeSplitter::perform()
{
if (!comp()->getOptions()->getOption(TR_EnableRangeSplittingGRA))
if (!comp()->getOption(TR_EnableRangeSplittingGRA))
return 0;

if (!cg()->prepareForGRA())
Expand Down
2 changes: 1 addition & 1 deletion compiler/optimizer/Inliner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ class OMR_InlinerPolicy : public TR::OptimizationPolicy, public OMR_InlinerHelpe
virtual int32_t getInitialBytecodeSize(TR_ResolvedMethod *feMethod, TR::ResolvedMethodSymbol * methodSymbol, TR::Compilation *comp);
virtual bool tryToInline(TR_CallTarget *, TR_CallStack *, bool);
virtual bool inlineMethodEvenForColdBlocks(TR_ResolvedMethod *method);
bool aggressiveSmallAppOpts() { return TR::Options::getCmdLineOptions()->getOption(TR_AggressiveOpts); }
bool aggressiveSmallAppOpts() { return comp()->getOption(TR_AggressiveOpts); }
virtual bool willBeInlinedInCodeGen(TR::RecognizedMethod method);
virtual bool canInlineMethodWhileInstrumenting(TR_ResolvedMethod *method);

Expand Down
8 changes: 4 additions & 4 deletions compiler/optimizer/LocalOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,7 +2276,7 @@ bool TR_CompactNullChecks::replaceNullCheckIfPossible(TR::Node *cursorNode, TR::
if (isEquivalent)
{
bool canBeRemoved = true; //comp()->cg()->canNullChkBeImplicit(cursorNode);
if (TR::comp()->getOptions()->getOption(TR_DisableTraps) ||
if (TR::comp()->getOption(TR_DisableTraps) ||
TR::Compiler->om.offsetOfObjectVftField() >= comp()->cg()->getNumberBytesReadInaccessible())
canBeRemoved = false;

Expand Down Expand Up @@ -5987,7 +5987,7 @@ int8_t TR_Rematerialization::getLoopNestingLevel(int32_t weight)

void TR_Rematerialization::makeEarlyLongRegDecision()
{
if (comp()->getOptions()->getOption(TR_Disable64BitRegsOn32Bit) ||
if (comp()->getOption(TR_Disable64BitRegsOn32Bit) ||
!cg()->supportsLongRegAllocation() ||
!comp()->getJittedMethodSymbol()->mayHaveLongOps())
{
Expand All @@ -5997,8 +5997,8 @@ void TR_Rematerialization::makeEarlyLongRegDecision()
return;
}

if (!comp()->getOptions()->getOption(TR_Disable64BitRegsOn32Bit) &&
comp()->getOptions()->getOption(TR_Disable64BitRegsOn32BitHeuristic))
if (!comp()->getOption(TR_Disable64BitRegsOn32Bit) &&
comp()->getOption(TR_Disable64BitRegsOn32BitHeuristic))
{
comp()->setUseLongRegAllocation(true);
setLongRegDecision(true);
Expand Down
18 changes: 9 additions & 9 deletions compiler/optimizer/LoopVersioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool TR_LoopVersioner::loopIsWorthVersioning(TR_RegionStructure *naturalLoop)
}

// if aggressive loop versioner flag is set then run at any optlevel, otherwise only at warm or less
bool aggressive = TR::Options::getCmdLineOptions()->getOption(TR_EnableAggressiveLoopVersioning);
bool aggressive = comp()->getOption(TR_EnableAggressiveLoopVersioning);
if (aggressive || comp()->getMethodHotness() <= warm)
{
if (naturalLoop->getParent())
Expand All @@ -225,7 +225,7 @@ bool TR_LoopVersioner::loopIsWorthVersioning(TR_RegionStructure *naturalLoop)
}
}

bool aggressive = TR::Options::getCmdLineOptions()->getOption(TR_EnableAggressiveLoopVersioning);
bool aggressive = comp()->getOption(TR_EnableAggressiveLoopVersioning);

int32_t lvBlockFreqCutoff;
static const char * b = feGetEnv("TR_LoopVersionerFreqCutoff");
Expand Down Expand Up @@ -567,7 +567,7 @@ int32_t TR_LoopVersioner::performWithoutDominators()
{
// default hotness threshold
TR_Hotness hotnessThreshold = hot;
if (TR::Options::getCmdLineOptions()->getOption(TR_EnableAggressiveLoopVersioning))
if (comp()->getOption(TR_EnableAggressiveLoopVersioning))
{
if (trace()) traceMsg(comp(), "aggressiveLoopVersioning: raising hotnessThreshold for conditionalsWillBeEliminated\n");
hotnessThreshold = maxHotness; // threshold which can't be matched by the > operator
Expand Down Expand Up @@ -712,7 +712,7 @@ int32_t TR_LoopVersioner::performWithoutDominators()
////if (!_virtualGuardPairs.isEmpty())
if (!_virtualGuardInfo.isEmpty())
{
bool disableLT = TR::Options::getCmdLineOptions()->getOption(TR_DisableLoopTransfer);
bool disableLT = comp()->getOption(TR_DisableLoopTransfer);
if (!disableLT)
performLoopTransfer();
}
Expand Down Expand Up @@ -3204,7 +3204,7 @@ bool TR_LoopVersioner::detectChecksToBeEliminated(TR_RegionStructure *whileLoop,

// If the aggressive loop versioning flag is set, only do the unimportant block test
// at lower optlevels
bool aggressive = TR::Options::getCmdLineOptions()->getOption(TR_EnableAggressiveLoopVersioning);
bool aggressive = comp()->getOption(TR_EnableAggressiveLoopVersioning);

static const bool useOuterHeader =
feGetEnv("TR_loopVersionerUseOuterHeaderForImportance") != NULL;
Expand Down Expand Up @@ -3252,7 +3252,7 @@ bool TR_LoopVersioner::detectChecksToBeEliminated(TR_RegionStructure *whileLoop,
)
{
isUnimportant = true;
if (trace() || comp()->getOptions()->getOption(TR_CountOptTransformations))
if (trace() || comp()->getOption(TR_CountOptTransformations))
{
for (TR::TreeTop *tt = entryTree; isUnimportant && tt != exitTree; tt = tt->getNextTreeTop())
{
Expand Down Expand Up @@ -3315,7 +3315,7 @@ bool TR_LoopVersioner::detectChecksToBeEliminated(TR_RegionStructure *whileLoop,
vcount_t visitCount = comp()->incVisitCount(); //@TODO: unsafe API/use pattern
updateDefinitionsAndCollectProfiledExprs(NULL, currentNode, visitCount, specializedInvariantNodes, invariantNodes, invariantTranslationNodesList, NULL, collectProfiledExprs, nextBlock, warmBranchCount);

bool disableLT = TR::Options::getCmdLineOptions()->getOption(TR_DisableLoopTransfer);
bool disableLT = comp()->getOption(TR_DisableLoopTransfer);
if (!disableLT &&
currentNode->isTheVirtualGuardForAGuardedInlinedCall() &&
blocksInWhileLoop.find(currentNode->getBranchDestination()->getNode()->getBlock()))
Expand Down Expand Up @@ -3791,7 +3791,7 @@ void TR_LoopVersioner::versionNaturalLoop(TR_RegionStructure *whileLoop, List<TR
}

TR::Node *lastTree = nextBlock->getLastRealTreeTop()->getNode();
bool disableLT = TR::Options::getCmdLineOptions()->getOption(TR_DisableLoopTransfer);
bool disableLT = comp()->getOption(TR_DisableLoopTransfer);
if (!disableLT &&
lastTree->getOpCode().isIf() &&
blocksInWhileLoop.find(lastTree->getBranchDestination()->getNode()->getBlock()) &&
Expand Down Expand Up @@ -4255,7 +4255,7 @@ void TR_LoopVersioner::versionNaturalLoop(TR_RegionStructure *whileLoop, List<TR
TR_Hotness hotnessThreshold = hot;

// If aggressive loop versioning is requested, don't call buildNullCheckComparisonsTree based on hotness
if (TR::Options::getCmdLineOptions()->getOption(TR_EnableAggressiveLoopVersioning))
if (comp()->getOption(TR_EnableAggressiveLoopVersioning))
{
if (trace()) traceMsg(comp(), "aggressiveLoopVersioning: raising hotnessThreshold for buildNullCheckComparisonsTree\n");
hotnessThreshold = maxHotness; // threshold which can't be matched by the > operator
Expand Down
Loading

0 comments on commit 2640976

Please sign in to comment.