author | never |
Mon, 05 Sep 2011 17:09:05 -0700 | |
changeset 10517 | f92c9ff3a15f |
parent 9946 | b3d5b50e2289 |
child 13391 | 30245956af37 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
9946
b3d5b50e2289
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
6418
diff
changeset
|
2 |
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.code; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
||
30 |
import sun.jvm.hotspot.asm.x86.*; |
|
31 |
import sun.jvm.hotspot.compiler.*; |
|
32 |
import sun.jvm.hotspot.debugger.*; |
|
33 |
import sun.jvm.hotspot.runtime.*; |
|
34 |
import sun.jvm.hotspot.types.*; |
|
35 |
import sun.jvm.hotspot.utilities.*; |
|
36 |
||
37 |
public class CodeBlob extends VMObject { |
|
38 |
private static AddressField nameField; |
|
39 |
private static CIntegerField sizeField; |
|
40 |
private static CIntegerField headerSizeField; |
|
41 |
private static CIntegerField relocationSizeField; |
|
6418 | 42 |
private static CIntegerField contentOffsetField; |
43 |
private static CIntegerField codeOffsetField; |
|
1 | 44 |
private static CIntegerField frameCompleteOffsetField; |
45 |
private static CIntegerField dataOffsetField; |
|
46 |
private static CIntegerField frameSizeField; |
|
47 |
private static AddressField oopMapsField; |
|
48 |
||
49 |
// Only used by server compiler on x86; computed over in SA rather |
|
50 |
// than relying on computation in target VM |
|
51 |
private static final int NOT_YET_COMPUTED = -2; |
|
52 |
private static final int UNDEFINED = -1; |
|
53 |
private int linkOffset = NOT_YET_COMPUTED; |
|
54 |
private static int matcherInterpreterFramePointerReg; |
|
55 |
||
56 |
static { |
|
57 |
VM.registerVMInitializedObserver(new Observer() { |
|
58 |
public void update(Observable o, Object data) { |
|
59 |
initialize(VM.getVM().getTypeDataBase()); |
|
60 |
} |
|
61 |
}); |
|
62 |
} |
|
63 |
||
64 |
private static void initialize(TypeDataBase db) { |
|
65 |
Type type = db.lookupType("CodeBlob"); |
|
66 |
||
67 |
nameField = type.getAddressField("_name"); |
|
68 |
sizeField = type.getCIntegerField("_size"); |
|
69 |
headerSizeField = type.getCIntegerField("_header_size"); |
|
70 |
relocationSizeField = type.getCIntegerField("_relocation_size"); |
|
71 |
frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset"); |
|
6418 | 72 |
contentOffsetField = type.getCIntegerField("_content_offset"); |
73 |
codeOffsetField = type.getCIntegerField("_code_offset"); |
|
1 | 74 |
dataOffsetField = type.getCIntegerField("_data_offset"); |
75 |
frameSizeField = type.getCIntegerField("_frame_size"); |
|
76 |
oopMapsField = type.getAddressField("_oop_maps"); |
|
77 |
||
78 |
if (VM.getVM().isServerCompiler()) { |
|
79 |
matcherInterpreterFramePointerReg = |
|
80 |
db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue(); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
public CodeBlob(Address addr) { |
|
85 |
super(addr); |
|
86 |
} |
|
87 |
||
88 |
// Typing |
|
89 |
public boolean isBufferBlob() { return false; } |
|
90 |
public boolean isNMethod() { return false; } |
|
91 |
public boolean isRuntimeStub() { return false; } |
|
92 |
public boolean isDeoptimizationStub() { return false; } |
|
93 |
public boolean isUncommonTrapStub() { return false; } |
|
94 |
public boolean isExceptionStub() { return false; } |
|
95 |
public boolean isSafepointStub() { return false; } |
|
9946
b3d5b50e2289
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
6418
diff
changeset
|
96 |
public boolean isRicochetBlob() { return false; } |
b3d5b50e2289
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
6418
diff
changeset
|
97 |
public boolean isAdapterBlob() { return false; } |
1 | 98 |
|
99 |
// Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod() |
|
100 |
public boolean isJavaMethod() { return false; } |
|
101 |
public boolean isNativeMethod() { return false; } |
|
102 |
/** On-Stack Replacement method */ |
|
103 |
public boolean isOSRMethod() { return false; } |
|
104 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
105 |
public NMethod asNMethodOrNull() { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
106 |
if (isNMethod()) return (NMethod)this; |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
107 |
return null; |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
108 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
109 |
|
1 | 110 |
// Boundaries |
111 |
public Address headerBegin() { |
|
112 |
return addr; |
|
113 |
} |
|
114 |
||
115 |
public Address headerEnd() { |
|
116 |
return addr.addOffsetTo(headerSizeField.getValue(addr)); |
|
117 |
} |
|
118 |
||
119 |
// FIXME: add RelocInfo |
|
120 |
// public RelocInfo relocationBegin(); |
|
121 |
// public RelocInfo relocationEnd(); |
|
122 |
||
6418 | 123 |
public Address contentBegin() { |
124 |
return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); |
|
1 | 125 |
} |
126 |
||
6418 | 127 |
public Address contentEnd() { |
128 |
return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
|
129 |
} |
|
130 |
||
131 |
public Address codeBegin() { |
|
132 |
return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); |
|
133 |
} |
|
134 |
||
135 |
public Address codeEnd() { |
|
1 | 136 |
return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
137 |
} |
|
138 |
||
139 |
public Address dataBegin() { |
|
140 |
return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
|
141 |
} |
|
142 |
||
143 |
public Address dataEnd() { |
|
144 |
return headerBegin().addOffsetTo(sizeField.getValue(addr)); |
|
145 |
} |
|
146 |
||
147 |
// Offsets |
|
6418 | 148 |
public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); } |
149 |
public int getContentOffset() { return (int) contentOffsetField.getValue(addr); } |
|
150 |
public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); } |
|
151 |
public int getDataOffset() { return (int) dataOffsetField .getValue(addr); } |
|
1 | 152 |
|
153 |
// Sizes |
|
6418 | 154 |
public int getSize() { return (int) sizeField .getValue(addr); } |
155 |
public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } |
|
1 | 156 |
// FIXME: add getRelocationSize() |
6418 | 157 |
public int getContentSize() { return (int) contentEnd().minus(contentBegin()); } |
158 |
public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); } |
|
159 |
public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); } |
|
1 | 160 |
|
161 |
// Containment |
|
6418 | 162 |
public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
1 | 163 |
// FIXME: add relocationContains |
6418 | 164 |
public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); } |
165 |
public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); } |
|
166 |
public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
|
167 |
public boolean contains(Address addr) { return contentContains(addr); } |
|
168 |
public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); } |
|
1 | 169 |
|
170 |
// Reclamation support (really only used by the nmethods, but in order to get asserts to work |
|
171 |
// in the CodeCache they are defined virtual here) |
|
172 |
public boolean isZombie() { return false; } |
|
173 |
public boolean isLockedByVM() { return false; } |
|
174 |
||
175 |
/** OopMap for frame; can return null if none available */ |
|
176 |
public OopMapSet getOopMaps() { |
|
177 |
Address oopMapsAddr = oopMapsField.getValue(addr); |
|
178 |
if (oopMapsAddr == null) { |
|
179 |
return null; |
|
180 |
} |
|
181 |
return new OopMapSet(oopMapsAddr); |
|
182 |
} |
|
183 |
// FIXME: not yet implementable |
|
184 |
// void set_oop_maps(OopMapSet* p); |
|
185 |
||
186 |
public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { |
|
187 |
Address pc = returnAddress; |
|
188 |
if (Assert.ASSERTS_ENABLED) { |
|
189 |
Assert.that(getOopMaps() != null, "nope"); |
|
190 |
} |
|
6418 | 191 |
return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging); |
1 | 192 |
} |
193 |
||
194 |
// virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } |
|
195 |
// FIXME; |
|
196 |
||
197 |
/** NOTE: this returns a size in BYTES in this system! */ |
|
198 |
public long getFrameSize() { |
|
199 |
return VM.getVM().getAddressSize() * frameSizeField.getValue(addr); |
|
200 |
} |
|
201 |
||
202 |
// Returns true, if the next frame is responsible for GC'ing oops passed as arguments |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
9946
diff
changeset
|
203 |
public boolean callerMustGCArguments() { return false; } |
1 | 204 |
|
205 |
public String getName() { |
|
206 |
return CStringUtilities.getString(nameField.getValue(addr)); |
|
207 |
} |
|
208 |
||
209 |
// FIXME: NOT FINISHED |
|
210 |
||
211 |
// FIXME: add more accessors |
|
212 |
||
213 |
public void print() { |
|
214 |
printOn(System.out); |
|
215 |
} |
|
216 |
||
217 |
public void printOn(PrintStream tty) { |
|
218 |
tty.print(getName()); |
|
219 |
printComponentsOn(tty); |
|
220 |
} |
|
221 |
||
222 |
protected void printComponentsOn(PrintStream tty) { |
|
6418 | 223 |
tty.println(" content: [" + contentBegin() + ", " + contentEnd() + "), " + |
224 |
" code: [" + codeBegin() + ", " + codeEnd() + "), " + |
|
1 | 225 |
" data: [" + dataBegin() + ", " + dataEnd() + "), " + |
226 |
" frame size: " + getFrameSize()); |
|
227 |
} |
|
228 |
} |