src/share/vm/oops/markOop.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 





  25 // The markOop describes the header of an object.
  26 //
  27 // Note that the mark is not a real oop but just a word.
  28 // It is placed in the oop hierarchy for historical reasons.
  29 //
  30 // Bit-format of an object header (most significant first, big endian layout below):
  31 //
  32 //  32 bits:
  33 //  --------
  34 //             hash:25 ------------>| age:4    biased_lock:1 lock:2 (normal object)
  35 //             JavaThread*:23 epoch:2 age:4    biased_lock:1 lock:2 (biased object)
  36 //             size:32 ------------------------------------------>| (CMS free block)
  37 //             PromotedObject*:29 ---------->| promo_bits:3 ----->| (CMS promoted object)
  38 //
  39 //  64 bits:
  40 //  --------
  41 //  unused:25 hash:31 -->| unused:1   age:4    biased_lock:1 lock:2 (normal object)
  42 //  JavaThread*:54 epoch:2 unused:1   age:4    biased_lock:1 lock:2 (biased object)
  43 //  PromotedObject*:61 --------------------->| promo_bits:3 ----->| (CMS promoted object)
  44 //  size:64 ----------------------------------------------------->| (CMS free block)


 389   static markOop cms_free_prototype() {
 390     return markOop(((intptr_t)prototype() & ~cms_mask_in_place) |
 391                    ((cms_free_chunk_pattern & cms_mask) << cms_shift));
 392   }
 393   uintptr_t cms_encoding() const {
 394     return mask_bits(value() >> cms_shift, cms_mask);
 395   }
 396   bool is_cms_free_chunk() const {
 397     return is_neutral() &&
 398            (cms_encoding() & cms_free_chunk_pattern) == cms_free_chunk_pattern;
 399   }
 400 
 401   size_t get_size() const       { return (size_t)(value() >> size_shift); }
 402   static markOop set_size_and_free(size_t size) {
 403     assert((size & ~size_mask) == 0, "shouldn't overflow size field");
 404     return markOop(((intptr_t)cms_free_prototype() & ~size_mask_in_place) |
 405                    (((intptr_t)size & size_mask) << size_shift));
 406   }
 407 #endif // _LP64
 408 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_MARKOOP_HPP
  26 #define SHARE_VM_OOPS_MARKOOP_HPP
  27 
  28 #include "oops/oop.hpp"
  29 
  30 // The markOop describes the header of an object.
  31 //
  32 // Note that the mark is not a real oop but just a word.
  33 // It is placed in the oop hierarchy for historical reasons.
  34 //
  35 // Bit-format of an object header (most significant first, big endian layout below):
  36 //
  37 //  32 bits:
  38 //  --------
  39 //             hash:25 ------------>| age:4    biased_lock:1 lock:2 (normal object)
  40 //             JavaThread*:23 epoch:2 age:4    biased_lock:1 lock:2 (biased object)
  41 //             size:32 ------------------------------------------>| (CMS free block)
  42 //             PromotedObject*:29 ---------->| promo_bits:3 ----->| (CMS promoted object)
  43 //
  44 //  64 bits:
  45 //  --------
  46 //  unused:25 hash:31 -->| unused:1   age:4    biased_lock:1 lock:2 (normal object)
  47 //  JavaThread*:54 epoch:2 unused:1   age:4    biased_lock:1 lock:2 (biased object)
  48 //  PromotedObject*:61 --------------------->| promo_bits:3 ----->| (CMS promoted object)
  49 //  size:64 ----------------------------------------------------->| (CMS free block)


 394   static markOop cms_free_prototype() {
 395     return markOop(((intptr_t)prototype() & ~cms_mask_in_place) |
 396                    ((cms_free_chunk_pattern & cms_mask) << cms_shift));
 397   }
 398   uintptr_t cms_encoding() const {
 399     return mask_bits(value() >> cms_shift, cms_mask);
 400   }
 401   bool is_cms_free_chunk() const {
 402     return is_neutral() &&
 403            (cms_encoding() & cms_free_chunk_pattern) == cms_free_chunk_pattern;
 404   }
 405 
 406   size_t get_size() const       { return (size_t)(value() >> size_shift); }
 407   static markOop set_size_and_free(size_t size) {
 408     assert((size & ~size_mask) == 0, "shouldn't overflow size field");
 409     return markOop(((intptr_t)cms_free_prototype() & ~size_mask_in_place) |
 410                    (((intptr_t)size & size_mask) << size_shift));
 411   }
 412 #endif // _LP64
 413 };
 414 
 415 #endif // SHARE_VM_OOPS_MARKOOP_HPP