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

Print this page
rev 611 : Merge
   1 /*
   2  * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *  


  62     hashShift           = db.lookupLongConstant("markOopDesc::hash_shift").longValue();
  63     lockMask            = db.lookupLongConstant("markOopDesc::lock_mask").longValue();
  64     lockMaskInPlace     = db.lookupLongConstant("markOopDesc::lock_mask_in_place").longValue();
  65     biasedLockMask      = db.lookupLongConstant("markOopDesc::biased_lock_mask").longValue();
  66     biasedLockMaskInPlace  = db.lookupLongConstant("markOopDesc::biased_lock_mask_in_place").longValue();
  67     biasedLockBitInPlace  = db.lookupLongConstant("markOopDesc::biased_lock_bit_in_place").longValue();
  68     ageMask             = db.lookupLongConstant("markOopDesc::age_mask").longValue();
  69     ageMaskInPlace      = db.lookupLongConstant("markOopDesc::age_mask_in_place").longValue();
  70     hashMask            = db.lookupLongConstant("markOopDesc::hash_mask").longValue();
  71     hashMaskInPlace     = db.lookupLongConstant("markOopDesc::hash_mask_in_place").longValue();
  72     biasedLockAlignment  = db.lookupLongConstant("markOopDesc::biased_lock_alignment").longValue();
  73     lockedValue         = db.lookupLongConstant("markOopDesc::locked_value").longValue();
  74     unlockedValue       = db.lookupLongConstant("markOopDesc::unlocked_value").longValue();
  75     monitorValue        = db.lookupLongConstant("markOopDesc::monitor_value").longValue();
  76     markedValue         = db.lookupLongConstant("markOopDesc::marked_value").longValue();
  77     biasedLockPattern = db.lookupLongConstant("markOopDesc::biased_lock_pattern").longValue();
  78     noHash              = db.lookupLongConstant("markOopDesc::no_hash").longValue();
  79     noHashInPlace       = db.lookupLongConstant("markOopDesc::no_hash_in_place").longValue();
  80     noLockInPlace       = db.lookupLongConstant("markOopDesc::no_lock_in_place").longValue();
  81     maxAge              = db.lookupLongConstant("markOopDesc::max_age").longValue();





  82   }
  83 
  84   // Field accessors
  85   private static CIntegerField markField;
  86 
  87   // Constants -- read from VM
  88   private static long ageBits;
  89   private static long lockBits;
  90   private static long biasedLockBits;
  91   private static long maxHashBits;
  92   private static long hashBits;
  93 
  94   private static long lockShift;
  95   private static long biasedLockShift;
  96   private static long ageShift;
  97   private static long hashShift;
  98 
  99   private static long lockMask;
 100   private static long lockMaskInPlace;
 101   private static long biasedLockMask;


 103   private static long biasedLockBitInPlace;
 104   private static long ageMask;
 105   private static long ageMaskInPlace;
 106   private static long hashMask;
 107   private static long hashMaskInPlace;
 108   private static long biasedLockAlignment; 
 109 
 110   private static long lockedValue;
 111   private static long unlockedValue;
 112   private static long monitorValue;
 113   private static long markedValue;
 114   private static long biasedLockPattern;
 115 
 116   private static long noHash;
 117 
 118   private static long noHashInPlace;
 119   private static long noLockInPlace;
 120 
 121   private static long maxAge;
 122 





 123   public Mark(Address addr) {
 124     super(addr);
 125   }
 126 
 127   public long value() {
 128     return markField.getValue(addr);
 129   }
 130 
 131   public Address valueAsAddress() {
 132     return addr.getAddressAt(markField.getOffset());
 133   }
 134 
 135   // Biased locking accessors
 136   // These must be checked by all code which calls into the
 137   // ObjectSynchoronizer and other code. The biasing is not understood
 138   // by the lower-level CAS-based locking code, although the runtime
 139   // fixes up biased locks to be compatible with it when a bias is
 140   // revoked.
 141   public boolean hasBiasPattern() {
 142     return (Bits.maskBitsLong(value(), biasedLockMaskInPlace) == biasedLockPattern);


 273     if (isLocked()) {
 274       tty.print("locked(0x" +
 275                 Long.toHexString(value()) + ")->");
 276       displacedMarkHelper().printOn(tty);
 277     } else {
 278       if (Assert.ASSERTS_ENABLED) {
 279         Assert.that(isUnlocked(), "just checking");
 280       }
 281       tty.print("mark(");
 282       tty.print("hash " + Long.toHexString(hash()) + ",");
 283       tty.print("age " + age() + ")");
 284     }
 285   }
 286 
 287   // FIXME
 288   //  // Prepare address of oop for placement into mark
 289   //  inline static markOop encode_pointer_as_mark(void* p) { return markOop(p)->set_marked(); }
 290   //
 291   //  // Recover address of oop from encoded form used in mark
 292   //  inline void* decode_pointer() { return clear_lock_bits(); }







 293 }
   1 /*
   2  * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *  


  62     hashShift           = db.lookupLongConstant("markOopDesc::hash_shift").longValue();
  63     lockMask            = db.lookupLongConstant("markOopDesc::lock_mask").longValue();
  64     lockMaskInPlace     = db.lookupLongConstant("markOopDesc::lock_mask_in_place").longValue();
  65     biasedLockMask      = db.lookupLongConstant("markOopDesc::biased_lock_mask").longValue();
  66     biasedLockMaskInPlace  = db.lookupLongConstant("markOopDesc::biased_lock_mask_in_place").longValue();
  67     biasedLockBitInPlace  = db.lookupLongConstant("markOopDesc::biased_lock_bit_in_place").longValue();
  68     ageMask             = db.lookupLongConstant("markOopDesc::age_mask").longValue();
  69     ageMaskInPlace      = db.lookupLongConstant("markOopDesc::age_mask_in_place").longValue();
  70     hashMask            = db.lookupLongConstant("markOopDesc::hash_mask").longValue();
  71     hashMaskInPlace     = db.lookupLongConstant("markOopDesc::hash_mask_in_place").longValue();
  72     biasedLockAlignment  = db.lookupLongConstant("markOopDesc::biased_lock_alignment").longValue();
  73     lockedValue         = db.lookupLongConstant("markOopDesc::locked_value").longValue();
  74     unlockedValue       = db.lookupLongConstant("markOopDesc::unlocked_value").longValue();
  75     monitorValue        = db.lookupLongConstant("markOopDesc::monitor_value").longValue();
  76     markedValue         = db.lookupLongConstant("markOopDesc::marked_value").longValue();
  77     biasedLockPattern = db.lookupLongConstant("markOopDesc::biased_lock_pattern").longValue();
  78     noHash              = db.lookupLongConstant("markOopDesc::no_hash").longValue();
  79     noHashInPlace       = db.lookupLongConstant("markOopDesc::no_hash_in_place").longValue();
  80     noLockInPlace       = db.lookupLongConstant("markOopDesc::no_lock_in_place").longValue();
  81     maxAge              = db.lookupLongConstant("markOopDesc::max_age").longValue();
  82 
  83     /* Constants in markOop used by CMS. */
  84     cmsShift            = db.lookupLongConstant("markOopDesc::cms_shift").longValue();
  85     cmsMask             = db.lookupLongConstant("markOopDesc::cms_mask").longValue();
  86     sizeShift           = db.lookupLongConstant("markOopDesc::size_shift").longValue();
  87   }
  88 
  89   // Field accessors
  90   private static CIntegerField markField;
  91 
  92   // Constants -- read from VM
  93   private static long ageBits;
  94   private static long lockBits;
  95   private static long biasedLockBits;
  96   private static long maxHashBits;
  97   private static long hashBits;
  98 
  99   private static long lockShift;
 100   private static long biasedLockShift;
 101   private static long ageShift;
 102   private static long hashShift;
 103 
 104   private static long lockMask;
 105   private static long lockMaskInPlace;
 106   private static long biasedLockMask;


 108   private static long biasedLockBitInPlace;
 109   private static long ageMask;
 110   private static long ageMaskInPlace;
 111   private static long hashMask;
 112   private static long hashMaskInPlace;
 113   private static long biasedLockAlignment; 
 114 
 115   private static long lockedValue;
 116   private static long unlockedValue;
 117   private static long monitorValue;
 118   private static long markedValue;
 119   private static long biasedLockPattern;
 120 
 121   private static long noHash;
 122 
 123   private static long noHashInPlace;
 124   private static long noLockInPlace;
 125 
 126   private static long maxAge;
 127 
 128   /* Constants in markOop used by CMS. */
 129   private static long cmsShift;
 130   private static long cmsMask;
 131   private static long sizeShift;
 132 
 133   public Mark(Address addr) {
 134     super(addr);
 135   }
 136 
 137   public long value() {
 138     return markField.getValue(addr);
 139   }
 140 
 141   public Address valueAsAddress() {
 142     return addr.getAddressAt(markField.getOffset());
 143   }
 144 
 145   // Biased locking accessors
 146   // These must be checked by all code which calls into the
 147   // ObjectSynchoronizer and other code. The biasing is not understood
 148   // by the lower-level CAS-based locking code, although the runtime
 149   // fixes up biased locks to be compatible with it when a bias is
 150   // revoked.
 151   public boolean hasBiasPattern() {
 152     return (Bits.maskBitsLong(value(), biasedLockMaskInPlace) == biasedLockPattern);


 283     if (isLocked()) {
 284       tty.print("locked(0x" +
 285                 Long.toHexString(value()) + ")->");
 286       displacedMarkHelper().printOn(tty);
 287     } else {
 288       if (Assert.ASSERTS_ENABLED) {
 289         Assert.that(isUnlocked(), "just checking");
 290       }
 291       tty.print("mark(");
 292       tty.print("hash " + Long.toHexString(hash()) + ",");
 293       tty.print("age " + age() + ")");
 294     }
 295   }
 296 
 297   // FIXME
 298   //  // Prepare address of oop for placement into mark
 299   //  inline static markOop encode_pointer_as_mark(void* p) { return markOop(p)->set_marked(); }
 300   //
 301   //  // Recover address of oop from encoded form used in mark
 302   //  inline void* decode_pointer() { return clear_lock_bits(); }
 303 
 304   // Copy markOop methods for CMS here.
 305   public boolean isCmsFreeChunk() {
 306     return isUnlocked() &&
 307            (Bits.maskBitsLong(value() >> cmsShift, cmsMask) & 0x1L) == 0x1L;
 308   }
 309   public long getSize() { return (long)(value() >> sizeShift); }
 310 }