Search in sources :

Example 6 with GCHeapLinkedFreeHeader

use of com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader in project openj9 by eclipse.

the class GCMemoryPoolSplitAddressOrderedList method freeEntryCheck.

private void freeEntryCheck(GCHeapLinkedFreeHeader freeListEntry, GCHeapLinkedFreeHeader previousFreeEntry) throws CorruptFreeEntryException, CorruptDataException {
    /* Checks Standard GC specific parameters */
    MM_HeapLinkedFreeHeaderPointer freeEntryPointer = freeListEntry.getHeader();
    MM_HeapLinkedFreeHeaderPointer previousFreeEntryPointer = MM_HeapLinkedFreeHeaderPointer.NULL;
    freeEntryCheckGeneric(freeListEntry);
    /* Checks ordering of AOL and SAOL entries */
    if (null != previousFreeEntry) {
        previousFreeEntryPointer = previousFreeEntry.getHeader();
        /* Validate list ordering.
			 * (This is done in GC code at runtime as an assert0 but just in case) */
        if (previousFreeEntryPointer.gte(freeEntryPointer)) {
            throw new CorruptFreeEntryException("invalidOrdering", freeEntryPointer);
        }
    }
    /* Validate size :
		 * Check if size less than 512 / 768 bytes */
    if (freeListEntry.getSize().lt(GCBase.getExtensions().tlhMinimumSize())) {
        throw new CorruptFreeEntryException("sizeFieldInvalid", freeListEntry.getHeader());
    }
}
Also used : MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)

Example 7 with GCHeapLinkedFreeHeader

use of com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader in project openj9 by eclipse.

the class GCObjectHeapIteratorSegregated_V1 method hasNext.

public boolean hasNext() {
    try {
        if (null != currentObject) {
            return true;
        }
        while (scanPtr.lt(scanPtrTop)) {
            while (scanPtr.gt(allocationCacheRanges[currentAllocationCacheRange][1])) {
                currentAllocationCacheRange++;
            }
            if (scanPtr.gte(allocationCacheRanges[currentAllocationCacheRange][0])) {
                // We're in an unused region.
                // TODO : this should report as a hole
                scanPtr = U8Pointer.cast(allocationCacheRanges[currentAllocationCacheRange][1]);
                currentAllocationCacheRange++;
                continue;
            }
            currentObject = J9ObjectPointer.cast(scanPtr);
            if (MM_HeapRegionDescriptor$RegionType.SEGREGATED_SMALL == type) {
                if (!ObjectModel.isDeadObject(currentObject)) {
                    UDATA sizeInBytes = ObjectModel.getConsumedSizeInBytesWithHeader(currentObject);
                    if (sizeInBytes.gt(cellSize)) {
                        /* The size of an object should never be greater than the size of its containing cell. */
                        currentObject = null;
                        throw new CorruptDataException("Allocated object at " + scanPtr.getHexAddress() + " has an invalid size of " + sizeInBytes.getHexValue());
                    }
                    scanPtr = scanPtr.add(cellSize);
                    if (includeLiveObjects) {
                        return true;
                    }
                } else {
                    UDATA sizeInBytes = ObjectModel.getSizeInBytesDeadObject(currentObject);
                    if (sizeInBytes.lt(cellSize)) {
                        /* The size of a hole should always be at least the size of a cell. */
                        currentObject = null;
                        throw new CorruptDataException("GCHeapLinkedFreeHeader at " + scanPtr.getHexAddress() + " has an invalid size of " + sizeInBytes.getHexValue());
                    }
                    scanPtr = scanPtr.addOffset(sizeInBytes);
                    if (includeDeadObjects) {
                        return true;
                    }
                }
            } else if (MM_HeapRegionDescriptor$RegionType.SEGREGATED_LARGE == type) {
                scanPtr = U8Pointer.cast(scanPtrTop);
                if (includeLiveObjects) {
                    return true;
                }
            } else {
                throw new CorruptDataException("Invalid region type");
            }
        }
        return false;
    } catch (CorruptDataException e) {
        // can try to recover from this
        raiseCorruptDataEvent("Error getting next item", e, false);
        return false;
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 8 with GCHeapLinkedFreeHeader

use of com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader in project openj9 by eclipse.

the class DumpSegregatedStatsCommand method getFreeCellCount.

/**
 * Count the number of free cells in the MM_HeapRegionDescriptorSegregatedPointer freelist
 * @throws CorruptDataException
 */
public long getFreeCellCount(MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptor) throws CorruptDataException {
    /* TODO assumes a small region */
    MM_MemoryPoolAggregatedCellListPointer memoryPoolACL = heapRegionDescriptor._memoryPoolACL();
    GCHeapLinkedFreeHeader heapLinkedFreeHeader = GCHeapLinkedFreeHeader.fromLinkedFreeHeaderPointer(memoryPoolACL._freeListHead());
    /* Get the size classes */
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
    UDATA sizeClassIndex = heapRegionDescriptor._sizeClass();
    long cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex).longValue();
    long freeCellCount = 0;
    while (heapLinkedFreeHeader.getHeader().notNull()) {
        freeCellCount += heapLinkedFreeHeader.getSize().longValue() / cellSize;
        heapLinkedFreeHeader = heapLinkedFreeHeader.getNext();
    }
    return freeCellCount;
}
Also used : MM_MemoryPoolAggregatedCellListPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_MemoryPoolAggregatedCellListPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9VMGCSizeClassesPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSizeClassesPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) GCHeapLinkedFreeHeader(com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader)

Example 9 with GCHeapLinkedFreeHeader

use of com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader in project openj9 by eclipse.

the class CheckEngine method checkJ9LinkedFreeHeader.

/**
 * Verify the integrity of an GCHeapLinkedFreeHeader (hole) on the heap.
 * Checks various aspects of hole integrity.
 *
 * @param hole Pointer to the hole
 * @param segment The segment containing the pointer
 * @param checkFlags Type/level of verification
 *
 * @return @ref GCCheckWalkStageErrorCodes
 * @throws CorruptDataException
 *
 * @see @ref checkFlags
 */
private int checkJ9LinkedFreeHeader(GCHeapLinkedFreeHeader hole, GCHeapRegionDescriptor regionDesc, int checkFlags) throws CorruptDataException {
    J9ObjectPointer object = hole.getObject();
    if (ObjectModel.isSingleSlotDeadObject(object)) {
        /* TODO: we can add warning here if header of single slot hole is not standard (0s or fs) */
        return J9MODRON_GCCHK_RC_OK;
    }
    UDATA holeSize = hole.getSize();
    /* Hole size can not be 0 */
    if (holeSize.eq(0)) {
        return J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE;
    }
    /* Hole size must be aligned */
    if (holeSize.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
        return J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE_NOT_ALIGNED;
    }
    UDATA regionStart = UDATA.cast(regionDesc.getLowAddress());
    UDATA regionEnd = regionStart.add(regionDesc.getSize());
    UDATA delta = regionEnd.sub(UDATA.cast(object));
    /* Hole does not fit region */
    if (delta.lt(holeSize)) {
        return J9MODRON_GCCHK_RC_INVALID_RANGE;
    }
    GCHeapLinkedFreeHeader nextHole = hole.getNext();
    J9ObjectPointer nextObject = nextHole.getObject();
    if (!nextObject.isNull()) {
        /* Next must be a hole */
        if (!ObjectModel.isDeadObject(nextObject)) {
            return J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_HOLE;
        }
        /* Next should point to the same region */
        if (regionStart.gt(UDATA.cast(nextObject)) || regionEnd.lte(UDATA.cast(nextObject))) {
            return J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_IN_REGION;
        }
        /* next should not point to inside the hole */
        if (holeSize.add(UDATA.cast(object)).gt(UDATA.cast(nextObject)) && object.lt(nextObject)) {
            return J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_POINTED_INSIDE;
        }
    }
    return J9MODRON_GCCHK_RC_OK;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) GCHeapLinkedFreeHeader(com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

MM_HeapLinkedFreeHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)5 UDATA (com.ibm.j9ddr.vm29.types.UDATA)5 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 GCHeapLinkedFreeHeader (com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader)2 J9ModronAllocateHintPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer)2 AddressedCorruptDataException (com.ibm.j9ddr.AddressedCorruptDataException)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)1 J9VMGCSizeClassesPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSizeClassesPointer)1 MM_MemoryPoolAggregatedCellListPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_MemoryPoolAggregatedCellListPointer)1