comparison agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @ 4737:75c0a73eee98

7102776: Pack instanceKlass boolean fields into single u1 field Summary: Reduce class runtime memory usage by packing 4 instanceKlass boolean fields into single u1 field. Save 4-byte for each loaded class. Reviewed-by: dholmes, bobv, phh, twisti, never, coleenp Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>
author coleenp
date Thu, 17 Nov 2011 12:53:59 -0500
parents cb315dc80374
children 8f8b94305aff
comparison
equal deleted inserted replaced
4038:869804b759e7 4737:75c0a73eee98
61 private static int CLASS_STATE_LINKED; 61 private static int CLASS_STATE_LINKED;
62 private static int CLASS_STATE_BEING_INITIALIZED; 62 private static int CLASS_STATE_BEING_INITIALIZED;
63 private static int CLASS_STATE_FULLY_INITIALIZED; 63 private static int CLASS_STATE_FULLY_INITIALIZED;
64 private static int CLASS_STATE_INITIALIZATION_ERROR; 64 private static int CLASS_STATE_INITIALIZATION_ERROR;
65 65
66 private static int IS_MARKED_DEPENDENT_MASK;
67
66 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 68 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
67 Type type = db.lookupType("instanceKlass"); 69 Type type = db.lookupType("instanceKlass");
68 arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize()); 70 arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
69 methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize()); 71 methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
70 methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize()); 72 methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
88 innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize()); 90 innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
89 nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize()); 91 nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
90 staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize()); 92 staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
91 staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize()); 93 staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize());
92 nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize()); 94 nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
93 isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize()); 95 miscFlags = new CIntField(type.getCIntegerField("_misc_flags"), Oop.getHeaderSize());
94 initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize()); 96 initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
95 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize()); 97 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
96 itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize()); 98 itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
97 breakpoints = type.getAddressField("_breakpoints"); 99 breakpoints = type.getAddressField("_breakpoints");
98 genericSignature = type.getAddressField("_generic_signature"); 100 genericSignature = type.getAddressField("_generic_signature");
115 CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue(); 117 CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
116 CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue(); 118 CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
117 CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue(); 119 CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue();
118 CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue(); 120 CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
119 CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue(); 121 CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
122
123 IS_MARKED_DEPENDENT_MASK = db.lookupIntConstant("instanceKlass::IS_MARKED_DEPENDENT").intValue();
120 124
121 } 125 }
122 126
123 InstanceKlass(OopHandle handle, ObjectHeap heap) { 127 InstanceKlass(OopHandle handle, ObjectHeap heap) {
124 super(handle, heap); 128 super(handle, heap);
149 private static OopField innerClasses; 153 private static OopField innerClasses;
150 private static CIntField nonstaticFieldSize; 154 private static CIntField nonstaticFieldSize;
151 private static CIntField staticFieldSize; 155 private static CIntField staticFieldSize;
152 private static CIntField staticOopFieldCount; 156 private static CIntField staticOopFieldCount;
153 private static CIntField nonstaticOopMapSize; 157 private static CIntField nonstaticOopMapSize;
154 private static CIntField isMarkedDependent; 158 private static CIntField miscFlags;
155 private static CIntField initState; 159 private static CIntField initState;
156 private static CIntField vtableLen; 160 private static CIntField vtableLen;
157 private static CIntField itableLen; 161 private static CIntField itableLen;
158 private static AddressField breakpoints; 162 private static AddressField breakpoints;
159 private static AddressField genericSignature; 163 private static AddressField genericSignature;
331 public Symbol getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); } 335 public Symbol getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
332 public TypeArray getInnerClasses() { return (TypeArray) innerClasses.getValue(this); } 336 public TypeArray getInnerClasses() { return (TypeArray) innerClasses.getValue(this); }
333 public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } 337 public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); }
334 public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } 338 public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); }
335 public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); } 339 public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); }
336 public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; } 340 public boolean getIsMarkedDependent() { return (miscFlags.getValue(this) & IS_MARKED_DEPENDENT_MASK) != 0; }
337 public long getVtableLen() { return vtableLen.getValue(this); } 341 public long getVtableLen() { return vtableLen.getValue(this); }
338 public long getItableLen() { return itableLen.getValue(this); } 342 public long getItableLen() { return itableLen.getValue(this); }
339 public Symbol getGenericSignature() { return getSymbol(genericSignature); } 343 public Symbol getGenericSignature() { return getSymbol(genericSignature); }
340 public long majorVersion() { return majorVersion.getValue(this); } 344 public long majorVersion() { return majorVersion.getValue(this); }
341 public long minorVersion() { return minorVersion.getValue(this); } 345 public long minorVersion() { return minorVersion.getValue(this); }
522 visitor.doOop(innerClasses, true); 526 visitor.doOop(innerClasses, true);
523 visitor.doCInt(nonstaticFieldSize, true); 527 visitor.doCInt(nonstaticFieldSize, true);
524 visitor.doCInt(staticFieldSize, true); 528 visitor.doCInt(staticFieldSize, true);
525 visitor.doCInt(staticOopFieldCount, true); 529 visitor.doCInt(staticOopFieldCount, true);
526 visitor.doCInt(nonstaticOopMapSize, true); 530 visitor.doCInt(nonstaticOopMapSize, true);
527 visitor.doCInt(isMarkedDependent, true); 531 visitor.doCInt(miscFlags, true);
528 visitor.doCInt(initState, true); 532 visitor.doCInt(initState, true);
529 visitor.doCInt(vtableLen, true); 533 visitor.doCInt(vtableLen, true);
530 visitor.doCInt(itableLen, true); 534 visitor.doCInt(itableLen, true);
531 } 535 }
532 } 536 }