annotate agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 2000, 2013, 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.types.basic;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
8755
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
27 import java.util.HashMap;
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
28 import java.util.Iterator;
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
29 import java.util.Map;
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
30
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
31 import sun.jvm.hotspot.debugger.Address;
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
32 import sun.jvm.hotspot.debugger.MachineDescription;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
33 import sun.jvm.hotspot.runtime.VM;
8755
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
34 import sun.jvm.hotspot.types.Type;
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
35 import sun.jvm.hotspot.types.TypeDataBase;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 /** <P> This is a basic implementation of the TypeDataBase interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 It allows an external type database builder to add types to be
a61af66fc99e Initial load
duke
parents:
diff changeset
39 consumed by a client through the Type interfaces. It has no
a61af66fc99e Initial load
duke
parents:
diff changeset
40 knowledge of symbol lookup; for example, the builder is
a61af66fc99e Initial load
duke
parents:
diff changeset
41 responsible for providing the addresses of static fields. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 <P> Among other things, the database builder is responsible for
a61af66fc99e Initial load
duke
parents:
diff changeset
44 providing the Types for the Java primitive types, as well as their
a61af66fc99e Initial load
duke
parents:
diff changeset
45 sizes. </P>
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 BasicTypeDataBase implements TypeDataBase {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private MachineDescription machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private VtblAccess vtblAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 /** Maps strings to Type objects. This does not contain the primitive types. */
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private Map nameToTypeMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 /** Maps strings to Integers, used for enums, etc. */
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private Map nameToIntConstantMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 /** Maps strings to Longs, used for 32/64-bit constants, etc. */
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private Map nameToLongConstantMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 /** Primitive types. */
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private Type jbooleanType;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private Type jbyteType;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private Type jcharType;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private Type jdoubleType;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 private Type jfloatType;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private Type jintType;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private Type jlongType;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private Type jshortType;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 /** For debugging */
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private static final boolean DEBUG;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 DEBUG = System.getProperty("sun.jvm.hotspot.types.basic.BasicTypeDataBase.DEBUG") != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public BasicTypeDataBase(MachineDescription machDesc, VtblAccess vtblAccess) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 this.machDesc = machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 this.vtblAccess = vtblAccess;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public Type lookupType(String cTypeName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return lookupType(cTypeName, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public Type lookupType(String cTypeName, boolean throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 Type type = (Type) nameToTypeMap.get(cTypeName);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (type == null && throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 throw new RuntimeException("No type named \"" + cTypeName + "\" in database");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public Integer lookupIntConstant(String constantName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return lookupIntConstant(constantName, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public Integer lookupIntConstant(String constantName, boolean throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Integer i = (Integer) nameToIntConstantMap.get(constantName);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (i == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 throw new RuntimeException("No integer constant named \"" + constantName + "\" present in type database");
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return i;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public Long lookupLongConstant(String constantName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return lookupLongConstant(constantName, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 public Long lookupLongConstant(String constantName, boolean throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Long i = (Long) nameToLongConstantMap.get(constantName);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (i == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (throwException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 throw new RuntimeException("No long constant named \"" + constantName + "\" present in type database");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return i;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public Type getJBooleanType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return jbooleanType;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public Type getJByteType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return jbyteType;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public Type getJCharType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return jcharType;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public Type getJDoubleType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return jdoubleType;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public Type getJFloatType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return jfloatType;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public Type getJIntType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return jintType;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 public Type getJLongType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return jlongType;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 public Type getJShortType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return jshortType;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public long getAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return machDesc.getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public long getOopSize() {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
155 return VM.getVM().getOopSize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
8755
117bb0519114 8009456: SA: typeToVtbl of BasicTypeDataBase should not be static
sla
parents: 3939
diff changeset
158 HashMap typeToVtbl = new HashMap();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
159
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
160 private Address vtblForType(Type type) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
161 Address vtblAddr = (Address)typeToVtbl.get(type);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
162 if (vtblAddr == null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
163 vtblAddr = vtblAccess.getVtblForType(type);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
164 if (vtblAddr != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
165 typeToVtbl.put(type, vtblAddr);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
166 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
167 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
168 return vtblAddr;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
169 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
170
0
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public boolean addressTypeIsEqualToType(Address addr, Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (addr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // This implementation should be suitably platform-independent; we
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // search nearby memory for the vtbl value of the given type.
a61af66fc99e Initial load
duke
parents:
diff changeset
178
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
179 Address vtblAddr = vtblForType(type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (vtblAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Type was not polymorphic, or an error occurred during lookup
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 System.err.println("BasicTypeDataBase.addressTypeIsEqualToType: vtblAddr == null");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // The first implementation searched three locations for this vtbl
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // value; scanning through the entire object was considered, but
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // we thought we knew where we were looking, and looking only in
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // these specific locations should reduce the probability of
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // mistaking random bits as a pointer (although, realistically
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // speaking, the likelihood of finding a match between the bit
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // pattern of, for example, a double and the vtbl is vanishingly
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // small.)
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // 1. The first word of the object (should handle MSVC++ as
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // well as the SparcWorks compilers with compatibility set to
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // v5.0 or greater)
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // 2. and 3. The last two Address-aligned words of the part of
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // the object defined by its topmost polymorphic superclass.
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // This should handle the SparcWorks compilers, v4.2 or
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // earlier, as well as any other compilers which place the vptr
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // at the end of the user-defined fields of the first base
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // class with virtual functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 //
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Unfortunately this algorithm did not work properly for the
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // specific case of the ThreadShadow/Thread inheritance situation,
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // because the Solaris compiler seems to cleverly eliminate the
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // vtbl for ThreadShadow since the only virtual is empty. (We
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // should get rid of the ThreadShadow and fix the include
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // databases, but need to postpone this for the present.) The
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // current solution performs the three-location check for this
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // class and all of its known superclasses rather than just the
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // topmost polymorphic one.
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Type curType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 while (curType != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // Using the size information we have for this type, check the
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // three locations described above.
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (vtblAddr.equals(addr.getAddressAt(0))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // (2)
a61af66fc99e Initial load
duke
parents:
diff changeset
231 long offset = curType.getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // I don't think this should be misaligned under any
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // circumstances, but I'm not sure (FIXME: also not sure which
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // way to go here, up or down -- assuming down)
a61af66fc99e Initial load
duke
parents:
diff changeset
235 offset -= (offset % getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if (offset <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 if (vtblAddr.equals(addr.getAddressAt(offset))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 offset -= getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 if (offset <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (vtblAddr.equals(addr.getAddressAt(offset))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 curType = curType.getSuperclass();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // Any UnmappedAddressExceptions, etc. are a good indication
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // that the pointer is not of the specified type
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 System.err.println("BasicTypeDataBase.addressTypeIsEqualToType: exception occurred during lookup:");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 System.err.println("BasicTypeDataBase.addressTypeIsEqualToType: all vptr tests failed for type " +
a61af66fc99e Initial load
duke
parents:
diff changeset
266 type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
272 public Type findDynamicTypeForAddress(Address addr, Type baseType) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
273 // This implementation should be suitably platform-independent; we
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
274 // search nearby memory for the vtbl value of the given type.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
275
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
276 if (vtblForType(baseType) == null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
277 // Type was not polymorphic which is an error of some sort
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
278 throw new InternalError(baseType + " does not appear to be polymorphic");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
279 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
280
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
281 // This is a more restricted version of guessTypeForAddress since
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
282 // that function has some limitations since it doesn't really know
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
283 // where in the hierarchy a virtual type starts and just poking
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
284 // around in memory is likely to trip over some vtable address,
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
285 // resulting in false positives. Eventually all uses should
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
286 // switch to this logic but in the interests of stability it will
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
287 // be separate for the moment.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
288
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
289 // Assuming that the base type is truly the first polymorphic type
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
290 // then the vtbl for all subclasss should be at several defined
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
291 // locations so only those locations will be checked. It's also
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
292 // required that the caller knows that the static type is at least
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
293 // baseType. See the notes in guessTypeForAddress for the logic of
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
294 // the locations searched.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
295
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
296 Address loc1 = addr.getAddressAt(0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
297 Address loc2 = null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
298 Address loc3 = null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
299 long offset2 = baseType.getSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
300 // I don't think this should be misaligned under any
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
301 // circumstances, but I'm not sure (FIXME: also not sure which
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
302 // way to go here, up or down -- assuming down)
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
303 offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
304 if (offset2 > 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
305 loc2 = addr.getAddressAt(offset2);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
306 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
307 long offset3 = offset2 - getAddressSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
308 if (offset3 > 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
309 loc3 = addr.getAddressAt(offset3);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
310 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
311
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
312 Type loc2Match = null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
313 Type loc3Match = null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
314 for (Iterator iter = getTypes(); iter.hasNext(); ) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
315 Type type = (Type) iter.next();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
316 Type superClass = type;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
317 while (superClass != baseType && superClass != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
318 superClass = superClass.getSuperclass();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
319 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
320 if (superClass == null) continue;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
321 Address vtblAddr = vtblForType(type);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
322 if (vtblAddr == null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
323 // This occurs sometimes for intermediate types that are never
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
324 // instantiated.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
325 if (DEBUG) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
326 System.err.println("null vtbl for " + type);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
327 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
328 continue;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
329 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
330 // Prefer loc1 match
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
331 if (vtblAddr.equals(loc1)) return type;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
332 if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
333 loc2Match = type;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
334 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
335 if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
336 loc3Match = type;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
337 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
338 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
339 if (loc2Match != null) return loc2Match;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
340 if (loc3Match != null) return loc3Match;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
341 return null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
342 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
343
0
a61af66fc99e Initial load
duke
parents:
diff changeset
344 public Type guessTypeForAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 for (Iterator iter = getTypes(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 Type t = (Type) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 if (addressTypeIsEqualToType(addr, t)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 public long cIntegerTypeMaxValue(long sizeInBytes, boolean isUnsigned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return machDesc.cIntegerTypeMaxValue(sizeInBytes, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 public long cIntegerTypeMinValue(long sizeInBytes, boolean isUnsigned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 return machDesc.cIntegerTypeMinValue(sizeInBytes, isUnsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 public Iterator getTypes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 return nameToTypeMap.values().iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 public Iterator getIntConstants() {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 return nameToIntConstantMap.keySet().iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 public Iterator getLongConstants() {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 return nameToLongConstantMap.keySet().iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // Public routines only for use by the database builder
a61af66fc99e Initial load
duke
parents:
diff changeset
376 //
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
379 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
380 public void setJBooleanType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 jbooleanType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
385 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
386 public void setJByteType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 jbyteType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
391 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
392 public void setJCharType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 jcharType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
397 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
398 public void setJDoubleType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 jdoubleType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
403 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
404 public void setJFloatType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
405 jfloatType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
409 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
410 public void setJIntType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 jintType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
a61af66fc99e Initial load
duke
parents:
diff changeset
414 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
415 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
416 public void setJLongType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 jlongType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 /** This method should only be called by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
421 TypeDataBase and at most once */
a61af66fc99e Initial load
duke
parents:
diff changeset
422 public void setJShortType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
423 jshortType = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
427 TypeDataBase. Throws a RuntimeException if a class with this
a61af66fc99e Initial load
duke
parents:
diff changeset
428 name was already present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
429 public void addType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 if (nameToTypeMap.get(type.getName()) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 throw new RuntimeException("type of name \"" + type.getName() + "\" already present");
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 nameToTypeMap.put(type.getName(), type);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
438 TypeDataBase. Throws a RuntimeException if this class was not
a61af66fc99e Initial load
duke
parents:
diff changeset
439 present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
440 public void removeType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 Type curType = (Type) nameToTypeMap.get(type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (curType == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 throw new RuntimeException("type of name \"" + type.getName() + "\" not present");
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 if (!curType.equals(type)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 throw new RuntimeException("a different type of name \"" + type.getName() + "\" was present");
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 nameToTypeMap.remove(type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
454 TypeDataBase. Throws a RuntimeException if an integer constant
a61af66fc99e Initial load
duke
parents:
diff changeset
455 with this name was already present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
456 public void addIntConstant(String name, int value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 if (nameToIntConstantMap.get(name) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 throw new RuntimeException("int constant of name \"" + name + "\" already present");
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 nameToIntConstantMap.put(name, new Integer(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
465 TypeDataBase. Throws a RuntimeException if an integer constant
a61af66fc99e Initial load
duke
parents:
diff changeset
466 with this name was not present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
467 public void removeIntConstant(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 Integer curConstant = (Integer) nameToIntConstantMap.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
469 if (curConstant == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 throw new RuntimeException("int constant of name \"" + name + "\" not present");
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 nameToIntConstantMap.remove(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
477 TypeDataBase. Throws a RuntimeException if a long constant with
a61af66fc99e Initial load
duke
parents:
diff changeset
478 this name was already present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
479 public void addLongConstant(String name, long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 if (nameToLongConstantMap.get(name) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
481 throw new RuntimeException("long constant of name \"" + name + "\" already present");
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 nameToLongConstantMap.put(name, new Long(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 /** This method should only be used by the builder of the
a61af66fc99e Initial load
duke
parents:
diff changeset
488 TypeDataBase. Throws a RuntimeException if a long constant with
a61af66fc99e Initial load
duke
parents:
diff changeset
489 this name was not present. */
a61af66fc99e Initial load
duke
parents:
diff changeset
490 public void removeLongConstant(String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 Long curConstant = (Long) nameToLongConstantMap.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 if (curConstant == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 throw new RuntimeException("long constant of name \"" + name + "\" not present");
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 nameToLongConstantMap.remove(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }