Skip to content

Commit

Permalink
WIP: RamClass: Segment allocation enhancements
Browse files Browse the repository at this point in the history
The changes reflect the feature request eclipse-openj9#20644.

Adding segment categories

Closes: eclipse-openj9#20644
Signed-off-by: Nick Kamal <[email protected]>
  • Loading branch information
h3110n3rv3 committed Dec 16, 2024
1 parent 9f1f2aa commit 2e22055
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 104 deletions.
84 changes: 68 additions & 16 deletions runtime/jcl/common/mgmtmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,77 @@ Java_com_ibm_java_lang_management_internal_MemoryMXBeanImpl_getNonHeapMemoryUsag
omrthread_monitor_enter(javaVM->classTableMutex);
classLoader = javaVM->internalVMFunctions->allClassLoadersStartDo(&walkState, javaVM, 0);
while (NULL != classLoader) {
UDATA *udataFreeListBlock = classLoader->ramClassUDATABlockFreeList;
J9RAMClassFreeListBlock *tinyFreeListBlock = classLoader->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = classLoader->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = classLoader->ramClassLargeBlockFreeList;
while (NULL != udataFreeListBlock) {
used -= sizeof(UDATA);
udataFreeListBlock = *(UDATA **) udataFreeListBlock;
RamClassUDATABlockFreelist *udataFreeListBlock = &classLoader->ramClassUDATABlocks;
J9RAMClassFreeListBlockType *sub4gFreeListBlock = &classLoader->sub4gBlock;
J9RAMClassFreeListBlockType *freqFreeListBlock = &classLoader->frequentlyAccessedBlock;
J9RAMClassFreeListBlockType *InFreqFreeListBlock = &classLoader->inFrequentlyAccessedBlock;
if (NULL != udataFreeListBlock) {
UDATA *sub4gListBlock = udataFreeListBlock->ramClassSub4gUDATABlockFreeList;
UDATA *freqListBlock = udataFreeListBlock->ramClassFreqUDATABlockFreeList;
UDATA *inFreqListBlock = udataFreeListBlock->ramClassInFreqUDATABlockFreeList;
while (NULL != sub4gListBlock) {
used -= sizeof(UDATA);
sub4gListBlock = *(UDATA **) sub4gListBlock;
}
while (NULL != freqListBlock) {
used -= sizeof(UDATA);
freqListBlock = *(UDATA **) freqListBlock;
}
while (NULL != inFreqListBlock) {
used -= sizeof(UDATA);
inFreqListBlock = *(UDATA **) inFreqListBlock;
}
}
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
if (NULL != sub4gFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = sub4gFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = sub4gFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = sub4gFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
if (NULL != freqFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = freqFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = freqFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = freqFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
if (NULL != InFreqFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = InFreqFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = InFreqFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = InFreqFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
classLoader = javaVM->internalVMFunctions->allClassLoadersNextDo(&walkState);
}
Expand Down
26 changes: 17 additions & 9 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ typedef struct J9ExceptionHandler {
U_32 exceptionClassIndex;
} J9ExceptionHandler;

#if defined(__xlC__) || defined(J9ZOS390) || defined(__open_xl__) /* Covers: AIX, Linux PPC and z/OS. */
#if defined(__xlC__) || defined(J9ZOS390) /* Covers: Z/OS, AIX, Linux PPC*/
#pragma pack(1)
#elif defined(__ibmxl__) || defined(__GNUC__) || defined(_MSC_VER) /* Covers: Linux PPC LE, Windows, Linux x86 */
#pragma pack(push, 1)
Expand All @@ -1641,7 +1641,7 @@ typedef struct J9MethodParametersData {
J9MethodParameter parameters;
} J9MethodParametersData;

#if defined(__xlC__) || defined(__ibmxl__) || defined(__open_xl__) || defined(__GNUC__) || defined(_MSC_VER) || defined(J9ZOS390) || defined(LINUX) || defined(AIXPPC) || defined(WIN32)
#if defined(__xlC__) || defined(__ibmxl__) || defined(__GNUC__) || defined(_MSC_VER) || defined(J9ZOS390) || defined(LINUX) || defined(AIXPPC) || defined(WIN32)
#pragma pack(pop)
#else
#error "Unrecognized compiler. Cannot pack struct J9MethodParameter and J9MethodParametersData."
Expand Down Expand Up @@ -3569,6 +3569,17 @@ typedef struct J9HookedNative {
} J9HookedNative;

/* @ddr_namespace: map_to_type=J9ClassLoader */
typedef struct J9RAMClassFreeListBlockType {
struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
} J9RAMClassFreeListBlockType;

typedef struct RamClassUDATABlockFreelist {
UDATA *ramClassSub4gUDATABlockFreeList;
UDATA *ramClassFreqUDATABlockFreeList;
UDATA *ramClassInFreqUDATABlockFreeList;
} RamClassUDATABlockFreelist;

typedef struct J9ClassLoader {
struct J9Pool* sharedLibraries;
Expand All @@ -3589,10 +3600,10 @@ typedef struct J9ClassLoader {
#endif /* defined(J9VM_NEEDS_JNI_REDIRECTION) */
struct J9JITExceptionTable* jitMetaDataList;
struct J9MemorySegment* classSegments;
struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
UDATA* ramClassUDATABlockFreeList;
struct J9RAMClassFreeListBlockType sub4gBlock;
struct J9RAMClassFreeListBlockType frequentlyAccessedBlock;
struct J9RAMClassFreeListBlockType inFrequentlyAccessedBlock;
struct RamClassUDATABlockFreelist ramClassUDATABlocks;
struct J9HashTable* redefinedClasses;
struct J9NativeLibrary* librariesHead;
struct J9NativeLibrary* librariesTail;
Expand Down Expand Up @@ -4950,9 +4961,6 @@ typedef struct J9InternalVMFunctions {
void ( *printThreadInfo)(struct J9JavaVM *vm, struct J9VMThread *self, char *toFile, BOOLEAN allThreads) ;
void (JNICALL *initializeAttachedThread)(struct J9VMThread *vmContext, const char *name, j9object_t *group, UDATA daemon, struct J9VMThread *initializee) ;
void ( *initializeMethodRunAddressNoHook)(struct J9JavaVM* vm, J9Method *method) ;
#if defined(J9VM_OPT_SNAPSHOTS)
void ( *initializeMethodRunAddressForSnapshot)(struct J9JavaVM *vm, struct J9Method *method) ;
#endif /* defined(J9VM_OPT_SNAPSHOTS) */
void (JNICALL *sidecarInvokeReflectMethod)(struct J9VMThread *vmContext, jobject methodRef, jobject recevierRef, jobjectArray argsRef) ;
void (JNICALL *sidecarInvokeReflectConstructor)(struct J9VMThread *vmContext, jobject constructorRef, jobject recevierRef, jobjectArray argsRef) ;
struct J9MemorySegmentList* ( *allocateMemorySegmentListWithSize)(struct J9JavaVM * javaVM, U_32 numberOfMemorySegments, UDATA sizeOfElements, U_32 memoryCategory) ;
Expand Down
Loading

0 comments on commit 2e22055

Please sign in to comment.