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 "oops/markWord.hpp"
26 #include "runtime/basicLock.inline.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_shift + markWord::klass_bits == 64);
33 // The hash (preceding klass bits) shall be a direct neighbor but not interleave
34 STATIC_ASSERT(markWord::klass_shift == markWord::hash_bits + markWord::hash_shift);
35 #endif
36
37 markWord markWord::displaced_mark_helper() const {
38 assert(has_displaced_mark_helper(), "check");
39 if (has_monitor()) {
40 // Has an inflated monitor. Must be checked before has_locker().
41 ObjectMonitor* monitor = this->monitor();
42 return monitor->header();
43 }
44 if (has_locker()) { // has a stack lock
45 BasicLock* locker = this->locker();
46 return locker->displaced_header();
47 }
48 // This should never happen:
49 fatal("bad header=" INTPTR_FORMAT, value());
50 return markWord(value());
51 }
52
53 void markWord::set_displaced_mark_helper(markWord m) const {
54 assert(has_displaced_mark_helper(), "check");
73 } else if (has_monitor()) { // last bits = 10
74 // have to check has_monitor() before is_locked()
75 st->print(" monitor(" INTPTR_FORMAT ")=", value());
76 if (print_monitor_info && !UseObjectMonitorTable) {
77 ObjectMonitor* mon = monitor();
78 if (mon == nullptr) {
79 st->print("null (this should never be seen!)");
80 } else {
81 mon->print_on(st);
82 }
83 }
84 } else if (is_locked()) { // last bits != 01 => 00
85 // thin locked
86 st->print(" locked(" INTPTR_FORMAT ")", value());
87 } else {
88 st->print(" mark(");
89 if (is_unlocked()) { // last bits = 01
90 st->print("is_unlocked");
91 if (has_no_hash()) {
92 st->print(" no_hash");
93 } else {
94 st->print(" hash=" INTPTR_FORMAT, hash());
95 }
96 } else {
97 st->print("??");
98 }
99 st->print(" age=%d)", age());
100 }
101 }
|
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 "oops/markWord.hpp"
26 #include "runtime/basicLock.inline.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_shift + markWord::klass_bits == 32);
33 // The hash (preceding klass bits) shall be a direct neighbor but not interleave
34 STATIC_ASSERT(markWord::klass_shift == markWord::hashctrl_bits + markWord::hashctrl_shift);
35 #endif
36
37 markWord markWord::displaced_mark_helper() const {
38 assert(has_displaced_mark_helper(), "check");
39 if (has_monitor()) {
40 // Has an inflated monitor. Must be checked before has_locker().
41 ObjectMonitor* monitor = this->monitor();
42 return monitor->header();
43 }
44 if (has_locker()) { // has a stack lock
45 BasicLock* locker = this->locker();
46 return locker->displaced_header();
47 }
48 // This should never happen:
49 fatal("bad header=" INTPTR_FORMAT, value());
50 return markWord(value());
51 }
52
53 void markWord::set_displaced_mark_helper(markWord m) const {
54 assert(has_displaced_mark_helper(), "check");
73 } else if (has_monitor()) { // last bits = 10
74 // have to check has_monitor() before is_locked()
75 st->print(" monitor(" INTPTR_FORMAT ")=", value());
76 if (print_monitor_info && !UseObjectMonitorTable) {
77 ObjectMonitor* mon = monitor();
78 if (mon == nullptr) {
79 st->print("null (this should never be seen!)");
80 } else {
81 mon->print_on(st);
82 }
83 }
84 } else if (is_locked()) { // last bits != 01 => 00
85 // thin locked
86 st->print(" locked(" INTPTR_FORMAT ")", value());
87 } else {
88 st->print(" mark(");
89 if (is_unlocked()) { // last bits = 01
90 st->print("is_unlocked");
91 if (has_no_hash()) {
92 st->print(" no_hash");
93 } else if (UseCompactObjectHeaders) {
94 st->print(" hash is-hashed=%s is-copied=%s", BOOL_TO_STR(is_hashed_not_expanded()), BOOL_TO_STR(
95 is_hashed_expanded()));
96 } else {
97 st->print(" hash=" INTPTR_FORMAT, hash());
98 }
99 } else {
100 st->print("??");
101 }
102 st->print(" age=%d)", age());
103 }
104 }
|