annotate agent/src/share/classes/sun/jvm/hotspot/oops/CellTypeState.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 a61af66fc99e
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: 0
diff changeset
2 * Copyright (c) 2001, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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 sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 /** Auxiliary class for GenerateOopMap */
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public class CellTypeState {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private int _state;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Masks for separating the BITS and INFO portions of a
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static final int info_mask = Bits.rightNBits(28);
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static final int bits_mask = ~info_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // These constant are used for manipulating the BITS portion of a
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static final int uninit_bit = Bits.nthBit(31);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private static final int ref_bit = Bits.nthBit(30);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static final int val_bit = Bits.nthBit(29);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static final int addr_bit = Bits.nthBit(28);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private static final int live_bits_mask = bits_mask & ~uninit_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // These constants are used for manipulating the INFO portion of a
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static final int top_info_bit = Bits.nthBit(27);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static final int not_bottom_info_bit = Bits.nthBit(26);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static final int info_data_mask = Bits.rightNBits(26);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private static final int info_conflict = info_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Within the INFO data, these values are used to distinguish
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // different kinds of references.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // 0 if this reference is locked as a monitor
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static final int ref_not_lock_bit = Bits.nthBit(25);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // 1 if this reference is a "slot" reference
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private static final int ref_slot_bit = Bits.nthBit(24);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // 0 if it is a "line" reference.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private static final int ref_data_mask = Bits.rightNBits(24);
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // These values are used to initialize commonly used CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private static final int bottom_value = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private static final int uninit_value = uninit_bit | info_conflict;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private static final int ref_value = ref_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private static final int ref_conflict = ref_bit | info_conflict;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private static final int val_value = val_bit | info_conflict;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private static final int addr_value = addr_bit;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private static final int addr_conflict = addr_bit | info_conflict;
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private CellTypeState() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private CellTypeState(int state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _state = state;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public CellTypeState copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return new CellTypeState(_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public static CellTypeState makeAny(int state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 CellTypeState s = new CellTypeState(state);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 Assert.that(s.isValidState(), "check to see if CellTypeState is valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public static CellTypeState makeBottom() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return makeAny(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public static CellTypeState makeTop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return makeAny(Bits.AllBits);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public static CellTypeState makeAddr(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Assert.that((bci >= 0) && (bci < info_data_mask),
a61af66fc99e Initial load
duke
parents:
diff changeset
102 "check to see if ret addr is valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return makeAny(addr_bit | not_bottom_info_bit | (bci & info_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public static CellTypeState makeSlotRef(int slot_num) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Assert.that(slot_num >= 0 && slot_num < ref_data_mask, "slot out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return makeAny(ref_bit | not_bottom_info_bit | ref_not_lock_bit | ref_slot_bit |
a61af66fc99e Initial load
duke
parents:
diff changeset
112 (slot_num & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public static CellTypeState makeLineRef(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 Assert.that(bci >= 0 && bci < ref_data_mask, "line out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return makeAny(ref_bit | not_bottom_info_bit | ref_not_lock_bit |
a61af66fc99e Initial load
duke
parents:
diff changeset
120 (bci & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public static CellTypeState makeLockRef(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 Assert.that(bci >= 0 && bci < ref_data_mask, "line out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return makeAny(ref_bit | not_bottom_info_bit | (bci & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Query methods:
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public boolean isBottom() { return _state == 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public boolean isLive() { return ((_state & live_bits_mask) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public boolean isValidState() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Uninitialized and value cells must contain no data in their info field:
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if ((canBeUninit() || canBeValue()) && !isInfoTop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // The top bit is only set when all info bits are set:
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (isInfoTop() && ((_state & info_mask) != info_mask)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // The not_bottom_bit must be set when any other info bit is set:
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (isInfoBottom() && ((_state & info_mask) != 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 public boolean isAddress() { return ((_state & bits_mask) == addr_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public boolean isReference() { return ((_state & bits_mask) == ref_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public boolean isValue() { return ((_state & bits_mask) == val_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public boolean isUninit() { return ((_state & bits_mask) == uninit_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public boolean canBeAddress() { return ((_state & addr_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public boolean canBeReference() { return ((_state & ref_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public boolean canBeValue() { return ((_state & val_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 public boolean canBeUninit() { return ((_state & uninit_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public boolean isInfoBottom() { return ((_state & not_bottom_info_bit) == 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public boolean isInfoTop() { return ((_state & top_info_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 public int getInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 Assert.that((!isInfoTop() && !isInfoBottom()),
a61af66fc99e Initial load
duke
parents:
diff changeset
164 "check to make sure top/bottom info is not used");
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return (_state & info_data_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public int getMonitorSource() {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 Assert.that(isLockReference(), "must be lock");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return getInfo();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 public boolean isGoodAddress() { return isAddress() && !isInfoTop(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 public boolean isLockReference() {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == ref_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public boolean isNonlockReference() {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == (ref_bit | ref_not_lock_bit));
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 public boolean equal(CellTypeState a) { return _state == a._state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public boolean equalKind(CellTypeState a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return (_state & bits_mask) == (a._state & bits_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 public char toChar() {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 if (canBeReference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (canBeValue() || canBeAddress())
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return '#'; // Conflict that needs to be rewritten
a61af66fc99e Initial load
duke
parents:
diff changeset
193 else
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return 'r';
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } else if (canBeValue())
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return 'v';
a61af66fc99e Initial load
duke
parents:
diff changeset
197 else if (canBeAddress())
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return 'p';
a61af66fc99e Initial load
duke
parents:
diff changeset
199 else if (canBeUninit())
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
201 else
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return '@';
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Set
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public void set(CellTypeState cts) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 _state = cts._state;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Merge
a61af66fc99e Initial load
duke
parents:
diff changeset
211 public CellTypeState merge (CellTypeState cts, int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 CellTypeState result = new CellTypeState();
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 Assert.that(!isBottom() && !cts.isBottom(),
a61af66fc99e Initial load
duke
parents:
diff changeset
216 "merge of bottom values is handled elsewhere");
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 result._state = _state | cts._state;
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // If the top bit is set, we don't need to do any more work.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (!result.isInfoTop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Assert.that((result.canBeAddress() || result.canBeReference()),
a61af66fc99e Initial load
duke
parents:
diff changeset
224 "only addresses and references have non-top info");
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (!equal(cts)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // The two values being merged are different. Raise to top.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 if (result.isReference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 result = CellTypeState.makeSlotRef(slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 result._state |= info_conflict;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Assert.that(result.isValidState(), "checking that CTS merge maintains legal state");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Debugging output
a61af66fc99e Initial load
duke
parents:
diff changeset
243 public void print(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (canBeAddress()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 tty.print("(p");
a61af66fc99e Initial load
duke
parents:
diff changeset
246 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 tty.print("( ");
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if (canBeReference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 tty.print("r");
a61af66fc99e Initial load
duke
parents:
diff changeset
251 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 tty.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (canBeValue()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 tty.print("v");
a61af66fc99e Initial load
duke
parents:
diff changeset
256 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 tty.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if (canBeUninit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 tty.print("u|");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 tty.print(" |");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (isInfoTop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 tty.print("Top)");
a61af66fc99e Initial load
duke
parents:
diff changeset
266 } else if (isInfoBottom()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 tty.print("Bot)");
a61af66fc99e Initial load
duke
parents:
diff changeset
268 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (isReference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 int info = getInfo();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 int data = info & ~(ref_not_lock_bit | ref_slot_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 if ((info & ref_not_lock_bit) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // Not a monitor lock reference.
a61af66fc99e Initial load
duke
parents:
diff changeset
274 if ((info & ref_slot_bit) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // slot
a61af66fc99e Initial load
duke
parents:
diff changeset
276 tty.print("slot" + data + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // line
a61af66fc99e Initial load
duke
parents:
diff changeset
279 tty.print("line" + data + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // lock
a61af66fc99e Initial load
duke
parents:
diff changeset
283 tty.print("lock" + data + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 tty.print("" + getInfo() + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Default values of common values
a61af66fc99e Initial load
duke
parents:
diff changeset
292 public static CellTypeState bottom = CellTypeState.makeBottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 public static CellTypeState uninit = CellTypeState.makeAny(uninit_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 public static CellTypeState ref = CellTypeState.makeAny(ref_conflict);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public static CellTypeState value = CellTypeState.makeAny(val_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 public static CellTypeState refUninit = CellTypeState.makeAny(ref_conflict | uninit_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 public static CellTypeState top = CellTypeState.makeTop();
a61af66fc99e Initial load
duke
parents:
diff changeset
298 public static CellTypeState addr = CellTypeState.makeAny(addr_conflict);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }