diff --git a/runtime/jcl/common/mgmtmemory.c b/runtime/jcl/common/mgmtmemory.c index 6b374b03713..02420b5ddbb 100644 --- a/runtime/jcl/common/mgmtmemory.c +++ b/runtime/jcl/common/mgmtmemory.c @@ -76,10 +76,10 @@ Java_com_ibm_java_lang_management_internal_MemoryMXBeanImpl_getNonHeapMemoryUsag omrthread_monitor_enter(javaVM->classTableMutex); classLoader = javaVM->internalVMFunctions->allClassLoadersStartDo(&walkState, javaVM, 0); while (NULL != classLoader) { - RamClassUDATABlockFreelist *udataFreeListBlock = &classLoader->ramClassUDATABlocks; - J9RAMClassFreeListBlockType *sub4gFreeListBlock = &classLoader->sub4gBlock; - J9RAMClassFreeListBlockType *freqFreeListBlock = &classLoader->frequentlyAccessedBlock; - J9RAMClassFreeListBlockType *InFreqFreeListBlock = &classLoader->inFrequentlyAccessedBlock; + J9RAMClassUDATABlockFreeList *udataFreeListBlock = &classLoader->ramClassUDATABlocks; + J9RAMClassFreeLists *sub4gFreeListBlock = &classLoader->sub4gBlock; + J9RAMClassFreeLists *freqFreeListBlock = &classLoader->frequentlyAccessedBlock; + J9RAMClassFreeLists *InFreqFreeListBlock = &classLoader->inFrequentlyAccessedBlock; if (NULL != udataFreeListBlock) { UDATA *sub4gListBlock = udataFreeListBlock->ramClassSub4gUDATABlockFreeList; UDATA *freqListBlock = udataFreeListBlock->ramClassFreqUDATABlockFreeList; diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 50913fdd2ab..a4b3728c8cd 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -3569,17 +3569,17 @@ typedef struct J9HookedNative { } J9HookedNative; /* @ddr_namespace: map_to_type=J9ClassLoader */ -typedef struct J9RAMClassFreeListBlockType { - struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList; - struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList; +typedef struct J9RAMClassFreeLists { struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList; -} J9RAMClassFreeListBlockType; + struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList; + struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList; +} J9RAMClassFreeLists; -typedef struct RamClassUDATABlockFreelist { +typedef struct J9RAMClassUDATABlockFreeList { UDATA *ramClassSub4gUDATABlockFreeList; UDATA *ramClassFreqUDATABlockFreeList; UDATA *ramClassInFreqUDATABlockFreeList; -} RamClassUDATABlockFreelist; +} J9RAMClassUDATABlockFreeList; typedef struct J9ClassLoader { struct J9Pool* sharedLibraries; @@ -3600,10 +3600,10 @@ typedef struct J9ClassLoader { #endif /* defined(J9VM_NEEDS_JNI_REDIRECTION) */ struct J9JITExceptionTable* jitMetaDataList; struct J9MemorySegment* classSegments; - struct J9RAMClassFreeListBlockType sub4gBlock; - struct J9RAMClassFreeListBlockType frequentlyAccessedBlock; - struct J9RAMClassFreeListBlockType inFrequentlyAccessedBlock; - struct RamClassUDATABlockFreelist ramClassUDATABlocks; + struct J9RAMClassFreeLists sub4gBlock; + struct J9RAMClassFreeLists frequentlyAccessedBlock; + struct J9RAMClassFreeLists inFrequentlyAccessedBlock; + struct J9RAMClassUDATABlockFreeList ramClassUDATABlocks; struct J9HashTable* redefinedClasses; struct J9NativeLibrary* librariesHead; struct J9NativeLibrary* librariesTail; diff --git a/runtime/vm/createramclass.cpp b/runtime/vm/createramclass.cpp index bf8ab152682..397ec663c4c 100644 --- a/runtime/vm/createramclass.cpp +++ b/runtime/vm/createramclass.cpp @@ -108,7 +108,7 @@ typedef struct J9RAMClassFreeListLargeBlock { UDATA maxSizeInList; } J9RAMClassFreeListLargeBlock; -enum SegmentType { +enum SegmentKind { SUB4G = 0, FREQUENTLY_ACCESSED, INFREQUENTLY_ACCESSED @@ -121,7 +121,7 @@ typedef struct RAMClassAllocationRequest { UDATA *address; UDATA index; UDATA fragmentSize; - SegmentType segmentType; + SegmentKind segmentType; struct RAMClassAllocationRequest *next; } RAMClassAllocationRequest; @@ -3738,7 +3738,7 @@ internalCreateRAMClassFromROMClass(J9VMThread *vmThread, J9ClassLoader *classLoa } static VMINLINE void -addBlockToLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLargeBlock *block, J9RAMClassFreeListBlockType *blockType) +addBlockToLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLargeBlock *block, J9RAMClassFreeLists *blockType) { J9RAMClassFreeListLargeBlock *tailBlock = (J9RAMClassFreeListLargeBlock *) blockType->ramClassLargeBlockFreeList; @@ -3753,7 +3753,7 @@ addBlockToLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLargeBlock } static void -addBlockToFreeList(J9ClassLoader *classLoader, UDATA address, UDATA size, J9RAMClassFreeListBlockType *blockType, UDATA *ramClassUDATABlockFreelist) +addBlockToFreeList(J9ClassLoader *classLoader, UDATA address, UDATA size, J9RAMClassFreeLists *blockType, UDATA *ramClassUDATABlockFreelist) { if (J9_ARE_ANY_BITS_SET(classLoader->flags, J9CLASSLOADER_ANON_CLASS_LOADER)) { /* We support individual class unloading for anonymous classes, so each anonymous class @@ -3763,7 +3763,7 @@ addBlockToFreeList(J9ClassLoader *classLoader, UDATA address, UDATA size, J9RAMC } if (sizeof(UDATA) == size) { UDATA *block = (UDATA *) address; - *block = (UDATA) ramClassUDATABlockFreelist; + *block = (UDATA)ramClassUDATABlockFreelist; ramClassUDATABlockFreelist = block; } else if (sizeof(J9RAMClassFreeListBlock) <= size) { J9RAMClassFreeListBlock *block = (J9RAMClassFreeListBlock *) address; @@ -3786,7 +3786,7 @@ addBlockToFreeList(J9ClassLoader *classLoader, UDATA address, UDATA size, J9RAMC * list to update their maxSizeInList values. */ static void -removeBlockFromLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLargeBlock **freeListBlockPtr, J9RAMClassFreeListLargeBlock *freeListBlock, J9RAMClassFreeListBlockType *blockType) +removeBlockFromLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLargeBlock **freeListBlockPtr, J9RAMClassFreeListLargeBlock *freeListBlock, J9RAMClassFreeLists *blockType) { J9RAMClassFreeListLargeBlock *nextBlock = freeListBlock->nextFreeListBlock; @@ -3816,7 +3816,7 @@ removeBlockFromLargeFreeList(J9ClassLoader *classLoader, J9RAMClassFreeListLarge * Returns TRUE if the fragment was allocated. */ static BOOLEAN -allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMClassFreeListBlock **freeList, J9ClassLoader *classLoader, UDATA *ramClassUDATABlockFreelist, J9RAMClassFreeListBlockType *blockType) +allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMClassFreeListBlock **freeList, J9ClassLoader *classLoader, UDATA *ramClassUDATABlockFreelist, J9RAMClassFreeLists *blockType) { J9RAMClassFreeListBlock **freeListBlockPtr = freeList; J9RAMClassFreeListBlock *freeListBlock = *freeListBlockPtr; @@ -3837,7 +3837,7 @@ allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMCl while (NULL != freeListBlock) { /* Allocate from the start of the block */ - UDATA addressForAlignedArea = ((UDATA) freeListBlock) + prefixSize; + UDATA addressForAlignedArea = ((UDATA)freeListBlock) + prefixSize; UDATA alignmentMod = addressForAlignedArea & alignmentMask; UDATA alignmentShift = (0 == alignmentMod) ? 0 : (alignment - alignmentMod); @@ -3857,12 +3857,12 @@ allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMCl /* Add a new block with the remaining space at the start of this block, if any, to an appropriate free list */ if (0 != alignmentShift) { - addBlockToFreeList(classLoader, (UDATA) freeListBlock, alignmentShift, blockType, ramClassUDATABlockFreelist); + addBlockToFreeList(classLoader, (UDATA)freeListBlock, alignmentShift, blockType, ramClassUDATABlockFreelist); } /* Add a new block with the remaining space at the end of this block, if any, to an appropriate free list */ if (0 != newBlockSize) { - addBlockToFreeList(classLoader, ((UDATA) freeListBlock) + alignmentShift + request->fragmentSize, newBlockSize, blockType, ramClassUDATABlockFreelist); + addBlockToFreeList(classLoader, ((UDATA)freeListBlock) + alignmentShift + request->fragmentSize, newBlockSize, blockType, ramClassUDATABlockFreelist); } return TRUE; @@ -3880,7 +3880,7 @@ allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMCl * Allocates fragments from free list. */ static void -allocateFreeListBlock (RAMClassAllocationRequest *request, J9ClassLoader *classLoader, RAMClassAllocationRequest *prev, J9RAMClassFreeListBlockType *blockType, UDATA *ramClassUDATABlockFreelist) +allocateFreeListBlock (RAMClassAllocationRequest *request, J9ClassLoader *classLoader, RAMClassAllocationRequest *prev, J9RAMClassFreeLists *blockType, UDATA *ramClassUDATABlockFreelist) { if ((sizeof(UDATA) == request->fragmentSize) && (NULL != ramClassUDATABlockFreelist) @@ -3893,10 +3893,10 @@ allocateFreeListBlock (RAMClassAllocationRequest *request, J9ClassLoader *classL UDATA **blockPtr = &ramClassUDATABlockFreelist; while (NULL != block) { /* Check alignment constraint */ - if (0 == (((UDATA) block) & (request->alignment - 1))) { + if (0 == (((UDATA)block) & (request->alignment - 1))) { /* Unhook block from list */ *blockPtr = *(UDATA **) block; - *block = (UDATA) NULL; + *block = (UDATA)NULL; /* Record allocation & adjust for alignment */ request->address = block; @@ -4049,7 +4049,7 @@ internalAllocateRAMClass(J9JavaVM *javaVM, J9ClassLoader *classLoader, RAMClassA /* TODO attempt to coalesce free blocks? */ for (i = 0; i < allocationRequestCount; i++) { if (NULL != allocationRequests[i].address) { - UDATA fragmentAddress = ((UDATA) allocationRequests[i].address) - allocationRequests[i].prefixSize; + UDATA fragmentAddress = ((UDATA)allocationRequests[i].address) - allocationRequests[i].prefixSize; if(SUB4G == allocationRequests[i].segmentType) { addBlockToFreeList(classLoader, fragmentAddress, allocationRequests[i].fragmentSize, &classLoader->sub4gBlock, classLoader->ramClassUDATABlocks.ramClassSub4gUDATABlockFreeList); @@ -4073,7 +4073,7 @@ internalAllocateRAMClass(J9JavaVM *javaVM, J9ClassLoader *classLoader, RAMClassA newSegment->heapAlloc = newSegment->heapTop; /* Allocate the remaining fragments in the new segment, adding holes to the free list */ - allocAddress = ((UDATA) newSegment->heapBase) + sizeof(UDATA); + allocAddress = ((UDATA)newSegment->heapBase) + sizeof(UDATA); for (request = requests; NULL != request; request = request->next) { /* Allocate from the start of the segment */ UDATA addressForAlignedArea = allocAddress + request->prefixSize; @@ -4088,33 +4088,21 @@ internalAllocateRAMClass(J9JavaVM *javaVM, J9ClassLoader *classLoader, RAMClassA if (0 != alignmentShift) { if(SUB4G == request->segmentType) { - addBlockToFreeList(classLoader, (UDATA) allocAddress, alignmentShift, &classLoader->sub4gBlock, classLoader->ramClassUDATABlocks.ramClassSub4gUDATABlockFreeList); + addBlockToFreeList(classLoader, (UDATA)allocAddress, alignmentShift, &classLoader->sub4gBlock, classLoader->ramClassUDATABlocks.ramClassSub4gUDATABlockFreeList); } else if (FREQUENTLY_ACCESSED == request->segmentType) { - addBlockToFreeList(classLoader, (UDATA) allocAddress, alignmentShift, &classLoader->frequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassFreqUDATABlockFreeList); + addBlockToFreeList(classLoader, (UDATA)allocAddress, alignmentShift, &classLoader->frequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassFreqUDATABlockFreeList); } else if (INFREQUENTLY_ACCESSED == request->segmentType) { - addBlockToFreeList(classLoader, (UDATA) allocAddress, alignmentShift, &classLoader->inFrequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassInFreqUDATABlockFreeList); + addBlockToFreeList(classLoader, (UDATA)allocAddress, alignmentShift, &classLoader->inFrequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassInFreqUDATABlockFreeList); } } - allocAddress += alignmentShift + request->fragmentSize; - fragmentsLeftToAllocate--; } - + /* Add a new block with the remaining space at the end of this segment, if any, to an appropriate free list */ - if (allocAddress != (UDATA) newSegment->heapTop) { + if (allocAddress != (UDATA)newSegment->heapTop) { addBlockToFreeList(classLoader, (UDATA)allocAddress, ((UDATA)newSegment->heapTop) - allocAddress, &classLoader->inFrequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassInFreqUDATABlockFreeList); - /*if(SUB4G == request->segmentType) - { - addBlockToFreeList(classLoader, (UDATA) allocAddress, ((UDATA) newSegment->heapTop) - allocAddress, &classLoader->sub4gBlock, classLoader->ramClassUDATABlocks.ramClassSub4gUDATABlockFreeList); - } else if (FREQUENTLY_ACCESSED == request->segmentType) - { - addBlockToFreeList(classLoader, (UDATA) allocAddress, ((UDATA) newSegment->heapTop) - allocAddress, &classLoader->frequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassFreqUDATABlockFreeList); - } else if (INFREQUENTLY_ACCESSED == request->segmentType) - { - addBlockToFreeList(classLoader, (UDATA) allocAddress, ((UDATA) newSegment->heapTop) - allocAddress, &classLoader->inFrequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassInFreqUDATABlockFreeList); - }*/ - } + } } /* Clear all allocated fragments */