1 /*
2 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.types.basic;
26
27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.types.*;
30
31 /** <P> This is a basic implementation of the TypeDataBase interface.
32 It allows an external type database builder to add types to be
33 consumed by a client through the Type interfaces. It has no
34 knowledge of symbol lookup; for example, the builder is
35 responsible for providing the addresses of static fields. </P>
36
37 <P> Among other things, the database builder is responsible for
38 providing the Types for the Java primitive types, as well as their
39 sizes. </P>
40 */
41
42 public class BasicTypeDataBase implements TypeDataBase {
43 private MachineDescription machDesc;
44 private VtblAccess vtblAccess;
45 /** Maps strings to Type objects. This does not contain the primitive types. */
46 private Map nameToTypeMap = new HashMap();
47 /** Maps strings to Integers, used for enums, etc. */
48 private Map nameToIntConstantMap = new HashMap();
49 /** Maps strings to Longs, used for 32/64-bit constants, etc. */
129 return jfloatType;
130 }
131
132 public Type getJIntType() {
133 return jintType;
134 }
135
136 public Type getJLongType() {
137 return jlongType;
138 }
139
140 public Type getJShortType() {
141 return jshortType;
142 }
143
144 public long getAddressSize() {
145 return machDesc.getAddressSize();
146 }
147
148 public long getOopSize() {
149 return machDesc.getOopSize();
150 }
151
152 public boolean addressTypeIsEqualToType(Address addr, Type type) {
153 if (addr == null) {
154 return false;
155 }
156
157 // This implementation should be suitably platform-independent; we
158 // search nearby memory for the vtbl value of the given type.
159
160 Address vtblAddr = vtblAccess.getVtblForType(type);
161
162 if (vtblAddr == null) {
163 // Type was not polymorphic, or an error occurred during lookup
164 if (DEBUG) {
165 System.err.println("BasicTypeDataBase.addressTypeIsEqualToType: vtblAddr == null");
166 }
167
168 return false;
169 }
|
1 /*
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.types.basic;
26
27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.types.*;
30 import sun.jvm.hotspot.runtime.VM;
31
32 /** <P> This is a basic implementation of the TypeDataBase interface.
33 It allows an external type database builder to add types to be
34 consumed by a client through the Type interfaces. It has no
35 knowledge of symbol lookup; for example, the builder is
36 responsible for providing the addresses of static fields. </P>
37
38 <P> Among other things, the database builder is responsible for
39 providing the Types for the Java primitive types, as well as their
40 sizes. </P>
41 */
42
43 public class BasicTypeDataBase implements TypeDataBase {
44 private MachineDescription machDesc;
45 private VtblAccess vtblAccess;
46 /** Maps strings to Type objects. This does not contain the primitive types. */
47 private Map nameToTypeMap = new HashMap();
48 /** Maps strings to Integers, used for enums, etc. */
49 private Map nameToIntConstantMap = new HashMap();
50 /** Maps strings to Longs, used for 32/64-bit constants, etc. */
130 return jfloatType;
131 }
132
133 public Type getJIntType() {
134 return jintType;
135 }
136
137 public Type getJLongType() {
138 return jlongType;
139 }
140
141 public Type getJShortType() {
142 return jshortType;
143 }
144
145 public long getAddressSize() {
146 return machDesc.getAddressSize();
147 }
148
149 public long getOopSize() {
150 return VM.getVM().getOopSize();
151 }
152
153 public boolean addressTypeIsEqualToType(Address addr, Type type) {
154 if (addr == null) {
155 return false;
156 }
157
158 // This implementation should be suitably platform-independent; we
159 // search nearby memory for the vtbl value of the given type.
160
161 Address vtblAddr = vtblAccess.getVtblForType(type);
162
163 if (vtblAddr == null) {
164 // Type was not polymorphic, or an error occurred during lookup
165 if (DEBUG) {
166 System.err.println("BasicTypeDataBase.addressTypeIsEqualToType: vtblAddr == null");
167 }
168
169 return false;
170 }
|