1 package sun.jvm.hotspot.compiler;
   2 
   3 import sun.jvm.hotspot.debugger.Address;
   4 import sun.jvm.hotspot.runtime.VM;
   5 import sun.jvm.hotspot.types.CIntegerField;
   6 import sun.jvm.hotspot.types.Type;
   7 import sun.jvm.hotspot.types.TypeDataBase;
   8 
   9 import java.util.Observable;
  10 import java.util.Observer;
  11 
  12 public class ImmutableOopMapPair {
  13   private static CIntegerField pcField;
  14   private static CIntegerField offsetField;
  15   private static long classSize;
  16 
  17   static {
  18     VM.registerVMInitializedObserver(new Observer() {
  19       public void update(Observable o, Object data) {
  20         initialize(VM.getVM().getTypeDataBase());
  21       }
  22     });
  23   }
  24 
  25   private final Address address;
  26 
  27   public ImmutableOopMapPair(Address address) {
  28     this.address = address;
  29   }
  30 
  31   public static long classSize() {
  32     return classSize;
  33   }
  34 
  35   public int getPC() {
  36     return (int) pcField.getValue(address);
  37   }
  38 
  39   public int getOffset() {
  40     return (int) offsetField.getValue(address);
  41   }
  42 
  43   private static void initialize(TypeDataBase db) {
  44     Type type = db.lookupType("ImmutableOopMapSet");
  45 
  46     pcField = type.getCIntegerField("_pc_offset");
  47     offsetField = type.getCIntegerField("_oopmap_offset");
  48     classSize = type.getSize();
  49   }
  50 }