annotate agent/src/share/classes/sun/jvm/hotspot/code/Location.java @ 1563:1a5913bf5e19

6951083: oops and relocations should part of nmethod not CodeBlob Summary: This moves the oops from Codeblob to nmethod. Reviewed-by: kvn, never
author twisti
date Thu, 20 May 2010 06:34:23 -0700
parents cecd8eb4e0ca
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
2 * Copyright 2000-2008 Sun Microsystems, Inc. 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 *
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:
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
42 Type: [3..0]
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
43 Where: [4]
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
44 Offset: [31..5]
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();
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
72 TYPE_NARROWOOP = db.lookupIntConstant("Location::narrowoop").intValue();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73 TYPE_INT_IN_LONG = db.lookupIntConstant("Location::int_in_long").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 TYPE_LNG = db.lookupIntConstant("Location::lng").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 TYPE_FLOAT_IN_DBL = db.lookupIntConstant("Location::float_in_dbl").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 TYPE_DBL = db.lookupIntConstant("Location::dbl").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 TYPE_ADDR = db.lookupIntConstant("Location::addr").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 TYPE_INVALID = db.lookupIntConstant("Location::invalid").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Location::Where constants
a61af66fc99e Initial load
duke
parents:
diff changeset
81 WHERE_ON_STACK = db.lookupIntConstant("Location::on_stack").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 WHERE_IN_REGISTER = db.lookupIntConstant("Location::in_register").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private int value;
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // type safe enum for "Where"
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public static class Where {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public static final Where ON_STACK = new Where("on_stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public static final Where IN_REGISTER = new Where("in_register");
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private Where(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 this.value = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private String value;
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public int getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (this == ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return WHERE_ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else if (this == IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return WHERE_IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 throw new RuntimeException("should not reach here");
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
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // type safe enum for "Type"
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public static class Type {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 /** Ints, floats, double halves */
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public static final Type NORMAL = new Type("normal");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 /** Oop (please GC me!) */
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public static final Type OOP = new Type("oop");
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
119 /** NarrowOop (please GC me!) */
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
120 public static final Type NARROWOOP = new Type("narrowoop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121 /** Long held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public static final Type INT_IN_LONG = new Type("int_in_long");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 /** Long held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public static final Type LNG = new Type("lng");
a61af66fc99e Initial load
duke
parents:
diff changeset
125 /** Float held in double register */
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public static final Type FLOAT_IN_DBL = new Type("float_in_dbl");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 /** Double held in one register */
a61af66fc99e Initial load
duke
parents:
diff changeset
128 public static final Type DBL = new Type("dbl");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 /** JSR return address */
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public static final Type ADDR = new Type("addr");
a61af66fc99e Initial load
duke
parents:
diff changeset
131 /** Invalid location */
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public static final Type INVALID = new Type("invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 private Type(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 this.value = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 private String value;
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public int getValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (this == NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return TYPE_NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else if (this == OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return TYPE_OOP;
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
148 } else if (this == NARROWOOP) {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
149 return TYPE_NARROWOOP;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
150 } else if (this == INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return TYPE_INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 } else if (this == LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return TYPE_LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 } else if (this == FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return TYPE_FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 } else if (this == DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return TYPE_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 } else if (this == ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return TYPE_ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 } else if (this == INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return TYPE_INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 private static int OFFSET_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 private static int OFFSET_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 private static int TYPE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 private static int TYPE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 private static int WHERE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 private static int WHERE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // constants in Type enum
a61af66fc99e Initial load
duke
parents:
diff changeset
176 private static int TYPE_NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 private static int TYPE_OOP;
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
178 private static int TYPE_NARROWOOP;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
179 private static int TYPE_INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 private static int TYPE_LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 private static int TYPE_FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 private static int TYPE_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private static int TYPE_ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 private static int TYPE_INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // constants in Where enum
a61af66fc99e Initial load
duke
parents:
diff changeset
187 private static int WHERE_ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 private static int WHERE_IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 /** Create a bit-packed Location */
a61af66fc99e Initial load
duke
parents:
diff changeset
191 Location(Where where, Type type, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 setWhere(where);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 setType(type);
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
194 setOffset(offset);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 public Where getWhere() {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 int where = (value & WHERE_MASK) >> WHERE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 if (where == WHERE_ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return Where.ON_STACK;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 } else if (where == WHERE_IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return Where.IN_REGISTER;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 public Type getType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 int type = (value & TYPE_MASK) >> TYPE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (type == TYPE_NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return Type.NORMAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 } else if (type == TYPE_OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 return Type.OOP;
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
214 } else if (type == TYPE_NARROWOOP) {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
215 return Type.NARROWOOP;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
216 } else if (type == TYPE_INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return Type.INT_IN_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else if (type == TYPE_LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return Type.LNG;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else if (type == TYPE_FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return Type.FLOAT_IN_DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 } else if (type == TYPE_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return Type.DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 } else if (type == TYPE_ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return Type.ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 } else if (type == TYPE_INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return Type.INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 throw new RuntimeException("should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
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 short getOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return (short) ((value & OFFSET_MASK) >> OFFSET_SHIFT);
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 isRegister() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return getWhere() == Where.IN_REGISTER;
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 isStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return getWhere() == Where.ON_STACK;
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 holdsOop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return getType() == Type.OOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
249 public boolean holdsNarrowOop() {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
250 return getType() == Type.NARROWOOP;
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
251 }
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
252
0
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public boolean holdsInt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 return getType() == Type.INT_IN_LONG;
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 holdsLong() {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return getType() == Type.LNG;
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 holdsFloat() {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return getType() == Type.FLOAT_IN_DBL;
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 boolean holdsDouble() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return getType() == Type.DBL;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 public boolean holdsAddr() {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 return getType() == Type.ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 public boolean isIllegal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 return getType() == Type.INVALID;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public int getStackOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 Assert.that(getWhere() == Where.ON_STACK, "wrong Where");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
281 return getOffset() * (int)VM.getVM().getIntSize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 public int getRegisterNumber() {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 Assert.that(getWhere() == Where.IN_REGISTER, "wrong Where");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 tty.print("Value " + value + ", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (isIllegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 tty.print("Illegal");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 Where w = getWhere();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 if (w == Where.ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 tty.print("stack[" + getStackOffset() + "]");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 } else if (w == Where.IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 tty.print("reg " + getRegisterNumber());
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 Type type = getType();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (type == Type.NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 } else if (type == Type.OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 tty.print(",oop");
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
311 } else if (type == Type.NARROWOOP) {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
312 tty.print(",narrowoop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
313 } else if (type == Type.INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 tty.print(",int");
a61af66fc99e Initial load
duke
parents:
diff changeset
315 } else if (type == Type.LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 tty.print(",long");
a61af66fc99e Initial load
duke
parents:
diff changeset
317 } else if (type == Type.FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 tty.print(",float");
a61af66fc99e Initial load
duke
parents:
diff changeset
319 } else if (type == Type.DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 tty.print(",double");
a61af66fc99e Initial load
duke
parents:
diff changeset
321 } else if (type == Type.ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 tty.print(",address");
a61af66fc99e Initial load
duke
parents:
diff changeset
323 } else if (type == Type.INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 tty.print(",invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 /** Serialization of debugging information */
a61af66fc99e Initial load
duke
parents:
diff changeset
330 public Location(DebugInfoReadStream stream) {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
331 value = stream.readInt();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // void write_on(DebugInfoWriteStream* stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
338 //-----------------------------------------------------------------------------
0
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
340 //
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 private void setWhere(Where where) {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
343 value |= ((where.getValue() << WHERE_SHIFT) & WHERE_MASK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 private void setType(Type type) {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
347 value |= ((type.getValue() << TYPE_SHIFT) & TYPE_MASK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 private void setOffset(int offset) {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
351 value |= ((offset << OFFSET_SHIFT) & OFFSET_MASK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }