comparison agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @ 6100:71afdabfd05b

7168280: Eliminate the generic signature index slot from field array for field without generic signature. Summary: Only allocate the generic signature index slot in the field array for field with generic signature attribute. Reviewed-by: coleenp, dlong
author jiangli
date Mon, 21 May 2012 14:10:35 -0400
parents 49036505ab5f
children 04ade88d9712
comparison
equal deleted inserted replaced
6069:03d61caacd1e 6100:71afdabfd05b
48 private static int NAME_INDEX_OFFSET; 48 private static int NAME_INDEX_OFFSET;
49 private static int SIGNATURE_INDEX_OFFSET; 49 private static int SIGNATURE_INDEX_OFFSET;
50 private static int INITVAL_INDEX_OFFSET; 50 private static int INITVAL_INDEX_OFFSET;
51 private static int LOW_OFFSET; 51 private static int LOW_OFFSET;
52 private static int HIGH_OFFSET; 52 private static int HIGH_OFFSET;
53 private static int GENERIC_SIGNATURE_INDEX_OFFSET;
54 private static int FIELD_SLOTS; 53 private static int FIELD_SLOTS;
55 54
56 // ClassState constants 55 // ClassState constants
57 private static int CLASS_STATE_UNPARSABLE_BY_GC; 56 private static int CLASS_STATE_UNPARSABLE_BY_GC;
58 private static int CLASS_STATE_ALLOCATED; 57 private static int CLASS_STATE_ALLOCATED;
97 NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue(); 96 NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
98 SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue(); 97 SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
99 INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue(); 98 INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
100 LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_offset").intValue(); 99 LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_offset").intValue();
101 HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue(); 100 HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue();
102 GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue();
103 FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue(); 101 FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue();
104 // read ClassState constants 102 // read ClassState constants
105 CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue(); 103 CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
106 CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue(); 104 CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
107 CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue(); 105 CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
277 return vmSymbols.symbolAt(signatureIndex); 275 return vmSymbols.symbolAt(signatureIndex);
278 } 276 }
279 } 277 }
280 278
281 public short getFieldGenericSignatureIndex(int index) { 279 public short getFieldGenericSignatureIndex(int index) {
282 return getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET); 280 int len = (int)getFields().getLength();
281 int allFieldsCount = getAllFieldsCount();
282 int generic_signature_slot = allFieldsCount * FIELD_SLOTS;
283 for (int i = 0; i < allFieldsCount; i++) {
284 short flags = getFieldAccessFlags(i);
285 AccessFlags access = new AccessFlags(flags);
286 if (i == index) {
287 if (access.fieldHasGenericSignature()) {
288 return getFields().getShortAt(generic_signature_slot);
289 } else {
290 return 0;
291 }
292 } else {
293 if (access.fieldHasGenericSignature()) {
294 generic_signature_slot ++;
295 }
296 }
297 }
298 return 0;
283 } 299 }
284 300
285 public Symbol getFieldGenericSignature(int index) { 301 public Symbol getFieldGenericSignature(int index) {
286 short genericSignatureIndex = getFieldGenericSignatureIndex(index); 302 short genericSignatureIndex = getFieldGenericSignatureIndex(index);
287 if (genericSignatureIndex != 0) { 303 if (genericSignatureIndex != 0) {
307 public TypeArray getMethodOrdering() { return (TypeArray) methodOrdering.getValue(this); } 323 public TypeArray getMethodOrdering() { return (TypeArray) methodOrdering.getValue(this); }
308 public ObjArray getLocalInterfaces() { return (ObjArray) localInterfaces.getValue(this); } 324 public ObjArray getLocalInterfaces() { return (ObjArray) localInterfaces.getValue(this); }
309 public ObjArray getTransitiveInterfaces() { return (ObjArray) transitiveInterfaces.getValue(this); } 325 public ObjArray getTransitiveInterfaces() { return (ObjArray) transitiveInterfaces.getValue(this); }
310 public TypeArray getFields() { return (TypeArray) fields.getValue(this); } 326 public TypeArray getFields() { return (TypeArray) fields.getValue(this); }
311 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } 327 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); }
312 public int getAllFieldsCount() { return (int)getFields().getLength() / FIELD_SLOTS; } 328 public int getAllFieldsCount() {
329 int len = (int)getFields().getLength();
330 int allFieldsCount = 0;
331 for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) {
332 short flags = getFieldAccessFlags(allFieldsCount);
333 AccessFlags access = new AccessFlags(flags);
334 if (access.fieldHasGenericSignature()) {
335 len --;
336 }
337 }
338 return allFieldsCount;
339 }
313 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } 340 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
314 public Oop getClassLoader() { return classLoader.getValue(this); } 341 public Oop getClassLoader() { return classLoader.getValue(this); }
315 public Oop getProtectionDomain() { return protectionDomain.getValue(this); } 342 public Oop getProtectionDomain() { return protectionDomain.getValue(this); }
316 public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } 343 public ObjArray getSigners() { return (ObjArray) signers.getValue(this); }
317 public Symbol getSourceFileName() { return getSymbol(sourceFileName); } 344 public Symbol getSourceFileName() { return getSymbol(sourceFileName); }