use of com.ibm.j9ddr.vm29.j9.gc.GCIterator in project openj9 by eclipse.
the class LiveSetWalker method walkLiveSet.
/*
* Walks the LiveSet in preorder, returns a HashSet of all walked objects. The HashSet is generated as a byproduct of the walk.
*
* @return a HashSet containing all visited objects
*/
public static void walkLiveSet(ObjectVisitor visitor, RootSetType rootSetType) throws CorruptDataException {
/* TODO: lpnguyen, use something less stupid than a hashSet (markMap?) for this */
HashSet<J9ObjectPointer> visitedObjects = new HashSet<J9ObjectPointer>();
/* Not using a singleton because we want to allow users to catch corruptData events. Not worrying about the perf loss taken
* by doing this as walking the live set will probably take an order of magnitude longer anyway
*/
RootSet rootSet = RootSet.from(rootSetType, false);
GCIterator rootIterator = rootSet.gcIterator(rootSetType);
GCIterator rootAddressIterator = rootSet.gcIterator(rootSetType);
while (rootIterator.hasNext()) {
J9ObjectPointer nextObject = (J9ObjectPointer) rootIterator.next();
VoidPointer nextAddress = rootAddressIterator.nextAddress();
if (nextObject.notNull()) {
scanObject(visitedObjects, visitor, nextObject, nextAddress);
}
}
}
Aggregations