Skip to content

Commit

Permalink
Add missed scan for modules in System and Application class loaders
Browse files Browse the repository at this point in the history
GC scans System and Application class loaders seperately as permanent
roots. Scanning of the modules has been missed for this path.

related eclipse-openj9#18805

Signed-off-by: Dmitri Pivkine <[email protected]>
  • Loading branch information
dmitripivkine committed Feb 27, 2024
1 parent a78d091 commit 0e069b3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
48 changes: 24 additions & 24 deletions runtime/gc_base/RootScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,44 +395,44 @@ MM_RootScanner::scanPermanentClasses(MM_EnvironmentBase *env)
{
reportScanningStarted(RootScannerEntity_PermanentClasses);

/* Do systemClassLoader */
scanClassloader(env, static_cast<J9JavaVM*>(_omrVM->_language_vm)->systemClassLoader);

/* Do applicationClassLoader */
scanClassloader(env, static_cast<J9JavaVM*>(_omrVM->_language_vm)->applicationClassLoader);

condYield();

reportScanningEnded(RootScannerEntity_PermanentClasses);
}

/**
* Scan all objects from class loader.
*/
void
MM_RootScanner::scanClassloader(MM_EnvironmentBase *env, J9ClassLoader *classLoader)
{
J9MemorySegment *segment = NULL;
J9Class *clazz = NULL;

/* Do systemClassLoader */
if (NULL != static_cast<J9JavaVM*>(_omrVM->_language_vm)->systemClassLoader) {
GC_ClassLoaderSegmentIterator segmentIterator(static_cast<J9JavaVM*>(_omrVM->_language_vm)->systemClassLoader, MEMORY_TYPE_RAM_CLASS);
while(NULL != (segment = segmentIterator.nextSegment())) {
if(_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
if (NULL != classLoader) {
GC_ClassLoaderSegmentIterator segmentIterator(classLoader, MEMORY_TYPE_RAM_CLASS);
while (NULL != (segment = segmentIterator.nextSegment())) {
if (_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
GC_ClassHeapIterator classHeapIterator(static_cast<J9JavaVM*>(_omrVM->_language_vm), segment);
while(NULL != (clazz = classHeapIterator.nextClass())) {
while (NULL != (clazz = classHeapIterator.nextClass())) {
doClass(clazz);
if (shouldYieldFromClassScan(100000)) {
yield();
}
}
}
}
}

/* Do applicationClassLoader */
if (NULL != static_cast<J9JavaVM*>(_omrVM->_language_vm)->applicationClassLoader) {
GC_ClassLoaderSegmentIterator segmentIterator(static_cast<J9JavaVM*>(_omrVM->_language_vm)->applicationClassLoader, MEMORY_TYPE_RAM_CLASS);
while(NULL != (segment = segmentIterator.nextSegment())) {
if(_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
GC_ClassHeapIterator classHeapIterator(static_cast<J9JavaVM*>(_omrVM->_language_vm), segment);
while(NULL != (clazz = classHeapIterator.nextClass())) {
doClass(clazz);
if (shouldYieldFromClassScan(100000)) {
yield();
}
}
}
if (_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
scanModularityObjects(classLoader);
}
}

condYield();

reportScanningEnded(RootScannerEntity_PermanentClasses);
}
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */

Expand Down
8 changes: 8 additions & 0 deletions runtime/gc_base/RootScanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ class MM_RootScanner : public MM_BaseVirtual
void scanArrayObject(MM_EnvironmentBase *env, J9Object *objectPtr, MM_MemoryPool *memoryPool, MM_HeapRegionManager *manager, uintptr_t memoryType);

bool isContinuationListEmpty(MM_EnvironmentBase *env);

/**
* Scan all objects from class loader.
* @param env thread GC environment
* @param classLoader class loader address
*/
void scanClassloader(MM_EnvironmentBase *env, J9ClassLoader *classLoader);

protected:
/* Family of yielding methods to be overridden by incremental scanners such
* as the RealtimeRootScanner. The default implementations of these do
Expand Down

0 comments on commit 0e069b3

Please sign in to comment.