8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder

Now iterating over all committed (used) G1 regions instead of all reserved.

Reviewed-by: brutisso, dsamersoff, mgerdin
This commit is contained in:
Stefan Johansson 2013-12-03 12:01:18 +01:00
parent aba1a79d81
commit 5811b8eb93
2 changed files with 12 additions and 5 deletions
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1

@ -103,14 +103,14 @@ public class G1HeapRegionTable extends VMObject {
@Override
public void remove() { /* not supported */ }
HeapRegionIterator(Address addr) {
HeapRegionIterator(long committedLength) {
index = 0;
length = length();
length = committedLength;
}
}
public Iterator<HeapRegion> heapRegionIterator() {
return new HeapRegionIterator(addr);
public Iterator<HeapRegion> heapRegionIterator(long committedLength) {
return new HeapRegionIterator(committedLength);
}
public G1HeapRegionTable(Address addr) {

@ -42,6 +42,8 @@ import sun.jvm.hotspot.types.TypeDataBase;
public class HeapRegionSeq extends VMObject {
// G1HeapRegionTable _regions
static private long regionsFieldOffset;
// uint _committed_length
static private CIntegerField committedLengthField;
static {
VM.registerVMInitializedObserver(new Observer() {
@ -55,6 +57,7 @@ public class HeapRegionSeq extends VMObject {
Type type = db.lookupType("HeapRegionSeq");
regionsFieldOffset = type.getField("_regions").getOffset();
committedLengthField = type.getCIntegerField("_committed_length");
}
private G1HeapRegionTable regions() {
@ -67,8 +70,12 @@ public class HeapRegionSeq extends VMObject {
return regions().length();
}
public long committedLength() {
return committedLengthField.getValue(addr);
}
public Iterator<HeapRegion> heapRegionIterator() {
return regions().heapRegionIterator();
return regions().heapRegionIterator(committedLength());
}
public HeapRegionSeq(Address addr) {