< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Mark.java

Print this page
@@ -49,19 +49,26 @@
  
      ageBits             = db.lookupLongConstant("markWord::age_bits").longValue();
      lockBits            = db.lookupLongConstant("markWord::lock_bits").longValue();
      maxHashBits         = db.lookupLongConstant("markWord::max_hash_bits").longValue();
      hashBits            = db.lookupLongConstant("markWord::hash_bits").longValue();
+     hashBitsCompact     = db.lookupLongConstant("markWord::hash_bits_compact").longValue();
      lockShift           = db.lookupLongConstant("markWord::lock_shift").longValue();
      ageShift            = db.lookupLongConstant("markWord::age_shift").longValue();
      hashShift           = db.lookupLongConstant("markWord::hash_shift").longValue();
+     hashShiftCompact    = db.lookupLongConstant("markWord::hash_shift_compact").longValue();
+     if (VM.getVM().isLP64()) {
+       klassShift          = db.lookupLongConstant("markWord::klass_shift").longValue();
+     }
      lockMask            = db.lookupLongConstant("markWord::lock_mask").longValue();
      lockMaskInPlace     = db.lookupLongConstant("markWord::lock_mask_in_place").longValue();
      ageMask             = db.lookupLongConstant("markWord::age_mask").longValue();
      ageMaskInPlace      = db.lookupLongConstant("markWord::age_mask_in_place").longValue();
      hashMask            = db.lookupLongConstant("markWord::hash_mask").longValue();
      hashMaskInPlace     = db.lookupLongConstant("markWord::hash_mask_in_place").longValue();
+     hashMaskCompact     = db.lookupLongConstant("markWord::hash_mask_compact").longValue();
+     hashMaskCompactInPlace = db.lookupLongConstant("markWord::hash_mask_compact_in_place").longValue();
      lockedValue         = db.lookupLongConstant("markWord::locked_value").longValue();
      unlockedValue       = db.lookupLongConstant("markWord::unlocked_value").longValue();
      monitorValue        = db.lookupLongConstant("markWord::monitor_value").longValue();
      markedValue         = db.lookupLongConstant("markWord::marked_value").longValue();
      noHash              = db.lookupLongConstant("markWord::no_hash").longValue();

@@ -76,21 +83,26 @@
    // Constants -- read from VM
    private static long ageBits;
    private static long lockBits;
    private static long maxHashBits;
    private static long hashBits;
+   private static long hashBitsCompact;
  
    private static long lockShift;
    private static long ageShift;
    private static long hashShift;
+   private static long hashShiftCompact;
+   private static long klassShift;
  
    private static long lockMask;
    private static long lockMaskInPlace;
    private static long ageMask;
    private static long ageMaskInPlace;
    private static long hashMask;
    private static long hashMaskInPlace;
+   private static long hashMaskCompact;
+   private static long hashMaskCompactInPlace;
  
    private static long lockedValue;
    private static long unlockedValue;
    private static long monitorValue;
    private static long markedValue;

@@ -100,10 +112,14 @@
    private static long noHashInPlace;
    private static long noLockInPlace;
  
    private static long maxAge;
  
+   public static long getKlassShift() {
+     return klassShift;
+   }
+ 
    public Mark(Address addr) {
      super(addr);
    }
  
    public long value() {

@@ -154,10 +170,20 @@
    }
    public ObjectMonitor monitor() {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(hasMonitor(), "check");
      }
+     if (VM.getVM().getCommandLineFlag("LockingMode").getInt() == LockingMode.getLightweight()) {
+       Iterator it = ObjectSynchronizer.objectMonitorIterator();
+       while (it != null && it.hasNext()) {
+         ObjectMonitor mon = (ObjectMonitor)it.next();
+         if (getAddress().equals(mon.object())) {
+           return mon;
+         }
+       }
+       return null;
+     }
      // Use xor instead of &~ to provide one extra tag-bit check.
      Address monAddr = valueAsAddress().xorWithMask(monitorValue);
      return new ObjectMonitor(monAddr);
    }
    public boolean hasDisplacedMarkHelper() {

@@ -172,17 +198,26 @@
    }
    public int age() { return (int) Bits.maskBitsLong(value() >> ageShift, ageMask); }
  
    // hash operations
    public long hash() {
-     return Bits.maskBitsLong(value() >> hashShift, hashMask);
+     if (VM.getVM().isCompactObjectHeadersEnabled()) {
+       return Bits.maskBitsLong(value() >> hashShiftCompact, hashMaskCompact);
+     } else {
+       return Bits.maskBitsLong(value() >> hashShift, hashMask);
+     }
    }
  
    public boolean hasNoHash() {
      return hash() == noHash;
    }
  
+   public Klass getKlass() {
+     assert(VM.getVM().isCompactObjectHeadersEnabled());
+     return (Klass)Metadata.instantiateWrapperFor(addr.getCompKlassAddressAt(0));
+   }
+ 
    // Debugging
    public void printOn(PrintStream tty) {
      if (isLocked()) {
        tty.print("locked(0x" +
                  Long.toHexString(value()) + ")->");
< prev index next >