Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#17554 from LinHu2016/GC_Loom_update_19
Browse files Browse the repository at this point in the history
Minimize continuation Object size in continuation list
  • Loading branch information
amicic committed Jul 10, 2023
2 parents 4eb0f54 + bbdd543 commit 4759999
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 39 deletions.
2 changes: 2 additions & 0 deletions runtime/gc/gctable.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ J9MemoryManagerFunctions MemoryManagerFunctions = {
j9mm_iterate_all_continuation_objects,
ownableSynchronizerObjectCreated,
continuationObjectCreated,
continuationObjectStarted,
continuationObjectFinished,
j9gc_notifyGCOfClassReplacement,
j9gc_get_jit_string_dedup_policy,
j9gc_stringHashFn,
Expand Down
6 changes: 6 additions & 0 deletions runtime/gc_base/GCExtensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class MM_GCExtensions : public MM_GCExtensionsBase {
};
ContinuationListOption continuationListOption;

enum TimingAddContinuationInList {
onCreated = 0,
onStarted = 1,
};
TimingAddContinuationInList timingAddContinuationInList;
protected:
private:
protected:
Expand Down Expand Up @@ -381,6 +386,7 @@ class MM_GCExtensions : public MM_GCExtensionsBase {
, freeSizeThresholdForSurvivor(DEFAULT_SURVIVOR_THRESHOLD)
, recycleRemainders(true)
, continuationListOption(enable_continuation_list)
, timingAddContinuationInList(onStarted)
{
_typeId = __FUNCTION__;
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/gc_base/gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ extern J9_CFUNC void* finalizeForcedClassLoaderUnload(J9VMThread *vmThread);

extern J9_CFUNC UDATA ownableSynchronizerObjectCreated(J9VMThread *vmThread, j9object_t object);
extern J9_CFUNC UDATA continuationObjectCreated(J9VMThread *vmThread, j9object_t object);
extern J9_CFUNC UDATA continuationObjectStarted(J9VMThread *vmThread, j9object_t object);
extern J9_CFUNC UDATA continuationObjectFinished(J9VMThread *vmThread, j9object_t object);

extern J9_CFUNC void j9gc_notifyGCOfClassReplacement(J9VMThread *vmThread, J9Class *originalClass, J9Class *replacementClass, UDATA isFastHCR);

Expand Down
37 changes: 31 additions & 6 deletions runtime/gc_base/modronapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,18 +1041,43 @@ continuationObjectCreated(J9VMThread *vmThread, j9object_t object)
Assert_MM_true(NULL != object);
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(vmThread->omrVMThread);

if (MM_GCExtensions::disable_continuation_list != MM_GCExtensions::getExtensions(env)->continuationListOption) {
if (MM_GCExtensions::onCreated == MM_GCExtensions::getExtensions(env)->timingAddContinuationInList) {
addContinuationObjectInList(env, object);
}
MM_ObjectAllocationInterface *objectAllocation = env->_objectAllocationInterface;

env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);
MM_ObjectAllocationInterface *objectAllocation = env->_objectAllocationInterface;
if (NULL != objectAllocation) {
objectAllocation->getAllocationStats()->_continuationObjectCount += 1;
}
return 0;
}

if (NULL != objectAllocation) {
objectAllocation->getAllocationStats()->_continuationObjectCount += 1;
}
UDATA
continuationObjectStarted(J9VMThread *vmThread, j9object_t object)
{
Assert_MM_true(NULL != object);
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(vmThread->omrVMThread);
if (MM_GCExtensions::onStarted == MM_GCExtensions::getExtensions(env)->timingAddContinuationInList) {
addContinuationObjectInList(env, object);
}
return 0;
}

UDATA
continuationObjectFinished(J9VMThread *vmThread, j9object_t object)
{
Assert_MM_true(NULL != object);
return 0;
}

void
addContinuationObjectInList(MM_EnvironmentBase *env, j9object_t object)
{
if (MM_GCExtensions::disable_continuation_list != MM_GCExtensions::getExtensions(env)->continuationListOption) {
env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);
}
}

void
j9gc_notifyGCOfClassReplacement(J9VMThread *vmThread, J9Class *oldClass, J9Class *newClass, UDATA isFastHCR)
{
Expand Down
5 changes: 5 additions & 0 deletions runtime/gc_base/modronapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "j9cfg.h"
#include "modronapicore.hpp"

class MM_EnvironmentBase;

extern "C" {
/* define constant memory pool name and garbage collector name here -- the name should not be over 31 characters */
#define J9_GC_MANAGEMENT_POOL_NAME_HEAP_OLD "Java heap"
Expand Down Expand Up @@ -102,6 +104,9 @@ J9HookInterface** j9gc_get_private_hook_interface(J9JavaVM *javaVM);
UDATA ownableSynchronizerObjectCreated(J9VMThread *vmThread, j9object_t object);

UDATA continuationObjectCreated(J9VMThread *vmThread, j9object_t object);
UDATA continuationObjectStarted(J9VMThread *vmThread, j9object_t object);
UDATA continuationObjectFinished(J9VMThread *vmThread, j9object_t object);
void addContinuationObjectInList(MM_EnvironmentBase *env, j9object_t object);
void preMountContinuation(J9VMThread *vmThread, j9object_t object);
void postUnmountContinuation(J9VMThread *vmThread, j9object_t object);

Expand Down
9 changes: 7 additions & 2 deletions runtime/gc_glue_java/MarkingSchemeRootClearer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "j9.h"
#include "j9cfg.h"
#include "j9consts.h"
#include "ModronAssertions.h"

#if defined(J9VM_GC_FINALIZATION)
#include "CollectorLanguageInterfaceImpl.hpp"
Expand All @@ -42,13 +43,15 @@
#include "ModronAssertions.h"
#include "OwnableSynchronizerObjectBuffer.hpp"
#include "ContinuationObjectBuffer.hpp"
#include "VMHelpers.hpp"
#include "ParallelDispatcher.hpp"
#include "ReferenceObjectBuffer.hpp"
#include "ReferenceStats.hpp"
#include "RootScanner.hpp"
#include "StackSlotValidator.hpp"
#include "UnfinalizedObjectBuffer.hpp"
#if JAVA_SPEC_VERSION >= 19
#include "ContinuationHelpers.hpp"
#endif /* JAVA_SPEC_VERSION >= 19 */

void
MM_MarkingSchemeRootClearer::doSlot(omrobjectptr_t *slotPtr)
Expand Down Expand Up @@ -308,6 +311,7 @@ MM_MarkingSchemeRootClearer::scanOwnableSynchronizerObjects(MM_EnvironmentBase *
void
MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
{
#if JAVA_SPEC_VERSION >= 19
if (_markingDelegate->shouldScanContinuationObjects()) {
/* allow the marking scheme to handle this */
reportScanningStarted(RootScannerEntity_ContinuationObjects);
Expand All @@ -325,7 +329,7 @@ MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
while (NULL != object) {
gcEnv->_markJavaStats._continuationCandidates += 1;
omrobjectptr_t next = _extensions->accessBarrier->getContinuationLink(object);
if (_markingScheme->isMarked(object)) {
if (_markingScheme->isMarked(object) && !VM_ContinuationHelpers::isFinished(*VM_ContinuationHelpers::getContinuationStateAddress((J9VMThread *)env->getLanguageVMThread() , object))) {
/* object was already marked. */
gcEnv->_continuationObjectBuffer->add(env, object);
} else {
Expand All @@ -344,6 +348,7 @@ MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
gcEnv->_continuationObjectBuffer->flush(env);
reportScanningEnded(RootScannerEntity_ContinuationObjects);
}
#endif /* JAVA_SPEC_VERSION >= 19 */
}

void
Expand Down
18 changes: 12 additions & 6 deletions runtime/gc_glue_java/ScavengerRootClearer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#include "UnfinalizedObjectList.hpp"
#include "ContinuationObjectBuffer.hpp"
#include "ContinuationObjectList.hpp"
#include "VMHelpers.hpp"
#if JAVA_SPEC_VERSION >= 19
#include "ContinuationHelpers.hpp"
#endif /* JAVA_SPEC_VERSION >= 19 */

#include "ScavengerRootClearer.hpp"

Expand Down Expand Up @@ -221,6 +223,7 @@ MM_ScavengerRootClearer::scavengeUnfinalizedObjects(MM_EnvironmentStandard *env)
void
MM_ScavengerRootClearer::scavengeContinuationObjects(MM_EnvironmentStandard *env)
{
#if JAVA_SPEC_VERSION >= 19
MM_HeapRegionDescriptorStandard *region = NULL;
GC_HeapRegionIteratorStandard regionIterator(_extensions->heapRegionManager);
GC_Environment *gcEnv = env->getGCEnvironment();
Expand All @@ -238,13 +241,15 @@ MM_ScavengerRootClearer::scavengeContinuationObjects(MM_EnvironmentStandard *env
gcEnv->_scavengerJavaStats._continuationCandidates += 1;

MM_ForwardedHeader forwardedHeader(object, compressed);
if (!forwardedHeader.isForwardedPointer()) {
Assert_GC_true_with_message2(env, _scavenger->isObjectInEvacuateMemory(object), "Continuation object %p should be a dead object, forwardedHeader=%p\n", object, &forwardedHeader);
omrobjectptr_t forwardedPtr = object;
if (forwardedHeader.isForwardedPointer()) {
forwardedPtr = forwardedHeader.getForwardedObject();
Assert_GC_true_with_message(env, NULL != forwardedPtr, "Continuation object %p should be forwarded\n", object);
}
if (!forwardedHeader.isForwardedPointer() || VM_ContinuationHelpers::isFinished(*VM_ContinuationHelpers::getContinuationStateAddress((J9VMThread *)env->getLanguageVMThread() , forwardedPtr))) {
gcEnv->_scavengerJavaStats._continuationCleared += 1;
_extensions->releaseNativesForContinuationObject(env, object);
_extensions->releaseNativesForContinuationObject(env, forwardedPtr);
} else {
omrobjectptr_t forwardedPtr = forwardedHeader.getForwardedObject();
Assert_GC_true_with_message(env, NULL != forwardedPtr, "Continuation object %p should be forwarded\n", object);
gcEnv->_continuationObjectBuffer->add(env, forwardedPtr);
}
object = next;
Expand All @@ -257,6 +262,7 @@ MM_ScavengerRootClearer::scavengeContinuationObjects(MM_EnvironmentStandard *env

/* restore everything to a flushed state before exiting */
gcEnv->_continuationObjectBuffer->flush(env);
#endif /* JAVA_SPEC_VERSION >= 19 */
}

#endif /* defined(OMR_GC_MODRON_SCAVENGER) */
Expand Down
9 changes: 9 additions & 0 deletions runtime/gc_modron_startup/mmparseXXgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,15 @@ gcParseXXgcArguments(J9JavaVM *vm, char *optArg)
continue;
}

if (try_scan(&scan_start, "AddContinuationInListOnStarted")) {
extensions->timingAddContinuationInList = MM_GCExtensions::onStarted;
continue;
}

if (try_scan(&scan_start, "AddContinuationInListOnCreated")) {
extensions->timingAddContinuationInList = MM_GCExtensions::onCreated;
continue;
}
/* Couldn't find a match for arguments */
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTION_UNKNOWN, error_scan);
returnValue = JNI_EINVAL;
Expand Down
Loading

0 comments on commit 4759999

Please sign in to comment.