Skip to content

Commit

Permalink
Merge pull request #2978 from dsouzai/AOTImprovementsPart2
Browse files Browse the repository at this point in the history
Improvements for Relocatable Compilations
  • Loading branch information
mstoodle authored Oct 4, 2018
2 parents 6864b36 + e0bc346 commit 70c42dc
Show file tree
Hide file tree
Showing 20 changed files with 375 additions and 77 deletions.
2 changes: 2 additions & 0 deletions compiler/codegen/FrontEnd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class TR_FrontEnd : public TR_Uncopyable

virtual int32_t getLineNumberForMethodAndByteCodeIndex(TR_OpaqueMethodBlock *, int32_t);

virtual bool canDevirtualizeDispatch() { return true; }

// --------------------------------------------------------------------------
// Codegen
// --------------------------------------------------------------------------
Expand Down
37 changes: 37 additions & 0 deletions compiler/codegen/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,43 @@ const char *TR::ExternalRelocation::_externalRelocationTargetKindNames[TR_NumExt
"TR_DebugCounter (59)",
"TR_ClassUnloadAssumption (60)",
"TR_J2IVirtualThunkPointer (61)",
"TR_InlinedAbstractMethodWithNopGuard (62)",
"TR_ValidateRootClass (63)",
"TR_ValidateClassByName (64)",
"TR_ValidateProfiledClass (65)",
"TR_ValidateClassFromCP (66)",
"TR_ValidateDefiningClassFromCP (67)",
"TR_ValidateStaticClassFromCP (68)",
"TR_ValidateClassFromMethod (69)",
"TR_ValidateComponentClassFromArrayClass (70)",
"TR_ValidateArrayClassFromComponentClass (71)",
"TR_ValidateSuperClassFromClass (72)",
"TR_ValidateClassInstanceOfClass (73)",
"TR_ValidateSystemClassByName (74)",
"TR_ValidateClassFromITableIndexCP (75)",
"TR_ValidateDeclaringClassFromFieldOrStatic (76)",
"TR_ValidateClassClass (77)",
"TR_ValidateConcreteSubClassFromClass (78)",
"TR_ValidateClassChain (79)",
"TR_ValidateRomClass (80)",
"TR_ValidatePrimitiveClass (81)",
"TR_ValidateMethodFromInlinedSite (82)",
"TR_ValidateMethodByName (83)",
"TR_ValidateMethodFromClass (84)",
"TR_ValidateStaticMethodFromCP (85)",
"TR_ValidateSpecialMethodFromCP (86)",
"TR_ValidateVirtualMethodFromCP (87)",
"TR_ValidateVirtualMethodFromOffset (88)",
"TR_ValidateInterfaceMethodFromCP (89)",
"TR_ValidateMethodFromClassAndSig (90)",
"TR_ValidateStackWalkerMaySkipFramesRecord (91)",
"TR_ValidateArrayClassFromJavaVM (92)",
"TR_ValidateClassInfoIsInitialized (93)",
"TR_ValidateMethodFromSingleImplementer (94)",
"TR_ValidateMethodFromSingleInterfaceImplementer (95)",
"TR_ValidateMethodFromSingleAbstractImplementer (96)",
"TR_ValidateImproperInterfaceMethodFromCP (97)",
"TR_SymbolFromManager (98)",
};

uintptr_t TR::ExternalRelocation::_globalValueList[TR_NumGlobalValueItems] =
Expand Down
1 change: 1 addition & 0 deletions compiler/compile/Method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ bool TR_ResolvedMethod::isPublic() { not
bool TR_ResolvedMethod::isFinal() { notImplemented("isFinal"); return false; }
bool TR_ResolvedMethod::isStrictFP() { notImplemented("isStrictFP"); return false; }
bool TR_ResolvedMethod::isInterpreted() { notImplemented("isInterpreted"); return false; }
bool TR_ResolvedMethod::isInterpretedForHeuristics() { notImplemented("isInterpretedForHeuristics"); return false; }
bool TR_ResolvedMethod::hasBackwardBranches() { notImplemented("hasBackwardBranches"); return false; }
bool TR_ResolvedMethod::isObjectConstructor() { notImplemented("isObjectConstructor"); return false; }
bool TR_ResolvedMethod::isNonEmptyObjectConstructor() { notImplemented("isNonEmptyObjectConstructor"); return false; }
Expand Down
6 changes: 6 additions & 0 deletions compiler/compile/OMRCompilation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ class OMR_EXTENSIBLE Compilation

bool compilationShouldBeInterrupted(TR_CallingContext) { return false; }

/* Can be used to ensure that a implementer chosen for inlining is valid;
* for example, to ensure that the implementer can be used for inlining
* in a relocatable compilation
*/
bool validateTargetToBeInlined(TR_ResolvedMethod *implementer) { return true; }

// ..........................................................................
// Optimizer mechanics
int16_t getOptIndex() { return _currentOptIndex; }
Expand Down
1 change: 1 addition & 0 deletions compiler/compile/ResolvedMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class TR_ResolvedMethod
virtual bool isFinal();

virtual bool isInterpreted();
virtual bool isInterpretedForHeuristics();
virtual bool hasBackwardBranches();
virtual bool isObjectConstructor();
virtual bool isNonEmptyObjectConstructor();
Expand Down
16 changes: 16 additions & 0 deletions compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"disableSupportForCpuSpentInCompilation", "M\tdo not provide CPU spent in compilation", SET_OPTION_BIT(TR_DisableSupportForCpuSpentInCompilation), "F" },
{"disableSwitchAnalyzer", "O\tdisable switch analyzer", TR::Options::disableOptimization, switchAnalyzer, 0, "P"},
{"disableSwitchAwayFromProfilingForHotAndVeryhot", "O\tdisable switch away from profiling for hot and veryhot", SET_OPTION_BIT(TR_DisableSwitchAwayFromProfilingForHotAndVeryhot), "F"},
{"disableSymbolValidationManager", "M\tEnable Symbol Validation Manager for Relocatable Compile Validations", RESET_OPTION_BIT(TR_EnableSymbolValidationManager), "F"},
{"disableSynchronizedFieldLoad", "O\tDisable the use of hardware optimized synchronized field load intrinsics", SET_OPTION_BIT(TR_DisableSynchronizedFieldLoad), "F"},
{"disableSyncMethodInlining", "O\tdisable inlining of synchronized methods", SET_OPTION_BIT(TR_DisableSyncMethodInlining), "F"},
{"disableTailRecursion", "O\tdisable tail recursion", SET_OPTION_BIT(TR_DisableTailRecursion), "F"},
Expand Down Expand Up @@ -754,6 +755,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"enableSharedCacheTiming", "M\tenable timing stats for accessing the shared cache", SET_OPTION_BIT(TR_EnableSharedCacheTiming), "F"},
{"enableSIMDLibrary", "M\tEnable recognized methods for SIMD library", SET_OPTION_BIT(TR_EnableSIMDLibrary), "F"},
{"enableSnapshotBlockOpts", "O\tenable block ordering/redirecting optimizations in the presences of snapshot nodes", SET_OPTION_BIT(TR_EnableSnapshotBlockOpts), "F"},
{"enableSymbolValidationManager", "M\tEnable Symbol Validation Manager for Relocatable Compile Validations", SET_OPTION_BIT(TR_EnableSymbolValidationManager), "F"},
{"enableTailCallOpt", "R\tenable tall call optimization in peephole", SET_OPTION_BIT(TR_EnableTailCallOpt), "F"},
{"enableThisLiveRangeExtension", "R\tenable this live range extesion to the end of the method", SET_OPTION_BIT(TR_EnableThisLiveRangeExtension), "F"},
{"enableTraps", "C\tenable trap instructions", RESET_OPTION_BIT(TR_DisableTraps), "F"},
Expand Down Expand Up @@ -1319,6 +1321,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"useSamplingJProfilingForInterpSampledMethods","M\tHeuristic. Use samplingJProfiling for methods sampled by interpreter", SET_OPTION_BIT(TR_UseSamplingJProfilingForInterpSampledMethods), "F", NOT_IN_SUBSET },
{"useSamplingJProfilingForLPQ", "M\tHeuristic. Use samplingJProfiling for methods from low priority queue", SET_OPTION_BIT(TR_UseSamplingJProfilingForLPQ), "F", NOT_IN_SUBSET },
{"useStrictStartupHints", "M\tStartup hints from application obeyed strictly", SET_OPTION_BIT(TR_UseStrictStartupHints), "F", NOT_IN_SUBSET},
{"useSymbolValidationManager", "M\tUse Symbol Validation Manager for Relocatable Compile Validations", SET_OPTION_BIT(TR_UseSymbolValidationManager), "F", NOT_IN_SUBSET},
{"useVmTotalCpuTimeAsAbstractTime", "M\tUse VmTotalCpuTime as abstractTime", SET_OPTION_BIT(TR_UseVmTotalCpuTimeAsAbstractTime), "F", NOT_IN_SUBSET },
{"varyInlinerAggressivenessWithTime", "M\tVary inliner aggressiveness with abstract time", SET_OPTION_BIT(TR_VaryInlinerAggressivenessWithTime), "F", NOT_IN_SUBSET },
{"verifyReferenceCounts", "I\tverify the sanity of object reference counts before manipulation", SET_OPTION_BIT(TR_VerifyReferenceCounts), "F"},
Expand Down Expand Up @@ -2216,6 +2219,19 @@ OMR::Options::jitLatePostProcess(TR::OptionSet *optionSet, void * jitConfig)
if (_coldUpgradeSampleThreshold == TR_DEFAULT_COLD_UPGRADE_SAMPLE_THRESHOLD)
_coldUpgradeSampleThreshold = 2;
}

// disable DelayRelocationForAOTCompilations feature because with higher
// method counts, the JIT collects enough IProfiler info prior to
// compilation that it doesn't need to wait any longer before running the

if (self()->getOption(TR_UseHigherMethodCounts))
{
self()->setOption(TR_DisableDelayRelocationForAOTCompilations, true);// If scount has not been changed on the command line, adjust it here
if (self()->getInitialSCount() == TR_INITIAL_SCOUNT)
{
_initialSCount = _initialCount;
}
}
}
else // No AOT
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ enum TR_CompilationOptions
TR_TraceMarkingOfHotFields = 0x00001000 + 4,
TR_EnableAnnotations = 0x00002000 + 4, // change to disable when on by default
TR_UnresolvedAreNotColdAtCold = 0x00004000 + 4, // cold block marker marks unresolved blocks as cold at hotness cold or less
// AVAILABLE = 0x00008000 + 4,
TR_UseSymbolValidationManager = 0x00008000 + 4,
TR_EnablePIDExtension = 0x00010000 + 4,
TR_GenerateCompleteInlineRanges = 0x00020000 + 4,
TR_DisableInliningOfNatives = 0x00040000 + 4,
Expand Down Expand Up @@ -264,7 +264,7 @@ enum TR_CompilationOptions
TR_enableProfiledDevirtualization = 0x00001000 + 5,
TR_EnableValueTracing = 0x00002000 + 5, // run-time value tracing
TR_IgnoreAssert = 0x00004000 + 5, // ignore failing assertions
// AVAILABLE = 0x00008000 + 5,
TR_EnableSymbolValidationManager = 0x00008000 + 5,
TR_EnableNewAllocationProfiling = 0x00010000 + 5, // enable tracing of fields load and store
TR_IgnoreIEEERestrictions = 0x00020000 + 5, // enable more aggressive, nonIEEE compliant xforms
TR_ProcessHugeMethods = 0x00040000 + 5, // allow processing of huge methods
Expand Down
4 changes: 3 additions & 1 deletion compiler/env/TRMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ const char * objectName[] =
"Debug",

"ClientSessionData",
"ROMClass"
"ROMClass",

"SymbolValidationManager"
};


Expand Down
4 changes: 2 additions & 2 deletions compiler/env/TRMemory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ class TR_MemoryBase
ClientSessionData,
ROMClass,

SymbolValidationManager,

NumObjectTypes,
// If adding new object types above, add the corresponding names
// to objectName[] array defined in TRMemory.cpp
Expand Down Expand Up @@ -682,8 +684,6 @@ inline void *
operator new[](size_t size, PERSISTENT_NEW_DECLARE) { return TR_Memory::jitPersistentAlloc(size, TR_MemoryBase::UnknownType); }




/*
* TR_ByteCodeInfo exists in an awkward situation where it seems TR_ALLOC()
* would be inappropriate for the structure, despite things needing to allocate them,
Expand Down
4 changes: 3 additions & 1 deletion compiler/il/symbol/OMRResolvedMethodSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ OMR::ResolvedMethodSymbol::ResolvedMethodSymbol(TR_ResolvedMethod * method, TR::
// Set the interpreted flag for an interpreted method unless we're calling
// the method that's being jitted
//
if ((_methodIndex > JITTED_METHOD_INDEX && !_resolvedMethod->isSameMethod(comp->getJittedMethodSymbol()->getResolvedMethod())) || comp->isDLT())
if ((_methodIndex > JITTED_METHOD_INDEX && !_resolvedMethod->isSameMethod(comp->getJittedMethodSymbol()->getResolvedMethod()))
|| comp->isDLT()
|| (comp->getOption(TR_UseSymbolValidationManager) && comp->compileRelocatableCode()))
{
if (_resolvedMethod->isInterpreted())
{
Expand Down
2 changes: 2 additions & 0 deletions compiler/optimizer/Inliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5689,6 +5689,8 @@ TR_CallSite::addTarget(TR_Memory* mem, TR_InlinerBase *inliner, TR_VirtualGuardS

addTarget(result);

_comp->validateTargetToBeInlined(implementer);

if(inliner->tracer()->heuristicLevel())
{
char name[1024];
Expand Down
16 changes: 14 additions & 2 deletions compiler/optimizer/LocalOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8058,7 +8058,9 @@ TR_ColdBlockMarker::hasNotYetRun(TR::Node *node)
TR::SymbolReference *symRef = node->getSymbolReference();
bool isUnresolved;

if (comp()->compileRelocatableCode() && !comp()->getOption(TR_DisablePeekAOTResolutions))
if (comp()->compileRelocatableCode() &&
!comp()->getOption(TR_UseSymbolValidationManager) &&
!comp()->getOption(TR_DisablePeekAOTResolutions))
isUnresolved = symRef->isUnresolvedMethodInCP(comp());
else
isUnresolved = symRef->isUnresolved();
Expand Down Expand Up @@ -8090,7 +8092,9 @@ TR_ColdBlockMarker::hasNotYetRun(TR::Node *node)
}
else
{
if (comp()->compileRelocatableCode() && !comp()->getOption(TR_DisablePeekAOTResolutions))
if (comp()->compileRelocatableCode() &&
!comp()->getOption(TR_UseSymbolValidationManager) &&
!comp()->getOption(TR_DisablePeekAOTResolutions))
{
bool isUnresolved = node->getSymbolReference()->isUnresolvedFieldInCP(comp());
//currentely node->hasUnresolvedSymbolReference() returns true more often for AOT than non-AOT beacause of
Expand All @@ -8104,7 +8108,15 @@ TR_ColdBlockMarker::hasNotYetRun(TR::Node *node)
return isUnresolved;
}
else
{
if (comp()->compileRelocatableCode()
&& comp()->getOption(TR_UseSymbolValidationManager)
&& node->getSymbol()->isConstString())
{
return false;
}
return true;
}
}
}
return false;
Expand Down
5 changes: 4 additions & 1 deletion compiler/optimizer/VPConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,9 @@ TR::VPClassType *TR::VPClassType::create(OMR::ValuePropagation *vp, const char *
if (classObject)
{
bool isClassInitialized = false;
bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager);
TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classObject, vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classObject, vp->comp(), allowForAOT);
if (classInfo && classInfo->isInitialized())
{
if (isFixed)
Expand Down Expand Up @@ -1293,6 +1294,8 @@ TR::VPKnownObject *TR::VPKnownObject::create(OMR::ValuePropagation *vp, TR::Know
{
TR::KnownObjectTable *knot = vp->comp()->getKnownObjectTable();
TR_ASSERT(knot, "Can't create a TR::VPKnownObject without a known-object table");
if (!knot)
return NULL;
if (knot->isNull(index)) // No point in worrying about the NULL case because existing constraints handle that optimally
return NULL;

Expand Down
21 changes: 13 additions & 8 deletions compiler/optimizer/VPHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,7 @@ TR::Node *constrainAload(OMR::ValuePropagation *vp, TR::Node *node)
sym->isFinal()))
haveClassLookaheadInfo = true;

bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager);
if (haveClassLookaheadInfo)
{
bool foundInfo = false;
Expand All @@ -1623,13 +1624,12 @@ TR::Node *constrainAload(OMR::ValuePropagation *vp, TR::Node *node)
}
bool isClassInitialized = false;
TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classOfStatic, vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classOfStatic, vp->comp(), allowForAOT);
if (classInfo && classInfo->isInitialized())
isClassInitialized = true;

if (classOfStatic != vp->comp()->getSystemClassPointer() &&
isClassInitialized &&
!vp->comp()->getOption(TR_AOT) &&
(type == TR::Address))
{
TR::VMAccessCriticalSection constrainAloadCriticalSection(vp->comp(),
Expand Down Expand Up @@ -1663,7 +1663,7 @@ TR::Node *constrainAload(OMR::ValuePropagation *vp, TR::Node *node)
if (!foundInfo)
{
TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(symRef->getOwningMethod(vp->comp())->classOfStatic(symRef->getCPIndex()), vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(symRef->getOwningMethod(vp->comp())->classOfStatic(symRef->getCPIndex()), vp->comp(), allowForAOT);
if (classInfo && classInfo->getFieldInfo())
{
TR_PersistentFieldInfo * fieldInfo = classInfo->getFieldInfo()->findFieldInfo(vp->comp(), node, false);
Expand Down Expand Up @@ -2366,6 +2366,7 @@ TR::Node *constrainIaload(OMR::ValuePropagation *vp, TR::Node *node)
sym->isFinal()))
haveClassLookaheadInfo = true;

bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager);
if (haveClassLookaheadInfo)
{
if (sym->isStatic() && sym->isFinal())
Expand All @@ -2375,13 +2376,12 @@ TR::Node *constrainIaload(OMR::ValuePropagation *vp, TR::Node *node)
TR_OpaqueClassBlock * classOfStatic = symRef->getOwningMethod(vp->comp())->classOfStatic(symRef->getCPIndex());
bool isClassInitialized = false;
TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classOfStatic, vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(classOfStatic, vp->comp(), allowForAOT);
if (classInfo && classInfo->isInitialized())
isClassInitialized = true;

if ((classOfStatic != vp->comp()->getSystemClassPointer() &&
isClassInitialized &&
!vp->comp()->getOption(TR_AOT) &&
(type == TR::Address)))
{
TR::VMAccessCriticalSection constrainIaloadCriticalSection(vp->comp(),
Expand Down Expand Up @@ -4870,6 +4870,9 @@ static void devirtualizeCall(OMR::ValuePropagation *vp, TR::Node *node)
return;
}

if (!vp->comp()->fe()->canDevirtualizeDispatch())
return;

int32_t firstArgIndex = node->getFirstArgumentIndex();
bool isGlobal;
TR::VPConstraint *constraint = vp->getConstraint(node->getChild(firstArgIndex), isGlobal);
Expand Down Expand Up @@ -9463,7 +9466,8 @@ static TR::Node *constrainIfcmpeqne(OMR::ValuePropagation *vp, TR::Node *node, b
}

#ifdef J9_PROJECT_SPECIFIC
if (!vp->comp()->compileRelocatableCode() &&

if ((!vp->comp()->compileRelocatableCode() || vp->comp()->getOption(TR_UseSymbolValidationManager)) &&
vp->lastTimeThrough() &&
vp->comp()->performVirtualGuardNOPing() &&
!vp->_curBlock->isCold() &&
Expand All @@ -9487,12 +9491,13 @@ static TR::Node *constrainIfcmpeqne(OMR::ValuePropagation *vp, TR::Node *node, b
if (typeConstraint)
{
TR::VPConstraint *resolvedTypeConstraint = typeConstraint->asResolvedClass();
bool allowForAOT = vp->comp()->getOption(TR_UseSymbolValidationManager);
if (resolvedTypeConstraint)
{
TR_OpaqueClassBlock *clazz = resolvedTypeConstraint->getClass();

TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(clazz, vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(clazz, vp->comp(), allowForAOT);

if (vp->trace())
traceMsg(vp->comp(), "MyDebug: clazz %p classInfo %p classInfo->isInitialized() %d\n",
Expand Down Expand Up @@ -9525,7 +9530,7 @@ static TR::Node *constrainIfcmpeqne(OMR::ValuePropagation *vp, TR::Node *node, b
else
{
TR_PersistentClassInfo * classInfo =
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(clazz, vp->comp());
vp->comp()->getPersistentInfo()->getPersistentCHTable()->findClassInfoAfterLocking(clazz, vp->comp(), allowForAOT);

if (vp->trace())
traceMsg(vp->comp(), "MyDebug: clazz %p classInfo %p classInfo->isInitialized() %d\n",
Expand Down
Loading

0 comments on commit 70c42dc

Please sign in to comment.