agent/src/share/classes/sun/jvm/hotspot/oops/Method.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7088955 Sdiff agent/src/share/classes/sun/jvm/hotspot/oops

agent/src/share/classes/sun/jvm/hotspot/oops/Method.java

Print this page




  32 import sun.jvm.hotspot.memory.*;
  33 import sun.jvm.hotspot.runtime.*;
  34 import sun.jvm.hotspot.types.*;
  35 import sun.jvm.hotspot.utilities.*;
  36 
  37 // A Method represents a Java method
  38 
  39 public class Method extends Oop {
  40   static {
  41     VM.registerVMInitializedObserver(new Observer() {
  42         public void update(Observable o, Object data) {
  43           initialize(VM.getVM().getTypeDataBase());
  44         }
  45       });
  46   }
  47 
  48   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  49     Type type                  = db.lookupType("methodOopDesc");
  50     constMethod                = new OopField(type.getOopField("_constMethod"), 0);
  51     constants                  = new OopField(type.getOopField("_constants"), 0);

  52     methodSize                 = new CIntField(type.getCIntegerField("_method_size"), 0);
  53     maxStack                   = new CIntField(type.getCIntegerField("_max_stack"), 0);
  54     maxLocals                  = new CIntField(type.getCIntegerField("_max_locals"), 0);
  55     sizeOfParameters           = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
  56     accessFlags                = new CIntField(type.getCIntegerField("_access_flags"), 0);
  57     code                       = type.getAddressField("_code");
  58     vtableIndex                = new CIntField(type.getCIntegerField("_vtable_index"), 0);
  59     if (!VM.getVM().isCore()) {
  60       invocationCounter        = new CIntField(type.getCIntegerField("_invocation_counter"), 0);

  61     }
  62     bytecodeOffset = type.getSize();
  63 



  64     /*
  65     interpreterEntry           = type.getAddressField("_interpreter_entry");
  66     fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");
  67 
  68     */
  69     objectInitializerName = null;
  70     classInitializerName = null;
  71   }
  72 
  73   Method(OopHandle handle, ObjectHeap heap) {
  74     super(handle, heap);
  75   }
  76 
  77   public boolean isMethod()            { return true; }
  78 
  79   // Fields
  80   private static OopField  constMethod;
  81   private static OopField  constants;

  82   private static CIntField methodSize;
  83   private static CIntField maxStack;
  84   private static CIntField maxLocals;
  85   private static CIntField sizeOfParameters;
  86   private static CIntField accessFlags;
  87   private static CIntField vtableIndex;
  88   private static CIntField invocationCounter;

  89   private static long      bytecodeOffset;
  90 
  91   private static AddressField       code;
  92 



  93   // constant method names - <init>, <clinit>
  94   // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable
  95   private static Symbol objectInitializerName;
  96   private static Symbol classInitializerName;
  97   private static Symbol objectInitializerName() {
  98     if (objectInitializerName == null) {
  99       objectInitializerName = VM.getVM().getSymbolTable().probe("<init>");
 100     }
 101     return objectInitializerName;
 102   }
 103   private static Symbol classInitializerName() {
 104     if (classInitializerName == null) {
 105       classInitializerName = VM.getVM().getSymbolTable().probe("<clinit>");
 106     }
 107     return classInitializerName;
 108   }
 109 
 110 
 111   /*
 112   private static AddressCField       interpreterEntry;
 113   private static AddressCField       fromCompiledCodeEntryPoint;
 114   */
 115 
 116   // Accessors for declared fields
 117   public ConstMethod  getConstMethod()                { return (ConstMethod)  constMethod.getValue(this);       }
 118   public ConstantPool getConstants()                  { return (ConstantPool) constants.getValue(this);         }

 119   public TypeArray    getExceptionTable()             { return getConstMethod().getExceptionTable();            }
 120   /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
 121   public long         getMethodSize()                 { return                methodSize.getValue(this);        }
 122   public long         getMaxStack()                   { return                maxStack.getValue(this);          }
 123   public long         getMaxLocals()                  { return                maxLocals.getValue(this);         }
 124   public long         getSizeOfParameters()           { return                sizeOfParameters.getValue(this);  }
 125   public long         getNameIndex()                  { return                getConstMethod().getNameIndex();  }
 126   public long         getSignatureIndex()             { return            getConstMethod().getSignatureIndex(); }
 127   public long         getGenericSignatureIndex()      { return     getConstMethod().getGenericSignatureIndex(); }
 128   public long         getAccessFlags()                { return                accessFlags.getValue(this);       }
 129   public long         getCodeSize()                   { return                getConstMethod().getCodeSize();   }
 130   public long         getVtableIndex()                { return                vtableIndex.getValue(this);       }
 131   public long         getInvocationCounter()          {
 132     if (Assert.ASSERTS_ENABLED) {
 133       Assert.that(!VM.getVM().isCore(), "must not be used in core build");
 134     }
 135     return invocationCounter.getValue(this);
 136   }






 137 
 138   // get associated compiled native method, if available, else return null.
 139   public NMethod getNativeMethod() {
 140     Address addr = code.getValue(getHandle());
 141     return (NMethod) VMObjectFactory.newObject(NMethod.class, addr);
 142   }
 143 
 144   // Convenience routine
 145   public AccessFlags getAccessFlagsObj() {
 146     return new AccessFlags(getAccessFlags());
 147   }
 148 
 149   /** Get a bytecode or breakpoint at the given bci */
 150   public int getBytecodeOrBPAt(int bci) {
 151     return getConstMethod().getBytecodeOrBPAt(bci);
 152   }
 153 
 154   /** Fetch the original non-breakpoint bytecode at the specified
 155       bci. It is required that there is currently a bytecode at this
 156       bci. */


 316     return getConstMethod().hasCheckedExceptions();
 317   }
 318 
 319   /** Should only be called if table is present */
 320   public CheckedExceptionElement[] getCheckedExceptions() {
 321     return getConstMethod().getCheckedExceptions();
 322   }
 323 
 324   /** Returns name and signature in external form for debugging
 325       purposes */
 326   public String externalNameAndSignature() {
 327     final StringBuffer buf = new StringBuffer();
 328     buf.append(getMethodHolder().getName().asString());
 329     buf.append(".");
 330     buf.append(getName().asString());
 331     buf.append("(");
 332     new SignatureConverter(getSignature(), buf).iterateParameters();
 333     buf.append(")");
 334     return buf.toString().replace('/', '.');
 335   }







 336 }


  32 import sun.jvm.hotspot.memory.*;
  33 import sun.jvm.hotspot.runtime.*;
  34 import sun.jvm.hotspot.types.*;
  35 import sun.jvm.hotspot.utilities.*;
  36 
  37 // A Method represents a Java method
  38 
  39 public class Method extends Oop {
  40   static {
  41     VM.registerVMInitializedObserver(new Observer() {
  42         public void update(Observable o, Object data) {
  43           initialize(VM.getVM().getTypeDataBase());
  44         }
  45       });
  46   }
  47 
  48   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  49     Type type                  = db.lookupType("methodOopDesc");
  50     constMethod                = new OopField(type.getOopField("_constMethod"), 0);
  51     constants                  = new OopField(type.getOopField("_constants"), 0);
  52     methodData                 = new OopField(type.getOopField("_method_data"), 0);
  53     methodSize                 = new CIntField(type.getCIntegerField("_method_size"), 0);
  54     maxStack                   = new CIntField(type.getCIntegerField("_max_stack"), 0);
  55     maxLocals                  = new CIntField(type.getCIntegerField("_max_locals"), 0);
  56     sizeOfParameters           = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
  57     accessFlags                = new CIntField(type.getCIntegerField("_access_flags"), 0);
  58     code                       = type.getAddressField("_code");
  59     vtableIndex                = new CIntField(type.getCIntegerField("_vtable_index"), 0);
  60     if (!VM.getVM().isCore()) {
  61       invocationCounter        = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
  62       backedgeCounter          = new CIntField(type.getCIntegerField("_backedge_counter"), 0);
  63     }
  64     bytecodeOffset = type.getSize();
  65 
  66     interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0);
  67     interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0);
  68 
  69     /*
  70     interpreterEntry           = type.getAddressField("_interpreter_entry");
  71     fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");
  72 
  73     */
  74     objectInitializerName = null;
  75     classInitializerName = null;
  76   }
  77 
  78   Method(OopHandle handle, ObjectHeap heap) {
  79     super(handle, heap);
  80   }
  81 
  82   public boolean isMethod()            { return true; }
  83 
  84   // Fields
  85   private static OopField  constMethod;
  86   private static OopField  constants;
  87   private static OopField  methodData;
  88   private static CIntField methodSize;
  89   private static CIntField maxStack;
  90   private static CIntField maxLocals;
  91   private static CIntField sizeOfParameters;
  92   private static CIntField accessFlags;
  93   private static CIntField vtableIndex;
  94   private static CIntField invocationCounter;
  95   private static CIntField backedgeCounter;
  96   private static long      bytecodeOffset;
  97 
  98   private static AddressField       code;
  99 
 100   private static CIntField interpreterThrowoutCountField;
 101   private static CIntField interpreterInvocationCountField;
 102 
 103   // constant method names - <init>, <clinit>
 104   // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable
 105   private static Symbol objectInitializerName;
 106   private static Symbol classInitializerName;
 107   private static Symbol objectInitializerName() {
 108     if (objectInitializerName == null) {
 109       objectInitializerName = VM.getVM().getSymbolTable().probe("<init>");
 110     }
 111     return objectInitializerName;
 112   }
 113   private static Symbol classInitializerName() {
 114     if (classInitializerName == null) {
 115       classInitializerName = VM.getVM().getSymbolTable().probe("<clinit>");
 116     }
 117     return classInitializerName;
 118   }
 119 
 120 
 121   /*
 122   private static AddressCField       interpreterEntry;
 123   private static AddressCField       fromCompiledCodeEntryPoint;
 124   */
 125 
 126   // Accessors for declared fields
 127   public ConstMethod  getConstMethod()                { return (ConstMethod)  constMethod.getValue(this);       }
 128   public ConstantPool getConstants()                  { return (ConstantPool) constants.getValue(this);         }
 129   public MethodData   getMethodData()                 { return (MethodData) methodData.getValue(this);          }
 130   public TypeArray    getExceptionTable()             { return getConstMethod().getExceptionTable();            }
 131   /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
 132   public long         getMethodSize()                 { return                methodSize.getValue(this);        }
 133   public long         getMaxStack()                   { return                maxStack.getValue(this);          }
 134   public long         getMaxLocals()                  { return                maxLocals.getValue(this);         }
 135   public long         getSizeOfParameters()           { return                sizeOfParameters.getValue(this);  }
 136   public long         getNameIndex()                  { return                getConstMethod().getNameIndex();  }
 137   public long         getSignatureIndex()             { return            getConstMethod().getSignatureIndex(); }
 138   public long         getGenericSignatureIndex()      { return     getConstMethod().getGenericSignatureIndex(); }
 139   public long         getAccessFlags()                { return                accessFlags.getValue(this);       }
 140   public long         getCodeSize()                   { return                getConstMethod().getCodeSize();   }
 141   public long         getVtableIndex()                { return                vtableIndex.getValue(this);       }
 142   public long         getInvocationCounter()          {
 143     if (Assert.ASSERTS_ENABLED) {
 144       Assert.that(!VM.getVM().isCore(), "must not be used in core build");
 145     }
 146     return invocationCounter.getValue(this);
 147   }
 148   public long         getBackedgeCounter()          {
 149     if (Assert.ASSERTS_ENABLED) {
 150       Assert.that(!VM.getVM().isCore(), "must not be used in core build");
 151     }
 152     return backedgeCounter.getValue(this);
 153   }
 154 
 155   // get associated compiled native method, if available, else return null.
 156   public NMethod getNativeMethod() {
 157     Address addr = code.getValue(getHandle());
 158     return (NMethod) VMObjectFactory.newObject(NMethod.class, addr);
 159   }
 160 
 161   // Convenience routine
 162   public AccessFlags getAccessFlagsObj() {
 163     return new AccessFlags(getAccessFlags());
 164   }
 165 
 166   /** Get a bytecode or breakpoint at the given bci */
 167   public int getBytecodeOrBPAt(int bci) {
 168     return getConstMethod().getBytecodeOrBPAt(bci);
 169   }
 170 
 171   /** Fetch the original non-breakpoint bytecode at the specified
 172       bci. It is required that there is currently a bytecode at this
 173       bci. */


 333     return getConstMethod().hasCheckedExceptions();
 334   }
 335 
 336   /** Should only be called if table is present */
 337   public CheckedExceptionElement[] getCheckedExceptions() {
 338     return getConstMethod().getCheckedExceptions();
 339   }
 340 
 341   /** Returns name and signature in external form for debugging
 342       purposes */
 343   public String externalNameAndSignature() {
 344     final StringBuffer buf = new StringBuffer();
 345     buf.append(getMethodHolder().getName().asString());
 346     buf.append(".");
 347     buf.append(getName().asString());
 348     buf.append("(");
 349     new SignatureConverter(getSignature(), buf).iterateParameters();
 350     buf.append(")");
 351     return buf.toString().replace('/', '.');
 352   }
 353   public int interpreterThrowoutCount() {
 354     return (int) interpreterThrowoutCountField.getValue(getHandle());
 355   }
 356 
 357   public int interpreterInvocationCount() {
 358     return (int) interpreterInvocationCountField.getValue(getHandle());
 359   }
 360 }
agent/src/share/classes/sun/jvm/hotspot/oops/Method.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File