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 // Make sure we have an inflated monitor.
40 guarantee(has_monitor(), "bad header=" INTPTR_FORMAT, value());
41 ObjectMonitor* monitor = this->monitor();
42 return monitor->header();
43 }
44
45 void markWord::set_displaced_mark_helper(markWord m) const {
46 assert(has_displaced_mark_helper(), "check");
47 // Make sure we have an inflated monitor.
48 guarantee(has_monitor(), "bad header=" INTPTR_FORMAT, value());
49 ObjectMonitor* monitor = this->monitor();
50 monitor->set_header(m);
51 }
52
53 void markWord::print_on(outputStream* st, bool print_monitor_info) const {
54 if (is_marked()) { // last bits = 11
56 } else if (has_monitor()) { // last bits = 10
57 // have to check has_monitor() before is_locked()
58 st->print(" monitor(" INTPTR_FORMAT ")=", value());
59 if (print_monitor_info && !UseObjectMonitorTable) {
60 ObjectMonitor* mon = monitor();
61 if (mon == nullptr) {
62 st->print("null (this should never be seen!)");
63 } else {
64 mon->print_on(st);
65 }
66 }
67 } else if (is_locked()) { // last bits != 01 => 00
68 // thin locked
69 st->print(" locked(" INTPTR_FORMAT ")", value());
70 } else {
71 st->print(" mark(");
72 if (is_unlocked()) { // last bits = 01
73 st->print("is_unlocked");
74 if (has_no_hash()) {
75 st->print(" no_hash");
76 } else {
77 st->print(" hash=" INTPTR_FORMAT, hash());
78 }
79 } else {
80 st->print("??");
81 }
82 st->print(" age=%d)", age());
83 }
84 }
|
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 hashctrl bits (preceding klass bits) shall be a direct neighbor but not interleave
34 // klass_shift=13, hashctrl_shift=11, hashctrl_bits=2, so 13 == 2 + 11
35 STATIC_ASSERT(markWord::klass_shift == markWord::hashctrl_bits + markWord::hashctrl_shift);
36 #endif
37
38 markWord markWord::displaced_mark_helper() const {
39 assert(has_displaced_mark_helper(), "check");
40 // Make sure we have an inflated monitor.
41 guarantee(has_monitor(), "bad header=" INTPTR_FORMAT, value());
42 ObjectMonitor* monitor = this->monitor();
43 return monitor->header();
44 }
45
46 void markWord::set_displaced_mark_helper(markWord m) const {
47 assert(has_displaced_mark_helper(), "check");
48 // Make sure we have an inflated monitor.
49 guarantee(has_monitor(), "bad header=" INTPTR_FORMAT, value());
50 ObjectMonitor* monitor = this->monitor();
51 monitor->set_header(m);
52 }
53
54 void markWord::print_on(outputStream* st, bool print_monitor_info) const {
55 if (is_marked()) { // last bits = 11
57 } else if (has_monitor()) { // last bits = 10
58 // have to check has_monitor() before is_locked()
59 st->print(" monitor(" INTPTR_FORMAT ")=", value());
60 if (print_monitor_info && !UseObjectMonitorTable) {
61 ObjectMonitor* mon = monitor();
62 if (mon == nullptr) {
63 st->print("null (this should never be seen!)");
64 } else {
65 mon->print_on(st);
66 }
67 }
68 } else if (is_locked()) { // last bits != 01 => 00
69 // thin locked
70 st->print(" locked(" INTPTR_FORMAT ")", value());
71 } else {
72 st->print(" mark(");
73 if (is_unlocked()) { // last bits = 01
74 st->print("is_unlocked");
75 if (has_no_hash()) {
76 st->print(" no_hash");
77 } else if (UseCompactObjectHeaders) {
78 st->print(" hash is-hashed=%s is-copied=%s", BOOL_TO_STR(is_hashed_not_expanded()), BOOL_TO_STR(
79 is_hashed_expanded()));
80 } else {
81 st->print(" hash=" INTPTR_FORMAT, hash());
82 }
83 } else {
84 st->print("??");
85 }
86 st->print(" age=%d)", age());
87 }
88 }
|