0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "oops/markOop.hpp"
1879N/A#ifdef TARGET_OS_FAMILY_linux
1879N/A# include "thread_linux.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_solaris
1879N/A# include "thread_solaris.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_windows
1879N/A# include "thread_windows.inline.hpp"
1879N/A#endif
2796N/A#ifdef TARGET_OS_FAMILY_bsd
2796N/A# include "thread_bsd.inline.hpp"
2796N/A#endif
0N/A
0N/A
0N/Avoid markOopDesc::print_on(outputStream* st) const {
0N/A if (is_locked()) {
0N/A st->print("locked(0x%lx)->", value());
0N/A markOop(*(markOop*)value())->print_on(st);
0N/A } else {
1039N/A assert(is_unlocked() || has_bias_pattern(), "just checking");
0N/A st->print("mark(");
1039N/A if (has_bias_pattern()) st->print("biased,");
0N/A st->print("hash %#lx,", hash());
0N/A st->print("age %d)", age());
0N/A }
0N/A}
48N/A
48N/A
48N/A// Give advice about whether the oop that contains this markOop
48N/A// should be cached or not.
48N/Abool markOopDesc::should_not_be_cached() const {
48N/A // the cast is because decode_pointer() isn't marked const
48N/A if (is_marked() && ((markOopDesc *)this)->decode_pointer() != NULL) {
48N/A // If the oop containing this markOop is being forwarded, then
48N/A // we are in the middle of GC and we do not want the containing
48N/A // oop to be added to a cache. We have no way of knowing whether
48N/A // the cache has already been visited by the current GC phase so
48N/A // we don't know whether the forwarded oop will be properly
48N/A // processed in this phase. If the forwarded oop is not properly
48N/A // processed, then we'll see strange crashes or asserts during
48N/A // the next GC run because the markOop will contain an unexpected
48N/A // value.
48N/A //
48N/A // This situation has been seen when we are GC'ing a methodOop
48N/A // because we use the methodOop while we're GC'ing it. Scary
48N/A // stuff. Some of the uses the methodOop cause the methodOop to
48N/A // be added to the OopMapCache in the instanceKlass as a side
48N/A // effect. This check lets the cache maintainer know when a
48N/A // cache addition would not be safe.
48N/A return true;
48N/A }
48N/A
48N/A // caching the containing oop should be just fine
48N/A return false;
48N/A}