hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
equal deleted inserted replaced
357:f4edb0d9f109 360:21d113ecbf6a
    51   private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField;
    51   private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField;
    52 
    52 
    53   // system obj array klass object
    53   // system obj array klass object
    54   private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
    54   private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
    55 
    55 
       
    56   private static AddressField heapBaseField;
       
    57 
    56   static {
    58   static {
    57     VM.registerVMInitializedObserver(new Observer() {
    59     VM.registerVMInitializedObserver(new Observer() {
    58         public void update(Observable o, Object data) {
    60         public void update(Observable o, Object data) {
    59           initialize(VM.getVM().getTypeDataBase());
    61           initialize(VM.getVM().getTypeDataBase());
    60         }
    62         }
    81     longArrayKlassObjField = type.getOopField("_longArrayKlassObj");
    83     longArrayKlassObjField = type.getOopField("_longArrayKlassObj");
    82     singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj");
    84     singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj");
    83     doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj");
    85     doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj");
    84 
    86 
    85     systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
    87     systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
       
    88 
       
    89     heapBaseField = type.getAddressField("_heap_base");
    86   }
    90   }
    87 
    91 
    88   public Universe() {
    92   public Universe() {
    89   }
    93   }
    90 
    94 
    91   public CollectedHeap heap() {
    95   public CollectedHeap heap() {
    92     try {
    96     try {
    93       return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
    97       return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
    94     } catch (WrongTypeException e) {
    98     } catch (WrongTypeException e) {
    95       return new CollectedHeap(collectedHeapField.getValue());
    99       return new CollectedHeap(collectedHeapField.getValue());
       
   100     }
       
   101   }
       
   102 
       
   103   public static long getHeapBase() {
       
   104     if (heapBaseField.getValue() == null) {
       
   105       return 0;
       
   106     } else {
       
   107       return heapBaseField.getValue().minus(null);
    96     }
   108     }
    97   }
   109   }
    98 
   110 
    99   /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
   111   /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
   100   public boolean isIn(Address p) {
   112   public boolean isIn(Address p) {