diff 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
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Fri Apr 11 09:56:35 2008 -0400
+++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Sun Apr 13 17:43:42 2008 -0400
@@ -36,6 +36,7 @@
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
+import sun.jvm.hotspot.runtime.*;
 
 /** <P> This class encapsulates the global state of the VM; the
     universe, object heap, interpreter, etc. It is a Singleton and
@@ -93,6 +94,10 @@
   private boolean      isLP64;
   private int          bytesPerLong;
   private int          minObjAlignmentInBytes;
+  private int          logMinObjAlignmentInBytes;
+  private int          heapWordSize;
+  private int          heapOopSize;
+  private int          oopSize;
   /** This is only present in a non-core build */
   private CodeCache    codeCache;
   /** This is only present in a C1 build */
@@ -117,6 +122,7 @@
   private static Type uintxType;
   private static CIntegerType boolType;
   private Boolean sharingEnabled;
+  private Boolean compressedOopsEnabled;
 
   // command line flags supplied to VM - see struct Flag in globals.hpp
   public static final class Flag {
@@ -308,6 +314,11 @@
     }
     bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
     minObjAlignmentInBytes = db.lookupIntConstant("MinObjAlignmentInBytes").intValue();
+    // minObjAlignment = db.lookupIntConstant("MinObjAlignment").intValue();
+    logMinObjAlignmentInBytes = db.lookupIntConstant("LogMinObjAlignmentInBytes").intValue();
+    heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
+    oopSize  = db.lookupIntConstant("oopSize").intValue();
+    heapOopSize  = db.lookupIntConstant("heapOopSize").intValue();
 
     intxType = db.lookupType("intx");
     uintxType = db.lookupType("uintx");
@@ -331,6 +342,8 @@
       throw new RuntimeException("Attempt to initialize VM twice");
     }
     soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
+    debugger.putHeapConst(Universe.getHeapBase(), soleInstance.getHeapOopSize(),
+                          soleInstance.logMinObjAlignmentInBytes);
     for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
       ((Observer) iter.next()).update(null, null);
     }
@@ -440,13 +453,17 @@
   }
 
   public long getOopSize() {
-    return db.getOopSize();
+    return oopSize;
   }
 
   public long getLogAddressSize() {
     return logAddressSize;
   }
 
+  public long getIntSize() {
+    return db.getJIntType().getSize();
+  }
+
   /** NOTE: this offset is in BYTES in this system! */
   public long getStackBias() {
     return stackBias;
@@ -467,10 +484,24 @@
   }
 
   /** Get minimum object alignment in bytes. */
+  public int getMinObjAlignment() {
+    return minObjAlignmentInBytes;
+  }
+
   public int getMinObjAlignmentInBytes() {
     return minObjAlignmentInBytes;
   }
+  public int getLogMinObjAlignmentInBytes() {
+    return logMinObjAlignmentInBytes;
+  }
 
+  public int getHeapWordSize() {
+    return heapWordSize;
+  }
+
+  public int getHeapOopSize() {
+    return heapOopSize;
+  }
   /** Utility routine for getting data structure alignment correct */
   public long alignUp(long size, long alignment) {
     return (size + alignment - 1) & ~(alignment - 1);
@@ -701,6 +732,14 @@
     return sharingEnabled.booleanValue();
   }
 
+  public boolean isCompressedOopsEnabled() {
+    if (compressedOopsEnabled == null) {
+        Flag flag = getCommandLineFlag("UseCompressedOops");
+        compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
+             (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
+    }
+    return compressedOopsEnabled.booleanValue();
+  }
 
   // returns null, if not available.
   public Flag[] getCommandLineFlags() {