use of com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject in project openj9 by eclipse.
the class GCHeapMap method queryRange.
/**
* Query the mark map to see what objects are marked within the specified range.
* Return an array of MarkedObject records describing each entry found.
* @param base Bottom of the range to query (inclusive)
* @param top Top of the range to query (exclusive)
* @return A MarkedObject[] containing the results
* @throws CorruptDataException
*/
public MarkedObject[] queryRange(J9ObjectPointer base, J9ObjectPointer top) throws CorruptDataException {
/* Naive implementation; should work but slow */
ArrayList<MarkedObject> results = new ArrayList<MarkedObject>();
if (base.lt(_heapBase)) {
base = J9ObjectPointer.cast(_heapBase);
}
if (top.gt(_heapTop)) {
top = J9ObjectPointer.cast(_heapTop);
}
if (base.gt(top)) {
base = top;
}
J9ObjectPointer cursor = base;
while (cursor.lt(top)) {
UDATA[] indexAndMask = getSlotIndexAndMask(cursor);
UDATAPointer slot = _heapMapBits.add(indexAndMask[0]);
if (slot.at(0).bitAnd(indexAndMask[1]).gt(0)) {
results.add(new MarkedObject(cursor, slot));
}
cursor = cursor.addOffset(getObjectGrain());
}
return results.toArray(new MarkedObject[results.size()]);
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject in project openj9 by eclipse.
the class GCMarkMapStandard method queryRange.
@Override
public MarkedObject[] queryRange(J9ObjectPointer base, J9ObjectPointer top) throws CorruptDataException {
/* Naive implementation; should work but slow -- ever more than the super.
* Add handling for compacted records in the mark map. */
ArrayList<MarkedObject> results = new ArrayList<MarkedObject>();
if (base.lt(_heapBase)) {
base = J9ObjectPointer.cast(_heapBase);
}
if (top.gt(_heapTop)) {
top = J9ObjectPointer.cast(_heapTop);
}
if (base.gt(top)) {
base = top;
}
J9ObjectPointer cursor = base;
while (cursor.lt(top)) {
UDATA heapBaseOffset = UDATA.cast(cursor).sub(UDATA.cast(_heapBase));
// pairs of UDATA, so *2
UDATA pageIndex = heapBaseOffset.div(MM_CompactScheme.sizeof_page).mult(2);
UDATA compactTableEntry_addr = _heapMapBits.at(pageIndex);
UDATA compactTableEntry_bits = _heapMapBits.at(pageIndex.add(1));
// Horribly inefficient -- recomputing relocations every single time!
if (compactTableEntry_addr.allBitsIn(3)) {
// Object has been compacted -- assuming that the pointer was the pre-compacted one
J9ObjectPointer newObject = J9ObjectPointer.cast(compactTableEntry_addr.bitAnd(~3));
UDATA bits = compactTableEntry_bits;
UDATA offset = heapBaseOffset.mod(MM_CompactScheme.sizeof_page).div(2 * MM_HeapMap.J9MODRON_HEAP_SLOTS_PER_HEAPMAP_BIT * UDATA.SIZEOF);
UDATA bitMask = new UDATA(1).leftShift(offset);
if (bits.bitAnd(bitMask).eq(bitMask)) {
long mask = 1;
int ordinal = 0;
for (int i = offset.intValue(); i > 0; i--) {
if (bits.allBitsIn(mask)) {
ordinal += 1;
}
mask <<= 1;
}
for (int i = 0; i < ordinal; i++) {
UDATA objectSize = ObjectModel.getConsumedSizeInBytesWithHeader(newObject);
newObject = newObject.addOffset(objectSize);
}
results.add(new MarkedObject(cursor, _heapMapBits.add(pageIndex), newObject));
}
cursor = cursor.addOffset(getObjectGrain() * 2);
} else {
/* Same as super */
UDATA[] indexAndMask = getSlotIndexAndMask(cursor);
UDATAPointer slot = _heapMapBits.add(indexAndMask[0]);
if (slot.at(0).bitAnd(indexAndMask[1]).gt(0)) {
results.add(new MarkedObject(cursor, slot));
}
cursor = cursor.addOffset(getObjectGrain());
}
}
return results.toArray(new MarkedObject[results.size()]);
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject in project openj9 by eclipse.
the class MarkMapCommand method isMarked.
protected void isMarked(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
MarkedObject result = markMap.queryObject(object);
if (result != null) {
if (result.wasRelocated()) {
out.format("Object %s is marked and relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
} else {
out.format("Object %s is marked\n", result.object.getHexAddress());
}
} else {
out.format("Object %s is not marked\n", object.getHexAddress());
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject in project openj9 by eclipse.
the class MarkMapCommand method findSource.
protected void findSource(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
J9ObjectPointer scanPtr = J9ObjectPointer.cast(markMap.getHeapBase());
J9ObjectPointer heapTop = J9ObjectPointer.cast(markMap.getHeapTop());
if (object.gte(scanPtr) && object.lt(heapTop)) {
int count = 0;
while (scanPtr.lt(heapTop)) {
J9ObjectPointer base = scanPtr;
J9ObjectPointer top = base.addOffset(markMap.getPageSize(scanPtr));
MarkedObject[] results = markMap.queryRange(base, top);
for (int i = 0; i < results.length; i++) {
MarkedObject result = results[i];
if (result.wasRelocated()) {
if (result.relocatedObject.eq(object)) {
// A match!
out.format("Object %s was relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
count += 1;
}
}
}
scanPtr = top;
}
if (count > 0) {
out.format("%1 relocation candidates found\n", count);
} else {
out.format("No relocation candidates found\n");
}
} else {
out.format("Object %s is not in the heap\n", object.getHexAddress());
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject in project openj9 by eclipse.
the class MarkMapCommand method near.
protected void near(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
J9ObjectPointer base = object.untag(markMap.getPageSize(object) - 1);
J9ObjectPointer top = base.addOffset(markMap.getPageSize(object));
MarkedObject[] results = markMap.queryRange(base, top);
reportResults(base, top, results, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations