Skip to content

Commit

Permalink
Fix discrepancy in definition of functions in GC Extensions
Browse files Browse the repository at this point in the history
There is number of functions in GC Extensions Base defined under
OMR_GC_MODRON_SCAVENGER flag. However there are many places these
functions are called unconditionally without checking of this flag.
This flag is on always in our compilation environment and code compiles.
If it is disabled code won't compile.
The solution is make these functions be defined always and wrap
Scavenger related content inside.

Signed-off-by: Dmitri Pivkine <[email protected]>
  • Loading branch information
dmitripivkine committed Sep 27, 2022
1 parent b1be89c commit 3473148
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 48 deletions.
26 changes: 13 additions & 13 deletions example/glue/ObjectModelDelegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ class GC_ObjectModelDelegate
{
return U_8_MAX;
}

/**
* Returns the field offset of the third hottest field of the object referred to by the forwarded header.
* Valid if scavenger dynamicBreadthFirstScanOrdering is enabled
*
* @param forwardedHeader pointer to the MM_ForwardedHeader instance encapsulating the object
* @return the offset of the third hottest field of the given object referred to by the forwarded header, return U_8_MAX if the hot field does not exist
*/
MMINLINE uint8_t
getHotFieldOffset3(MM_ForwardedHeader *forwardedHeader)
{
return U_8_MAX;
}
#endif /* defined(OMR_GC_MODRON_SCAVENGER) || defined(OMR_GC_VLHGC) */

/**
Expand All @@ -229,19 +242,6 @@ class GC_ObjectModelDelegate
return false;
}

/**
* Returns the field offset of the third hottest field of the object referred to by the forwarded header.
* Valid if scavenger dynamicBreadthFirstScanOrdering is enabled
*
* @param forwardedHeader pointer to the MM_ForwardedHeader instance encapsulating the object
* @return the offset of the third hottest field of the given object referred to by the forwarded header, return U_8_MAX if the hot field does not exist
*/
MMINLINE uint8_t
getHotFieldOffset3(MM_ForwardedHeader *forwardedHeader)
{
return U_8_MAX;
}

/**
* Get the instance size (total) of a forwarded object from the forwarding pointer. The size must
* include the header and any expansion bytes to be allocated if the object will grow when moved.
Expand Down
75 changes: 69 additions & 6 deletions gc/base/GCExtensionsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,31 +1105,94 @@ class MM_GCExtensionsBase : public MM_BaseVirtual {

MMINLINE MM_Heap* getHeap() { return heap; }

#if defined(OMR_GC_MODRON_SCAVENGER)
MMINLINE void
setGuaranteedNurseryRange(void* start, void* end)
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_guaranteedNurseryStart = start;
_guaranteedNurseryEnd = end;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE void
getGuaranteedNurseryRange(void** start, void** end)
{
#if defined(OMR_GC_MODRON_SCAVENGER)
*start = _guaranteedNurseryStart;
*end = _guaranteedNurseryEnd;
#else /* OMR_GC_MODRON_SCAVENGER */
*start = NULL;
*end = NULL;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE bool isRememberedSetInOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
return _isRememberedSetInOverflow;
#else /* OMR_GC_MODRON_SCAVENGER */
return false;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE void setRememberedSetOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_isRememberedSetInOverflow = true;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE void clearRememberedSetOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_isRememberedSetInOverflow = false;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE bool isScavengerRememberedSetInOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
return _isRememberedSetInOverflow;
#else /* OMR_GC_MODRON_SCAVENGER */
return false;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE void setScavengerRememberedSetOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_isRememberedSetInOverflow = true;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE void clearScavengerRememberedSetOverflowState()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_isRememberedSetInOverflow = false;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE bool isScavengerBackOutFlagRaised()
{
#if defined(OMR_GC_MODRON_SCAVENGER)
return backOutFlagCleared < _backOutState;
#else /* OMR_GC_MODRON_SCAVENGER */
return false;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

MMINLINE bool isRememberedSetInOverflowState() { return _isRememberedSetInOverflow; }
MMINLINE void setRememberedSetOverflowState() { _isRememberedSetInOverflow = true; }
MMINLINE void clearRememberedSetOverflowState() { _isRememberedSetInOverflow = false; }
MMINLINE void setConcurrentGlobalGCInProgress(bool inProgress)
{
#if defined(OMR_GC_MODRON_SCAVENGER)
_concurrentGlobalGCInProgress = inProgress;
#endif /* OMR_GC_MODRON_SCAVENGER */
}

#if defined(OMR_GC_MODRON_SCAVENGER)
MMINLINE void setScavengerBackOutState(BackOutState backOutState) { _backOutState = backOutState; }
MMINLINE BackOutState getScavengerBackOutState() { return _backOutState; }
MMINLINE bool isScavengerBackOutFlagRaised() { return backOutFlagCleared < _backOutState; }

MMINLINE bool shouldScavengeNotifyGlobalGCOfOldToOldReference() { return _concurrentGlobalGCInProgress; }
MMINLINE void setConcurrentGlobalGCInProgress(bool inProgress) { _concurrentGlobalGCInProgress = inProgress; }

/**
* Determine whether Adaptive Threading is enabled. AdaptiveGCThreading flag
Expand Down
2 changes: 1 addition & 1 deletion gc/base/standard/ConcurrentCardTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ MM_ConcurrentCardTable::cleanSingleCard(MM_EnvironmentBase *env, Card *card, uin
* mean we re-trace objects not in the RS but RS overflow is assumed to be
* an exceptional circumstance.
*/
if (rememberedObjectsFound && (env->getExtensions()->isRememberedSetInOverflowState())) {
if (rememberedObjectsFound && (env->getExtensions()->isScavengerRememberedSetInOverflowState())) {
*card = (Card)CARD_DIRTY;
}

Expand Down
14 changes: 4 additions & 10 deletions gc/base/standard/ConcurrentGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,9 +1676,7 @@ MM_ConcurrentGC::timeToKickoffConcurrent(MM_EnvironmentBase *env, MM_AllocateDes
if (LANGUAGE_DEFINED_REASON != _stats.getKickoffReason()) {
_languageKickoffReason = NO_LANGUAGE_KICKOFF_REASON;
}
#if defined(OMR_GC_MODRON_SCAVENGER)
_extensions->setConcurrentGlobalGCInProgress(true);
#endif
reportConcurrentKickoff(env);
}
return true;
Expand Down Expand Up @@ -1923,8 +1921,6 @@ MM_ConcurrentGC::clearWorkStackOverflow()
void
MM_ConcurrentGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *subSpace, MM_AllocateDescription *allocDescription, uint32_t gcCode)
{
OMRPORT_ACCESS_FROM_ENVIRONMENT(env);

Trc_MM_ConcurrentGC_internalPreCollect_Entry(env->getLanguageVMThread(), subSpace);

/* Thread roots must have been flushed by this point */
Expand Down Expand Up @@ -1997,8 +1993,8 @@ MM_ConcurrentGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *
MM_ParallelGlobalGC::internalPreCollect(env, subSpace, allocDescription, gcCode);
} else
#endif /* OMR_GC_IDLE_HEAP_MANAGER */
if (_extensions->isRememberedSetInOverflowState() || ((CONCURRENT_OFF < executionModeAtGC) && (CONCURRENT_TRACE_ONLY > executionModeAtGC))) {
CollectionAbortReason reason = (_extensions->isRememberedSetInOverflowState() ? ABORT_COLLECTION_REMEMBERSET_OVERFLOW : ABORT_COLLECTION_INSUFFICENT_PROGRESS);
if (_extensions->isScavengerRememberedSetInOverflowState() || ((CONCURRENT_OFF < executionModeAtGC) && (CONCURRENT_TRACE_ONLY > executionModeAtGC))) {
CollectionAbortReason reason = (_extensions->isScavengerRememberedSetInOverflowState() ? ABORT_COLLECTION_REMEMBERSET_OVERFLOW : ABORT_COLLECTION_INSUFFICENT_PROGRESS);
abortCollection(env, reason);
/* concurrent cycle was aborted so we need to kick off a new cycle and set up the cycle state */
MM_ParallelGlobalGC::internalPreCollect(env, subSpace, allocDescription, gcCode);
Expand All @@ -2011,9 +2007,7 @@ MM_ConcurrentGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *
/* Switch the executionMode to OFF to complete the STW collection */
_stats.switchExecutionMode(executionModeAtGC, CONCURRENT_OFF);

#if defined(OMR_GC_MODRON_SCAVENGER)
_extensions->setConcurrentGlobalGCInProgress(false);
#endif

/* Mark map is usable. We got far enough into the concurrent to be
* sure we at least initialized the mark map so no need to do so again.
Expand All @@ -2024,6 +2018,7 @@ MM_ConcurrentGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *

#if defined(OMR_GC_MODRON_SCAVENGER)
if (_extensions->scavengerEnabled) {
OMRPORT_ACCESS_FROM_ENVIRONMENT(env);
reportConcurrentRememberedSetScanStart(env);
uint64_t startTime = omrtime_hires_clock();

Expand Down Expand Up @@ -2186,9 +2181,8 @@ MM_ConcurrentGC::abortCollection(MM_EnvironmentBase *env, CollectionAbortReason
switchConHelperRequest(CONCURRENT_HELPER_MARK, CONCURRENT_HELPER_WAIT);

_stats.switchExecutionMode(_stats.getExecutionMode(), CONCURRENT_OFF);
#if defined(OMR_GC_MODRON_SCAVENGER)

_extensions->setConcurrentGlobalGCInProgress(false);
#endif

/* make sure to reset the init ranges before the next kickOff */
resetInitRangesForConcurrentKO();
Expand Down
8 changes: 6 additions & 2 deletions gc/base/standard/ConcurrentOverflow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
* Copyright (c) 1991, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -70,12 +70,14 @@ MM_ConcurrentOverflow::initialize(MM_EnvironmentBase *env)
{
bool result = MM_WorkPacketOverflow::initialize(env);

#if defined(OMR_GC_MODRON_SCAVENGER)
if (result) {
/* Initialize monitor for safe initial Cards cleaning in Work Packets Overflow handler */
if(omrthread_monitor_init_with_name(&_cardsClearingMonitor, 0, "MM_ConcurrentOverflow::cardsClearingMonitor")) {
result = false;
}
}
#endif /* OMR_GC_MODRON_SCAVENGER */

return result;
}
Expand All @@ -86,10 +88,12 @@ MM_ConcurrentOverflow::initialize(MM_EnvironmentBase *env)
void
MM_ConcurrentOverflow::tearDown(MM_EnvironmentBase *env)
{
if(NULL != _cardsClearingMonitor) {
#if defined(OMR_GC_MODRON_SCAVENGER)
if (NULL != _cardsClearingMonitor) {
omrthread_monitor_destroy(_cardsClearingMonitor);
_cardsClearingMonitor = NULL;
}
#endif /* OMR_GC_MODRON_SCAVENGER */

MM_WorkPacketOverflow::tearDown(env);
}
Expand Down
7 changes: 2 additions & 5 deletions gc/base/standard/ConfigurationGenerational.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -217,7 +217,6 @@ MM_ConfigurationGenerational::createHeapWithManager(MM_EnvironmentBase *env, UDA
MM_GCExtensionsBase *extensions = env->getExtensions();
MM_Heap *heap = NULL;

#if defined(OMR_GC_MODRON_SCAVENGER)
/* gencon supports split heaps so check that flag here when deciding what kind of MM_Heap to create */
if (extensions->enableSplitHeap) {
UDATA lowSize = extensions->oldSpaceSize;
Expand All @@ -228,9 +227,7 @@ MM_ConfigurationGenerational::createHeapWithManager(MM_EnvironmentBase *env, UDA
* set and "inverted" flag in the extensions and check that in the PSA attach code when determining attachment policy.
* May allow more versatile use cases of the split heaps, though.
*/
} else
#endif /* OMR_GC_MODRON_SCAVENGER */
{
} else {
heap = MM_ConfigurationStandard::createHeapWithManager(env, heapBytesRequested, regionManager);
}
return heap;
Expand Down
4 changes: 1 addition & 3 deletions gc/base/standard/HeapWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,12 @@ MM_HeapWalker::allObjectSlotsDo(MM_EnvironmentBase *env, MM_HeapWalkerSlotFunc f
SlotObjectDoUserData slotObjectDoUserData = { function, userData, walkFlags, this };
uintptr_t modifiedWalkFlags = walkFlags;

#if defined(OMR_GC_MODRON_SCAVENGER)
/* If J9_MU_WALK_NEW_AND_REMEMBERED_ONLY is specified, and rsOverflow has
* occurred, any object in old space might be remembered, so we must walk them all
*/
if (env->getExtensions()->isRememberedSetInOverflowState()) {
if (env->getExtensions()->isScavengerRememberedSetInOverflowState()) {
modifiedWalkFlags &= ~J9_MU_WALK_NEW_AND_REMEMBERED_ONLY;
}
#endif /* OMR_GC_MODRON_SCAVENGER */

allObjectsDo(env, heapWalkerObjectSlotsDo, (void *)&slotObjectDoUserData, modifiedWalkFlags, parallel, prepareHeapForWalk);

Expand Down
2 changes: 1 addition & 1 deletion gc/base/standard/ParallelGlobalGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ hookGlobalGcSweepEndRsoSafetyFixHeap(J9HookInterface** hook, uintptr_t eventNum,
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(event->currentThread);
MM_GCExtensionsBase *extensions = env->getExtensions();

extensions->scavengerRsoScanUnsafe = !extensions->isRememberedSetInOverflowState();
extensions->scavengerRsoScanUnsafe = !extensions->isScavengerRememberedSetInOverflowState();
if (!extensions->scavengerRsoScanUnsafe) {
MM_ParallelGlobalGC *pggc = (MM_ParallelGlobalGC *)userData;
pggc->fixHeapForWalk(env, MEMORY_TYPE_OLD_RAM, FIXUP_DEBUG_TOOLING, fixObject);
Expand Down
6 changes: 3 additions & 3 deletions gc/base/standard/Scavenger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ class MM_Scavenger : public MM_Collector

void clearRememberedSetLists(MM_EnvironmentStandard *env);

MMINLINE bool isRememberedSetInOverflowState() { return _extensions->isRememberedSetInOverflowState(); }
MMINLINE void setRememberedSetOverflowState() { _extensions->setRememberedSetOverflowState(); }
MMINLINE void clearRememberedSetOverflowState() { _extensions->clearRememberedSetOverflowState(); }
MMINLINE bool isRememberedSetInOverflowState() { return _extensions->isScavengerRememberedSetInOverflowState(); }
MMINLINE void setRememberedSetOverflowState() { _extensions->setScavengerRememberedSetOverflowState(); }
MMINLINE void clearRememberedSetOverflowState() { _extensions->clearScavengerRememberedSetOverflowState(); }

/* Auto-remember stack objects so JIT can omit generational barriers */
void rescanThreadSlots(MM_EnvironmentStandard *env);
Expand Down
6 changes: 2 additions & 4 deletions gc/structs/SublistFragment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2016 IBM Corp. and others
* Copyright (c) 1991, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -53,9 +53,7 @@ allocateMemoryForSublistFragment(void *vmThreadRawPtr, J9VMGC_SublistFragment *f
if (result) {
return 0;
} else {
#if defined(OMR_GC_MODRON_SCAVENGER)
env->getExtensions()->setRememberedSetOverflowState();
#endif /* OMR_GC_MODRON_SCAVENGER */
env->getExtensions()->setScavengerRememberedSetOverflowState();
return 1;
}
}
Expand Down

0 comments on commit 3473148

Please sign in to comment.