comparison agent/src/share/classes/sun/jvm/hotspot/oops/Method.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 8150fa46d2ed
children 18fb7da42534
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
34 import sun.jvm.hotspot.types.*; 34 import sun.jvm.hotspot.types.*;
35 import sun.jvm.hotspot.utilities.*; 35 import sun.jvm.hotspot.utilities.*;
36 36
37 // A Method represents a Java method 37 // A Method represents a Java method
38 38
39 public class Method extends Oop { 39 public class Method extends Metadata {
40 static { 40 static {
41 VM.registerVMInitializedObserver(new Observer() { 41 VM.registerVMInitializedObserver(new Observer() {
42 public void update(Observable o, Object data) { 42 public void update(Observable o, Object data) {
43 initialize(VM.getVM().getTypeDataBase()); 43 initialize(VM.getVM().getTypeDataBase());
44 } 44 }
45 }); 45 });
46 } 46 }
47 47
48 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 48 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
49 Type type = db.lookupType("methodOopDesc"); 49 Type type = db.lookupType("Method");
50 constMethod = new OopField(type.getOopField("_constMethod"), 0); 50 constMethod = type.getAddressField("_constMethod");
51 methodData = new OopField(type.getOopField("_method_data"), 0); 51 methodData = type.getAddressField("_method_data");
52 methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); 52 methodSize = new CIntField(type.getCIntegerField("_method_size"), 0);
53 maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0); 53 maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0);
54 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0); 54 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
55 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0); 55 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
56 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); 56 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
72 */ 72 */
73 objectInitializerName = null; 73 objectInitializerName = null;
74 classInitializerName = null; 74 classInitializerName = null;
75 } 75 }
76 76
77 Method(OopHandle handle, ObjectHeap heap) { 77 public Method(Address addr) {
78 super(handle, heap); 78 super(addr);
79 } 79 }
80 80
81 public boolean isMethod() { return true; } 81 public boolean isMethod() { return true; }
82 82
83 // Fields 83 // Fields
84 private static OopField constMethod; 84 private static AddressField constMethod;
85 private static OopField methodData; 85 private static AddressField methodData;
86 private static CIntField methodSize; 86 private static CIntField methodSize;
87 private static CIntField maxStack; 87 private static CIntField maxStack;
88 private static CIntField maxLocals; 88 private static CIntField maxLocals;
89 private static CIntField sizeOfParameters; 89 private static CIntField sizeOfParameters;
90 private static CIntField accessFlags; 90 private static CIntField accessFlags;
120 private static AddressCField interpreterEntry; 120 private static AddressCField interpreterEntry;
121 private static AddressCField fromCompiledCodeEntryPoint; 121 private static AddressCField fromCompiledCodeEntryPoint;
122 */ 122 */
123 123
124 // Accessors for declared fields 124 // Accessors for declared fields
125 public ConstMethod getConstMethod() { return (ConstMethod) constMethod.getValue(this); } 125 public ConstMethod getConstMethod() {
126 Address addr = constMethod.getValue(getAddress());
127 return (ConstMethod) VMObjectFactory.newObject(ConstMethod.class, addr);
128 }
126 public ConstantPool getConstants() { 129 public ConstantPool getConstants() {
127 return getConstMethod().getConstants(); 130 return getConstMethod().getConstants();
128 } 131 }
129 public MethodData getMethodData() { return (MethodData) methodData.getValue(this); } 132 public MethodData getMethodData() {
133 Address addr = methodData.getValue(getAddress());
134 return (MethodData) VMObjectFactory.newObject(MethodData.class, addr);
135 }
130 /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */ 136 /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
131 public long getMethodSize() { return methodSize.getValue(this); } 137 public long getMethodSize() { return methodSize.getValue(this); }
132 public long getMaxStack() { return maxStack.getValue(this); } 138 public long getMaxStack() { return maxStack.getValue(this); }
133 public long getMaxLocals() { return maxLocals.getValue(this); } 139 public long getMaxLocals() { return maxLocals.getValue(this); }
134 public long getSizeOfParameters() { return sizeOfParameters.getValue(this); } 140 public long getSizeOfParameters() { return sizeOfParameters.getValue(this); }
151 return backedgeCounter.getValue(this); 157 return backedgeCounter.getValue(this);
152 } 158 }
153 159
154 // get associated compiled native method, if available, else return null. 160 // get associated compiled native method, if available, else return null.
155 public NMethod getNativeMethod() { 161 public NMethod getNativeMethod() {
156 Address addr = code.getValue(getHandle()); 162 Address addr = code.getValue(getAddress());
157 return (NMethod) VMObjectFactory.newObject(NMethod.class, addr); 163 return (NMethod) VMObjectFactory.newObject(NMethod.class, addr);
158 } 164 }
159 165
160 // Convenience routine 166 // Convenience routine
161 public AccessFlags getAccessFlagsObj() { 167 public AccessFlags getAccessFlagsObj() {
266 OopMapCacheEntry entry = new OopMapCacheEntry(); 272 OopMapCacheEntry entry = new OopMapCacheEntry();
267 entry.fill(this, bci); 273 entry.fill(this, bci);
268 return entry; 274 return entry;
269 } 275 }
270 276
271 public long getObjectSize() { 277 public long getSize() {
272 return getMethodSize() * getHeap().getOopSize(); 278 return getMethodSize();
273 } 279 }
274 280
275 public void printValueOn(PrintStream tty) { 281 public void printValueOn(PrintStream tty) {
276 tty.print("Method " + getName().asString() + getSignature().asString() + "@" + getHandle()); 282 tty.print("Method " + getName().asString() + getSignature().asString() + "@" + getAddress());
277 } 283 }
278 284
279 public void iterateFields(OopVisitor visitor, boolean doVMFields) { 285 public void iterateFields(MetadataVisitor visitor) {
280 super.iterateFields(visitor, doVMFields);
281 if (doVMFields) {
282 visitor.doOop(constMethod, true);
283 visitor.doCInt(methodSize, true); 286 visitor.doCInt(methodSize, true);
284 visitor.doCInt(maxStack, true); 287 visitor.doCInt(maxStack, true);
285 visitor.doCInt(maxLocals, true); 288 visitor.doCInt(maxLocals, true);
286 visitor.doCInt(sizeOfParameters, true); 289 visitor.doCInt(sizeOfParameters, true);
287 visitor.doCInt(accessFlags, true); 290 visitor.doCInt(accessFlags, true);
288 } 291 }
289 }
290 292
291 public boolean hasLineNumberTable() { 293 public boolean hasLineNumberTable() {
292 return getConstMethod().hasLineNumberTable(); 294 return getConstMethod().hasLineNumberTable();
293 } 295 }
294 296
355 new SignatureConverter(getSignature(), buf).iterateParameters(); 357 new SignatureConverter(getSignature(), buf).iterateParameters();
356 buf.append(")"); 358 buf.append(")");
357 return buf.toString().replace('/', '.'); 359 return buf.toString().replace('/', '.');
358 } 360 }
359 public int interpreterThrowoutCount() { 361 public int interpreterThrowoutCount() {
360 return (int) interpreterThrowoutCountField.getValue(getHandle()); 362 return (int) interpreterThrowoutCountField.getValue(this);
361 } 363 }
362 364
363 public int interpreterInvocationCount() { 365 public int interpreterInvocationCount() {
364 return (int) interpreterInvocationCountField.getValue(getHandle()); 366 return (int) interpreterInvocationCountField.getValue(this);
365 } 367 }
366 } 368 }