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 #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 {
|
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 #include "precompiled.hpp"
26 #include "oops/markWord.hpp"
27 #include "runtime/basicLock.inline.hpp"
28 #include "runtime/javaThread.hpp"
29 #include "runtime/objectMonitor.inline.hpp"
30 #include "utilities/ostream.hpp"
31
32 #ifdef _LP64
33 STATIC_ASSERT((markWord::klass_shadow_mask_inplace & markWord::klass_mask_in_place) == 0);
34 STATIC_ASSERT((markWord::klass_load_shift + markWord::klass_shadow_bits) == markWord::klass_shift);
35 STATIC_ASSERT(markWord::klass_shift + markWord::klass_bits == 64);
36 // The hash (preceding nKlass) shall be a direct neighbor but not interleave
37 STATIC_ASSERT(markWord::klass_shift == markWord::hash_bits_compact + markWord::hash_shift_compact);
38 #endif
39
40 markWord markWord::displaced_mark_helper() const {
41 assert(has_displaced_mark_helper(), "check");
42 if (has_monitor()) {
43 // Has an inflated monitor. Must be checked before has_locker().
44 ObjectMonitor* monitor = this->monitor();
45 return monitor->header();
46 }
47 if (has_locker()) { // has a stack lock
48 BasicLock* locker = this->locker();
49 return locker->displaced_header();
50 }
51 // This should never happen:
52 fatal("bad header=" INTPTR_FORMAT, value());
53 return markWord(value());
54 }
55
56 void markWord::set_displaced_mark_helper(markWord m) const {
57 assert(has_displaced_mark_helper(), "check");
58 if (has_monitor()) {
59 // Has an inflated monitor. Must be checked before has_locker().
60 ObjectMonitor* monitor = this->monitor();
61 monitor->set_header(m);
62 return;
63 }
64 if (has_locker()) { // has a stack lock
65 BasicLock* locker = this->locker();
66 locker->set_displaced_header(m);
67 return;
68 }
69 // This should never happen:
70 fatal("bad header=" INTPTR_FORMAT, value());
71 }
72
73 void markWord::print_on(outputStream* st, bool print_monitor_info) const {
74 if (is_marked()) { // last bits = 11
75 st->print(" marked(" INTPTR_FORMAT ")", value());
76 } else if (has_monitor()) { // last bits = 10
77 // have to check has_monitor() before is_locked()
78 st->print(" monitor(" INTPTR_FORMAT ")=", value());
79 if (print_monitor_info && !UseObjectMonitorTable) {
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 {
|