Skip to content

Instantly share code, notes, and snippets.

@rwy7
Created February 13, 2019 15:37
Show Gist options
  • Save rwy7/1d5304957e6690d9d742405d5f8f5076 to your computer and use it in GitHub Desktop.
Save rwy7/1d5304957e6690d9d742405d5f8f5076 to your computer and use it in GitHub Desktop.
--- upstream-master-cli-hpp 2019-02-13 10:36:24.110900173 -0500
+++ /Users/rwyoung/wsp/openj9-openjdk-jdk11/openj9/runtime/gc_glue_java/ScavengerDelegate.hpp 2019-02-06 16:52:43.411617730 -0500
@@ -1,6 +1,6 @@
/*******************************************************************************
- * Copyright (c) 1991, 2018 IBM Corp. and others
+ * Copyright (c) 2019, 2019 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
@@ -21,8 +21,17 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
-#ifndef COLLECTORLANGUAGEINTERFACEJAVA_HPP_
-#define COLLECTORLANGUAGEINTERFACEJAVA_HPP_
+#if !defined(SCAVENGERDELEGATEJAVA_HPP_)
+#define SCAVENGERDELEGATEJAVA_HPP_
+
+#include "j9.h"
+#include "omrcfg.h"
+
+#if defined(OMR_GC_MODRON_SCAVENGER)
+
+#if defined(J9VM_GC_MODRON_CONCURRENT_MARK) && !defined(OMR_GC_MODRON_CONCURRENT_MARK)
+#error "J9VM_GC_MODRON_CONCURRENT_MARK in j9cfg.h requires OMR_GC_MODRON_CONCURRENT_MARK in omrcfg.h"
+#endif /* defined(J9VM_GC_MODRON_CONCURRENT_MARK) && !defined(OMR_GC_MODRON_CONCURRENT_MARK) */
#include "j9.h"
#include "CollectorLanguageInterface.hpp"
@@ -48,107 +57,34 @@
#endif /* defined(J9VM_GC_MODRON_CONCURRENT_MARK) && !defined(OMR_GC_MODRON_CONCURRENT_MARK) */
/**
- * Class representing a collector language interface. This implements the API between the OMR
- * functionality and the language being implemented.
+ * Class implementing project-specific scavenger functionality.
* @ingroup GC_Base
*/
-class MM_CollectorLanguageInterfaceImpl : public MM_CollectorLanguageInterface {
+class MM_ScavengerDelegate : public MM_BaseNonVirtual {
private:
-protected:
OMR_VM *_omrVM;
J9JavaVM *_javaVM;
MM_GCExtensions *_extensions;
- volatile bool _scavenger_shouldScavengeFinalizableObjects; /**< Set to true at the beginning of a collection if there are any pending finalizable objects */
- volatile bool _scavenger_shouldScavengeUnfinalizedObjects; /**< Set to true at the beginning of a collection if there are any unfinalized objects */
- volatile bool _scavenger_shouldScavengeSoftReferenceObjects; /**< Set to true if there are any SoftReference objects discovered */
- volatile bool _scavenger_shouldScavengeWeakReferenceObjects; /**< Set to true if there are any WeakReference objects discovered */
- volatile bool _scavenger_shouldScavengePhantomReferenceObjects; /**< Set to true if there are any PhantomReference objects discovered */
+ volatile bool _shouldScavengeFinalizableObjects; /**< Set to true at the beginning of a collection if there are any pending finalizable objects */
+ volatile bool _shouldScavengeUnfinalizedObjects; /**< Set to true at the beginning of a collection if there are any unfinalized objects */
+ volatile bool _shouldScavengeSoftReferenceObjects; /**< Set to true if there are any SoftReference objects discovered */
+ volatile bool _shouldScavengeWeakReferenceObjects; /**< Set to true if there are any WeakReference objects discovered */
+ volatile bool _shouldScavengePhantomReferenceObjects; /**< Set to true if there are any PhantomReference objects discovered */
#if defined(J9VM_GC_FINALIZATION)
- bool _scavenger_finalizationRequired; /**< Scavenger variable used to determine if finalization should be triggered */
+ bool _finalizationRequired; /**< Scavenger variable used to determine if finalization should be triggered */
#endif /* J9VM_GC_FINALIZATION */
-public:
-private:
protected:
- bool initialize(MM_EnvironmentBase *env);
- void tearDown(MM_EnvironmentBase *env);
-
- MM_CollectorLanguageInterfaceImpl(J9JavaVM *vm)
- : MM_CollectorLanguageInterface()
- ,_omrVM(vm->omrVM)
- ,_javaVM(vm)
- ,_extensions(MM_GCExtensions::getExtensions(vm))
- ,_scavenger_shouldScavengeFinalizableObjects(false)
- ,_scavenger_shouldScavengeUnfinalizedObjects(false)
- ,_scavenger_shouldScavengeSoftReferenceObjects(false)
- ,_scavenger_shouldScavengeWeakReferenceObjects(false)
- ,_scavenger_shouldScavengePhantomReferenceObjects(false)
-#if defined(J9VM_GC_FINALIZATION)
- ,_scavenger_finalizationRequired(false)
-#endif /* J9VM_GC_FINALIZATION */
- {
- _typeId = __FUNCTION__;
- }
-
public:
- static MM_CollectorLanguageInterfaceImpl *newInstance(MM_EnvironmentBase *env);
- virtual void kill(MM_EnvironmentBase *env);
-
-#if defined(OMR_ENV_DATA64) && !defined(OMR_GC_COMPRESSED_POINTERS)
- virtual void scavenger_poisonSlots(MM_EnvironmentBase *env);
- virtual void scavenger_healSlots(MM_EnvironmentBase *env);
-#endif /* defined(OMR_ENV_DATA64) && !defined(OMR_GC_COMPRESSED_POINTERS) */
-
- static MM_CollectorLanguageInterfaceImpl *getInterface(MM_CollectorLanguageInterface *cli) { return (MM_CollectorLanguageInterfaceImpl *)cli; }
-
-#if defined(OMR_GC_MODRON_SCAVENGER)
- virtual void scavenger_masterSetupForGC(MM_EnvironmentBase *env);
- virtual void scavenger_workerSetupForGC_clearEnvironmentLangStats(MM_EnvironmentBase *env);
- virtual void scavenger_reportScavengeEnd(MM_EnvironmentBase * envBase, bool scavengeSuccessful);
- virtual void scavenger_mergeGCStats_mergeLangStats(MM_EnvironmentBase *envBase);
- virtual void scavenger_masterThreadGarbageCollect_scavengeComplete(MM_EnvironmentBase *envBase);
- virtual void scavenger_masterThreadGarbageCollect_scavengeSuccess(MM_EnvironmentBase *envBase);
- virtual bool scavenger_internalGarbageCollect_shouldPercolateGarbageCollect(MM_EnvironmentBase *envBase, PercolateReason *reason, U_32 *gcCode);
- virtual GC_ObjectScanner *scavenger_getObjectScanner(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr, void *allocSpace, uintptr_t flags);
- virtual void scavenger_flushReferenceObjects(MM_EnvironmentStandard *env);
- virtual bool scavenger_hasIndirectReferentsInNewSpace(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
- virtual bool scavenger_scavengeIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
- virtual void scavenger_backOutIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
- virtual void scavenger_backOutIndirectObjects(MM_EnvironmentStandard *env);
- virtual void scavenger_reverseForwardedObject(MM_EnvironmentBase *env, MM_ForwardedHeader *forwardedObject);
-#if defined (J9VM_INTERP_COMPRESSED_OBJECT_HEADER)
- virtual void scavenger_fixupDestroyedSlot(MM_EnvironmentBase *env, MM_ForwardedHeader *forwardedObject, MM_MemorySubSpaceSemiSpace *subSpaceNew);
-#endif /* J9VM_INTERP_COMPRESSED_OBJECT_HEADER */
-
- void scavenger_setShouldScavengeUnfinalizedObjects(bool shouldScavenge) { _scavenger_shouldScavengeUnfinalizedObjects = shouldScavenge; }
-
- volatile bool scavenger_getShouldScavengeFinalizableObjects() { return _scavenger_shouldScavengeFinalizableObjects; }
- volatile bool scavenger_getShouldScavengeUnfinalizedObjects() { return _scavenger_shouldScavengeUnfinalizedObjects; }
- volatile bool scavenger_getShouldScavengeSoftReferenceObjects() { return _scavenger_shouldScavengeSoftReferenceObjects; }
- volatile bool scavenger_getShouldScavengeWeakReferenceObjects() { return _scavenger_shouldScavengeWeakReferenceObjects; }
- volatile bool scavenger_getShouldScavengePhantomReferenceObjects() { return _scavenger_shouldScavengePhantomReferenceObjects; }
-
-#if defined(J9VM_GC_FINALIZATION)
- void scavenger_setFinalizationRequired(bool req) { _scavenger_finalizationRequired = req; }
- bool scavenger_getFinalizationRequired(void) { return _scavenger_finalizationRequired; }
-#endif /* J9VM_GC_FINALIZATION */
-#if defined(OMR_GC_CONCURRENT_SCAVENGER)
- virtual void scavenger_switchConcurrentForThread(MM_EnvironmentBase *env);
- virtual void scavenger_fixupIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
- virtual bool scavenger_shouldYield();
-#endif /* OMR_GC_CONCURRENT_SCAVENGER */
-#endif /* OMR_GC_MODRON_SCAVENGER */
-
-protected:
private:
/*
* ParallelScavenger, Private
*/
- void private_scavenger_addOwnableSynchronizerObjectInList(MM_EnvironmentStandard *env, omrobjectptr_t object);
- void private_scavenger_setupForOwnableSynchronizerProcessing(MM_EnvironmentStandard *env);
+ void private_addOwnableSynchronizerObjectInList(MM_EnvironmentStandard *env, omrobjectptr_t object);
+ void private_setupForOwnableSynchronizerProcessing(MM_EnvironmentStandard *env);
/*
* Scavenger Collector, Private
@@ -158,14 +94,64 @@
* Decide if GC percolation should occur for class unloading.
* The class unloading occurs after a user defined number of cycles.
*/
- bool private_scavenger_shouldPercolateGarbageCollect_classUnloading(MM_EnvironmentBase *envBase);
+ bool private_shouldPercolateGarbageCollect_classUnloading(MM_EnvironmentBase *envBase);
/**
* Decide if GC percolation should occur due to active JNI critical
* regions. Active regions require that objects do not move, which
* prevents scavenging. Percolate collect instead.
*/
- bool private_scavenger_shouldPercolateGarbageCollect_activeJNICriticalRegions(MM_EnvironmentBase *envBase);
+ bool private_shouldPercolateGarbageCollect_activeJNICriticalRegions(MM_EnvironmentBase *envBase);
+
+protected:
+public:
+ void masterSetupForGC(MM_EnvironmentBase *env);
+ void workerSetupForGC_clearEnvironmentLangStats(MM_EnvironmentBase *env);
+ void reportScavengeEnd(MM_EnvironmentBase * envBase, bool scavengeSuccessful);
+ void mergeGCStats_mergeLangStats(MM_EnvironmentBase *envBase);
+ void masterThreadGarbageCollect_scavengeComplete(MM_EnvironmentBase *envBase);
+ void masterThreadGarbageCollect_scavengeSuccess(MM_EnvironmentBase *envBase);
+ bool internalGarbageCollect_shouldPercolateGarbageCollect(MM_EnvironmentBase *envBase, PercolateReason *reason, U_32 *gcCode);
+ GC_ObjectScanner *getObjectScanner(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr, void *allocSpace, uintptr_t flags);
+ void flushReferenceObjects(MM_EnvironmentStandard *env);
+ bool hasIndirectReferentsInNewSpace(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
+ bool scavengeIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
+ void backOutIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
+ void backOutIndirectObjects(MM_EnvironmentStandard *env);
+ void reverseForwardedObject(MM_EnvironmentBase *env, MM_ForwardedHeader *forwardedObject);
+#if defined (J9VM_INTERP_COMPRESSED_OBJECT_HEADER)
+ void fixupDestroyedSlot(MM_EnvironmentBase *env, MM_ForwardedHeader *forwardedObject, MM_MemorySubSpaceSemiSpace *subSpaceNew);
+#endif /* J9VM_INTERP_COMPRESSED_OBJECT_HEADER */
+
+#if defined(OMR_GC_CONCURRENT_SCAVENGER)
+ void switchConcurrentForThread(MM_EnvironmentBase *env);
+ void fixupIndirectObjectSlots(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr);
+ bool shouldYield();
+#endif /* OMR_GC_CONCURRENT_SCAVENGER */
+
+ void setShouldScavengeUnfinalizedObjects(bool shouldScavenge) { _shouldScavengeUnfinalizedObjects = shouldScavenge; }
+
+ volatile bool getShouldScavengeFinalizableObjects() { return _shouldScavengeFinalizableObjects; }
+ volatile bool getShouldScavengeUnfinalizedObjects() { return _shouldScavengeUnfinalizedObjects; }
+ volatile bool getShouldScavengeSoftReferenceObjects() { return _shouldScavengeSoftReferenceObjects; }
+ volatile bool getShouldScavengeWeakReferenceObjects() { return _shouldScavengeWeakReferenceObjects; }
+ volatile bool getShouldScavengePhantomReferenceObjects() { return _shouldScavengePhantomReferenceObjects; }
+
+#if defined(J9VM_GC_FINALIZATION)
+ void setFinalizationRequired(bool req) { _finalizationRequired = req; }
+ bool getFinalizationRequired(void) { return _finalizationRequired; }
+#endif /* J9VM_GC_FINALIZATION */
+
+#if defined(OMR_ENV_DATA64) && !defined(OMR_GC_COMPRESSED_POINTERS)
+ void poisonSlots(MM_EnvironmentBase *env);
+ void healSlots(MM_EnvironmentBase *env);
+#endif /* defined(OMR_ENV_DATA64) && !defined(OMR_GC_COMPRESSED_POINTERS) */
+
+ bool initialize(MM_EnvironmentBase *env);
+ void tearDown(MM_EnvironmentBase *env);
+
+ MM_ScavengerDelegate(MM_EnvironmentBase* env);
};
-#endif /* COLLECTORLANGUAGEINTERFACEJAVA_HPP_ */
+#endif /* OMR_GC_MODRON_SCAVENGER */
+#endif /* SCAVENGERDELETAGEJAVA_HPP_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment