agent/src/share/classes/sun/jvm/hotspot/memory/Generation.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/Generation.java

Print this page
rev 7215 : imported patch remove_levels


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


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




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


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


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