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