annotate agent/src/share/classes/sun/jvm/hotspot/types/TypeDataBase.java @ 3939:f6f3bb0ee072

7088955: add C2 IR support to the SA Reviewed-by: kvn
author never
date Sun, 11 Sep 2011 14:48:24 -0700
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.types;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.Iterator;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.Address;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 public interface TypeDataBase {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 /** Equivalent to lookupType(cTypeName, true) */
a61af66fc99e Initial load
duke
parents:
diff changeset
32 public Type lookupType(String cTypeName);
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 /** For simplicity of the initial implementation, this is not
a61af66fc99e Initial load
duke
parents:
diff changeset
35 guaranteed to work for primitive types. If throwException is
a61af66fc99e Initial load
duke
parents:
diff changeset
36 true, throws an (unspecified) run-time exception if the type is
a61af66fc99e Initial load
duke
parents:
diff changeset
37 not found. */
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public Type lookupType(String cTypeName, boolean throwException);
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 /** Equivalent to lookupIntConstant(constantName, true) */
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public Integer lookupIntConstant(String constantName);
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 /* For convenience, this interface also encapsulates the fetching of
a61af66fc99e Initial load
duke
parents:
diff changeset
44 integer constants, i.e., enums. If no constant of this name was
a61af66fc99e Initial load
duke
parents:
diff changeset
45 present, either throws an (unspecified) run-time exception or
a61af66fc99e Initial load
duke
parents:
diff changeset
46 returns null. */
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public Integer lookupIntConstant(String constantName, boolean throwException);
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 /** Equivalent to lookupLongConstant(constantName, true) */
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public Long lookupLongConstant(String constantName);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 /* For convenience, this interface also encapsulates the fetching of
a61af66fc99e Initial load
duke
parents:
diff changeset
53 long constants (those requiring 64 bits on 64-bit platforms). If
a61af66fc99e Initial load
duke
parents:
diff changeset
54 no constant of this name was present, either throws an
a61af66fc99e Initial load
duke
parents:
diff changeset
55 (unspecified) run-time exception or returns null. */
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public Long lookupLongConstant(String constantName, boolean throwException);
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 /** Accessors for types representing the Java primitive types; used
a61af66fc99e Initial load
duke
parents:
diff changeset
59 for both proper type checking and for walking down Java arrays. */
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public Type getJBooleanType();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public Type getJByteType();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public Type getJCharType();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public Type getJDoubleType();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public Type getJFloatType();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public Type getJIntType();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public Type getJLongType();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public Type getJShortType();
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /** Returns the size of a C address in bytes. This is currently
a61af66fc99e Initial load
duke
parents:
diff changeset
70 needed in order to properly traverse an array of pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 Traversing an array of structs, for example, is possible by
a61af66fc99e Initial load
duke
parents:
diff changeset
72 looking up the type of the struct and multiplying the index by
a61af66fc99e Initial load
duke
parents:
diff changeset
73 its size when indexing off of a base Address. (FIXME: what about
a61af66fc99e Initial load
duke
parents:
diff changeset
74 alignment?) */
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public long getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 /** Returns the size of an oop in bytes. This is currently needed in
a61af66fc99e Initial load
duke
parents:
diff changeset
78 order to properly traverse an array of oops; it is distinguished
a61af66fc99e Initial load
duke
parents:
diff changeset
79 from the address size, above, because object pointers could
a61af66fc99e Initial load
duke
parents:
diff changeset
80 conceivably have a different representation than direct
a61af66fc99e Initial load
duke
parents:
diff changeset
81 pointers. Traversing an array of structs, for example, is
a61af66fc99e Initial load
duke
parents:
diff changeset
82 possible by looking up the type of the struct and multiplying
a61af66fc99e Initial load
duke
parents:
diff changeset
83 the index by its size when indexing off of a base Address. */
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public long getOopSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 /** <P> This is an experimental interface emulating C++'s run-time
a61af66fc99e Initial load
duke
parents:
diff changeset
87 type information (RTTI) mechanism: determines whether the given
a61af66fc99e Initial load
duke
parents:
diff changeset
88 address is a pointer to the start of a C++ object of precisely
a61af66fc99e Initial load
duke
parents:
diff changeset
89 the given type -- it does not search superclasses of the type.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 The convention is that this returns false for the null pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 It is needed to allow wrapper Java objects of the appropriate
a61af66fc99e Initial load
duke
parents:
diff changeset
92 type to be constructed for existing C++ objects of polymorphic
a61af66fc99e Initial load
duke
parents:
diff changeset
93 type. This method is only intended to work for C++ types
a61af66fc99e Initial load
duke
parents:
diff changeset
94 (implying that we should rename this package and the classes
a61af66fc99e Initial load
duke
parents:
diff changeset
95 contained within back to "ctypes"). Further, since the vptr
a61af66fc99e Initial load
duke
parents:
diff changeset
96 offset in an object is known at compile time but not necessarily
a61af66fc99e Initial load
duke
parents:
diff changeset
97 at runtime (unless debugging information is available), it is
a61af66fc99e Initial load
duke
parents:
diff changeset
98 reasonable for an implementation of this method to search nearby
a61af66fc99e Initial load
duke
parents:
diff changeset
99 memory for the (known) vtbl value for the given type. For this
a61af66fc99e Initial load
duke
parents:
diff changeset
100 reason, this method is not intended to support scans through
a61af66fc99e Initial load
duke
parents:
diff changeset
101 memory finding C++ objects, but is instead targeted towards
a61af66fc99e Initial load
duke
parents:
diff changeset
102 discovering the true type of a pointer assumed to be
a61af66fc99e Initial load
duke
parents:
diff changeset
103 intact. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 <P> The reason this method was placed in the type database is
a61af66fc99e Initial load
duke
parents:
diff changeset
106 that the latter is the first level at which it could be exposed,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 and placing it here could avoid modifying the Type interface. It
a61af66fc99e Initial load
duke
parents:
diff changeset
108 is unclear what other, if any, vtbl access would be useful (or
a61af66fc99e Initial load
duke
parents:
diff changeset
109 implementable), so we are trying to avoid changing interfaces at
a61af66fc99e Initial load
duke
parents:
diff changeset
110 this point to support this kind of functionality. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 <P> This method necessarily does not support multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
113 inheritance. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public boolean addressTypeIsEqualToType(Address addr, Type type);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 /** Helper routine for guessing the most derived type of a
a61af66fc99e Initial load
duke
parents:
diff changeset
117 polymorphic C++ object. Iterates the type database calling
a61af66fc99e Initial load
duke
parents:
diff changeset
118 addressTypeIsEqualToType for all known types. Returns a matching
a61af66fc99e Initial load
duke
parents:
diff changeset
119 Type for the given address if one was found, or null if none was
a61af66fc99e Initial load
duke
parents:
diff changeset
120 found. */
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public Type guessTypeForAddress(Address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
123 /** Helper routine for guessing the most derived type of a
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
124 polymorphic C++ object. Requires a baseType that must be virtual
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
125 so that lookup can be performed without false positives */
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
126 public Type findDynamicTypeForAddress(Address addr, Type baseType);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
127
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 /** Returns an Iterator over the Types in the database. */
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public Iterator getTypes();
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 /** Returns an Iterator over the String names of the integer
a61af66fc99e Initial load
duke
parents:
diff changeset
132 constants in the database. */
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public Iterator getIntConstants();
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 /** Returns an Iterator over the String names of the long constants
a61af66fc99e Initial load
duke
parents:
diff changeset
136 in the database. */
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public Iterator getLongConstants();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }