agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Fri Sep  9 11:55:27 2011
--- new/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Fri Sep  9 11:55:27 2011

*** 49,59 **** --- 49,59 ---- public static int SIGNATURE_INDEX_OFFSET; public static int INITVAL_INDEX_OFFSET; public static int LOW_OFFSET; public static int HIGH_OFFSET; public static int GENERIC_SIGNATURE_INDEX_OFFSET; ! public static int NEXT_OFFSET; ! public static int FIELD_SLOTS; public static int IMPLEMENTORS_LIMIT; // ClassState constants private static int CLASS_STATE_UNPARSABLE_BY_GC; private static int CLASS_STATE_ALLOCATED;
*** 76,85 **** --- 76,86 ---- for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) { long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize()); implementors[i] = new OopField(type.getOopField("_implementors[0]"), arrayOffset); } fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize()); + javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize()); constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize()); classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize()); protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize()); signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize()); sourceFileName = type.getAddressField("_source_file_name");
*** 98,115 **** --- 99,116 ---- majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize()); minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize()); headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize()); // read field offset constants ! ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue(); ! NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue(); ! SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::signature_index_offset").intValue(); ! INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue(); ! LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue(); ! HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue(); ! GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue(); ! NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue(); ! ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue(); ! NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue(); ! SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue(); ! INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue(); ! LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_offset").intValue(); ! HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue(); ! GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue(); ! FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue(); // read ClassState constants CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue(); CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue(); CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue(); CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
*** 129,138 **** --- 130,140 ---- private static OopField localInterfaces; private static OopField transitiveInterfaces; private static CIntField nofImplementors; private static OopField[] implementors; private static OopField fields; + private static CIntField javaFieldsCount; private static OopField constants; private static OopField classLoader; private static OopField protectionDomain; private static OopField signers; private static AddressField sourceFileName;
*** 245,254 **** --- 247,284 ---- return getSizeHelper() * VM.getVM().getAddressSize(); } public static long getHeaderSize() { return headerSize; } + public short getFieldAccessFlags(int index) { + return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET); + } + + public Symbol getFieldName(int index) { + int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET); + return getConstants().getSymbolAt(nameIndex); + } + + public Symbol getFieldSignature(int index) { + int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); + return getConstants().getSymbolAt(signatureIndex); + } + + public Symbol getFieldGenericSignature(int index) { + short genericSignatureIndex = getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET); + if (genericSignatureIndex != 0) { + return getConstants().getSymbolAt(genericSignatureIndex); + } + return null; + } + + public int getFieldOffset(int index) { + TypeArray fields = getFields(); + return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET), + fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET)); + } + // Accessors for declared fields public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); } public ObjArray getMethods() { return (ObjArray) methods.getValue(this); } public TypeArray getMethodOrdering() { return (TypeArray) methodOrdering.getValue(this); } public ObjArray getLocalInterfaces() { return (ObjArray) localInterfaces.getValue(this); }
*** 255,264 **** --- 285,296 ---- public ObjArray getTransitiveInterfaces() { return (ObjArray) transitiveInterfaces.getValue(this); } public long nofImplementors() { return nofImplementors.getValue(this); } public Klass getImplementor() { return (Klass) implementors[0].getValue(this); } public Klass getImplementor(int i) { return (Klass) implementors[i].getValue(this); } public TypeArray getFields() { return (TypeArray) fields.getValue(this); } + public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } + public int getAllFieldsCount() { return (int)getFields().getLength(); } public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } public Oop getClassLoader() { return classLoader.getValue(this); } public Oop getProtectionDomain() { return protectionDomain.getValue(this); } public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } public Symbol getSourceFileName() { return getSymbol(sourceFileName); }
*** 478,489 **** --- 510,521 ---- } void iterateStaticFieldsInternal(OopVisitor visitor) { TypeArray fields = getFields(); ! int length = (int) fields.getLength(); ! for (int index = 0; index < length; index += NEXT_OFFSET) { ! int length = getJavaFieldsCount(); ! for (int index = 0; index < length; index += FIELD_SLOTS) { short accessFlags = fields.getShortAt(index + ACCESS_FLAGS_OFFSET); short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET); FieldType type = new FieldType(getConstants().getSymbolAt(signatureIndex)); AccessFlags access = new AccessFlags(accessFlags); if (access.isStatic()) {
*** 500,511 **** --- 532,543 ---- if (getSuper() != null) { ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); } TypeArray fields = getFields(); ! int length = (int) fields.getLength(); ! for (int index = 0; index < length; index += NEXT_OFFSET) { ! int length = getJavaFieldsCount(); ! for (int index = 0; index < length; index += FIELD_SLOTS) { short accessFlags = fields.getShortAt(index + ACCESS_FLAGS_OFFSET); short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET); FieldType type = new FieldType(getConstants().getSymbolAt(signatureIndex)); AccessFlags access = new AccessFlags(accessFlags);
*** 516,528 **** --- 548,560 ---- } /** Field access by name. */ public Field findLocalField(Symbol name, Symbol sig) { TypeArray fields = getFields(); ! int length = (int) fields.getLength(); ConstantPool cp = getConstants(); ! for (int i = 0; i < n; i += NEXT_OFFSET) { ! for (int i = 0; i < length; i += FIELD_SLOTS) { int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET); int sigIndex = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET); Symbol f_name = cp.getSymbolAt(nameIndex); Symbol f_sig = cp.getSymbolAt(sigIndex); if (name.equals(f_name) && sig.equals(f_sig)) {
*** 611,623 **** --- 643,655 ---- public List getImmediateFields() { // A list of Fields for each field declared in this class/interface, // not including inherited fields. TypeArray fields = getFields(); ! int length = (int) fields.getLength(); - List immediateFields = new ArrayList(length / NEXT_OFFSET); ! for (int index = 0; index < length; index += NEXT_OFFSET) { ! int length = getJavaFieldsCount(); ! List immediateFields = new ArrayList(length); ! for (int index = 0; index < length; index += FIELD_SLOTS) { immediateFields.add(getFieldByIndex(index)); } return immediateFields; }

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