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


  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   private static AddressField genSpecsField;


  41 
  42   private static GenerationFactory genFactory;
  43 
  44   static {
  45     VM.registerVMInitializedObserver(new Observer() {
  46         public void update(Observable o, Object data) {
  47           initialize(VM.getVM().getTypeDataBase());
  48         }
  49       });
  50   }
  51 
  52   private static synchronized void initialize(TypeDataBase db) {
  53     Type type = db.lookupType("GenCollectedHeap");
  54 
  55     nGensField = type.getCIntegerField("_n_gens");
  56     youngGenField = type.getAddressField("_young_gen");
  57     oldGenField = type.getAddressField("_old_gen");
  58     genSpecsField = type.getAddressField("_gen_specs");
  59 
  60     genFactory = new GenerationFactory();




  61   }
  62 
  63   public GenCollectedHeap(Address addr) {
  64     super(addr);
  65   }
  66 
  67   public int nGens() {
  68     return (int) nGensField.getValue(addr);
  69   }
  70 
  71   public Generation getGen(int i) {
  72     if (Assert.ASSERTS_ENABLED) {
  73       Assert.that((i >= 0) && (i < nGens()), "Index " + i +
  74                   " out of range (should be between 0 and " + nGens() + ")");
  75     }
  76 
  77     switch (i) {
  78     case 0:
  79       return genFactory.newObject(youngGenField.getAddress());
  80     case 1:


 106 
 107   public long used() {
 108     long used = 0;
 109     for (int i = 0; i < nGens(); i++) {
 110       used += getGen(i).used();
 111     }
 112     return used;
 113   }
 114 
 115   /** Package-private access to GenerationSpecs */
 116   GenerationSpec spec(int level) {
 117     if (Assert.ASSERTS_ENABLED) {
 118       Assert.that((level >= 0) && (level < nGens()), "Index " + level +
 119                   " out of range (should be between 0 and " + nGens() + ")");
 120     }
 121 
 122     if ((level < 0) || (level >= nGens())) {
 123       return null;
 124     }
 125 
 126     Address ptrList = genSpecsField.getValue(addr);
 127     if (ptrList == null) {
 128       return null;
 129     }
 130     return (GenerationSpec)
 131       VMObjectFactory.newObject(GenerationSpec.class,
 132                                 ptrList.getAddressAt(level * VM.getVM().getAddressSize()));





 133   }
 134 
 135   public CollectedHeapName kind() {
 136     return CollectedHeapName.GEN_COLLECTED_HEAP;
 137   }
 138 
 139   public void printOn(PrintStream tty) {
 140     for (int i = 0; i < nGens(); i++) {
 141       tty.print("Gen " + i + ": ");
 142       getGen(i).printOn(tty);
 143       tty.println("Invocations: " + getGen(i).invocations());
 144       tty.println();
 145     }
 146   }
 147 }


  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:


 111 
 112   public long used() {
 113     long used = 0;
 114     for (int i = 0; i < nGens(); i++) {
 115       used += getGen(i).used();
 116     }
 117     return used;
 118   }
 119 
 120   /** Package-private access to GenerationSpecs */
 121   GenerationSpec spec(int level) {
 122     if (Assert.ASSERTS_ENABLED) {
 123       Assert.that((level >= 0) && (level < nGens()), "Index " + level +
 124                   " out of range (should be between 0 and " + nGens() + ")");
 125     }
 126 
 127     if ((level < 0) || (level >= nGens())) {
 128       return null;
 129     }
 130 
 131     if (level == 0) {



 132       return (GenerationSpec)
 133               VMObjectFactory.newObject(GenerationSpec.class,
 134                       youngGenSpecField.getAddress());
 135     } else {
 136       return (GenerationSpec)
 137               VMObjectFactory.newObject(GenerationSpec.class,
 138                       oldGenSpecField.getAddress());
 139     }
 140   }
 141 
 142   public CollectedHeapName kind() {
 143     return CollectedHeapName.GEN_COLLECTED_HEAP;
 144   }
 145 
 146   public void printOn(PrintStream tty) {
 147     for (int i = 0; i < nGens(); i++) {
 148       tty.print("Gen " + i + ": ");
 149       getGen(i).printOn(tty);
 150       tty.println("Invocations: " + getGen(i).invocations());
 151       tty.println();
 152     }
 153   }
 154 }
agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File