< prev index next >

agent/src/share/classes/sun/jvm/hotspot/gc/shared/Generation.java

Print this page




  32 import sun.jvm.hotspot.types.*;
  33 
  34 /** <P> The (supported) Generation hierarchy currently looks like this: </P>
  35 
  36     <ul>
  37     <li> Generation
  38       <ul>
  39       <li> CardGeneration
  40         <ul>
  41         <li> TenuredGeneration
  42         </ul>
  43       <li> DefNewGeneration
  44       </ul>
  45     </ul>
  46 */
  47 
  48 
  49 public abstract class Generation extends VMObject {
  50   private static long          reservedFieldOffset;
  51   private static long          virtualSpaceFieldOffset;
  52   private static CIntegerField levelField;
  53   protected static final int  K = 1024;
  54   // Fields for class StatRecord
  55   private static Field         statRecordField;
  56   private static CIntegerField invocationField;
  57 
  58   // constants from Name enum
  59   private static int NAME_DEF_NEW;
  60   private static int NAME_PAR_NEW;
  61   private static int NAME_MARK_SWEEP_COMPACT;
  62   private static int NAME_CONCURRENT_MARK_SWEEP;
  63   private static int NAME_OTHER;
  64 
  65   static {
  66     VM.registerVMInitializedObserver(new Observer() {
  67         public void update(Observable o, Object data) {
  68           initialize(VM.getVM().getTypeDataBase());
  69         }
  70       });
  71   }
  72 
  73   private static synchronized void initialize(TypeDataBase db) {
  74     Type type = db.lookupType("Generation");
  75 
  76     reservedFieldOffset     = type.getField("_reserved").getOffset();
  77     virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset();
  78     levelField              = type.getCIntegerField("_level");
  79     // StatRecord
  80     statRecordField         = type.getField("_stat_record");
  81     type                    = db.lookupType("Generation::StatRecord");
  82     invocationField         = type.getCIntegerField("invocations");
  83 
  84     // constants from Generation::Name
  85     NAME_DEF_NEW = db.lookupIntConstant("Generation::DefNew").intValue();
  86     NAME_PAR_NEW = db.lookupIntConstant("Generation::ParNew").intValue();
  87     NAME_MARK_SWEEP_COMPACT = db.lookupIntConstant("Generation::MarkSweepCompact").intValue();
  88     NAME_CONCURRENT_MARK_SWEEP = db.lookupIntConstant("Generation::ConcurrentMarkSweep").intValue();
  89     NAME_OTHER = db.lookupIntConstant("Generation::Other").intValue();
  90   }
  91 
  92   public Generation(Address addr) {
  93     super(addr);
  94   }
  95 
  96   public static class Name {
  97     public static final Name DEF_NEW = new Name("DefNew");
  98     public static final Name PAR_NEW = new Name("ParNew");


 113   public Generation.Name kind() {
 114     return Generation.Name.OTHER;
 115   }
 116 
 117   static Generation.Name nameForEnum(int value) {
 118      if (value == NAME_DEF_NEW) {
 119         return Name.DEF_NEW;
 120      } else if (value == NAME_PAR_NEW) {
 121         return Name.PAR_NEW;
 122      } else if (value == NAME_MARK_SWEEP_COMPACT) {
 123         return Name.MARK_SWEEP_COMPACT;
 124      } else if (value == NAME_CONCURRENT_MARK_SWEEP) {
 125         return Name.CONCURRENT_MARK_SWEEP;
 126      } else if (value == NAME_OTHER) {
 127         return Name.OTHER;
 128      } else {
 129         throw new RuntimeException("should not reach here");
 130      }
 131   }
 132 
 133   public GenerationSpec spec() {
 134     return ((GenCollectedHeap) VM.getVM().getUniverse().heap()).spec(level());
 135   }
 136 
 137   public int level() {
 138     return (int) levelField.getValue(addr);
 139   }
 140 
 141   public int invocations() {
 142     return getStatRecord().getInvocations();
 143   }
 144 
 145   /** The maximum number of object bytes the generation can currently
 146       hold. */
 147   public abstract long capacity();
 148 
 149   /** The number of used bytes in the gen. */
 150   public abstract long used();
 151 
 152   /** The number of free bytes in the gen. */
 153   public abstract long free();
 154 
 155   /** The largest number of contiguous free words in the generation,
 156       including expansion. (VM's version assumes it is called at a
 157       safepoint.)  */
 158   public abstract long contiguousAvailable();
 159 
 160   public MemRegion reserved() {




  32 import sun.jvm.hotspot.types.*;
  33 
  34 /** <P> The (supported) Generation hierarchy currently looks like this: </P>
  35 
  36     <ul>
  37     <li> Generation
  38       <ul>
  39       <li> CardGeneration
  40         <ul>
  41         <li> TenuredGeneration
  42         </ul>
  43       <li> DefNewGeneration
  44       </ul>
  45     </ul>
  46 */
  47 
  48 
  49 public abstract class Generation extends VMObject {
  50   private static long          reservedFieldOffset;
  51   private static long          virtualSpaceFieldOffset;

  52   protected static final int  K = 1024;
  53   // Fields for class StatRecord
  54   private static Field         statRecordField;
  55   private static CIntegerField invocationField;
  56 
  57   // constants from Name enum
  58   private static int NAME_DEF_NEW;
  59   private static int NAME_PAR_NEW;
  60   private static int NAME_MARK_SWEEP_COMPACT;
  61   private static int NAME_CONCURRENT_MARK_SWEEP;
  62   private static int NAME_OTHER;
  63 
  64   static {
  65     VM.registerVMInitializedObserver(new Observer() {
  66         public void update(Observable o, Object data) {
  67           initialize(VM.getVM().getTypeDataBase());
  68         }
  69       });
  70   }
  71 
  72   private static synchronized void initialize(TypeDataBase db) {
  73     Type type = db.lookupType("Generation");
  74 
  75     reservedFieldOffset     = type.getField("_reserved").getOffset();
  76     virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset();

  77     // StatRecord
  78     statRecordField         = type.getField("_stat_record");
  79     type                    = db.lookupType("Generation::StatRecord");
  80     invocationField         = type.getCIntegerField("invocations");
  81 
  82     // constants from Generation::Name
  83     NAME_DEF_NEW = db.lookupIntConstant("Generation::DefNew").intValue();
  84     NAME_PAR_NEW = db.lookupIntConstant("Generation::ParNew").intValue();
  85     NAME_MARK_SWEEP_COMPACT = db.lookupIntConstant("Generation::MarkSweepCompact").intValue();
  86     NAME_CONCURRENT_MARK_SWEEP = db.lookupIntConstant("Generation::ConcurrentMarkSweep").intValue();
  87     NAME_OTHER = db.lookupIntConstant("Generation::Other").intValue();
  88   }
  89 
  90   public Generation(Address addr) {
  91     super(addr);
  92   }
  93 
  94   public static class Name {
  95     public static final Name DEF_NEW = new Name("DefNew");
  96     public static final Name PAR_NEW = new Name("ParNew");


 111   public Generation.Name kind() {
 112     return Generation.Name.OTHER;
 113   }
 114 
 115   static Generation.Name nameForEnum(int value) {
 116      if (value == NAME_DEF_NEW) {
 117         return Name.DEF_NEW;
 118      } else if (value == NAME_PAR_NEW) {
 119         return Name.PAR_NEW;
 120      } else if (value == NAME_MARK_SWEEP_COMPACT) {
 121         return Name.MARK_SWEEP_COMPACT;
 122      } else if (value == NAME_CONCURRENT_MARK_SWEEP) {
 123         return Name.CONCURRENT_MARK_SWEEP;
 124      } else if (value == NAME_OTHER) {
 125         return Name.OTHER;
 126      } else {
 127         throw new RuntimeException("should not reach here");
 128      }
 129   }
 130 








 131   public int invocations() {
 132     return getStatRecord().getInvocations();
 133   }
 134 
 135   /** The maximum number of object bytes the generation can currently
 136       hold. */
 137   public abstract long capacity();
 138 
 139   /** The number of used bytes in the gen. */
 140   public abstract long used();
 141 
 142   /** The number of free bytes in the gen. */
 143   public abstract long free();
 144 
 145   /** The largest number of contiguous free words in the generation,
 146       including expansion. (VM's version assumes it is called at a
 147       safepoint.)  */
 148   public abstract long contiguousAvailable();
 149 
 150   public MemRegion reserved() {


< prev index next >