Skip to content

Commit

Permalink
Merge pull request #16553 from LinHu2016/GC_Loom_update_4
Browse files Browse the repository at this point in the history
Fix ContinuationObjectList ScavengerBackOut issue
  • Loading branch information
dmitripivkine committed Jan 17, 2023
2 parents de74266 + 750d8aa commit f0ef7c0
Showing 1 changed file with 73 additions and 8 deletions.
81 changes: 73 additions & 8 deletions runtime/gc_glue_java/ScavengerBackOutScanner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2022 IBM Corp. and others
* Copyright (c) 2015, 2023 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 @@ -34,7 +34,9 @@
#include "ObjectAccessBarrier.hpp"
#include "ReferenceObjectBuffer.hpp"
#include "UnfinalizedObjectBuffer.hpp"
#include "ContinuationObjectBuffer.hpp"
#include "ContinuationObjectList.hpp"

#include "ScavengerBackOutScanner.hpp"

void
Expand Down Expand Up @@ -317,23 +319,86 @@ MM_ScavengerBackOutScanner::backoutUnfinalizedObjects(MM_EnvironmentStandard *en
env->getGCEnvironment()->_unfinalizedObjectBuffer->flush(env);
}
#endif /* J9VM_GC_FINALIZATION */

void
MM_ScavengerBackOutScanner::backoutContinuationObjects(MM_EnvironmentStandard *env)
{
/* TODO: need to solution to handle the backout in case the list has been refreshed. (the related J9VMContinuations has been cleaned up) */
if (!_extensions->isConcurrentScavengerEnabled()) {
/* Back out Continuation Processing */
MM_HeapRegionDescriptorStandard *region = NULL;
GC_HeapRegionIteratorStandard regionIterator(_extensions->heapRegionManager);
while (NULL != (region = regionIterator.nextRegion())) {
MM_Heap *heap = _extensions->heap;
MM_HeapRegionManager *regionManager = heap->getHeapRegionManager();
MM_HeapRegionDescriptorStandard *region = NULL;
bool const compressed = _extensions->compressObjectReferences();

GC_HeapRegionIteratorStandard regionIterator(regionManager);
while (NULL != (region = regionIterator.nextRegion())) {
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
for (uintptr_t i = 0; i < regionExtension->_maxListIndex; i++) {
MM_ContinuationObjectList *list = &regionExtension->_continuationObjectLists[i];
list->startProcessing();
}
}

#if defined(OMR_GC_CONCURRENT_SCAVENGER)
if (_extensions->isConcurrentScavengerEnabled()) {
GC_HeapRegionIteratorStandard regionIterator2(regionManager);
while (NULL != (region = regionIterator2.nextRegion())) {
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
for (uintptr_t i = 0; i < regionExtension->_maxListIndex; i++) {
MM_ContinuationObjectList *list = &regionExtension->_continuationObjectLists[i];
list->backoutList();
if (!list->wasEmpty()) {
omrobjectptr_t object = list->getPriorList();
while (NULL != object) {
MM_ForwardedHeader forwardHeader(object, compressed);
omrobjectptr_t forwardPtr = forwardHeader.getNonStrictForwardedObject();
if (NULL != forwardPtr) {
if (forwardHeader.isSelfForwardedPointer()) {
forwardHeader.restoreSelfForwardedPointer();
} else {
object = forwardPtr;
}
}

omrobjectptr_t next = _extensions->accessBarrier->getContinuationLink(object);
env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);

object = next;
}
}
}
}
} else
#endif /* OMR_GC_CONCURRENT_SCAVENGER */
{
GC_HeapRegionIteratorStandard regionIterator2(regionManager);
while (NULL != (region = regionIterator2.nextRegion())) {
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
for (uintptr_t i = 0; i < regionExtension->_maxListIndex; i++) {
MM_ContinuationObjectList *list = &regionExtension->_continuationObjectLists[i];
if (!list->wasEmpty()) {
omrobjectptr_t object = list->getPriorList();
while (NULL != object) {
omrobjectptr_t next = NULL;
MM_ForwardedHeader forwardHeader(object, compressed);
Assert_MM_false(forwardHeader.isForwardedPointer());
if (forwardHeader.isReverseForwardedPointer()) {
omrobjectptr_t originalObject = forwardHeader.getReverseForwardedPointer();
Assert_MM_true(NULL != originalObject);
next = _extensions->accessBarrier->getContinuationLink(originalObject);
env->getGCEnvironment()->_continuationObjectBuffer->add(env, originalObject);
} else {
next = _extensions->accessBarrier->getContinuationLink(object);
env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);
}

object = next;
}
}
}
}
}

/* restore everything to a flushed state before exiting */
env->getGCEnvironment()->_continuationObjectBuffer->flush(env);

/* Done backout */
}
#endif /* defined(OMR_GC_MODRON_SCAVENGER) */

0 comments on commit f0ef7c0

Please sign in to comment.