author | zmajo |
Mon, 27 Apr 2015 10:49:43 +0200 | |
changeset 30305 | b92a97e1e9cb |
parent 29571 | 6627b10e05f8 |
child 30590 | 14f7f48c1377 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29571
6627b10e05f8
6313046: Remove unused frame::native_param_addr code
mikael
parents:
13728
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, 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.runtime.x86; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
import sun.jvm.hotspot.code.*; |
|
29 |
import sun.jvm.hotspot.compiler.*; |
|
30 |
import sun.jvm.hotspot.debugger.*; |
|
31 |
import sun.jvm.hotspot.oops.*; |
|
32 |
import sun.jvm.hotspot.runtime.*; |
|
33 |
import sun.jvm.hotspot.types.*; |
|
34 |
import sun.jvm.hotspot.utilities.*; |
|
35 |
||
36 |
/** Specialization of and implementation of abstract methods of the |
|
37 |
Frame class for the x86 family of CPUs. */ |
|
38 |
||
39 |
public class X86Frame extends Frame { |
|
40 |
private static final boolean DEBUG; |
|
41 |
static { |
|
42 |
DEBUG = System.getProperty("sun.jvm.hotspot.runtime.x86.X86Frame.DEBUG") != null; |
|
43 |
} |
|
44 |
||
45 |
// All frames |
|
46 |
private static final int LINK_OFFSET = 0; |
|
47 |
private static final int RETURN_ADDR_OFFSET = 1; |
|
48 |
private static final int SENDER_SP_OFFSET = 2; |
|
49 |
||
50 |
// Interpreter frames |
|
51 |
private static final int INTERPRETER_FRAME_MIRROR_OFFSET = 2; // for native calls only |
|
52 |
private static final int INTERPRETER_FRAME_SENDER_SP_OFFSET = -1; |
|
53 |
private static final int INTERPRETER_FRAME_LAST_SP_OFFSET = INTERPRETER_FRAME_SENDER_SP_OFFSET - 1; |
|
54 |
private static final int INTERPRETER_FRAME_METHOD_OFFSET = INTERPRETER_FRAME_LAST_SP_OFFSET - 1; |
|
55 |
private static int INTERPRETER_FRAME_MDX_OFFSET; // Non-core builds only |
|
56 |
private static int INTERPRETER_FRAME_CACHE_OFFSET; |
|
57 |
private static int INTERPRETER_FRAME_LOCALS_OFFSET; |
|
58 |
private static int INTERPRETER_FRAME_BCX_OFFSET; |
|
59 |
private static int INTERPRETER_FRAME_INITIAL_SP_OFFSET; |
|
60 |
private static int INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET; |
|
61 |
private static int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET; |
|
62 |
||
63 |
// Entry frames |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
64 |
private static int ENTRY_FRAME_CALL_WRAPPER_OFFSET; |
1 | 65 |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
66 |
private static VMReg rbp; |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
67 |
|
1 | 68 |
static { |
69 |
VM.registerVMInitializedObserver(new Observer() { |
|
70 |
public void update(Observable o, Object data) { |
|
71 |
initialize(VM.getVM().getTypeDataBase()); |
|
72 |
} |
|
73 |
}); |
|
74 |
} |
|
75 |
||
76 |
private static synchronized void initialize(TypeDataBase db) { |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
77 |
INTERPRETER_FRAME_MDX_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1; |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
78 |
INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1; |
1 | 79 |
INTERPRETER_FRAME_LOCALS_OFFSET = INTERPRETER_FRAME_CACHE_OFFSET - 1; |
80 |
INTERPRETER_FRAME_BCX_OFFSET = INTERPRETER_FRAME_LOCALS_OFFSET - 1; |
|
81 |
INTERPRETER_FRAME_INITIAL_SP_OFFSET = INTERPRETER_FRAME_BCX_OFFSET - 1; |
|
82 |
INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET; |
|
83 |
INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET; |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
84 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
85 |
ENTRY_FRAME_CALL_WRAPPER_OFFSET = db.lookupIntConstant("frame::entry_frame_call_wrapper_offset"); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
86 |
if (VM.getVM().getAddressSize() == 4) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
87 |
rbp = new VMReg(5); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
88 |
} else { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
89 |
rbp = new VMReg(5 << 1); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
90 |
} |
1 | 91 |
} |
92 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
93 |
|
1 | 94 |
// an additional field beyond sp and pc: |
95 |
Address raw_fp; // frame pointer |
|
96 |
private Address raw_unextendedSP; |
|
97 |
||
98 |
private X86Frame() { |
|
99 |
} |
|
100 |
||
101 |
private void adjustForDeopt() { |
|
102 |
if ( pc != null) { |
|
103 |
// Look for a deopt pc and if it is deopted convert to original pc |
|
104 |
CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc); |
|
105 |
if (cb != null && cb.isJavaMethod()) { |
|
106 |
NMethod nm = (NMethod) cb; |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
107 |
if (pc.equals(nm.deoptHandlerBegin())) { |
1 | 108 |
if (Assert.ASSERTS_ENABLED) { |
109 |
Assert.that(this.getUnextendedSP() != null, "null SP in Java frame"); |
|
110 |
} |
|
111 |
// adjust pc if frame is deoptimized. |
|
112 |
pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset()); |
|
113 |
deoptimized = true; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
||
119 |
public X86Frame(Address raw_sp, Address raw_fp, Address pc) { |
|
120 |
this.raw_sp = raw_sp; |
|
121 |
this.raw_unextendedSP = raw_sp; |
|
122 |
this.raw_fp = raw_fp; |
|
123 |
this.pc = pc; |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
124 |
adjustUnextendedSP(); |
1 | 125 |
|
126 |
// Frame must be fully constructed before this call |
|
127 |
adjustForDeopt(); |
|
128 |
||
129 |
if (DEBUG) { |
|
130 |
System.out.println("X86Frame(sp, fp, pc): " + this); |
|
131 |
dumpStack(); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
public X86Frame(Address raw_sp, Address raw_fp) { |
|
136 |
this.raw_sp = raw_sp; |
|
137 |
this.raw_unextendedSP = raw_sp; |
|
138 |
this.raw_fp = raw_fp; |
|
139 |
this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()); |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
140 |
adjustUnextendedSP(); |
1 | 141 |
|
142 |
// Frame must be fully constructed before this call |
|
143 |
adjustForDeopt(); |
|
144 |
||
145 |
if (DEBUG) { |
|
146 |
System.out.println("X86Frame(sp, fp): " + this); |
|
147 |
dumpStack(); |
|
148 |
} |
|
149 |
} |
|
150 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
151 |
public X86Frame(Address raw_sp, Address raw_unextendedSp, Address raw_fp, Address pc) { |
1 | 152 |
this.raw_sp = raw_sp; |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
153 |
this.raw_unextendedSP = raw_unextendedSp; |
1 | 154 |
this.raw_fp = raw_fp; |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
155 |
this.pc = pc; |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
156 |
adjustUnextendedSP(); |
1 | 157 |
|
158 |
// Frame must be fully constructed before this call |
|
159 |
adjustForDeopt(); |
|
160 |
||
161 |
if (DEBUG) { |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
162 |
System.out.println("X86Frame(sp, unextendedSP, fp, pc): " + this); |
1 | 163 |
dumpStack(); |
164 |
} |
|
165 |
||
166 |
} |
|
167 |
||
168 |
public Object clone() { |
|
169 |
X86Frame frame = new X86Frame(); |
|
170 |
frame.raw_sp = raw_sp; |
|
171 |
frame.raw_unextendedSP = raw_unextendedSP; |
|
172 |
frame.raw_fp = raw_fp; |
|
173 |
frame.pc = pc; |
|
174 |
frame.deoptimized = deoptimized; |
|
175 |
return frame; |
|
176 |
} |
|
177 |
||
178 |
public boolean equals(Object arg) { |
|
179 |
if (arg == null) { |
|
180 |
return false; |
|
181 |
} |
|
182 |
||
183 |
if (!(arg instanceof X86Frame)) { |
|
184 |
return false; |
|
185 |
} |
|
186 |
||
187 |
X86Frame other = (X86Frame) arg; |
|
188 |
||
189 |
return (AddressOps.equal(getSP(), other.getSP()) && |
|
190 |
AddressOps.equal(getUnextendedSP(), other.getUnextendedSP()) && |
|
191 |
AddressOps.equal(getFP(), other.getFP()) && |
|
192 |
AddressOps.equal(getPC(), other.getPC())); |
|
193 |
} |
|
194 |
||
195 |
public int hashCode() { |
|
196 |
if (raw_sp == null) { |
|
197 |
return 0; |
|
198 |
} |
|
199 |
||
200 |
return raw_sp.hashCode(); |
|
201 |
} |
|
202 |
||
203 |
public String toString() { |
|
204 |
return "sp: " + (getSP() == null? "null" : getSP().toString()) + |
|
205 |
", unextendedSP: " + (getUnextendedSP() == null? "null" : getUnextendedSP().toString()) + |
|
206 |
", fp: " + (getFP() == null? "null" : getFP().toString()) + |
|
207 |
", pc: " + (pc == null? "null" : pc.toString()); |
|
208 |
} |
|
209 |
||
210 |
// accessors for the instance variables |
|
211 |
public Address getFP() { return raw_fp; } |
|
212 |
public Address getSP() { return raw_sp; } |
|
213 |
public Address getID() { return raw_sp; } |
|
214 |
||
215 |
// FIXME: not implemented yet (should be done for Solaris/X86) |
|
216 |
public boolean isSignalHandlerFrameDbg() { return false; } |
|
217 |
public int getSignalNumberDbg() { return 0; } |
|
218 |
public String getSignalNameDbg() { return null; } |
|
219 |
||
220 |
public boolean isInterpretedFrameValid() { |
|
221 |
if (Assert.ASSERTS_ENABLED) { |
|
222 |
Assert.that(isInterpretedFrame(), "Not an interpreted frame"); |
|
223 |
} |
|
224 |
||
225 |
// These are reasonable sanity checks |
|
226 |
if (getFP() == null || getFP().andWithMask(0x3) != null) { |
|
227 |
return false; |
|
228 |
} |
|
229 |
||
230 |
if (getSP() == null || getSP().andWithMask(0x3) != null) { |
|
231 |
return false; |
|
232 |
} |
|
233 |
||
234 |
if (getFP().addOffsetTo(INTERPRETER_FRAME_INITIAL_SP_OFFSET * VM.getVM().getAddressSize()).lessThan(getSP())) { |
|
235 |
return false; |
|
236 |
} |
|
237 |
||
238 |
// These are hacks to keep us out of trouble. |
|
239 |
// The problem with these is that they mask other problems |
|
240 |
if (getFP().lessThanOrEqual(getSP())) { |
|
241 |
// this attempts to deal with unsigned comparison above |
|
242 |
return false; |
|
243 |
} |
|
244 |
||
245 |
if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) { |
|
246 |
// stack frames shouldn't be large. |
|
247 |
return false; |
|
248 |
} |
|
249 |
||
250 |
return true; |
|
251 |
} |
|
252 |
||
253 |
// FIXME: not applicable in current system |
|
254 |
// void patch_pc(Thread* thread, address pc); |
|
255 |
||
256 |
public Frame sender(RegisterMap regMap, CodeBlob cb) { |
|
257 |
X86RegisterMap map = (X86RegisterMap) regMap; |
|
258 |
||
259 |
if (Assert.ASSERTS_ENABLED) { |
|
260 |
Assert.that(map != null, "map must be set"); |
|
261 |
} |
|
262 |
||
263 |
// Default is we done have to follow them. The sender_for_xxx will |
|
264 |
// update it accordingly |
|
265 |
map.setIncludeArgumentOops(false); |
|
266 |
||
267 |
if (isEntryFrame()) return senderForEntryFrame(map); |
|
268 |
if (isInterpretedFrame()) return senderForInterpreterFrame(map); |
|
269 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
270 |
if(cb == null) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
271 |
cb = VM.getVM().getCodeCache().findBlob(getPC()); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
272 |
} else { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
273 |
if (Assert.ASSERTS_ENABLED) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
274 |
Assert.that(cb.equals(VM.getVM().getCodeCache().findBlob(getPC())), "Must be the same"); |
1 | 275 |
} |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
276 |
} |
1 | 277 |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
278 |
if (cb != null) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
279 |
return senderForCompiledFrame(map, cb); |
1 | 280 |
} |
281 |
||
282 |
// Must be native-compiled frame, i.e. the marshaling code for native |
|
283 |
// methods that exists in the core system. |
|
284 |
return new X86Frame(getSenderSP(), getLink(), getSenderPC()); |
|
285 |
} |
|
286 |
||
287 |
private Frame senderForEntryFrame(X86RegisterMap map) { |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
288 |
if (DEBUG) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
289 |
System.out.println("senderForEntryFrame"); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
290 |
} |
1 | 291 |
if (Assert.ASSERTS_ENABLED) { |
292 |
Assert.that(map != null, "map must be set"); |
|
293 |
} |
|
294 |
// Java frame called from C; skip all C frames and return top C |
|
295 |
// frame of that chunk as the sender |
|
296 |
X86JavaCallWrapper jcw = (X86JavaCallWrapper) getEntryFrameCallWrapper(); |
|
297 |
if (Assert.ASSERTS_ENABLED) { |
|
298 |
Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero"); |
|
299 |
Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack"); |
|
300 |
} |
|
301 |
X86Frame fr; |
|
302 |
if (jcw.getLastJavaPC() != null) { |
|
303 |
fr = new X86Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP(), jcw.getLastJavaPC()); |
|
304 |
} else { |
|
305 |
fr = new X86Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP()); |
|
306 |
} |
|
307 |
map.clear(); |
|
308 |
if (Assert.ASSERTS_ENABLED) { |
|
309 |
Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); |
|
310 |
} |
|
311 |
return fr; |
|
312 |
} |
|
313 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
314 |
//------------------------------------------------------------------------------ |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
315 |
// frame::adjust_unextended_sp |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
316 |
private void adjustUnextendedSP() { |
30305
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
317 |
// On x86, sites calling method handle intrinsics and lambda forms are treated |
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
318 |
// as any other call site. Therefore, no special action is needed when we are |
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
319 |
// returning to any of these call sites. |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
320 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
321 |
CodeBlob cb = cb(); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
322 |
NMethod senderNm = (cb == null) ? null : cb.asNMethodOrNull(); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
323 |
if (senderNm != null) { |
30305
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
324 |
// If the sender PC is a deoptimization point, get the original PC. |
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
325 |
if (senderNm.isDeoptEntry(getPC()) || |
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
326 |
senderNm.isDeoptMhEntry(getPC())) { |
b92a97e1e9cb
8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents:
29571
diff
changeset
|
327 |
// DEBUG_ONLY(verifyDeoptriginalPc(senderNm, raw_unextendedSp)); |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
328 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
329 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
330 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
331 |
|
1 | 332 |
private Frame senderForInterpreterFrame(X86RegisterMap map) { |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
333 |
if (DEBUG) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
334 |
System.out.println("senderForInterpreterFrame"); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
335 |
} |
1 | 336 |
Address unextendedSP = addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0); |
337 |
Address sp = addressOfStackSlot(SENDER_SP_OFFSET); |
|
338 |
// We do not need to update the callee-save register mapping because above |
|
339 |
// us is either another interpreter frame or a converter-frame, but never |
|
340 |
// directly a compiled frame. |
|
341 |
// 11/24/04 SFG. With the removal of adapter frames this is no longer true. |
|
342 |
// However c2 no longer uses callee save register for java calls so there |
|
343 |
// are no callee register to find. |
|
344 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
345 |
if (map.getUpdateMap()) |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
346 |
updateMapWithSavedLink(map, addressOfStackSlot(LINK_OFFSET)); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
347 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
348 |
return new X86Frame(sp, unextendedSP, getLink(), getSenderPC()); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
349 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
350 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
351 |
private void updateMapWithSavedLink(RegisterMap map, Address savedFPAddr) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
352 |
map.setLocation(rbp, savedFPAddr); |
1 | 353 |
} |
354 |
||
355 |
private Frame senderForCompiledFrame(X86RegisterMap map, CodeBlob cb) { |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
356 |
if (DEBUG) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
357 |
System.out.println("senderForCompiledFrame"); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
358 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
359 |
|
1 | 360 |
// |
361 |
// NOTE: some of this code is (unfortunately) duplicated in X86CurrentFrameGuess |
|
362 |
// |
|
363 |
||
364 |
if (Assert.ASSERTS_ENABLED) { |
|
365 |
Assert.that(map != null, "map must be set"); |
|
366 |
} |
|
367 |
||
368 |
// frame owned by optimizing compiler |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
369 |
if (Assert.ASSERTS_ENABLED) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
370 |
Assert.that(cb.getFrameSize() >= 0, "must have non-zero frame size"); |
1 | 371 |
} |
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
372 |
Address senderSP = getUnextendedSP().addOffsetTo(cb.getFrameSize()); |
1 | 373 |
|
374 |
// On Intel the return_address is always the word on the stack |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
375 |
Address senderPC = senderSP.getAddressAt(-1 * VM.getVM().getAddressSize()); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
376 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
377 |
// This is the saved value of EBP which may or may not really be an FP. |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
378 |
// It is only an FP if the sender is an interpreter frame (or C1?). |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
379 |
Address savedFPAddr = senderSP.addOffsetTo(- SENDER_SP_OFFSET * VM.getVM().getAddressSize()); |
1 | 380 |
|
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
381 |
if (map.getUpdateMap()) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
382 |
// Tell GC to use argument oopmaps for some runtime stubs that need it. |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
383 |
// For C1, the runtime stub might not have oop maps, so set this flag |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
384 |
// outside of update_register_map. |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
385 |
map.setIncludeArgumentOops(cb.callerMustGCArguments()); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
386 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
387 |
if (cb.getOopMaps() != null) { |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
388 |
OopMapSet.updateRegisterMap(this, cb, map, true); |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
389 |
} |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
390 |
|
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
391 |
// Since the prolog does the save and restore of EBP there is no oopmap |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
392 |
// for it so we must fill in its location as if there was an oopmap entry |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
393 |
// since if our caller was compiled code there could be live jvm state in it. |
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
394 |
updateMapWithSavedLink(map, savedFPAddr); |
1 | 395 |
} |
396 |
||
10517
f92c9ff3a15f
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
5547
diff
changeset
|
397 |
return new X86Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC); |
1 | 398 |
} |
399 |
||
400 |
protected boolean hasSenderPD() { |
|
401 |
// FIXME |
|
402 |
// Check for null ebp? Need to do some tests. |
|
403 |
return true; |
|
404 |
} |
|
405 |
||
406 |
public long frameSize() { |
|
407 |
return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize()); |
|
408 |
} |
|
409 |
||
410 |
public Address getLink() { |
|
411 |
return addressOfStackSlot(LINK_OFFSET).getAddressAt(0); |
|
412 |
} |
|
413 |
||
414 |
public Address getUnextendedSP() { return raw_unextendedSP; } |
|
415 |
||
416 |
// Return address: |
|
417 |
public Address getSenderPCAddr() { return addressOfStackSlot(RETURN_ADDR_OFFSET); } |
|
418 |
public Address getSenderPC() { return getSenderPCAddr().getAddressAt(0); } |
|
419 |
||
420 |
public Address getSenderSP() { return addressOfStackSlot(SENDER_SP_OFFSET); } |
|
421 |
||
422 |
public Address addressOfInterpreterFrameLocals() { |
|
423 |
return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET); |
|
424 |
} |
|
425 |
||
426 |
private Address addressOfInterpreterFrameBCX() { |
|
427 |
return addressOfStackSlot(INTERPRETER_FRAME_BCX_OFFSET); |
|
428 |
} |
|
429 |
||
430 |
public int getInterpreterFrameBCI() { |
|
431 |
// FIXME: this is not atomic with respect to GC and is unsuitable |
|
432 |
// for use in a non-debugging, or reflective, system. Need to |
|
433 |
// figure out how to express this. |
|
434 |
Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
435 |
Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
436 |
Method method = (Method)Metadata.instantiateWrapperFor(methodHandle); |
1 | 437 |
return bcpToBci(bcp, method); |
438 |
} |
|
439 |
||
440 |
public Address addressOfInterpreterFrameMDX() { |
|
441 |
return addressOfStackSlot(INTERPRETER_FRAME_MDX_OFFSET); |
|
442 |
} |
|
443 |
||
444 |
// FIXME |
|
445 |
//inline int frame::interpreter_frame_monitor_size() { |
|
446 |
// return BasicObjectLock::size(); |
|
447 |
//} |
|
448 |
||
449 |
// expression stack |
|
450 |
// (the max_stack arguments are used by the GC; see class FrameClosure) |
|
451 |
||
452 |
public Address addressOfInterpreterFrameExpressionStack() { |
|
453 |
Address monitorEnd = interpreterFrameMonitorEnd().address(); |
|
454 |
return monitorEnd.addOffsetTo(-1 * VM.getVM().getAddressSize()); |
|
455 |
} |
|
456 |
||
457 |
public int getInterpreterFrameExpressionStackDirection() { return -1; } |
|
458 |
||
459 |
// top of expression stack |
|
460 |
public Address addressOfInterpreterFrameTOS() { |
|
461 |
return getSP(); |
|
462 |
} |
|
463 |
||
464 |
/** Expression stack from top down */ |
|
465 |
public Address addressOfInterpreterFrameTOSAt(int slot) { |
|
466 |
return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize()); |
|
467 |
} |
|
468 |
||
469 |
public Address getInterpreterFrameSenderSP() { |
|
470 |
if (Assert.ASSERTS_ENABLED) { |
|
471 |
Assert.that(isInterpretedFrame(), "interpreted frame expected"); |
|
472 |
} |
|
473 |
return addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0); |
|
474 |
} |
|
475 |
||
476 |
// Monitors |
|
477 |
public BasicObjectLock interpreterFrameMonitorBegin() { |
|
478 |
return new BasicObjectLock(addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET)); |
|
479 |
} |
|
480 |
||
481 |
public BasicObjectLock interpreterFrameMonitorEnd() { |
|
482 |
Address result = addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET).getAddressAt(0); |
|
483 |
if (Assert.ASSERTS_ENABLED) { |
|
484 |
// make sure the pointer points inside the frame |
|
485 |
Assert.that(AddressOps.gt(getFP(), result), "result must < than frame pointer"); |
|
486 |
Assert.that(AddressOps.lte(getSP(), result), "result must >= than stack pointer"); |
|
487 |
} |
|
488 |
return new BasicObjectLock(result); |
|
489 |
} |
|
490 |
||
491 |
public int interpreterFrameMonitorSize() { |
|
492 |
return BasicObjectLock.size(); |
|
493 |
} |
|
494 |
||
495 |
// Method |
|
496 |
public Address addressOfInterpreterFrameMethod() { |
|
497 |
return addressOfStackSlot(INTERPRETER_FRAME_METHOD_OFFSET); |
|
498 |
} |
|
499 |
||
500 |
// Constant pool cache |
|
501 |
public Address addressOfInterpreterFrameCPCache() { |
|
502 |
return addressOfStackSlot(INTERPRETER_FRAME_CACHE_OFFSET); |
|
503 |
} |
|
504 |
||
505 |
// Entry frames |
|
506 |
public JavaCallWrapper getEntryFrameCallWrapper() { |
|
507 |
return new X86JavaCallWrapper(addressOfStackSlot(ENTRY_FRAME_CALL_WRAPPER_OFFSET).getAddressAt(0)); |
|
508 |
} |
|
509 |
||
510 |
protected Address addressOfSavedOopResult() { |
|
511 |
// offset is 2 for compiler2 and 3 for compiler1 |
|
512 |
return getSP().addOffsetTo((VM.getVM().isClientCompiler() ? 2 : 3) * |
|
513 |
VM.getVM().getAddressSize()); |
|
514 |
} |
|
515 |
||
516 |
protected Address addressOfSavedReceiver() { |
|
517 |
return getSP().addOffsetTo(-4 * VM.getVM().getAddressSize()); |
|
518 |
} |
|
519 |
||
520 |
private void dumpStack() { |
|
521 |
if (getFP() != null) { |
|
522 |
for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize()); |
|
523 |
AddressOps.lte(addr, getFP().addOffsetTo(5 * VM.getVM().getAddressSize())); |
|
524 |
addr = addr.addOffsetTo(VM.getVM().getAddressSize())) { |
|
525 |
System.out.println(addr + ": " + addr.getAddressAt(0)); |
|
526 |
} |
|
527 |
} else { |
|
528 |
for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize()); |
|
529 |
AddressOps.lte(addr, getSP().addOffsetTo(20 * VM.getVM().getAddressSize())); |
|
530 |
addr = addr.addOffsetTo(VM.getVM().getAddressSize())) { |
|
531 |
System.out.println(addr + ": " + addr.getAddressAt(0)); |
|
532 |
} |
|
533 |
} |
|
534 |
} |
|
535 |
} |