annotate agent/src/share/classes/sun/jvm/hotspot/types/Field.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.types;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 /** <P> This is the basic interface which describes a field in a C/C++
a61af66fc99e Initial load
duke
parents:
diff changeset
30 data structure or a Java object. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 <P> The accessors in this class are designed to allow manual
a61af66fc99e Initial load
duke
parents:
diff changeset
33 coercion of the data within the field, which is often necessary
a61af66fc99e Initial load
duke
parents:
diff changeset
34 when interfacing with C programs. Therefore, the accessors here do
a61af66fc99e Initial load
duke
parents:
diff changeset
35 not perform any type checking. Specializations of the Field
a61af66fc99e Initial load
duke
parents:
diff changeset
36 interface, such as JByteField, provide getValue() methods which
a61af66fc99e Initial load
duke
parents:
diff changeset
37 both perform type checking and return the appropriate specialized
a61af66fc99e Initial load
duke
parents:
diff changeset
38 type. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 <P> See @see CIntegerType for a description of why all C integer
a61af66fc99e Initial load
duke
parents:
diff changeset
41 types are bundled into the category "CIntegerType". </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 <P> As an example, coercing a pointer field into an int can be
a61af66fc99e Initial load
duke
parents:
diff changeset
44 done in the following fashion (assuming the application has
a61af66fc99e Initial load
duke
parents:
diff changeset
45 registered an integer type in the type database called
a61af66fc99e Initial load
duke
parents:
diff changeset
46 "intptr_t"): </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 <PRE>
a61af66fc99e Initial load
duke
parents:
diff changeset
49 {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 ...
a61af66fc99e Initial load
duke
parents:
diff changeset
51 Address myObject = ...;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 CIntegerType intptr_tType = (CIntegerType) db.lookupType("intptr_t");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 long addrVal = field.getCInteger(myObject, intptr_tType);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 ...
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 </PRE>
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 FIXME: among other things, this interface is not sufficient to
a61af66fc99e Initial load
duke
parents:
diff changeset
59 describe fields which are themselves arrays (like symbolOop's
a61af66fc99e Initial load
duke
parents:
diff changeset
60 jbyte _body[1]). */
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public interface Field {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 /** Get the name of this field */
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public String getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 /** Get the type of this field */
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public Type getType();
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 /** Get the size, in bytes, of this field. Used for manual data
a61af66fc99e Initial load
duke
parents:
diff changeset
69 structure traversal where necessary. */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public long getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 /** Is this a static field? */
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public boolean isStatic();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 /** The offset of this field, in bytes, in its containing data
a61af66fc99e Initial load
duke
parents:
diff changeset
76 structure, if nonstatic. If this is a static field, throws a
a61af66fc99e Initial load
duke
parents:
diff changeset
77 WrongTypeException. */
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public long getOffset() throws WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 /** The address of this field, if it is a static field. If this is a
a61af66fc99e Initial load
duke
parents:
diff changeset
81 nonstatic field, throws a WrongTypeException. */
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public Address getStaticFieldAddress() throws WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 /** <P> These accessors require that the field be nonstatic;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 otherwise, a WrongTypeException will be thrown. Note that type
a61af66fc99e Initial load
duke
parents:
diff changeset
86 checking is not performed by these accessors in order to allow
a61af66fc99e Initial load
duke
parents:
diff changeset
87 manual type coercion of field data. For better protection when
a61af66fc99e Initial load
duke
parents:
diff changeset
88 accessing primitive fields, use the get(Type)Field accessors in
a61af66fc99e Initial load
duke
parents:
diff changeset
89 Type.java. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 <P> NOTE that the Address passed in to these routines may, in
a61af66fc99e Initial load
duke
parents:
diff changeset
92 fact, be an OopHandle. Specifically, in a reflective system,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 dereferencing operations applied to the OopHandle must be
a61af66fc99e Initial load
duke
parents:
diff changeset
94 performed atomically with respect to GC. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 <P> See @see CIntegerType for a description of why all C integer
a61af66fc99e Initial load
duke
parents:
diff changeset
97 types are bundled into the category "CIntegerType". </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
98 */
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public boolean getJBoolean (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public byte getJByte (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public char getJChar (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public short getJShort (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public int getJInt (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public long getJLong (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 public float getJFloat (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public double getJDouble (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public long getCInteger (Address addr, CIntegerType type)
a61af66fc99e Initial load
duke
parents:
diff changeset
108 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public Address getAddress (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public OopHandle getOopHandle(Address addr)
a61af66fc99e Initial load
duke
parents:
diff changeset
111 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
112 public OopHandle getNarrowOopHandle(Address addr)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
113 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 /** <P> These accessors require that the field be static; otherwise,
a61af66fc99e Initial load
duke
parents:
diff changeset
116 a WrongTypeException will be thrown. Note that type checking is
a61af66fc99e Initial load
duke
parents:
diff changeset
117 not performed by these accessors in order to allow manual type
a61af66fc99e Initial load
duke
parents:
diff changeset
118 coercion of field data. For better protection when accessing
a61af66fc99e Initial load
duke
parents:
diff changeset
119 primitive fields, use the get(Type)Field accessors in
a61af66fc99e Initial load
duke
parents:
diff changeset
120 Type.java. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 <P> NOTE that the Address passed in to these routines may, in
a61af66fc99e Initial load
duke
parents:
diff changeset
123 fact, be an OopHandle. Specifically, in a reflective system,
a61af66fc99e Initial load
duke
parents:
diff changeset
124 dereferencing operations applied to the OopHandle must be
a61af66fc99e Initial load
duke
parents:
diff changeset
125 performed atomically with respect to GC. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 <P> See @see CIntegerType for a description of why all C integer
a61af66fc99e Initial load
duke
parents:
diff changeset
128 types are bundled into the category "CIntegerType". </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
129 */
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public boolean getJBoolean () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public byte getJByte () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public char getJChar () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public float getJFloat () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public double getJDouble () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public int getJInt () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public long getJLong () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public short getJShort () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public long getCInteger (CIntegerType type)
a61af66fc99e Initial load
duke
parents:
diff changeset
139 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public Address getAddress () throws UnmappedAddressException, UnalignedAddressException;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public OopHandle getOopHandle()
a61af66fc99e Initial load
duke
parents:
diff changeset
142 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
143 public OopHandle getNarrowOopHandle()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
144 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }