--- old/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java 2014-10-17 16:28:29.000000000 +0200 +++ new/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java 2014-10-17 16:28:29.000000000 +0200 @@ -34,9 +34,11 @@ import sun.jvm.hotspot.utilities.*; public class GenCollectedHeap extends SharedHeap { - private static CIntegerField nGensField; - private static long gensOffset; - private static AddressField genSpecsField; + private static AddressField youngGenField; + private static AddressField oldGenField; + + private static AddressField youngGenSpecField; + private static AddressField oldGenSpecField; private static GenerationFactory genFactory; @@ -51,11 +53,14 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("GenCollectedHeap"); - nGensField = type.getCIntegerField("_n_gens"); - gensOffset = type.getField("_gens").getOffset(); - genSpecsField = type.getAddressField("_gen_specs"); + youngGenField = type.getAddressField("_young_gen"); + oldGenField = type.getAddressField("_old_gen"); genFactory = new GenerationFactory(); + + Type colPolType = db.lookupType("GenCollectorPolicy"); + youngGenSpecField = colPolType.getAddressField("_young_gen_spec"); + oldGenSpecField = colPolType.getAddressField("_old_gen_spec"); } public GenCollectedHeap(Address addr) { @@ -63,7 +68,7 @@ } public int nGens() { - return (int) nGensField.getValue(addr); + return 2; } public Generation getGen(int i) { @@ -72,14 +77,15 @@ " out of range (should be between 0 and " + nGens() + ")"); } - if ((i < 0) || (i >= nGens())) { + switch (i) { + case 0: + return genFactory.newObject(youngGenField.getAddress()); + case 1: + return genFactory.newObject(oldGenField.getAddress()); + default: + // no generation for i, and assertions disabled. return null; } - - Address genAddr = addr.getAddressAt(gensOffset + - (i * VM.getVM().getAddressSize())); - return genFactory.newObject(addr.getAddressAt(gensOffset + - (i * VM.getVM().getAddressSize()))); } public boolean isIn(Address a) { @@ -120,13 +126,15 @@ return null; } - Address ptrList = genSpecsField.getValue(addr); - if (ptrList == null) { - return null; + if (level == 0) { + return (GenerationSpec) + VMObjectFactory.newObject(GenerationSpec.class, + youngGenSpecField.getAddress()); + } else { + return (GenerationSpec) + VMObjectFactory.newObject(GenerationSpec.class, + oldGenSpecField.getAddress()); } - return (GenerationSpec) - VMObjectFactory.newObject(GenerationSpec.class, - ptrList.getAddressAt(level * VM.getVM().getAddressSize())); } public CollectedHeapName kind() {