Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.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 | f6f3bb0ee072 |
children | bd7a7ce2e264 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
31 import sun.jvm.hotspot.types.*; | 31 import sun.jvm.hotspot.types.*; |
32 import sun.jvm.hotspot.utilities.*; | 32 import sun.jvm.hotspot.utilities.*; |
33 | 33 |
34 // A MethodData provides interpreter profiling information | 34 // A MethodData provides interpreter profiling information |
35 | 35 |
36 public class MethodData extends Oop { | 36 public class MethodData extends Metadata { |
37 static int TypeProfileWidth = 2; | 37 static int TypeProfileWidth = 2; |
38 static int BciProfileWidth = 2; | 38 static int BciProfileWidth = 2; |
39 static int CompileThreshold; | 39 static int CompileThreshold; |
40 | 40 |
41 static int Reason_many; // indicates presence of several reasons | 41 static int Reason_many; // indicates presence of several reasons |
127 } | 127 } |
128 }); | 128 }); |
129 } | 129 } |
130 | 130 |
131 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | 131 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
132 Type type = db.lookupType("methodDataOopDesc"); | 132 Type type = db.lookupType("MethodData"); |
133 baseOffset = type.getSize(); | 133 baseOffset = type.getSize(); |
134 | 134 |
135 size = new CIntField(type.getCIntegerField("_size"), 0); | 135 size = new CIntField(type.getCIntegerField("_size"), 0); |
136 method = new OopField(type.getOopField("_method"), 0); | 136 method = new MetadataField(type.getAddressField("_method"), 0); |
137 | 137 |
138 VM.Flag[] flags = VM.getVM().getCommandLineFlags(); | 138 VM.Flag[] flags = VM.getVM().getCommandLineFlags(); |
139 for (int f = 0; f < flags.length; f++) { | 139 for (int f = 0; f < flags.length; f++) { |
140 VM.Flag flag = flags[f]; | 140 VM.Flag flag = flags[f]; |
141 if (flag.getName().equals("TypeProfileWidth")) { | 141 if (flag.getName().equals("TypeProfileWidth")) { |
186 } | 186 } |
187 System.out.println(trapReasonName[index]); | 187 System.out.println(trapReasonName[index]); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 MethodData(OopHandle handle, ObjectHeap heap) { | 191 public MethodData(Address addr) { |
192 super(handle, heap); | 192 super(addr); |
193 } | 193 } |
194 | 194 |
195 public boolean isMethodData() { return true; } | 195 public boolean isMethodData() { return true; } |
196 | 196 |
197 private static long baseOffset; | 197 private static long baseOffset; |
198 private static CIntField size; | 198 private static CIntField size; |
199 private static OopField method; | 199 private static MetadataField method; |
200 private static CIntField dataSize; | 200 private static CIntField dataSize; |
201 private static AddressField data; | 201 private static AddressField data; |
202 | 202 |
203 public static int sizeofMethodDataOopDesc; | 203 public static int sizeofMethodDataOopDesc; |
204 public static int cellSize; | 204 public static int cellSize; |
205 | |
206 public long getObjectSize() { | |
207 return alignObjectSize(size.getValue(this)); | |
208 } | |
209 | 205 |
210 public Method getMethod() { | 206 public Method getMethod() { |
211 return (Method) method.getValue(this); | 207 return (Method) method.getValue(this); |
212 } | 208 } |
213 | 209 |
214 public void printValueOn(PrintStream tty) { | 210 public void printValueOn(PrintStream tty) { |
215 Method m = getMethod(); | 211 Method m = getMethod(); |
216 tty.print("MethodData for " + m.getName().asString() + m.getSignature().asString()); | 212 tty.print("MethodData for " + m.getName().asString() + m.getSignature().asString()); |
217 } | 213 } |
218 | 214 |
219 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | 215 public void iterateFields(MetadataVisitor visitor) { |
220 super.iterateFields(visitor, doVMFields); | 216 super.iterateFields(visitor); |
221 if (doVMFields) { | 217 visitor.doMetadata(method, true); |
222 visitor.doOop(method, true); | |
223 visitor.doCInt(size, true); | 218 visitor.doCInt(size, true); |
224 } | 219 } |
225 } | |
226 | 220 |
227 int dataSize() { | 221 int dataSize() { |
228 if (dataSize == null) { | 222 if (dataSize == null) { |
229 return 0; | 223 return 0; |
230 } else { | 224 } else { |
231 return (int)dataSize.getValue(this); | 225 return (int)dataSize.getValue(getAddress()); |
232 } | 226 } |
233 } | 227 } |
234 | 228 |
235 boolean outOfBounds(int dataIndex) { | 229 boolean outOfBounds(int dataIndex) { |
236 return dataIndex >= dataSize(); | 230 return dataIndex >= dataSize(); |
296 } | 290 } |
297 return result; | 291 return result; |
298 } | 292 } |
299 | 293 |
300 public byte[] orig() { | 294 public byte[] orig() { |
301 // fetch the orig methodDataOopDesc data between header and dataSize | 295 // fetch the orig MethodData data between header and dataSize |
302 return fetchDataAt(this.getHandle(), 0, sizeofMethodDataOopDesc); | 296 return fetchDataAt(getAddress(), 0, sizeofMethodDataOopDesc); |
303 } | 297 } |
304 | 298 |
305 public long[] data() { | 299 public long[] data() { |
306 // Read the data as an array of intptr_t elements | 300 // Read the data as an array of intptr_t elements |
307 OopHandle base = getHandle(); | 301 Address base = getAddress(); |
308 long offset = data.getOffset(); | 302 long offset = data.getOffset(); |
309 int elements = dataSize() / cellSize; | 303 int elements = dataSize() / cellSize; |
310 long[] result = new long[elements]; | 304 long[] result = new long[elements]; |
311 for (int i = 0; i < elements; i++) { | 305 for (int i = 0; i < elements; i++) { |
312 Address value = base.getAddressAt(offset + i * MethodData.cellSize); | 306 Address value = base.getAddressAt(offset + i * MethodData.cellSize); |