annotate agent/src/share/classes/sun/jvm/hotspot/oops/Mark.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents d1605aabd0a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 /** Mark is the analogue of the VM's markOop. In this system it does
a61af66fc99e Initial load
duke
parents:
diff changeset
36 not subclass Oop but VMObject. For a mark on the stack, the mark's
a61af66fc99e Initial load
duke
parents:
diff changeset
37 address will be an Address; for a mark in the header of an object,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 it will be an OopHandle. It is assumed in a couple of places in
a61af66fc99e Initial load
duke
parents:
diff changeset
39 this code that the mark is the first word in an object. */
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public class Mark extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 });
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 Type type = db.lookupType("oopDesc");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 markField = type.getCIntegerField("_mark");
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 ageBits = db.lookupLongConstant("markOopDesc::age_bits").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 lockBits = db.lookupLongConstant("markOopDesc::lock_bits").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 biasedLockBits = db.lookupLongConstant("markOopDesc::biased_lock_bits").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 maxHashBits = db.lookupLongConstant("markOopDesc::max_hash_bits").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 hashBits = db.lookupLongConstant("markOopDesc::hash_bits").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 lockShift = db.lookupLongConstant("markOopDesc::lock_shift").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 biasedLockShift = db.lookupLongConstant("markOopDesc::biased_lock_shift").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 ageShift = db.lookupLongConstant("markOopDesc::age_shift").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 hashShift = db.lookupLongConstant("markOopDesc::hash_shift").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 lockMask = db.lookupLongConstant("markOopDesc::lock_mask").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 lockMaskInPlace = db.lookupLongConstant("markOopDesc::lock_mask_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 biasedLockMask = db.lookupLongConstant("markOopDesc::biased_lock_mask").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 biasedLockMaskInPlace = db.lookupLongConstant("markOopDesc::biased_lock_mask_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 biasedLockBitInPlace = db.lookupLongConstant("markOopDesc::biased_lock_bit_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ageMask = db.lookupLongConstant("markOopDesc::age_mask").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 ageMaskInPlace = db.lookupLongConstant("markOopDesc::age_mask_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 hashMask = db.lookupLongConstant("markOopDesc::hash_mask").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 hashMaskInPlace = db.lookupLongConstant("markOopDesc::hash_mask_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 biasedLockAlignment = db.lookupLongConstant("markOopDesc::biased_lock_alignment").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 lockedValue = db.lookupLongConstant("markOopDesc::locked_value").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 unlockedValue = db.lookupLongConstant("markOopDesc::unlocked_value").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 monitorValue = db.lookupLongConstant("markOopDesc::monitor_value").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 markedValue = db.lookupLongConstant("markOopDesc::marked_value").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 biasedLockPattern = db.lookupLongConstant("markOopDesc::biased_lock_pattern").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 noHash = db.lookupLongConstant("markOopDesc::no_hash").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 noHashInPlace = db.lookupLongConstant("markOopDesc::no_hash_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 noLockInPlace = db.lookupLongConstant("markOopDesc::no_lock_in_place").longValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 maxAge = db.lookupLongConstant("markOopDesc::max_age").longValue();
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
82
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
83 /* Constants in markOop used by CMS. */
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
84 cmsShift = db.lookupLongConstant("markOopDesc::cms_shift").longValue();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
85 cmsMask = db.lookupLongConstant("markOopDesc::cms_mask").longValue();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
86 sizeShift = db.lookupLongConstant("markOopDesc::size_shift").longValue();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Field accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
90 private static CIntegerField markField;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Constants -- read from VM
a61af66fc99e Initial load
duke
parents:
diff changeset
93 private static long ageBits;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private static long lockBits;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private static long biasedLockBits;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 private static long maxHashBits;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private static long hashBits;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 private static long lockShift;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private static long biasedLockShift;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 private static long ageShift;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 private static long hashShift;
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 private static long lockMask;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 private static long lockMaskInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 private static long biasedLockMask;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 private static long biasedLockMaskInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 private static long biasedLockBitInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private static long ageMask;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 private static long ageMaskInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 private static long hashMask;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 private static long hashMaskInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private static long biasedLockAlignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 private static long lockedValue;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 private static long unlockedValue;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 private static long monitorValue;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 private static long markedValue;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 private static long biasedLockPattern;
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 private static long noHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private static long noHashInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 private static long noLockInPlace;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private static long maxAge;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
128 /* Constants in markOop used by CMS. */
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
129 private static long cmsShift;
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
130 private static long cmsMask;
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
131 private static long sizeShift;
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
132
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public Mark(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public long value() {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return markField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public Address valueAsAddress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return addr.getAddressAt(markField.getOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // Biased locking accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // These must be checked by all code which calls into the
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // ObjectSynchoronizer and other code. The biasing is not understood
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // by the lower-level CAS-based locking code, although the runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // fixes up biased locks to be compatible with it when a bias is
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // revoked.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public boolean hasBiasPattern() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return (Bits.maskBitsLong(value(), biasedLockMaskInPlace) == biasedLockPattern);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public JavaThread biasedLocker() {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Address addr = valueAsAddress().andWithMask(~(biasedLockMaskInPlace & ageMaskInPlace));
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return threads.createJavaThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Indicates that the mark gas the bias bit set but that it has not
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // yet been biased toward a particular thread
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public boolean isBiasedAnonymously() {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return hasBiasPattern() && (biasedLocker() == null);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // lock accessors (note that these assume lock_shift == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
168 public boolean isLocked() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return (Bits.maskBitsLong(value(), lockMaskInPlace) != unlockedValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public boolean isUnlocked() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return (Bits.maskBitsLong(value(), biasedLockMaskInPlace) == unlockedValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public boolean isMarked() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return (Bits.maskBitsLong(value(), lockMaskInPlace) == markedValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Special temporary state of the markOop while being inflated.
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Code that looks at mark outside a lock need to take this into account.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public boolean isBeingInflated() {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return (value() == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Should this header be preserved during GC?
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public boolean mustBePreserved() {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return (!isUnlocked() || !hasNoHash());
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // WARNING: The following routines are used EXCLUSIVELY by
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // synchronization functions. They are not really gc safe.
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // They must get updated if markOop layout get changed.
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // markOop set_unlocked() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // return markOop(value() | unlocked_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 public boolean hasLocker() {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return ((value() & lockMaskInPlace) == lockedValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 public BasicLock locker() {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 Assert.that(hasLocker(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return new BasicLock(valueAsAddress());
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public boolean hasMonitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return ((value() & monitorValue) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 public ObjectMonitor monitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 Assert.that(hasMonitor(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Use xor instead of &~ to provide one extra tag-bit check.
a61af66fc99e Initial load
duke
parents:
diff changeset
214 Address monAddr = valueAsAddress().xorWithMask(monitorValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 return new ObjectMonitor(monAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 public boolean hasDisplacedMarkHelper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return ((value() & unlockedValue) == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 public Mark displacedMarkHelper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 Assert.that(hasDisplacedMarkHelper(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 Address addr = valueAsAddress().andWithMask(~monitorValue);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return new Mark(addr.getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // void set_displaced_mark_helper(markOop m) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // assert(has_displaced_mark_helper(), "check");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // intptr_t ptr = (value() & ~monitor_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // *(markOop*)ptr = m;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // markOop copy_set_hash(intptr_t hash) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // intptr_t tmp = value() & (~hash_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // tmp |= ((hash & hash_mask) << hash_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // return (markOop)tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // it is only used to be stored into BasicLock as the
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // indicator that the lock is using heavyweight monitor
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // static markOop unused_mark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // return (markOop) marked_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // // the following two functions create the markOop to be
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // // stored into object header, it encodes monitor info
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // static markOop encode(BasicLock* lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // return (markOop) lock;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // static markOop encode(ObjectMonitor* monitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // intptr_t tmp = (intptr_t) monitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // return (markOop) (tmp | monitor_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // used for alignment-based marking to reuse the busy state to encode pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // (see markOop_alignment.hpp)
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // markOop clear_lock_bits() { return markOop(value() & ~lock_mask_in_place); }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 //
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // // age operations
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // markOop set_marked() { return markOop((value() & ~lock_mask_in_place) | marked_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 //
a61af66fc99e Initial load
duke
parents:
diff changeset
259 public int age() { return (int) Bits.maskBitsLong(value() >> ageShift, ageMask); }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // markOop set_age(int v) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // assert((v & ~age_mask) == 0, "shouldn't overflow age field");
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // return markOop((value() & ~age_mask_in_place) | (((intptr_t)v & age_mask) << age_shift));
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // markOop incr_age() const { return age() == max_age ? markOop(this) : set_age(age() + 1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // hash operations
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public long hash() {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return Bits.maskBitsLong(value() >> hashShift, hashMask);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 public boolean hasNoHash() {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return hash() == noHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Prototype mark for initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // static markOop prototype() {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // return markOop( no_hash_in_place | no_lock_in_place );
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
282 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (isLocked()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 tty.print("locked(0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
285 Long.toHexString(value()) + ")->");
a61af66fc99e Initial load
duke
parents:
diff changeset
286 displacedMarkHelper().printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 Assert.that(isUnlocked(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 tty.print("mark(");
a61af66fc99e Initial load
duke
parents:
diff changeset
292 tty.print("hash " + Long.toHexString(hash()) + ",");
a61af66fc99e Initial load
duke
parents:
diff changeset
293 tty.print("age " + age() + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // // Prepare address of oop for placement into mark
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // inline static markOop encode_pointer_as_mark(void* p) { return markOop(p)->set_marked(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 //
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // // Recover address of oop from encoded form used in mark
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // inline void* decode_pointer() { return clear_lock_bits(); }
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
303
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
304 // Copy markOop methods for CMS here.
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
305 public boolean isCmsFreeChunk() {
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
306 return isUnlocked() &&
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
307 (Bits.maskBitsLong(value() >> cmsShift, cmsMask) & 0x1L) == 0x1L;
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
308 }
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
309 public long getSize() { return (long)(value() >> sizeShift); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }