8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder
authorsjohanss
Tue, 03 Dec 2013 12:01:18 +0100
changeset 21918 c1c826e0e2ec
parent 21917 325b980b3208
child 21919 70200a883e9d
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
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java
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/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<HeapRegion> heapRegionIterator() {
-        return new HeapRegionIterator(addr);
+    public Iterator<HeapRegion> heapRegionIterator(long committedLength) {
+        return new HeapRegionIterator(committedLength);
     }
 
     public G1HeapRegionTable(Address addr) {
--- 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<HeapRegion> heapRegionIterator() {
-        return regions().heapRegionIterator();
+        return regions().heapRegionIterator(committedLength());
     }
 
     public HeapRegionSeq(Address addr) {