# HG changeset patch # User sjohanss # Date 1386068478 -3600 # Node ID c1c826e0e2ec27a0268a5ec112127eeb6956d4ce # Parent 325b980b32080a91d9bc5f688e0e36a88cf0a29f 8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder Summary: Now iterating over all committed (used) G1 regions instead of all reserved. Reviewed-by: brutisso, dsamersoff, mgerdin diff -r 325b980b3208 -r c1c826e0e2ec hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java Mon Dec 02 15:43:04 2013 +0100 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java Tue Dec 03 12:01:18 2013 +0100 @@ -103,14 +103,14 @@ @Override public void remove() { /* not supported */ } - HeapRegionIterator(Address addr) { + HeapRegionIterator(long committedLength) { index = 0; - length = length(); + length = committedLength; } } - public Iterator heapRegionIterator() { - return new HeapRegionIterator(addr); + public Iterator heapRegionIterator(long committedLength) { + return new HeapRegionIterator(committedLength); } public G1HeapRegionTable(Address addr) { diff -r 325b980b3208 -r c1c826e0e2ec hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java Mon Dec 02 15:43:04 2013 +0100 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java Tue Dec 03 12:01:18 2013 +0100 @@ -42,6 +42,8 @@ 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 @@ Type type = db.lookupType("HeapRegionSeq"); regionsFieldOffset = type.getField("_regions").getOffset(); + committedLengthField = type.getCIntegerField("_committed_length"); } private G1HeapRegionTable regions() { @@ -67,8 +70,12 @@ return regions().length(); } + public long committedLength() { + return committedLengthField.getValue(addr); + } + public Iterator heapRegionIterator() { - return regions().heapRegionIterator(); + return regions().heapRegionIterator(committedLength()); } public HeapRegionSeq(Address addr) {