Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
+++ new/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
1 1 /*
2 - * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
2 + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 package sun.jvm.hotspot.code;
26 26
27 27 import java.io.*;
28 28 import java.util.*;
29 29
30 30 import sun.jvm.hotspot.asm.x86.*;
31 31 import sun.jvm.hotspot.compiler.*;
32 32 import sun.jvm.hotspot.debugger.*;
33 33 import sun.jvm.hotspot.runtime.*;
34 34 import sun.jvm.hotspot.types.*;
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
35 35 import sun.jvm.hotspot.utilities.*;
36 36
37 37 public class CodeBlob extends VMObject {
38 38 private static AddressField nameField;
39 39 private static CIntegerField sizeField;
40 40 private static CIntegerField headerSizeField;
41 41 private static CIntegerField relocationSizeField;
42 42 private static CIntegerField instructionsOffsetField;
43 43 private static CIntegerField frameCompleteOffsetField;
44 44 private static CIntegerField dataOffsetField;
45 - private static CIntegerField oopsOffsetField;
46 - private static CIntegerField oopsLengthField;
47 45 private static CIntegerField frameSizeField;
48 46 private static AddressField oopMapsField;
49 47
50 48 // Only used by server compiler on x86; computed over in SA rather
51 49 // than relying on computation in target VM
52 50 private static final int NOT_YET_COMPUTED = -2;
53 51 private static final int UNDEFINED = -1;
54 52 private int linkOffset = NOT_YET_COMPUTED;
55 53 private static int matcherInterpreterFramePointerReg;
56 54
57 55 static {
58 56 VM.registerVMInitializedObserver(new Observer() {
59 57 public void update(Observable o, Object data) {
60 58 initialize(VM.getVM().getTypeDataBase());
61 59 }
62 60 });
63 61 }
64 62
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
65 63 private static void initialize(TypeDataBase db) {
66 64 Type type = db.lookupType("CodeBlob");
67 65
68 66 nameField = type.getAddressField("_name");
69 67 sizeField = type.getCIntegerField("_size");
70 68 headerSizeField = type.getCIntegerField("_header_size");
71 69 relocationSizeField = type.getCIntegerField("_relocation_size");
72 70 frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
73 71 instructionsOffsetField = type.getCIntegerField("_instructions_offset");
74 72 dataOffsetField = type.getCIntegerField("_data_offset");
75 - oopsOffsetField = type.getCIntegerField("_oops_offset");
76 - oopsLengthField = type.getCIntegerField("_oops_length");
77 73 frameSizeField = type.getCIntegerField("_frame_size");
78 74 oopMapsField = type.getAddressField("_oop_maps");
79 75
80 76 if (VM.getVM().isServerCompiler()) {
81 77 matcherInterpreterFramePointerReg =
82 78 db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
83 79 }
84 80 }
85 81
86 82 public CodeBlob(Address addr) {
87 83 super(addr);
88 84 }
89 85
90 86 // Typing
91 87 public boolean isBufferBlob() { return false; }
92 88 public boolean isNMethod() { return false; }
93 89 public boolean isRuntimeStub() { return false; }
94 90 public boolean isDeoptimizationStub() { return false; }
95 91 public boolean isUncommonTrapStub() { return false; }
96 92 public boolean isExceptionStub() { return false; }
97 93 public boolean isSafepointStub() { return false; }
98 94
99 95 // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod()
100 96 public boolean isJavaMethod() { return false; }
101 97 public boolean isNativeMethod() { return false; }
102 98 /** On-Stack Replacement method */
103 99 public boolean isOSRMethod() { return false; }
104 100
105 101 // Boundaries
106 102 public Address headerBegin() {
107 103 return addr;
108 104 }
109 105
110 106 public Address headerEnd() {
111 107 return addr.addOffsetTo(headerSizeField.getValue(addr));
112 108 }
113 109
114 110 // FIXME: add RelocInfo
115 111 // public RelocInfo relocationBegin();
116 112 // public RelocInfo relocationEnd();
117 113
118 114 public Address instructionsBegin() {
119 115 return headerBegin().addOffsetTo(instructionsOffsetField.getValue(addr));
120 116 }
121 117
122 118 public Address instructionsEnd() {
123 119 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
124 120 }
125 121
126 122 public Address dataBegin() {
127 123 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
128 124 }
129 125
130 126 public Address dataEnd() {
131 127 return headerBegin().addOffsetTo(sizeField.getValue(addr));
132 128 }
133 129
134 - public Address oopsBegin() {
135 - return headerBegin().addOffsetTo(oopsOffsetField.getValue(addr));
136 - }
137 -
138 - public Address oopsEnd() {
139 - return oopsBegin().addOffsetTo(getOopsLength());
140 - }
141 -
142 130 // Offsets
143 131 public int getRelocationOffset() { return (int) headerSizeField.getValue(addr); }
144 132 public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); }
145 133 public int getDataOffset() { return (int) dataOffsetField.getValue(addr); }
146 - public int getOopsOffset() { return (int) oopsOffsetField.getValue(addr); }
147 134
148 135 // Sizes
149 136 public int getSize() { return (int) sizeField.getValue(addr); }
150 137 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); }
151 138 // FIXME: add getRelocationSize()
152 139 public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); }
153 140 public int getDataSize() { return (int) dataEnd().minus(dataBegin()); }
154 141
155 142 // Containment
156 143 public boolean blobContains(Address addr) { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); }
157 144 // FIXME: add relocationContains
158 145 public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); }
159 146 public boolean dataContains(Address addr) { return dataBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); }
160 - public boolean oopsContains(Address addr) { return oopsBegin().lessThanOrEqual(addr) && oopsEnd().greaterThan(addr); }
161 147 public boolean contains(Address addr) { return instructionsContains(addr); }
162 148 public boolean isFrameCompleteAt(Address a) { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); }
163 149
164 - /** Support for oops in scopes and relocs. Note: index 0 is reserved for null. */
165 - public OopHandle getOopAt(int index) {
166 - if (index == 0) return null;
167 - if (Assert.ASSERTS_ENABLED) {
168 - Assert.that(index > 0 && index <= getOopsLength(), "must be a valid non-zero index");
169 - }
170 - return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize());
171 - }
172 -
173 150 // Reclamation support (really only used by the nmethods, but in order to get asserts to work
174 151 // in the CodeCache they are defined virtual here)
175 152 public boolean isZombie() { return false; }
176 153 public boolean isLockedByVM() { return false; }
177 154
178 155 /** OopMap for frame; can return null if none available */
179 156 public OopMapSet getOopMaps() {
180 157 Address oopMapsAddr = oopMapsField.getValue(addr);
181 158 if (oopMapsAddr == null) {
182 159 return null;
183 160 }
184 161 return new OopMapSet(oopMapsAddr);
185 162 }
186 163 // FIXME: not yet implementable
187 164 // void set_oop_maps(OopMapSet* p);
188 165
189 166 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
190 167 Address pc = returnAddress;
191 168 if (Assert.ASSERTS_ENABLED) {
192 169 Assert.that(getOopMaps() != null, "nope");
193 170 }
194 171 return getOopMaps().findMapAtOffset(pc.minus(instructionsBegin()), debugging);
195 172 }
196 173
197 174 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); }
198 175 // FIXME;
199 176
200 177 /** NOTE: this returns a size in BYTES in this system! */
201 178 public long getFrameSize() {
202 179 return VM.getVM().getAddressSize() * frameSizeField.getValue(addr);
203 180 }
204 181
205 182 // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
206 183 public boolean callerMustGCArguments(JavaThread thread) { return false; }
207 184
208 185 public String getName() {
209 186 return CStringUtilities.getString(nameField.getValue(addr));
210 187 }
211 188
212 189 // FIXME: NOT FINISHED
213 190
214 191 // FIXME: add more accessors
215 192
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
216 193 public void print() {
217 194 printOn(System.out);
218 195 }
219 196
220 197 public void printOn(PrintStream tty) {
221 198 tty.print(getName());
222 199 printComponentsOn(tty);
223 200 }
224 201
225 202 protected void printComponentsOn(PrintStream tty) {
226 - // FIXME: add relocation information
227 203 tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " +
228 204 " data: [" + dataBegin() + ", " + dataEnd() + "), " +
229 - " oops: [" + oopsBegin() + ", " + oopsEnd() + "), " +
230 205 " frame size: " + getFrameSize());
231 206 }
232 -
233 - //--------------------------------------------------------------------------------
234 - // Internals only below this point
235 - //
236 -
237 - private int getOopsLength() {
238 - return (int) oopsLengthField.getValue(addr);
239 - }
240 207 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX