changeset 5784:50287b659eb8

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
author sjohanss
date Tue, 03 Dec 2013 12:01:18 +0100
parents 9fc985481d78
children 816c89d5957d
files agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java	Mon Dec 02 15:43:04 2013 +0100
+++ b/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/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java	Mon Dec 02 15:43:04 2013 +0100
+++ b/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) {