< prev index next >

src/hotspot/share/oops/markWord.cpp

Print this page

 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 #include "precompiled.hpp"
 26 #include "oops/markWord.hpp"
 27 #include "runtime/javaThread.hpp"
 28 #include "runtime/objectMonitor.inline.hpp"
 29 #include "utilities/ostream.hpp"
 30 








 31 markWord markWord::displaced_mark_helper() const {
 32   assert(has_displaced_mark_helper(), "check");
 33   if (has_monitor()) {
 34     // Has an inflated monitor. Must be checked before has_locker().
 35     ObjectMonitor* monitor = this->monitor();
 36     return monitor->header();
 37   }
 38   if (has_locker()) {  // has a stack lock
 39     BasicLock* locker = this->locker();
 40     return locker->displaced_header();
 41   }
 42   // This should never happen:
 43   fatal("bad header=" INTPTR_FORMAT, value());
 44   return markWord(value());
 45 }
 46 
 47 void markWord::set_displaced_mark_helper(markWord m) const {
 48   assert(has_displaced_mark_helper(), "check");
 49   if (has_monitor()) {
 50     // Has an inflated monitor. Must be checked before has_locker().
 51     ObjectMonitor* monitor = this->monitor();
 52     monitor->set_header(m);
 53     return;
 54   }
 55   if (has_locker()) {  // has a stack lock
 56     BasicLock* locker = this->locker();
 57     locker->set_displaced_header(m);
 58     return;
 59   }
 60   // This should never happen:
 61   fatal("bad header=" INTPTR_FORMAT, value());
 62 }
 63 
 64 void markWord::print_on(outputStream* st, bool print_monitor_info) const {
 65   if (is_marked()) {  // last bits = 11
 66     st->print(" marked(" INTPTR_FORMAT ")", value());
 67   } else if (has_monitor()) {  // last bits = 10
 68     // have to check has_monitor() before is_locked()
 69     st->print(" monitor(" INTPTR_FORMAT ")=", value());
 70     if (print_monitor_info) {

 71       ObjectMonitor* mon = monitor();
 72       if (mon == nullptr) {
 73         st->print("null (this should never be seen!)");
 74       } else {
 75         mon->print_on(st);
 76       }
 77     }
 78   } else if (is_locked()) {  // last bits != 01 => 00
 79     // thin locked
 80     st->print(" locked(" INTPTR_FORMAT ")", value());
 81   } else {
 82     st->print(" mark(");
 83     if (is_unlocked()) {   // last bits = 01
 84       st->print("is_unlocked");
 85       if (has_no_hash()) {
 86         st->print(" no_hash");
 87       } else {
 88         st->print(" hash=" INTPTR_FORMAT, hash());
 89       }
 90     } else {

 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 #include "precompiled.hpp"
 26 #include "oops/markWord.hpp"
 27 #include "runtime/javaThread.hpp"
 28 #include "runtime/objectMonitor.inline.hpp"
 29 #include "utilities/ostream.hpp"
 30 
 31 #ifdef _LP64
 32 STATIC_ASSERT((markWord::klass_shadow_mask_inplace & markWord::klass_mask_in_place) == 0);
 33 STATIC_ASSERT((markWord::klass_load_shift + markWord::klass_shadow_bits) == markWord::klass_shift);
 34 STATIC_ASSERT(markWord::klass_shift + markWord::klass_bits == 64);
 35 // The hash (preceding nKlass) shall be a direct neighbor but not interleave
 36 STATIC_ASSERT(markWord::klass_shift == markWord::hash_bits_compact + markWord::hash_shift_compact);
 37 #endif
 38 
 39 markWord markWord::displaced_mark_helper() const {
 40   assert(has_displaced_mark_helper(), "check");
 41   if (has_monitor()) {
 42     // Has an inflated monitor. Must be checked before has_locker().
 43     ObjectMonitor* monitor = this->monitor();
 44     return monitor->header();
 45   }
 46   if (has_locker()) {  // has a stack lock
 47     BasicLock* locker = this->locker();
 48     return locker->displaced_header();
 49   }
 50   // This should never happen:
 51   fatal("bad header=" INTPTR_FORMAT, value());
 52   return markWord(value());
 53 }
 54 
 55 void markWord::set_displaced_mark_helper(markWord m) const {
 56   assert(has_displaced_mark_helper(), "check");
 57   if (has_monitor()) {
 58     // Has an inflated monitor. Must be checked before has_locker().
 59     ObjectMonitor* monitor = this->monitor();
 60     monitor->set_header(m);
 61     return;
 62   }
 63   if (has_locker()) {  // has a stack lock
 64     BasicLock* locker = this->locker();
 65     locker->set_displaced_header(m);
 66     return;
 67   }
 68   // This should never happen:
 69   fatal("bad header=" INTPTR_FORMAT, value());
 70 }
 71 
 72 void markWord::print_on(outputStream* st, bool print_monitor_info) const {
 73   if (is_marked()) {  // last bits = 11
 74     st->print(" marked(" INTPTR_FORMAT ")", value());
 75   } else if (has_monitor()) {  // last bits = 10
 76     // have to check has_monitor() before is_locked()
 77     st->print(" monitor(" INTPTR_FORMAT ")=", value());
 78     if (print_monitor_info && LockingMode != LM_LIGHTWEIGHT) {
 79       // TODO[OMWorld]: Cleanup, even if the monitor read is racy, something should be printed.
 80       ObjectMonitor* mon = monitor();
 81       if (mon == nullptr) {
 82         st->print("null (this should never be seen!)");
 83       } else {
 84         mon->print_on(st);
 85       }
 86     }
 87   } else if (is_locked()) {  // last bits != 01 => 00
 88     // thin locked
 89     st->print(" locked(" INTPTR_FORMAT ")", value());
 90   } else {
 91     st->print(" mark(");
 92     if (is_unlocked()) {   // last bits = 01
 93       st->print("is_unlocked");
 94       if (has_no_hash()) {
 95         st->print(" no_hash");
 96       } else {
 97         st->print(" hash=" INTPTR_FORMAT, hash());
 98       }
 99     } else {
< prev index next >