< prev index next >

agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java

Print this page
rev 7696 : 8061802: REDO - Remove the generations array
Summary: The _gens array is removed and replaced by explicit _young_gen and _old_gen variables.
Reviewed-by:

@@ -33,11 +33,12 @@
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
 public class GenCollectedHeap extends SharedHeap {
   private static CIntegerField nGensField;
-  private static long gensOffset;
+  private static AddressField youngGenField;
+  private static AddressField oldGenField;
   private static AddressField genSpecsField;
 
   private static GenerationFactory genFactory;
 
   static {

@@ -50,11 +51,12 @@
 
   private static synchronized void initialize(TypeDataBase db) {
     Type type = db.lookupType("GenCollectedHeap");
 
     nGensField = type.getCIntegerField("_n_gens");
-    gensOffset = type.getField("_gens").getOffset();
+    youngGenField = type.getAddressField("_young_gen");
+    oldGenField = type.getAddressField("_old_gen");
     genSpecsField = type.getAddressField("_gen_specs");
 
     genFactory = new GenerationFactory();
   }
 

@@ -70,18 +72,19 @@
     if (Assert.ASSERTS_ENABLED) {
       Assert.that((i >= 0) && (i < nGens()), "Index " + i +
                   " 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) {
     for (int i = 0; i < nGens(); i++) {
       Generation gen = getGen(i);
< prev index next >