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