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

Print this page




  52 
  53   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  54     Type type                  = db.lookupType("ConstMethod");
  55     constants                  = new MetadataField(type.getAddressField("_constants"), 0);
  56     constMethodSize            = new CIntField(type.getCIntegerField("_constMethod_size"), 0);
  57     flags                      = new ByteField(type.getJByteField("_flags"), 0);
  58 
  59     // enum constants for flags
  60     HAS_LINENUMBER_TABLE      = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue();
  61     HAS_CHECKED_EXCEPTIONS     = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue();
  62     HAS_LOCALVARIABLE_TABLE   = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue();
  63     HAS_EXCEPTION_TABLE       = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue();
  64     HAS_GENERIC_SIGNATURE     = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue();
  65 
  66     // Size of Java bytecodes allocated immediately after ConstMethod*.
  67     codeSize                   = new CIntField(type.getCIntegerField("_code_size"), 0);
  68     nameIndex                  = new CIntField(type.getCIntegerField("_name_index"), 0);
  69     signatureIndex             = new CIntField(type.getCIntegerField("_signature_index"), 0);
  70     idnum                      = new CIntField(type.getCIntegerField("_method_idnum"), 0);
  71     maxStack                   = new CIntField(type.getCIntegerField("_max_stack"), 0);


  72 
  73     // start of byte code
  74     bytecodeOffset = type.getSize();
  75 
  76     type                       = db.lookupType("CheckedExceptionElement");
  77     checkedExceptionElementSize = type.getSize();
  78 
  79     type                       = db.lookupType("LocalVariableTableElement");
  80     localVariableTableElementSize = type.getSize();
  81 
  82     type                       = db.lookupType("ExceptionTableElement");
  83     exceptionTableElementSize = type.getSize();
  84   }
  85 
  86   public ConstMethod(Address addr) {
  87     super(addr);
  88   }
  89 
  90   // Fields
  91   private static MetadataField constants;
  92   private static CIntField constMethodSize;
  93   private static ByteField flags;
  94   private static CIntField codeSize;
  95   private static CIntField nameIndex;
  96   private static CIntField signatureIndex;
  97   private static CIntField idnum;
  98   private static CIntField maxStack;


  99 
 100   // start of bytecode
 101   private static long bytecodeOffset;
 102 
 103   private static long checkedExceptionElementSize;
 104   private static long localVariableTableElementSize;
 105   private static long exceptionTableElementSize;
 106 
 107   public Method getMethod() {
 108     InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder();
 109     MethodArray methods = ik.getMethods();
 110     return methods.at((int)getIdNum());
 111   }
 112 
 113   // Accessors for declared fields
 114   public ConstantPool getConstants() {
 115     return (ConstantPool) constants.getValue(this);
 116   }
 117 
 118   public long getConstMethodSize() {


 134   public long getSignatureIndex() {
 135     return signatureIndex.getValue(this);
 136   }
 137 
 138   public long getGenericSignatureIndex() {
 139     if (hasGenericSignature()) {
 140       return getAddress().getCIntegerAt(offsetOfGenericSignatureIndex(), 2, true);
 141     } else {
 142       return 0;
 143     }
 144   }
 145 
 146   public long getIdNum() {
 147     return idnum.getValue(this);
 148   }
 149 
 150   public long getMaxStack() {
 151     return maxStack.getValue(this);
 152   }
 153 








 154   public Symbol getName() {
 155     return getMethod().getName();
 156   }
 157 
 158   public Symbol getSignature() {
 159     return getMethod().getSignature();
 160   }
 161 
 162   public Symbol getGenericSignature() {
 163     return getMethod().getGenericSignature();
 164   }
 165 
 166   // bytecode accessors
 167 
 168   /** Get a bytecode or breakpoint at the given bci */
 169   public int getBytecodeOrBPAt(int bci) {
 170     return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF;
 171   }
 172 
 173   public byte getBytecodeByteArg(int bci) {


 230      return bc;
 231   }
 232 
 233   public long getSize() {
 234     return getConstMethodSize();
 235   }
 236 
 237   public void printValueOn(PrintStream tty) {
 238     tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress());
 239   }
 240 
 241   public void iterateFields(MetadataVisitor visitor) {
 242     visitor.doMetadata(constants, true);
 243       visitor.doCInt(constMethodSize, true);
 244       visitor.doByte(flags, true);
 245       visitor.doCInt(codeSize, true);
 246       visitor.doCInt(nameIndex, true);
 247       visitor.doCInt(signatureIndex, true);
 248       visitor.doCInt(codeSize, true);
 249       visitor.doCInt(maxStack, true);


 250     }
 251 
 252   // Accessors
 253 
 254   public boolean hasLineNumberTable() {
 255     return (getFlags() & HAS_LINENUMBER_TABLE) != 0;
 256   }
 257 
 258   public int getLineNumberFromBCI(int bci) {
 259     if (!VM.getVM().isCore()) {
 260       if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0;
 261     }
 262 
 263     if (isNative()) {
 264       return -1;
 265     }
 266 
 267     if (Assert.ASSERTS_ENABLED) {
 268       Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci");
 269     }




  52 
  53   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
  54     Type type                  = db.lookupType("ConstMethod");
  55     constants                  = new MetadataField(type.getAddressField("_constants"), 0);
  56     constMethodSize            = new CIntField(type.getCIntegerField("_constMethod_size"), 0);
  57     flags                      = new ByteField(type.getJByteField("_flags"), 0);
  58 
  59     // enum constants for flags
  60     HAS_LINENUMBER_TABLE      = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue();
  61     HAS_CHECKED_EXCEPTIONS     = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue();
  62     HAS_LOCALVARIABLE_TABLE   = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue();
  63     HAS_EXCEPTION_TABLE       = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue();
  64     HAS_GENERIC_SIGNATURE     = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue();
  65 
  66     // Size of Java bytecodes allocated immediately after ConstMethod*.
  67     codeSize                   = new CIntField(type.getCIntegerField("_code_size"), 0);
  68     nameIndex                  = new CIntField(type.getCIntegerField("_name_index"), 0);
  69     signatureIndex             = new CIntField(type.getCIntegerField("_signature_index"), 0);
  70     idnum                      = new CIntField(type.getCIntegerField("_method_idnum"), 0);
  71     maxStack                   = new CIntField(type.getCIntegerField("_max_stack"), 0);
  72     maxLocals                  = new CIntField(type.getCIntegerField("_max_locals"), 0);
  73     sizeOfParameters           = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
  74 
  75     // start of byte code
  76     bytecodeOffset = type.getSize();
  77 
  78     type                       = db.lookupType("CheckedExceptionElement");
  79     checkedExceptionElementSize = type.getSize();
  80 
  81     type                       = db.lookupType("LocalVariableTableElement");
  82     localVariableTableElementSize = type.getSize();
  83 
  84     type                       = db.lookupType("ExceptionTableElement");
  85     exceptionTableElementSize = type.getSize();
  86   }
  87 
  88   public ConstMethod(Address addr) {
  89     super(addr);
  90   }
  91 
  92   // Fields
  93   private static MetadataField constants;
  94   private static CIntField constMethodSize;
  95   private static ByteField flags;
  96   private static CIntField codeSize;
  97   private static CIntField nameIndex;
  98   private static CIntField signatureIndex;
  99   private static CIntField idnum;
 100   private static CIntField maxStack;
 101   private static CIntField maxLocals;
 102   private static CIntField sizeOfParameters;
 103 
 104   // start of bytecode
 105   private static long bytecodeOffset;
 106 
 107   private static long checkedExceptionElementSize;
 108   private static long localVariableTableElementSize;
 109   private static long exceptionTableElementSize;
 110 
 111   public Method getMethod() {
 112     InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder();
 113     MethodArray methods = ik.getMethods();
 114     return methods.at((int)getIdNum());
 115   }
 116 
 117   // Accessors for declared fields
 118   public ConstantPool getConstants() {
 119     return (ConstantPool) constants.getValue(this);
 120   }
 121 
 122   public long getConstMethodSize() {


 138   public long getSignatureIndex() {
 139     return signatureIndex.getValue(this);
 140   }
 141 
 142   public long getGenericSignatureIndex() {
 143     if (hasGenericSignature()) {
 144       return getAddress().getCIntegerAt(offsetOfGenericSignatureIndex(), 2, true);
 145     } else {
 146       return 0;
 147     }
 148   }
 149 
 150   public long getIdNum() {
 151     return idnum.getValue(this);
 152   }
 153 
 154   public long getMaxStack() {
 155     return maxStack.getValue(this);
 156   }
 157 
 158   public long getMaxLocals() {
 159     return maxLocals.getValue(this);
 160   }
 161 
 162   public long getSizeOfParameters() {
 163     return sizeOfParameters.getValue(this);
 164   }
 165 
 166   public Symbol getName() {
 167     return getMethod().getName();
 168   }
 169 
 170   public Symbol getSignature() {
 171     return getMethod().getSignature();
 172   }
 173 
 174   public Symbol getGenericSignature() {
 175     return getMethod().getGenericSignature();
 176   }
 177 
 178   // bytecode accessors
 179 
 180   /** Get a bytecode or breakpoint at the given bci */
 181   public int getBytecodeOrBPAt(int bci) {
 182     return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF;
 183   }
 184 
 185   public byte getBytecodeByteArg(int bci) {


 242      return bc;
 243   }
 244 
 245   public long getSize() {
 246     return getConstMethodSize();
 247   }
 248 
 249   public void printValueOn(PrintStream tty) {
 250     tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress());
 251   }
 252 
 253   public void iterateFields(MetadataVisitor visitor) {
 254     visitor.doMetadata(constants, true);
 255       visitor.doCInt(constMethodSize, true);
 256       visitor.doByte(flags, true);
 257       visitor.doCInt(codeSize, true);
 258       visitor.doCInt(nameIndex, true);
 259       visitor.doCInt(signatureIndex, true);
 260       visitor.doCInt(codeSize, true);
 261       visitor.doCInt(maxStack, true);
 262       visitor.doCInt(maxLocals, true);
 263       visitor.doCInt(sizeOfParameters, true);
 264     }
 265 
 266   // Accessors
 267 
 268   public boolean hasLineNumberTable() {
 269     return (getFlags() & HAS_LINENUMBER_TABLE) != 0;
 270   }
 271 
 272   public int getLineNumberFromBCI(int bci) {
 273     if (!VM.getVM().isCore()) {
 274       if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0;
 275     }
 276 
 277     if (isNative()) {
 278       return -1;
 279     }
 280 
 281     if (Assert.ASSERTS_ENABLED) {
 282       Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci");
 283     }