diff -r 1edb08142cea -r 47c20fc6a517 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java Fri Nov 08 09:16:48 2019 +0100 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java Fri Nov 08 10:01:13 2019 +0100 @@ -45,9 +45,12 @@ // any of its fields but only iterate over it. public class HeapRegion extends CompactibleSpace implements LiveRegionsProvider { - // static int GrainBytes; + private static AddressField bottomField; + static private AddressField topField; + private static AddressField endField; + private static AddressField compactionTopField; + static private CIntegerField grainBytesField; - static private AddressField topField; private static long typeFieldOffset; private static long pointerSize; @@ -64,8 +67,12 @@ static private synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("HeapRegion"); + bottomField = type.getAddressField("_bottom"); + topField = type.getAddressField("_top"); + endField = type.getAddressField("_end"); + compactionTopField = type.getAddressField("_compaction_top"); + grainBytesField = type.getCIntegerField("GrainBytes"); - topField = type.getAddressField("_top"); typeFieldOffset = type.getField("_type").getOffset(); pointerSize = db.lookupType("HeapRegion*").getSize(); @@ -82,9 +89,11 @@ type = (HeapRegionType)VMObjectFactory.newObject(HeapRegionType.class, typeAddr); } - public Address top() { - return topField.getValue(addr); - } + public Address bottom() { return bottomField.getValue(addr); } + public Address top() { return topField.getValue(addr); } + public Address end() { return endField.getValue(addr); } + + public Address compactionTop() { return compactionTopField.getValue(addr); } @Override public List getLiveRegions() { @@ -93,12 +102,16 @@ return res; } - @Override + /** Returns a subregion of the space containing all the objects in + the space. */ + public MemRegion usedRegion() { + return new MemRegion(bottom(), end()); + } + public long used() { return top().minus(bottom()); } - @Override public long free() { return end().minus(top()); }