src/share/vm/oops/markOop.hpp

changeset 779
6aae2f9d0294
parent 777
37f87013dfd8
parent 622
790e66e5fbac
child 791
1ee8caae33af
     1.1 --- a/src/share/vm/oops/markOop.hpp	Thu Jun 05 15:57:56 2008 -0700
     1.2 +++ b/src/share/vm/oops/markOop.hpp	Thu Jun 12 13:50:55 2008 -0700
     1.3 @@ -29,8 +29,10 @@
     1.4  //
     1.5  // Bit-format of an object header (most significant first):
     1.6  //
     1.7 -//
     1.8 -//  unused:0/25 hash:25/31 age:4 biased_lock:1 lock:2 = 32/64 bits
     1.9 +//  32 bits: unused:0  hash:25 age:4 biased_lock:1 lock:2
    1.10 +//  64 bits: unused:24 hash:31 cms:2 age:4 biased_lock:1 lock:2
    1.11 +//           unused:20 size:35 cms:2 age:4 biased_lock:1 lock:2 (if cms
    1.12 +//                                                               free chunk)
    1.13  //
    1.14  //  - hash contains the identity hash value: largest value is
    1.15  //    31 bits, see os::random().  Also, 64-bit vm's require
    1.16 @@ -91,6 +93,7 @@
    1.17           biased_lock_bits         = 1,
    1.18           max_hash_bits            = BitsPerWord - age_bits - lock_bits - biased_lock_bits,
    1.19           hash_bits                = max_hash_bits > 31 ? 31 : max_hash_bits,
    1.20 +         cms_bits                 = LP64_ONLY(1) NOT_LP64(0),
    1.21           epoch_bits               = 2
    1.22    };
    1.23  
    1.24 @@ -106,7 +109,8 @@
    1.25    enum { lock_shift               = 0,
    1.26           biased_lock_shift        = lock_bits,
    1.27           age_shift                = lock_bits + biased_lock_bits,
    1.28 -         hash_shift               = lock_bits + biased_lock_bits + age_bits,
    1.29 +         cms_shift                = age_shift + age_bits,
    1.30 +         hash_shift               = cms_shift + cms_bits,
    1.31           epoch_shift              = hash_shift
    1.32    };
    1.33  
    1.34 @@ -118,7 +122,9 @@
    1.35           age_mask                 = right_n_bits(age_bits),
    1.36           age_mask_in_place        = age_mask << age_shift,
    1.37           epoch_mask               = right_n_bits(epoch_bits),
    1.38 -         epoch_mask_in_place      = epoch_mask << epoch_shift
    1.39 +         epoch_mask_in_place      = epoch_mask << epoch_shift,
    1.40 +         cms_mask                 = right_n_bits(cms_bits),
    1.41 +         cms_mask_in_place        = cms_mask << cms_shift
    1.42  #ifndef _WIN64
    1.43           ,hash_mask               = right_n_bits(hash_bits),
    1.44           hash_mask_in_place       = (address_word)hash_mask << hash_shift
    1.45 @@ -348,4 +354,40 @@
    1.46  
    1.47    // see the definition in markOop.cpp for the gory details
    1.48    bool should_not_be_cached() const;
    1.49 +
    1.50 +  // These markOops indicate cms free chunk blocks and not objects.
    1.51 +  // In 64 bit, the markOop is set to distinguish them from oops.
    1.52 +  // These are defined in 32 bit mode for vmStructs.
    1.53 +  const static uintptr_t cms_free_chunk_pattern  = 0x1;
    1.54 +
    1.55 +  // Constants for the size field.
    1.56 +  enum { size_shift                = cms_shift + cms_bits,
    1.57 +         size_bits                 = 35    // need for compressed oops 32G
    1.58 +       };
    1.59 +  // These values are too big for Win64
    1.60 +  const static uintptr_t size_mask = LP64_ONLY(right_n_bits(size_bits))
    1.61 +                                     NOT_LP64(0);
    1.62 +  const static uintptr_t size_mask_in_place =
    1.63 +                                     (address_word)size_mask << size_shift;
    1.64 +
    1.65 +#ifdef _LP64
    1.66 +  static markOop cms_free_prototype() {
    1.67 +    return markOop(((intptr_t)prototype() & ~cms_mask_in_place) |
    1.68 +                   ((cms_free_chunk_pattern & cms_mask) << cms_shift));
    1.69 +  }
    1.70 +  uintptr_t cms_encoding() const {
    1.71 +    return mask_bits(value() >> cms_shift, cms_mask);
    1.72 +  }
    1.73 +  bool is_cms_free_chunk() const {
    1.74 +    return is_neutral() &&
    1.75 +           (cms_encoding() & cms_free_chunk_pattern) == cms_free_chunk_pattern;
    1.76 +  }
    1.77 +
    1.78 +  size_t get_size() const       { return (size_t)(value() >> size_shift); }
    1.79 +  static markOop set_size_and_free(size_t size) {
    1.80 +    assert((size & ~size_mask) == 0, "shouldn't overflow size field");
    1.81 +    return markOop(((intptr_t)cms_free_prototype() & ~size_mask_in_place) |
    1.82 +                   (((intptr_t)size & size_mask) << size_shift));
    1.83 +  }
    1.84 +#endif // _LP64
    1.85  };

mercurial