agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff agent/src/share/classes/sun/jvm/hotspot/memory

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

Print this page
rev 7211 : [mq]: remove_ngen
rev 7213 : imported patch move_genspecs
rev 7214 : imported patch remove_n_gen


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.memory;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.gc_interface.*;
  32 import sun.jvm.hotspot.runtime.*;
  33 import sun.jvm.hotspot.types.*;
  34 import sun.jvm.hotspot.utilities.*;
  35 
  36 public class GenCollectedHeap extends SharedHeap {
  37   private static CIntegerField nGensField;
  38   private static AddressField youngGenField;
  39   private static AddressField oldGenField;
  40 
  41   private static AddressField youngGenSpecField;
  42   private static AddressField oldGenSpecField;
  43 
  44   private static GenerationFactory genFactory;
  45 
  46   static {
  47     VM.registerVMInitializedObserver(new Observer() {
  48         public void update(Observable o, Object data) {
  49           initialize(VM.getVM().getTypeDataBase());
  50         }
  51       });
  52   }
  53 
  54   private static synchronized void initialize(TypeDataBase db) {
  55     Type type = db.lookupType("GenCollectedHeap");
  56 
  57     nGensField = type.getCIntegerField("_n_gens");
  58     youngGenField = type.getAddressField("_young_gen");
  59     oldGenField = type.getAddressField("_old_gen");
  60 
  61     genFactory = new GenerationFactory();
  62 
  63     Type colPolType = db.lookupType("GenCollectorPolicy");
  64     youngGenSpecField = colPolType.getAddressField("_young_gen_spec");
  65     oldGenSpecField = colPolType.getAddressField("_old_gen_spec");
  66   }
  67 
  68   public GenCollectedHeap(Address addr) {
  69     super(addr);
  70   }
  71 
  72   public int nGens() {
  73     return (int) nGensField.getValue(addr);
  74   }
  75 
  76   public Generation getGen(int i) {
  77     if (Assert.ASSERTS_ENABLED) {
  78       Assert.that((i >= 0) && (i < nGens()), "Index " + i +
  79                   " out of range (should be between 0 and " + nGens() + ")");
  80     }
  81 
  82     switch (i) {
  83     case 0:
  84       return genFactory.newObject(youngGenField.getAddress());
  85     case 1:
  86       return genFactory.newObject(oldGenField.getAddress());
  87     default:
  88       // no generation for i, and assertions disabled.
  89       return null;
  90     }
  91   }
  92 
  93   public boolean isIn(Address a) {




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.memory;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.gc_interface.*;
  32 import sun.jvm.hotspot.runtime.*;
  33 import sun.jvm.hotspot.types.*;
  34 import sun.jvm.hotspot.utilities.*;
  35 
  36 public class GenCollectedHeap extends SharedHeap {

  37   private static AddressField youngGenField;
  38   private static AddressField oldGenField;
  39 
  40   private static AddressField youngGenSpecField;
  41   private static AddressField oldGenSpecField;
  42 
  43   private static GenerationFactory genFactory;
  44 
  45   static {
  46     VM.registerVMInitializedObserver(new Observer() {
  47         public void update(Observable o, Object data) {
  48           initialize(VM.getVM().getTypeDataBase());
  49         }
  50       });
  51   }
  52 
  53   private static synchronized void initialize(TypeDataBase db) {
  54     Type type = db.lookupType("GenCollectedHeap");
  55 

  56     youngGenField = type.getAddressField("_young_gen");
  57     oldGenField = type.getAddressField("_old_gen");
  58 
  59     genFactory = new GenerationFactory();
  60 
  61     Type colPolType = db.lookupType("GenCollectorPolicy");
  62     youngGenSpecField = colPolType.getAddressField("_young_gen_spec");
  63     oldGenSpecField = colPolType.getAddressField("_old_gen_spec");
  64   }
  65 
  66   public GenCollectedHeap(Address addr) {
  67     super(addr);
  68   }
  69 
  70   public int nGens() {
  71     return 2;
  72   }
  73 
  74   public Generation getGen(int i) {
  75     if (Assert.ASSERTS_ENABLED) {
  76       Assert.that((i >= 0) && (i < nGens()), "Index " + i +
  77                   " out of range (should be between 0 and " + nGens() + ")");
  78     }
  79 
  80     switch (i) {
  81     case 0:
  82       return genFactory.newObject(youngGenField.getAddress());
  83     case 1:
  84       return genFactory.newObject(oldGenField.getAddress());
  85     default:
  86       // no generation for i, and assertions disabled.
  87       return null;
  88     }
  89   }
  90 
  91   public boolean isIn(Address a) {


agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File