Search in sources :

Example 1 with J9ModronAllocateHintPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer in project openj9 by eclipse.

the class GCMemoryPoolSplitAddressOrderedList method checkFreeListsImpl.

/* Validates hints and free list entries without needing additional storage for the free list entries */
@Override
public void checkFreeListsImpl() {
    try {
        /* Get free list and hint iterators for self */
        GCFreeListHeapIterator freeEntryIterator = freeListIterator();
        GCHeapLinkedFreeHeader previousFreeEntry = null;
        J9ModronAllocateHintPointer hint = null;
        MM_HeapLinkedFreeHeaderPointer freeEntryFromHint = null;
        /* Needed to return hints in ascending order of free entry address
			 * Here, we convert : iterator -> list -> (sort list) -> iterator */
        @SuppressWarnings("unchecked") List<J9ModronAllocateHintPointer> hints = IteratorHelpers.toList(hintIterator());
        Collections.sort(hints, new Comparator<J9ModronAllocateHintPointer>() {

            public int compare(J9ModronAllocateHintPointer o1, J9ModronAllocateHintPointer o2) {
                try {
                    if (o2.heapFreeHeader().gt(o1.heapFreeHeader())) {
                        return -1;
                    } else if (o2.heapFreeHeader().eq(o1.heapFreeHeader())) {
                        return 0;
                    } else {
                        return 1;
                    }
                } catch (CorruptDataException e) {
                    raiseCorruptDataEvent("corruption detected in allocation hints", e, false);
                }
                throw new UnsupportedOperationException("Unreachable");
            }
        });
        Iterator<J9ModronAllocateHintPointer> allocHintIterator = hints.iterator();
        if (allocHintIterator.hasNext()) {
            hint = allocHintIterator.next();
            freeEntryFromHint = hint.heapFreeHeader();
        }
        while (freeEntryIterator.hasNext()) {
            GCHeapLinkedFreeHeader freeListEntry = freeEntryIterator.next();
            /* Free List Entry(FLE) checks */
            try {
                /* Call the generic check from base class */
                freeEntryCheck(freeListEntry, previousFreeEntry);
                /* Cache the previousFreeEntry for ordering checks */
                previousFreeEntry = freeListEntry;
            } catch (CorruptFreeEntryException e) {
                raiseCorruptDataEvent("Free list corruption detected", e, false);
            } catch (CorruptDataException e) {
                raiseCorruptDataEvent("Corruption detected in free entry", e, false);
            }
            /* Check hint is in Free List */
            MM_HeapLinkedFreeHeaderPointer freeListEntryPointer = freeListEntry.getHeader();
            /* null is the success condition. It indicated that the free entry from the hint was found in the pools free list.
				 * If we find a entry from hint that is less than current free entry in pools list, fail. */
            while ((null != freeEntryFromHint) && freeEntryFromHint.lte(freeListEntryPointer)) {
                if (freeEntryFromHint.lt(freeListEntryPointer)) {
                    throw new CorruptHintException("allocHintFreeEntryCorrupt", hint);
                } else {
                    if (allocHintIterator.hasNext()) {
                        hint = allocHintIterator.next();
                        freeEntryFromHint = hint.heapFreeHeader();
                    } else {
                        freeEntryFromHint = null;
                    }
                }
            }
        }
        /* If the FLE from the hint was never found in the pools FL, it was a bogus entry */
        if (null != freeEntryFromHint) {
            raiseCorruptDataEvent("Hint corruption detected ", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Data corruption detected while validating freelists", e, false);
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with J9ModronAllocateHintPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer in project openj9 by eclipse.

the class GCModronAllocateHintIteratorAOL method next.

@Override
public J9ModronAllocateHintPointer next() {
    if (hasNext()) {
        J9ModronAllocateHintPointer next = _currentHint;
        advanceHint();
        return next;
    } else {
        throw new NoSuchElementException("There are no more items available through this iterator");
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with J9ModronAllocateHintPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer in project openj9 by eclipse.

the class GCModronAllocateHintIteratorSAOL method next.

@Override
public J9ModronAllocateHintPointer next() {
    if (hasNext()) {
        J9ModronAllocateHintPointer next = _currentHint;
        advanceHint();
        return next;
    } else {
        throw new NoSuchElementException("There are no more items available through this iterator");
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with J9ModronAllocateHintPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer in project openj9 by eclipse.

the class GCMemoryPoolAddressOrderedList method checkFreeListsImpl.

/* Validates hints and free list entries without needing additional storage for the free list entries */
@Override
public void checkFreeListsImpl() {
    try {
        /* Get free list and hint iterators for self */
        GCFreeListHeapIterator freeEntryIterator = freeListIterator();
        GCHeapLinkedFreeHeader previousFreeEntry = null;
        J9ModronAllocateHintPointer hint = null;
        MM_HeapLinkedFreeHeaderPointer freeEntryFromHint = null;
        /* Needed to return hints in ascending order of free entry address
			 * Here, we convert : iterator -> list -> (sort list) -> iterator */
        @SuppressWarnings("unchecked") List<J9ModronAllocateHintPointer> hints = IteratorHelpers.toList(hintIterator());
        Collections.sort(hints, new Comparator<J9ModronAllocateHintPointer>() {

            public int compare(J9ModronAllocateHintPointer o1, J9ModronAllocateHintPointer o2) {
                try {
                    if (o2.heapFreeHeader().gt(o1.heapFreeHeader())) {
                        return -1;
                    } else if (o2.heapFreeHeader().eq(o1.heapFreeHeader())) {
                        return 0;
                    } else {
                        return 1;
                    }
                } catch (CorruptDataException e) {
                    raiseCorruptDataEvent("Corruption detected in image", e, false);
                    throw new UnsupportedOperationException("Unreachable");
                }
            }
        });
        Iterator<J9ModronAllocateHintPointer> allocHintIterator = hints.iterator();
        if (allocHintIterator.hasNext()) {
            hint = allocHintIterator.next();
            freeEntryFromHint = hint.heapFreeHeader();
        }
        while (freeEntryIterator.hasNext()) {
            GCHeapLinkedFreeHeader freeListEntry = freeEntryIterator.next();
            /* Free List Entry(FLE) checks */
            try {
                /* Call the generic check from base class */
                freeEntryCheck(freeListEntry, previousFreeEntry);
                /* Cache the previousFreeEntry for ordering checks */
                previousFreeEntry = freeListEntry;
            } catch (CorruptFreeEntryException e) {
                raiseCorruptDataEvent("Free list corruption detected", e, false);
            } catch (CorruptDataException e) {
                raiseCorruptDataEvent("Corruption detected in image", e, false);
            }
            /* Check if the hints entry is in the pools free list */
            MM_HeapLinkedFreeHeaderPointer freeListEntryPointer = freeListEntry.getHeader();
            /* null is the success condition. It indicated that the free entry from the hint was found in the pools free list.
				 * If we find a entry from hint that is less than current free entry in pools list, fail. */
            while ((null != freeEntryFromHint) && freeEntryFromHint.lte(freeListEntryPointer)) {
                if (freeEntryFromHint.lt(freeListEntryPointer)) {
                    raiseCorruptDataEvent("Hint corruption detected", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
                } else {
                    if (allocHintIterator.hasNext()) {
                        hint = allocHintIterator.next();
                        freeEntryFromHint = hint.heapFreeHeader();
                    } else {
                        freeEntryFromHint = null;
                    }
                }
            }
        }
        /* If the FLE from the hint was never found in the pools FL, it was a bogus entry */
        if (null != freeEntryFromHint) {
            raiseCorruptDataEvent("Hint corruption detected ", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Data corruption detected while validating freelists", e, false);
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

J9ModronAllocateHintPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer)4 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 MM_HeapLinkedFreeHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)2 NoSuchElementException (java.util.NoSuchElementException)2