Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java @ 8031:927a311d00f9
8007320: NPG: move method annotations
Summary: allocate method annotations and attach to ConstMethod if present
Reviewed-by: dcubed, jiangli, sspitsyn, iklam
author | coleenp |
---|---|
date | Mon, 11 Feb 2013 14:06:22 -0500 |
parents | ec0c4951286c |
children | f82bcc429e8c |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.runtime; | |
26 | |
27 import java.io.*; | |
28 import java.net.*; | |
29 import java.util.*; | |
30 import java.util.regex.*; | |
31 import sun.jvm.hotspot.code.*; | |
32 import sun.jvm.hotspot.c1.*; | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
2411
diff
changeset
|
33 import sun.jvm.hotspot.code.*; |
0 | 34 import sun.jvm.hotspot.debugger.*; |
35 import sun.jvm.hotspot.interpreter.*; | |
36 import sun.jvm.hotspot.memory.*; | |
37 import sun.jvm.hotspot.oops.*; | |
38 import sun.jvm.hotspot.types.*; | |
39 import sun.jvm.hotspot.utilities.*; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
40 import sun.jvm.hotspot.runtime.*; |
0 | 41 |
42 /** <P> This class encapsulates the global state of the VM; the | |
43 universe, object heap, interpreter, etc. It is a Singleton and | |
44 must be initialized with a call to initialize() before calling | |
45 getVM(). </P> | |
46 | |
47 <P> Many auxiliary classes (i.e., most of the VMObjects) keep | |
48 needed field offsets in the form of static Field objects. In a | |
49 debugging system, the VM might be shutdown and re-initialized (on | |
50 a differently-configured build, i.e., 32- vs. 64-bit), and all old | |
51 cached state (including fields and field offsets) must be | |
52 flushed. </P> | |
53 | |
54 <P> An Observer pattern is used to implement the initialization of | |
55 such classes. Each such class, in its static initializer, | |
56 registers an Observer with the VM class via | |
57 VM.registerVMInitializedObserver(). This Observer is guaranteed to | |
58 be notified whenever the VM is initialized (or re-initialized). To | |
59 implement the first-time initialization, the observer is also | |
60 notified when it registers itself with the VM. (For bootstrapping | |
61 reasons, this implies that the constructor of VM can not | |
62 instantiate any such objects, since VM.soleInstance will not have | |
63 been set yet. This is a bootstrapping issue which may have to be | |
64 revisited later.) </P> | |
65 */ | |
66 | |
67 public class VM { | |
68 private static VM soleInstance; | |
69 private static List vmInitializedObservers = new ArrayList(); | |
70 private List vmResumedObservers = new ArrayList(); | |
71 private List vmSuspendedObservers = new ArrayList(); | |
72 private TypeDataBase db; | |
73 private boolean isBigEndian; | |
74 /** This is only present if in a debugging system */ | |
75 private JVMDebugger debugger; | |
76 private long stackBias; | |
77 private long logAddressSize; | |
78 private Universe universe; | |
79 private ObjectHeap heap; | |
80 private SymbolTable symbols; | |
81 private StringTable strings; | |
82 private SystemDictionary dict; | |
83 private Threads threads; | |
84 private ObjectSynchronizer synchronizer; | |
85 private JNIHandles handles; | |
86 private Interpreter interpreter; | |
87 private StubRoutines stubRoutines; | |
88 private Bytes bytes; | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
2411
diff
changeset
|
89 |
0 | 90 /** Flags indicating whether we are attached to a core, C1, or C2 build */ |
91 private boolean usingClientCompiler; | |
92 private boolean usingServerCompiler; | |
93 /** Flag indicating whether UseTLAB is turned on */ | |
94 private boolean useTLAB; | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
95 /** Flag indicating whether invokedynamic support is on */ |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
96 private boolean enableInvokeDynamic; |
0 | 97 /** alignment constants */ |
98 private boolean isLP64; | |
99 private int bytesPerLong; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
100 private int bytesPerWord; |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
101 private int objectAlignmentInBytes; |
0 | 102 private int minObjAlignmentInBytes; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
103 private int logMinObjAlignmentInBytes; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
104 private int heapWordSize; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
105 private int heapOopSize; |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
106 private int klassPtrSize; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
107 private int oopSize; |
0 | 108 /** This is only present in a non-core build */ |
109 private CodeCache codeCache; | |
110 /** This is only present in a C1 build */ | |
111 private Runtime1 runtime1; | |
112 /** These constants come from globalDefinitions.hpp */ | |
113 private int invocationEntryBCI; | |
114 private int invalidOSREntryBCI; | |
115 private ReversePtrs revPtrs; | |
116 private VMRegImpl vmregImpl; | |
8005
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
117 private int reserveForAllocationPrefetch; |
0 | 118 |
119 // System.getProperties from debuggee VM | |
120 private Properties sysProps; | |
121 | |
122 // VM version strings come from Abstract_VM_Version class | |
123 private String vmRelease; | |
124 private String vmInternalInfo; | |
125 | |
126 private Flag[] commandLineFlags; | |
127 private Map flagsMap; | |
128 | |
129 private static Type intxType; | |
130 private static Type uintxType; | |
131 private static CIntegerType boolType; | |
132 private Boolean sharingEnabled; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
133 private Boolean compressedOopsEnabled; |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
134 private Boolean compressedKlassPointersEnabled; |
0 | 135 |
136 // command line flags supplied to VM - see struct Flag in globals.hpp | |
137 public static final class Flag { | |
138 private String type; | |
139 private String name; | |
140 private Address addr; | |
141 private String kind; | |
3939 | 142 private int origin; |
0 | 143 |
3939 | 144 private Flag(String type, String name, Address addr, String kind, int origin) { |
0 | 145 this.type = type; |
146 this.name = name; | |
147 this.addr = addr; | |
148 this.kind = kind; | |
3939 | 149 this.origin = origin; |
0 | 150 } |
151 | |
152 public String getType() { | |
153 return type; | |
154 } | |
155 | |
156 public String getName() { | |
157 return name; | |
158 } | |
159 | |
160 public Address getAddress() { | |
161 return addr; | |
162 } | |
163 | |
164 public String getKind() { | |
165 return kind; | |
166 } | |
167 | |
3939 | 168 public int getOrigin() { |
169 return origin; | |
170 } | |
171 | |
0 | 172 public boolean isBool() { |
173 return type.equals("bool"); | |
174 } | |
175 | |
176 public boolean getBool() { | |
177 if (Assert.ASSERTS_ENABLED) { | |
178 Assert.that(isBool(), "not a bool flag!"); | |
179 } | |
180 return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) | |
181 != 0; | |
182 } | |
183 | |
184 public boolean isIntx() { | |
185 return type.equals("intx"); | |
186 } | |
187 | |
188 public long getIntx() { | |
189 if (Assert.ASSERTS_ENABLED) { | |
190 Assert.that(isIntx(), "not a intx flag!"); | |
191 } | |
192 return addr.getCIntegerAt(0, intxType.getSize(), false); | |
193 } | |
194 | |
195 public boolean isUIntx() { | |
196 return type.equals("uintx"); | |
197 } | |
198 | |
199 public long getUIntx() { | |
200 if (Assert.ASSERTS_ENABLED) { | |
201 Assert.that(isUIntx(), "not a uintx flag!"); | |
202 } | |
203 return addr.getCIntegerAt(0, uintxType.getSize(), true); | |
204 } | |
205 | |
206 public String getValue() { | |
207 if (isBool()) { | |
208 return new Boolean(getBool()).toString(); | |
209 } else if (isIntx()) { | |
210 return new Long(getIntx()).toString(); | |
211 } else if (isUIntx()) { | |
212 return new Long(getUIntx()).toString(); | |
213 } else { | |
214 return null; | |
215 } | |
216 } | |
217 }; | |
218 | |
219 private static void checkVMVersion(String vmRelease) { | |
220 if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) { | |
221 // read sa build version. | |
222 String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion"; | |
223 String saVersion = saProps.getProperty(versionProp); | |
224 if (saVersion == null) | |
225 throw new RuntimeException("Missing property " + versionProp); | |
226 | |
227 // Strip nonproduct VM version substring (note: saVersion doesn't have it). | |
228 String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)",""); | |
229 | |
230 if (saVersion.equals(vmVersion)) { | |
231 // Exact match | |
232 return; | |
233 } | |
234 if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') && | |
235 vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) { | |
236 // Throw exception if different release versions: | |
237 // <major>.<minor>-b<n> | |
238 throw new VMVersionMismatchException(saVersion, vmRelease); | |
239 } else { | |
240 // Otherwise print warning to allow mismatch not release versions | |
241 // during development. | |
242 System.err.println("WARNING: Hotspot VM version " + vmRelease + | |
243 " does not match with SA version " + saVersion + | |
244 "." + " You may see unexpected results. "); | |
245 } | |
246 } else { | |
247 System.err.println("WARNING: You have disabled SA and VM version check. You may be " + | |
248 "using incompatible version of SA and you may see unexpected " + | |
249 "results."); | |
250 } | |
251 } | |
252 | |
253 private static final boolean disableDerivedPrinterTableCheck; | |
254 private static final Properties saProps; | |
255 | |
256 static { | |
257 saProps = new Properties(); | |
258 URL url = null; | |
259 try { | |
260 url = VM.class.getClassLoader().getResource("sa.properties"); | |
261 saProps.load(new BufferedInputStream(url.openStream())); | |
262 } catch (Exception e) { | |
263 throw new RuntimeException("Unable to load properties " + | |
264 (url == null ? "null" : url.toString()) + | |
265 ": " + e.getMessage()); | |
266 } | |
267 | |
268 disableDerivedPrinterTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null; | |
269 } | |
270 | |
271 private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) { | |
272 this.db = db; | |
273 this.debugger = debugger; | |
274 this.isBigEndian = isBigEndian; | |
275 | |
276 // Note that we don't construct universe, heap, threads, | |
277 // interpreter, or stubRoutines here (any more). The current | |
278 // initialization mechanisms require that the VM be completely set | |
279 // up (i.e., out of its constructor, with soleInstance assigned) | |
280 // before their static initializers are run. | |
281 | |
282 if (db.getAddressSize() == 4) { | |
283 logAddressSize = 2; | |
284 } else if (db.getAddressSize() == 8) { | |
285 logAddressSize = 3; | |
286 } else { | |
287 throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported"); | |
288 } | |
289 | |
290 // read VM version info | |
291 try { | |
292 Type vmVersion = db.lookupType("Abstract_VM_Version"); | |
293 Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue(); | |
294 vmRelease = CStringUtilities.getString(releaseAddr); | |
295 Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue(); | |
296 vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr); | |
8005
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
297 |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
298 CIntegerType intType = (CIntegerType) db.lookupType("int"); |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
299 CIntegerField reserveForAllocationPrefetchField = vmVersion.getCIntegerField("_reserve_for_allocation_prefetch"); |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
300 reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); |
0 | 301 } catch (Exception exp) { |
302 throw new RuntimeException("can't determine target's VM version : " + exp.getMessage()); | |
303 } | |
304 | |
305 checkVMVersion(vmRelease); | |
306 | |
307 stackBias = db.lookupIntConstant("STACK_BIAS").intValue(); | |
308 invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue(); | |
309 invalidOSREntryBCI = db.lookupIntConstant("InvalidOSREntryBci").intValue(); | |
310 | |
311 // We infer the presence of C1 or C2 from a couple of fields we | |
312 // already have present in the type database | |
313 { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
314 Type type = db.lookupType("Method"); |
0 | 315 if (type.getField("_from_compiled_entry", false, false) == null) { |
316 // Neither C1 nor C2 is present | |
317 usingClientCompiler = false; | |
318 usingServerCompiler = false; | |
319 } else { | |
320 // Determine whether C2 is present | |
3944 | 321 if (db.lookupType("Matcher", false) != null) { |
0 | 322 usingServerCompiler = true; |
323 } else { | |
324 usingClientCompiler = true; | |
325 } | |
326 } | |
327 } | |
328 | |
329 useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0); | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
330 enableInvokeDynamic = (db.lookupIntConstant("EnableInvokeDynamic").intValue() != 0); |
0 | 331 |
332 if (debugger != null) { | |
333 isLP64 = debugger.getMachineDescription().isLP64(); | |
334 } | |
335 bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
336 bytesPerWord = db.lookupIntConstant("BytesPerWord").intValue(); |
1576
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
337 heapWordSize = db.lookupIntConstant("HeapWordSize").intValue(); |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
338 oopSize = db.lookupIntConstant("oopSize").intValue(); |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
339 |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
340 intxType = db.lookupType("intx"); |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
341 uintxType = db.lookupType("uintx"); |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
342 boolType = (CIntegerType) db.lookupType("bool"); |
4a2e260bb13a
6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents:
1571
diff
changeset
|
343 |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
344 minObjAlignmentInBytes = getObjectAlignmentInBytes(); |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
345 if (minObjAlignmentInBytes == 8) { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
346 logMinObjAlignmentInBytes = 3; |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
347 } else if (minObjAlignmentInBytes == 16) { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
348 logMinObjAlignmentInBytes = 4; |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
349 } else { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
350 throw new RuntimeException("Object alignment " + minObjAlignmentInBytes + " not yet supported"); |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
351 } |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
352 |
749 | 353 if (isCompressedOopsEnabled()) { |
354 // Size info for oops within java objects is fixed | |
355 heapOopSize = (int)getIntSize(); | |
356 } else { | |
357 heapOopSize = (int)getOopSize(); | |
358 } | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
359 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
360 if (isCompressedKlassPointersEnabled()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
361 klassPtrSize = (int)getIntSize(); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
362 } else { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
363 klassPtrSize = (int)getOopSize(); // same as an oop |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
364 } |
0 | 365 } |
366 | |
367 /** This could be used by a reflective runtime system */ | |
368 public static void initialize(TypeDataBase db, boolean isBigEndian) { | |
369 if (soleInstance != null) { | |
370 throw new RuntimeException("Attempt to initialize VM twice"); | |
371 } | |
372 soleInstance = new VM(db, null, isBigEndian); | |
373 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) { | |
374 ((Observer) iter.next()).update(null, null); | |
375 } | |
376 } | |
377 | |
378 /** This is used by the debugging system */ | |
379 public static void initialize(TypeDataBase db, JVMDebugger debugger) { | |
380 if (soleInstance != null) { | |
381 throw new RuntimeException("Attempt to initialize VM twice"); | |
382 } | |
383 soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian()); | |
689
f30ba3b36599
6822407: heapOopSize lookup is incorrect in Serviceability Agent.
poonam
parents:
655
diff
changeset
|
384 |
0 | 385 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) { |
386 ((Observer) iter.next()).update(null, null); | |
387 } | |
650 | 388 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
389 debugger.putHeapConst(soleInstance.getHeapOopSize(), soleInstance.getKlassPtrSize(), |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
390 Universe.getNarrowOopBase(), Universe.getNarrowOopShift(), |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
391 Universe.getNarrowKlassBase(), Universe.getNarrowKlassShift()); |
0 | 392 } |
393 | |
394 /** This is used by the debugging system */ | |
395 public static void shutdown() { | |
396 soleInstance = null; | |
397 } | |
398 | |
399 /** This is used by both the debugger and any runtime system. It is | |
400 the basic mechanism by which classes which mimic underlying VM | |
401 functionality cause themselves to be initialized. The given | |
402 observer will be notified (with arguments (null, null)) when the | |
403 VM is re-initialized, as well as when it registers itself with | |
404 the VM. */ | |
405 public static void registerVMInitializedObserver(Observer o) { | |
406 vmInitializedObservers.add(o); | |
407 o.update(null, null); | |
408 } | |
409 | |
410 /** This is the primary accessor used by both the debugger and any | |
411 potential runtime system */ | |
412 public static VM getVM() { | |
413 if (soleInstance == null) { | |
414 throw new RuntimeException("VM.initialize() was not yet called"); | |
415 } | |
416 return soleInstance; | |
417 } | |
418 | |
419 /** This is only used by the debugging system. The given observer | |
420 will be notified if the underlying VM resumes execution. NOTE | |
421 that the given observer is not triggered if the VM is currently | |
422 running and therefore differs in behavior from {@link | |
423 #registerVMInitializedObserver} (because of the possibility of | |
424 race conditions if the observer is added while the VM is being | |
425 suspended or resumed). */ | |
426 public void registerVMResumedObserver(Observer o) { | |
427 vmResumedObservers.add(o); | |
428 } | |
429 | |
430 /** This is only used by the debugging system. The given observer | |
431 will be notified if the underlying VM suspends execution. NOTE | |
432 that the given observer is not triggered if the VM is currently | |
433 suspended and therefore differs in behavior from {@link | |
434 #registerVMInitializedObserver} (because of the possibility of | |
435 race conditions if the observer is added while the VM is being | |
436 suspended or resumed). */ | |
437 public void registerVMSuspendedObserver(Observer o) { | |
438 vmSuspendedObservers.add(o); | |
439 } | |
440 | |
441 /** This is only used by the debugging system. Informs all | |
442 registered resumption observers that the VM has been resumed. | |
443 The application is responsible for actually having performed the | |
444 resumption. No OopHandles must be used after this point, as they | |
445 may move in the target address space due to garbage | |
446 collection. */ | |
447 public void fireVMResumed() { | |
448 for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext(); ) { | |
449 ((Observer) iter.next()).update(null, null); | |
450 } | |
451 } | |
452 | |
453 /** This is only used by the debugging system. Informs all | |
454 registered suspension observers that the VM has been suspended. | |
455 The application is responsible for actually having performed the | |
456 suspension. Garbage collection must be forbidden at this point; | |
457 for example, a JPDA-level suspension is not adequate since the | |
458 VM thread may still be running. */ | |
459 public void fireVMSuspended() { | |
460 for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext(); ) { | |
461 ((Observer) iter.next()).update(null, null); | |
462 } | |
463 } | |
464 | |
465 /** Returns the OS this VM is running on. Notice that by delegating | |
466 to the debugger we can transparently support remote | |
467 debugging. */ | |
468 public String getOS() { | |
469 if (debugger != null) { | |
470 return debugger.getOS(); | |
471 } | |
472 return PlatformInfo.getOS(); | |
473 } | |
474 | |
475 /** Returns the CPU this VM is running on. Notice that by delegating | |
476 to the debugger we can transparently support remote | |
477 debugging. */ | |
478 public String getCPU() { | |
479 if (debugger != null) { | |
480 return debugger.getCPU(); | |
481 } | |
482 return PlatformInfo.getCPU(); | |
483 } | |
484 | |
485 public Type lookupType(String cTypeName) { | |
486 return db.lookupType(cTypeName); | |
487 } | |
488 | |
489 public Integer lookupIntConstant(String name) { | |
490 return db.lookupIntConstant(name); | |
491 } | |
492 | |
6782 | 493 // Convenience function for conversions |
494 static public long getAddressValue(Address addr) { | |
495 return VM.getVM().getDebugger().getAddressValue(addr); | |
496 } | |
497 | |
0 | 498 public long getAddressSize() { |
499 return db.getAddressSize(); | |
500 } | |
501 | |
502 public long getOopSize() { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
503 return oopSize; |
0 | 504 } |
505 | |
506 public long getLogAddressSize() { | |
507 return logAddressSize; | |
508 } | |
509 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
510 public long getIntSize() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
511 return db.getJIntType().getSize(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
512 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
513 |
0 | 514 /** NOTE: this offset is in BYTES in this system! */ |
515 public long getStackBias() { | |
516 return stackBias; | |
517 } | |
518 | |
519 /** Indicates whether the underlying machine supports the LP64 data | |
520 model. This is needed for conditionalizing code in a few places */ | |
521 public boolean isLP64() { | |
522 if (Assert.ASSERTS_ENABLED) { | |
523 Assert.that(isDebugging(), "Debugging system only for now"); | |
524 } | |
525 return isLP64; | |
526 } | |
527 | |
528 /** Get bytes-per-long == long/double natural alignment. */ | |
529 public int getBytesPerLong() { | |
530 return bytesPerLong; | |
531 } | |
532 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
533 public int getBytesPerWord() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
534 return bytesPerWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
535 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
536 |
0 | 537 /** Get minimum object alignment in bytes. */ |
538 public int getMinObjAlignmentInBytes() { | |
539 return minObjAlignmentInBytes; | |
540 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
541 public int getLogMinObjAlignmentInBytes() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
542 return logMinObjAlignmentInBytes; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
543 } |
0 | 544 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
545 public int getHeapWordSize() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
546 return heapWordSize; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
547 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
548 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
549 public int getHeapOopSize() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
550 return heapOopSize; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
551 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
552 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
553 public int getKlassPtrSize() { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
554 return klassPtrSize; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
555 } |
0 | 556 /** Utility routine for getting data structure alignment correct */ |
557 public long alignUp(long size, long alignment) { | |
558 return (size + alignment - 1) & ~(alignment - 1); | |
559 } | |
560 | |
561 /** Utility routine for getting data structure alignment correct */ | |
562 public long alignDown(long size, long alignment) { | |
563 return size & ~(alignment - 1); | |
564 } | |
565 | |
566 /** Utility routine for building an int from two "unsigned" 16-bit | |
567 shorts */ | |
568 public int buildIntFromShorts(short low, short high) { | |
569 return (((int) high) << 16) | (((int) low) & 0xFFFF); | |
570 } | |
571 | |
572 /** Utility routine for building a long from two "unsigned" 32-bit | |
573 ints in <b>platform-dependent</b> order */ | |
574 public long buildLongFromIntsPD(int oneHalf, int otherHalf) { | |
575 if (isBigEndian) { | |
576 return (((long) otherHalf) << 32) | (((long) oneHalf) & 0x00000000FFFFFFFFL); | |
577 } else{ | |
578 return (((long) oneHalf) << 32) | (((long) otherHalf) & 0x00000000FFFFFFFFL); | |
579 } | |
580 } | |
581 | |
582 /** Indicates whether Thread-Local Allocation Buffers are used */ | |
583 public boolean getUseTLAB() { | |
584 return useTLAB; | |
585 } | |
586 | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
587 public boolean getEnableInvokeDynamic() { |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
588 return enableInvokeDynamic; |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
589 } |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
6266
diff
changeset
|
590 |
0 | 591 public TypeDataBase getTypeDataBase() { |
592 return db; | |
593 } | |
594 | |
595 public Universe getUniverse() { | |
596 if (universe == null) { | |
597 universe = new Universe(); | |
598 } | |
599 return universe; | |
600 } | |
601 | |
602 public ObjectHeap getObjectHeap() { | |
603 if (heap == null) { | |
604 heap = new ObjectHeap(db); | |
605 } | |
606 return heap; | |
607 } | |
608 | |
609 public SymbolTable getSymbolTable() { | |
610 if (symbols == null) { | |
611 symbols = SymbolTable.getTheTable(); | |
612 } | |
613 return symbols; | |
614 } | |
615 | |
616 public StringTable getStringTable() { | |
617 if (strings == null) { | |
618 strings = StringTable.getTheTable(); | |
619 } | |
620 return strings; | |
621 } | |
622 | |
623 public SystemDictionary getSystemDictionary() { | |
624 if (dict == null) { | |
625 dict = new SystemDictionary(); | |
626 } | |
627 return dict; | |
628 } | |
629 | |
630 public Threads getThreads() { | |
631 if (threads == null) { | |
632 threads = new Threads(); | |
633 } | |
634 return threads; | |
635 } | |
636 | |
637 public ObjectSynchronizer getObjectSynchronizer() { | |
638 if (synchronizer == null) { | |
639 synchronizer = new ObjectSynchronizer(); | |
640 } | |
641 return synchronizer; | |
642 } | |
643 | |
644 public JNIHandles getJNIHandles() { | |
645 if (handles == null) { | |
646 handles = new JNIHandles(); | |
647 } | |
648 return handles; | |
649 } | |
650 | |
651 public Interpreter getInterpreter() { | |
652 if (interpreter == null) { | |
653 interpreter = new Interpreter(); | |
654 } | |
655 return interpreter; | |
656 } | |
657 | |
658 public StubRoutines getStubRoutines() { | |
659 if (stubRoutines == null) { | |
660 stubRoutines = new StubRoutines(); | |
661 } | |
662 return stubRoutines; | |
663 } | |
664 | |
665 public VMRegImpl getVMRegImplInfo() { | |
666 if (vmregImpl == null) { | |
667 vmregImpl = new VMRegImpl(); | |
668 } | |
669 return vmregImpl; | |
670 } | |
671 | |
672 public Bytes getBytes() { | |
673 if (bytes == null) { | |
674 bytes = new Bytes(debugger.getMachineDescription()); | |
675 } | |
676 return bytes; | |
677 } | |
678 | |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
196
diff
changeset
|
679 /** Returns true if this is a isBigEndian, false otherwise */ |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
196
diff
changeset
|
680 public boolean isBigEndian() { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
196
diff
changeset
|
681 return isBigEndian; |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
196
diff
changeset
|
682 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
196
diff
changeset
|
683 |
0 | 684 /** Returns true if this is a "core" build, false if either C1 or C2 |
685 is present */ | |
686 public boolean isCore() { | |
687 return (!(usingClientCompiler || usingServerCompiler)); | |
688 } | |
689 | |
690 /** Returns true if this is a C1 build, false otherwise */ | |
691 public boolean isClientCompiler() { | |
692 return usingClientCompiler; | |
693 } | |
694 | |
695 /** Returns true if this is a C2 build, false otherwise */ | |
696 public boolean isServerCompiler() { | |
697 return usingServerCompiler; | |
698 } | |
699 | |
700 /** Returns true if C2 derived pointer table should be used, false otherwise */ | |
701 public boolean useDerivedPointerTable() { | |
702 return !disableDerivedPrinterTableCheck; | |
703 } | |
704 | |
705 /** Returns the code cache; should not be used if is core build */ | |
706 public CodeCache getCodeCache() { | |
707 if (Assert.ASSERTS_ENABLED) { | |
708 Assert.that(!isCore(), "noncore builds only"); | |
709 } | |
710 if (codeCache == null) { | |
711 codeCache = new CodeCache(); | |
712 } | |
713 return codeCache; | |
714 } | |
715 | |
716 /** Should only be called for C1 builds */ | |
717 public Runtime1 getRuntime1() { | |
718 if (Assert.ASSERTS_ENABLED) { | |
719 Assert.that(isClientCompiler(), "C1 builds only"); | |
720 } | |
721 if (runtime1 == null) { | |
722 runtime1 = new Runtime1(); | |
723 } | |
724 return runtime1; | |
725 } | |
726 | |
727 /** Test to see whether we're in debugging mode (NOTE: this really | |
728 should not be tested by this code; currently only used in | |
729 StackFrameStream) */ | |
730 public boolean isDebugging() { | |
731 return (debugger != null); | |
732 } | |
733 | |
734 /** This is only used by the debugging (i.e., non-runtime) system */ | |
735 public JVMDebugger getDebugger() { | |
736 if (debugger == null) { | |
737 throw new RuntimeException("Attempt to use debugger in runtime system"); | |
738 } | |
739 return debugger; | |
740 } | |
741 | |
742 /** Indicates whether a given program counter is in Java code. This | |
743 includes but is not spanned by the interpreter and code cache. | |
744 Only used in the debugging system, for implementing | |
745 JavaThread.currentFrameGuess() on x86. */ | |
746 public boolean isJavaPCDbg(Address addr) { | |
747 // FIXME: this is not a complete enough set: must include areas | |
748 // like vtable stubs | |
749 return (getInterpreter().contains(addr) || | |
750 getCodeCache().contains(addr)); | |
751 } | |
752 | |
753 /** FIXME: figure out where to stick this */ | |
754 public int getInvocationEntryBCI() { | |
755 return invocationEntryBCI; | |
756 } | |
757 | |
758 /** FIXME: figure out where to stick this */ | |
759 public int getInvalidOSREntryBCI() { | |
760 return invalidOSREntryBCI; | |
761 } | |
762 | |
763 // FIXME: figure out where to stick this | |
764 public boolean wizardMode() { | |
765 return true; | |
766 } | |
767 | |
768 public ReversePtrs getRevPtrs() { | |
769 return revPtrs; | |
770 } | |
771 | |
772 public void setRevPtrs(ReversePtrs rp) { | |
773 revPtrs = rp; | |
774 } | |
775 | |
776 // returns null, if not available. | |
777 public String getVMRelease() { | |
778 return vmRelease; | |
779 } | |
780 | |
781 // returns null, if not available. | |
782 public String getVMInternalInfo() { | |
783 return vmInternalInfo; | |
784 } | |
785 | |
8005
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
786 public int getReserveForAllocationPrefetch() { |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
787 return reserveForAllocationPrefetch; |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
788 } |
ec0c4951286c
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents:
6848
diff
changeset
|
789 |
0 | 790 public boolean isSharingEnabled() { |
791 if (sharingEnabled == null) { | |
792 Flag flag = getCommandLineFlag("UseSharedSpaces"); | |
793 sharingEnabled = (flag == null)? Boolean.FALSE : | |
794 (flag.getBool()? Boolean.TRUE: Boolean.FALSE); | |
795 } | |
796 return sharingEnabled.booleanValue(); | |
797 } | |
798 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
799 public boolean isCompressedOopsEnabled() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
800 if (compressedOopsEnabled == null) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
801 Flag flag = getCommandLineFlag("UseCompressedOops"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
802 compressedOopsEnabled = (flag == null) ? Boolean.FALSE: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
803 (flag.getBool()? Boolean.TRUE: Boolean.FALSE); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
804 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
805 return compressedOopsEnabled.booleanValue(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
806 } |
0 | 807 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
808 public boolean isCompressedKlassPointersEnabled() { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
809 if (compressedKlassPointersEnabled == null) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
810 Flag flag = getCommandLineFlag("UseCompressedKlassPointers"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
811 compressedKlassPointersEnabled = (flag == null) ? Boolean.FALSE: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
812 (flag.getBool()? Boolean.TRUE: Boolean.FALSE); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
813 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6782
diff
changeset
|
814 return compressedKlassPointersEnabled.booleanValue(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
815 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6641
diff
changeset
|
816 |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
817 public int getObjectAlignmentInBytes() { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
818 if (objectAlignmentInBytes == 0) { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
819 Flag flag = getCommandLineFlag("ObjectAlignmentInBytes"); |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
820 objectAlignmentInBytes = (flag == null) ? 8 : (int)flag.getIntx(); |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
821 } |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
822 return objectAlignmentInBytes; |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
823 } |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
844
diff
changeset
|
824 |
0 | 825 // returns null, if not available. |
826 public Flag[] getCommandLineFlags() { | |
827 if (commandLineFlags == null) { | |
828 readCommandLineFlags(); | |
829 } | |
830 | |
831 return commandLineFlags; | |
832 } | |
833 | |
834 public Flag getCommandLineFlag(String name) { | |
835 if (flagsMap == null) { | |
836 flagsMap = new HashMap(); | |
837 Flag[] flags = getCommandLineFlags(); | |
838 for (int i = 0; i < flags.length; i++) { | |
839 flagsMap.put(flags[i].getName(), flags[i]); | |
840 } | |
841 } | |
842 return (Flag) flagsMap.get(name); | |
843 } | |
844 | |
845 private void readCommandLineFlags() { | |
846 // get command line flags | |
847 TypeDataBase db = getTypeDataBase(); | |
3939 | 848 Type flagType = db.lookupType("Flag"); |
849 int numFlags = (int) flagType.getCIntegerField("numFlags").getValue(); | |
850 // NOTE: last flag contains null values. | |
851 commandLineFlags = new Flag[numFlags - 1]; | |
852 | |
853 Address flagAddr = flagType.getAddressField("flags").getValue(); | |
0 | 854 |
3939 | 855 AddressField typeFld = flagType.getAddressField("type"); |
856 AddressField nameFld = flagType.getAddressField("name"); | |
857 AddressField addrFld = flagType.getAddressField("addr"); | |
858 AddressField kindFld = flagType.getAddressField("kind"); | |
859 CIntField originFld = new CIntField(flagType.getCIntegerField("origin"), 0); | |
0 | 860 |
3939 | 861 long flagSize = flagType.getSize(); // sizeof(Flag) |
0 | 862 |
3939 | 863 // NOTE: last flag contains null values. |
864 for (int f = 0; f < numFlags - 1; f++) { | |
865 String type = CStringUtilities.getString(typeFld.getValue(flagAddr)); | |
866 String name = CStringUtilities.getString(nameFld.getValue(flagAddr)); | |
867 Address addr = addrFld.getValue(flagAddr); | |
868 String kind = CStringUtilities.getString(kindFld.getValue(flagAddr)); | |
869 int origin = (int)originFld.getValue(flagAddr); | |
870 commandLineFlags[f] = new Flag(type, name, addr, kind, origin); | |
871 flagAddr = flagAddr.addOffsetTo(flagSize); | |
872 } | |
0 | 873 |
3939 | 874 // sort flags by name |
875 Arrays.sort(commandLineFlags, new Comparator() { | |
876 public int compare(Object o1, Object o2) { | |
877 Flag f1 = (Flag) o1; | |
878 Flag f2 = (Flag) o2; | |
879 return f1.getName().compareTo(f2.getName()); | |
880 } | |
881 }); | |
0 | 882 } |
883 | |
884 public String getSystemProperty(String key) { | |
885 Properties props = getSystemProperties(); | |
886 return (props != null)? props.getProperty(key) : null; | |
887 } | |
888 | |
889 public Properties getSystemProperties() { | |
890 if (sysProps == null) { | |
891 readSystemProperties(); | |
892 } | |
893 return sysProps; | |
894 } | |
895 | |
896 private void readSystemProperties() { | |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
897 final InstanceKlass systemKls = getSystemDictionary().getSystemKlass(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
898 systemKls.iterateStaticFields(new DefaultOopVisitor() { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
899 ObjectReader objReader = new ObjectReader(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
900 public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
901 if (field.getID().getName().equals("props")) { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
902 try { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
903 sysProps = (Properties) objReader.readObject(field.getValue(getObj())); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
904 } catch (Exception e) { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
905 e.printStackTrace(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
906 } |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
907 } |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
908 } |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
909 }); |
0 | 910 } |
911 } |