annotate agent/src/share/classes/sun/jvm/hotspot/code/Location.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children cecd8eb4e0ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.code;
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.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 /** <P> A Location describes a concrete machine variable location
a61af66fc99e Initial load
duke
parents:
diff changeset
35 (such as integer or floating point register or a stack-held
a61af66fc99e Initial load
duke
parents:
diff changeset
36 variable). Used when generating debug-information for
a61af66fc99e Initial load
duke
parents:
diff changeset
37 nmethods. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 <P> Encoding: </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
40 <PRE>
a61af66fc99e Initial load
duke
parents:
diff changeset
41 bits:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 Where: [15]
a61af66fc99e Initial load
duke
parents:
diff changeset
43 Type: [14..12]
a61af66fc99e Initial load
duke
parents:
diff changeset
44 Offset: [11..0]
a61af66fc99e Initial load
duke
parents:
diff changeset
45 </PRE>
a61af66fc99e Initial load
duke
parents:
diff changeset
46 */
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public class Location {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 });
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 Assert.that(!VM.getVM().isCore(), "Debug info not used in core build");
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 OFFSET_MASK = db.lookupIntConstant("Location::OFFSET_MASK").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 OFFSET_SHIFT = db.lookupIntConstant("Location::OFFSET_SHIFT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 TYPE_MASK = db.lookupIntConstant("Location::TYPE_MASK").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 TYPE_SHIFT = db.lookupIntConstant("Location::TYPE_SHIFT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 WHERE_MASK = db.lookupIntConstant("Location::WHERE_MASK").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 WHERE_SHIFT = db.lookupIntConstant("Location::WHERE_SHIFT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Location::Type constants
a61af66fc99e Initial load
duke
parents:
diff changeset
70 TYPE_NORMAL = db.lookupIntConstant("Location::normal").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 TYPE_OOP = db.lookupIntConstant("Location::oop").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 TYPE_INT_IN_LONG = db.lookupIntConstant("Location::int_in_long").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 TYPE_LNG = db.lookupIntConstant("Location::lng").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 TYPE_FLOAT_IN_DBL = db.lookupIntConstant("Location::float_in_dbl").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 TYPE_DBL = db.lookupIntConstant("Location::dbl").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 TYPE_ADDR = db.lookupIntConstant("Location::addr").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 TYPE_INVALID = db.lookupIntConstant("Location::invalid").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Location::Where constants
a61af66fc99e Initial load
duke
parents:
diff changeset
80 WHERE_ON_STACK = db.lookupIntConstant("Location::on_stack").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 WHERE_IN_REGISTER = db.lookupIntConstant("Location::in_register").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private int value;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // type safe enum for "Where"
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public static class Where {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public static final Where ON_STACK = new Where("on_stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public static final Where IN_REGISTER = new Where("in_register");
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private Where(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 this.value = value;
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 String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 private String value;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public int getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (this == ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return WHERE_ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 } else if (this == IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return WHERE_IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // type safe enum for "Type"
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public static class Type {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 /** Ints, floats, double halves */
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public static final Type NORMAL = new Type("normal");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 /** Oop (please GC me!) */
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public static final Type OOP = new Type("oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 /** Long held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public static final Type INT_IN_LONG = new Type("int_in_long");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 /** Long held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public static final Type LNG = new Type("lng");
a61af66fc99e Initial load
duke
parents:
diff changeset
122 /** Float held in double register */
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public static final Type FLOAT_IN_DBL = new Type("float_in_dbl");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 /** Double held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public static final Type DBL = new Type("dbl");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 /** JSR return address */
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public static final Type ADDR = new Type("addr");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 /** Invalid location */
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public static final Type INVALID = new Type("invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 private Type(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 this.value = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 private String value;
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public int getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 if (this == NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return TYPE_NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 } else if (this == OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return TYPE_OOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 } else if (this == INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return TYPE_INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 } else if (this == LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return TYPE_LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 } else if (this == FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return TYPE_FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 } else if (this == DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return TYPE_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 } else if (this == ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return TYPE_ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } else if (this == INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return TYPE_INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 private static int OFFSET_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 private static int OFFSET_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 private static int TYPE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 private static int TYPE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 private static int WHERE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 private static int WHERE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // constants in Type enum
a61af66fc99e Initial load
duke
parents:
diff changeset
171 private static int TYPE_NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 private static int TYPE_OOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 private static int TYPE_INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 private static int TYPE_LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 private static int TYPE_FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 private static int TYPE_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 private static int TYPE_ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 private static int TYPE_INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // constants in Where enum
a61af66fc99e Initial load
duke
parents:
diff changeset
181 private static int WHERE_ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 private static int WHERE_IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 /** Create a bit-packed Location */
a61af66fc99e Initial load
duke
parents:
diff changeset
185 Location(Where where, Type type, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 setWhere(where);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 setType(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 setOffset(offset & 0x0000FFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public Where getWhere() {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int where = (value & WHERE_MASK) >> WHERE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (where == WHERE_ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return Where.ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } else if (where == WHERE_IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return Where.IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public Type getType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 int type = (value & TYPE_MASK) >> TYPE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (type == TYPE_NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return Type.NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 } else if (type == TYPE_OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return Type.OOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 } else if (type == TYPE_INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return Type.INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 } else if (type == TYPE_LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return Type.LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 } else if (type == TYPE_FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 return Type.FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
214 } else if (type == TYPE_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 return Type.DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 } else if (type == TYPE_ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return Type.ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else if (type == TYPE_INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return Type.INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 public short getOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return (short) ((value & OFFSET_MASK) >> OFFSET_SHIFT);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 public boolean isRegister() {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 return getWhere() == Where.IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 public boolean isStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return getWhere() == Where.ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 public boolean holdsOop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return getType() == Type.OOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 public boolean holdsInt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return getType() == Type.INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public boolean holdsLong() {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return getType() == Type.LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 public boolean holdsFloat() {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return getType() == Type.FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public boolean holdsDouble() {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 return getType() == Type.DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 public boolean holdsAddr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return getType() == Type.ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 public boolean isIllegal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return getType() == Type.INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 public int getStackOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 Assert.that(getWhere() == Where.ON_STACK, "wrong Where");
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return getOffset() << VM.getVM().getLogAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 public int getRegisterNumber() {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Assert.that(getWhere() == Where.IN_REGISTER, "wrong Where");
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 tty.print("Value " + value + ", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (isIllegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 tty.print("Illegal");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 Where w = getWhere();
a61af66fc99e Initial load
duke
parents:
diff changeset
289 if (w == Where.ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 tty.print("stack[" + getStackOffset() + "]");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 } else if (w == Where.IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 tty.print("reg " + getRegisterNumber());
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 Type type = getType();
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (type == Type.NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 } else if (type == Type.OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 tty.print(",oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 } else if (type == Type.INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 tty.print(",int");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 } else if (type == Type.LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 tty.print(",long");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 } else if (type == Type.FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 tty.print(",float");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 } else if (type == Type.DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 tty.print(",double");
a61af66fc99e Initial load
duke
parents:
diff changeset
307 } else if (type == Type.ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 tty.print(",address");
a61af66fc99e Initial load
duke
parents:
diff changeset
309 } else if (type == Type.INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 tty.print(",invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 /** Serialization of debugging information */
a61af66fc99e Initial load
duke
parents:
diff changeset
316 public Location(DebugInfoReadStream stream) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 value = (0x0000FFFF & stream.readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // void write_on(DebugInfoWriteStream* stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
326 //
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 private void setWhere(Where where) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 value |= (where.getValue() << WHERE_SHIFT);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 private void setType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 value |= (type.getValue() << TYPE_SHIFT);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 private void setOffset(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 value |= (offset << OFFSET_SHIFT);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }