1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 *
66 //
67 // Note also that the biased state contains the age bits normally
68 // contained in the object header. Large increases in scavenge
69 // times were seen when these bits were absent and an arbitrary age
70 // assigned to all biased objects, because they tended to consume a
71 // significant fraction of the eden semispaces and were not
72 // promoted promptly, causing an increase in the amount of copying
73 // performed. The runtime system aligns all JavaThread* pointers to
74 // a very large value (currently 128 bytes (32bVM) or 256 bytes (64bVM))
75 // to make room for the age bits & the epoch bits (used in support of
76 // biased locking).
77 //
78 // [JavaThread* | epoch | age | 1 | 01] lock is biased toward given thread
79 // [0 | epoch | age | 1 | 01] lock is anonymously biased
80 //
81 // - the two lock bits are used to describe three states: locked/unlocked and monitor.
82 //
83 // [ptr | 00] locked ptr points to real header on stack
84 // [header | 0 | 01] unlocked regular object header
85 // [ptr | 10] monitor inflated lock (header is wapped out)
86 // [ptr | 11] marked used by markSweep to mark an object
87 // not valid at any other time
88 //
89 // We assume that stack/thread pointers have the lowest two bits cleared.
90
91 class BasicLock;
92 class ObjectMonitor;
93 class JavaThread;
94
95 class markWord {
96 private:
97 uintptr_t _value;
98
99 public:
100 explicit markWord(uintptr_t value) : _value(value) {}
101
102 markWord() { /* uninitialized */}
103
104 // It is critical for performance that this class be trivially
105 // destructable, copyable, and assignable.
106
107 static markWord from_pointer(void* ptr) {
|
1 /*
2 * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 *
66 //
67 // Note also that the biased state contains the age bits normally
68 // contained in the object header. Large increases in scavenge
69 // times were seen when these bits were absent and an arbitrary age
70 // assigned to all biased objects, because they tended to consume a
71 // significant fraction of the eden semispaces and were not
72 // promoted promptly, causing an increase in the amount of copying
73 // performed. The runtime system aligns all JavaThread* pointers to
74 // a very large value (currently 128 bytes (32bVM) or 256 bytes (64bVM))
75 // to make room for the age bits & the epoch bits (used in support of
76 // biased locking).
77 //
78 // [JavaThread* | epoch | age | 1 | 01] lock is biased toward given thread
79 // [0 | epoch | age | 1 | 01] lock is anonymously biased
80 //
81 // - the two lock bits are used to describe three states: locked/unlocked and monitor.
82 //
83 // [ptr | 00] locked ptr points to real header on stack
84 // [header | 0 | 01] unlocked regular object header
85 // [ptr | 10] monitor inflated lock (header is wapped out)
86 // [ptr | 11] marked used to mark an object
87 //
88 // We assume that stack/thread pointers have the lowest two bits cleared.
89
90 class BasicLock;
91 class ObjectMonitor;
92 class JavaThread;
93
94 class markWord {
95 private:
96 uintptr_t _value;
97
98 public:
99 explicit markWord(uintptr_t value) : _value(value) {}
100
101 markWord() { /* uninitialized */}
102
103 // It is critical for performance that this class be trivially
104 // destructable, copyable, and assignable.
105
106 static markWord from_pointer(void* ptr) {
|