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