@@ -707,10 +707,6 @@ class VM_JFRConstantPoolTypes {
707707
708708 void addSystemGCEntry (J9JFRSystemGC *systemGCData);
709709
710- void addModuleRequireEntry (J9JFRModuleRequire *moduleRequireData);
711-
712- void addModuleExportEntry (J9JFRModuleExport *moduleExportData);
713-
714710 J9Pool *getExecutionSampleTable ()
715711 {
716712 return _executionSampleTable;
@@ -1060,12 +1056,6 @@ class VM_JFRConstantPoolTypes {
10601056 case J9JFR_EVENT_TYPE_SYSTEM_GC :
10611057 addSystemGCEntry ((J9JFRSystemGC *)event);
10621058 break ;
1063- case J9JFR_EVENT_TYPE_MODULE_REQUIRE :
1064- addModuleRequireEntry ((J9JFRModuleRequire *)event);
1065- break ;
1066- case J9JFR_EVENT_TYPE_MODULE_EXPORT :
1067- addModuleExportEntry ((J9JFRModuleExport *)event);
1068- break ;
10691059 default :
10701060 Assert_VM_unreachable ();
10711061 break ;
@@ -1080,6 +1070,7 @@ class VM_JFRConstantPoolTypes {
10801070 if (dumpCalled) {
10811071 loadSystemProcesses (_currentThread);
10821072 loadNativeLibraries (_currentThread);
1073+ loadModuleRequireAndModuleExportEvents ();
10831074 }
10841075
10851076 shallowEntries = pool_new (sizeof (ClassEntry **), 0 , sizeof (U_64 ), 0 , J9_GET_CALLSITE (), OMRMEM_CATEGORY_VM , POOL_FOR_PORT (privatePortLibrary));
@@ -1487,6 +1478,88 @@ class VM_JFRConstantPoolTypes {
14871478 omrsl_get_libraries (processNativeLibrariesCallback, this );
14881479 }
14891480
1481+ void loadModuleRequireAndModuleExportEvents ()
1482+ {
1483+ J9InternalVMFunctions *vmFuncs = _vm->internalVMFunctions ;
1484+ J9ClassLoaderWalkState walkState;
1485+ J9ClassLoader *classLoader = vmFuncs->allClassLoadersStartDo (&walkState, _vm, 0 );
1486+ int64_t time = j9time_nano_time ();
1487+ #ifdef J9VM_THR_PREEMPTIVE
1488+ omrthread_monitor_enter (_vm->classLoaderModuleAndLocationMutex );
1489+ #endif
1490+
1491+ while (NULL != classLoader) {
1492+ J9HashTableState moduleWalkState;
1493+ J9Module **modulePtr = (J9Module **)hashTableStartDo (classLoader->moduleHashTable , &moduleWalkState);
1494+ J9HashTableState packageWalkState;
1495+ J9Package **packagePtr = NULL ;
1496+
1497+ while (NULL != modulePtr) {
1498+ J9HashTableState fromModuleWalkState;
1499+ J9Module **fromModulePtr = (J9Module **)hashTableStartDo ((*modulePtr)->readAccessHashTable , &fromModuleWalkState);
1500+ while (NULL != fromModulePtr) {
1501+ ModuleRequireEntry *entry = (ModuleRequireEntry *)pool_newElement (_moduleRequireTable);
1502+
1503+ if (NULL == entry) {
1504+ _buildResult = OutOfMemory;
1505+ goto done;
1506+ }
1507+
1508+ entry->ticks = time;
1509+ entry->sourceModuleIndex = addModuleEntry (*fromModulePtr);
1510+ if (isResultNotOKay ()) goto done;
1511+
1512+ entry->requiredModuleIndex = addModuleEntry (*modulePtr);
1513+ if (isResultNotOKay ()) goto done;
1514+
1515+ _moduleRequireCount += 1 ;
1516+
1517+ fromModulePtr = (J9Module **)hashTableNextDo (&fromModuleWalkState);
1518+ }
1519+
1520+ modulePtr = (J9Module **)hashTableNextDo (&moduleWalkState);
1521+ }
1522+
1523+ packagePtr = (J9Package **)hashTableStartDo (classLoader->packageHashTable , &packageWalkState);
1524+ while (NULL != packagePtr) {
1525+ J9HashTableState toModuleWalkState;
1526+ J9Module **toModulePtr = (J9Module **)hashTableStartDo ((*packagePtr)->exportsHashTable , &toModuleWalkState);
1527+ while (NULL != toModulePtr) {
1528+ U_32 exportedPackageIndex = addPackageEntry ((*packagePtr)->module , *packagePtr, TRUE );
1529+ /* Skip this entry if no class from the package has been loaded. */
1530+ if (0 != exportedPackageIndex) {
1531+ ModuleExportEntry *entry = (ModuleExportEntry *)pool_newElement (_moduleExportTable);
1532+
1533+ if (NULL == entry) {
1534+ _buildResult = OutOfMemory;
1535+ goto done;
1536+ }
1537+
1538+ entry->ticks = time;
1539+ entry->exportedPackageIndex = exportedPackageIndex;
1540+ if (isResultNotOKay ()) goto done;
1541+
1542+ entry->targetModuleIndex = addModuleEntry (*toModulePtr);
1543+ if (isResultNotOKay ()) goto done;
1544+
1545+ _moduleExportCount += 1 ;
1546+ }
1547+
1548+ toModulePtr = (J9Module **)hashTableNextDo (&toModuleWalkState);
1549+ }
1550+
1551+ packagePtr = (J9Package **)hashTableNextDo (&packageWalkState);
1552+ }
1553+
1554+ classLoader = vmFuncs->allClassLoadersNextDo (&walkState);
1555+ }
1556+ done:
1557+ #ifdef J9VM_THR_PREEMPTIVE
1558+ omrthread_monitor_exit (_vm->classLoaderModuleAndLocationMutex );
1559+ #endif
1560+ vmFuncs->allClassLoadersEndDo (&walkState);
1561+ }
1562+
14901563 VM_JFRConstantPoolTypes (J9VMThread *currentThread)
14911564 : _currentThread(currentThread)
14921565 , _vm(currentThread->javaVM)
0 commit comments