comparison agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1
comparison
equal deleted inserted replaced
110:a49a647afe9a 113:ba764ed4b6f2
34 import sun.jvm.hotspot.interpreter.*; 34 import sun.jvm.hotspot.interpreter.*;
35 import sun.jvm.hotspot.memory.*; 35 import sun.jvm.hotspot.memory.*;
36 import sun.jvm.hotspot.oops.*; 36 import sun.jvm.hotspot.oops.*;
37 import sun.jvm.hotspot.types.*; 37 import sun.jvm.hotspot.types.*;
38 import sun.jvm.hotspot.utilities.*; 38 import sun.jvm.hotspot.utilities.*;
39 import sun.jvm.hotspot.runtime.*;
39 40
40 /** <P> This class encapsulates the global state of the VM; the 41 /** <P> This class encapsulates the global state of the VM; the
41 universe, object heap, interpreter, etc. It is a Singleton and 42 universe, object heap, interpreter, etc. It is a Singleton and
42 must be initialized with a call to initialize() before calling 43 must be initialized with a call to initialize() before calling
43 getVM(). </P> 44 getVM(). </P>
91 private boolean useTLAB; 92 private boolean useTLAB;
92 /** alignment constants */ 93 /** alignment constants */
93 private boolean isLP64; 94 private boolean isLP64;
94 private int bytesPerLong; 95 private int bytesPerLong;
95 private int minObjAlignmentInBytes; 96 private int minObjAlignmentInBytes;
97 private int logMinObjAlignmentInBytes;
98 private int heapWordSize;
99 private int heapOopSize;
100 private int oopSize;
96 /** This is only present in a non-core build */ 101 /** This is only present in a non-core build */
97 private CodeCache codeCache; 102 private CodeCache codeCache;
98 /** This is only present in a C1 build */ 103 /** This is only present in a C1 build */
99 private Runtime1 runtime1; 104 private Runtime1 runtime1;
100 /** These constants come from globalDefinitions.hpp */ 105 /** These constants come from globalDefinitions.hpp */
115 120
116 private static Type intxType; 121 private static Type intxType;
117 private static Type uintxType; 122 private static Type uintxType;
118 private static CIntegerType boolType; 123 private static CIntegerType boolType;
119 private Boolean sharingEnabled; 124 private Boolean sharingEnabled;
125 private Boolean compressedOopsEnabled;
120 126
121 // command line flags supplied to VM - see struct Flag in globals.hpp 127 // command line flags supplied to VM - see struct Flag in globals.hpp
122 public static final class Flag { 128 public static final class Flag {
123 private String type; 129 private String type;
124 private String name; 130 private String name;
306 if (debugger != null) { 312 if (debugger != null) {
307 isLP64 = debugger.getMachineDescription().isLP64(); 313 isLP64 = debugger.getMachineDescription().isLP64();
308 } 314 }
309 bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue(); 315 bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
310 minObjAlignmentInBytes = db.lookupIntConstant("MinObjAlignmentInBytes").intValue(); 316 minObjAlignmentInBytes = db.lookupIntConstant("MinObjAlignmentInBytes").intValue();
317 // minObjAlignment = db.lookupIntConstant("MinObjAlignment").intValue();
318 logMinObjAlignmentInBytes = db.lookupIntConstant("LogMinObjAlignmentInBytes").intValue();
319 heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
320 oopSize = db.lookupIntConstant("oopSize").intValue();
321 heapOopSize = db.lookupIntConstant("heapOopSize").intValue();
311 322
312 intxType = db.lookupType("intx"); 323 intxType = db.lookupType("intx");
313 uintxType = db.lookupType("uintx"); 324 uintxType = db.lookupType("uintx");
314 boolType = (CIntegerType) db.lookupType("bool"); 325 boolType = (CIntegerType) db.lookupType("bool");
315 } 326 }
329 public static void initialize(TypeDataBase db, JVMDebugger debugger) { 340 public static void initialize(TypeDataBase db, JVMDebugger debugger) {
330 if (soleInstance != null) { 341 if (soleInstance != null) {
331 throw new RuntimeException("Attempt to initialize VM twice"); 342 throw new RuntimeException("Attempt to initialize VM twice");
332 } 343 }
333 soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian()); 344 soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
345 debugger.putHeapConst(Universe.getHeapBase(), soleInstance.getHeapOopSize(),
346 soleInstance.logMinObjAlignmentInBytes);
334 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) { 347 for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
335 ((Observer) iter.next()).update(null, null); 348 ((Observer) iter.next()).update(null, null);
336 } 349 }
337 } 350 }
338 351
438 public long getAddressSize() { 451 public long getAddressSize() {
439 return db.getAddressSize(); 452 return db.getAddressSize();
440 } 453 }
441 454
442 public long getOopSize() { 455 public long getOopSize() {
443 return db.getOopSize(); 456 return oopSize;
444 } 457 }
445 458
446 public long getLogAddressSize() { 459 public long getLogAddressSize() {
447 return logAddressSize; 460 return logAddressSize;
461 }
462
463 public long getIntSize() {
464 return db.getJIntType().getSize();
448 } 465 }
449 466
450 /** NOTE: this offset is in BYTES in this system! */ 467 /** NOTE: this offset is in BYTES in this system! */
451 public long getStackBias() { 468 public long getStackBias() {
452 return stackBias; 469 return stackBias;
465 public int getBytesPerLong() { 482 public int getBytesPerLong() {
466 return bytesPerLong; 483 return bytesPerLong;
467 } 484 }
468 485
469 /** Get minimum object alignment in bytes. */ 486 /** Get minimum object alignment in bytes. */
487 public int getMinObjAlignment() {
488 return minObjAlignmentInBytes;
489 }
490
470 public int getMinObjAlignmentInBytes() { 491 public int getMinObjAlignmentInBytes() {
471 return minObjAlignmentInBytes; 492 return minObjAlignmentInBytes;
472 } 493 }
473 494 public int getLogMinObjAlignmentInBytes() {
495 return logMinObjAlignmentInBytes;
496 }
497
498 public int getHeapWordSize() {
499 return heapWordSize;
500 }
501
502 public int getHeapOopSize() {
503 return heapOopSize;
504 }
474 /** Utility routine for getting data structure alignment correct */ 505 /** Utility routine for getting data structure alignment correct */
475 public long alignUp(long size, long alignment) { 506 public long alignUp(long size, long alignment) {
476 return (size + alignment - 1) & ~(alignment - 1); 507 return (size + alignment - 1) & ~(alignment - 1);
477 } 508 }
478 509
699 (flag.getBool()? Boolean.TRUE: Boolean.FALSE); 730 (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
700 } 731 }
701 return sharingEnabled.booleanValue(); 732 return sharingEnabled.booleanValue();
702 } 733 }
703 734
735 public boolean isCompressedOopsEnabled() {
736 if (compressedOopsEnabled == null) {
737 Flag flag = getCommandLineFlag("UseCompressedOops");
738 compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
739 (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
740 }
741 return compressedOopsEnabled.booleanValue();
742 }
704 743
705 // returns null, if not available. 744 // returns null, if not available.
706 public Flag[] getCommandLineFlags() { 745 public Flag[] getCommandLineFlags() {
707 if (commandLineFlags == null) { 746 if (commandLineFlags == null) {
708 readCommandLineFlags(); 747 readCommandLineFlags();