annotate agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java @ 3908:7588156f5cf9

7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244) Reviewed-by: kvn
author never
date Mon, 05 Sep 2011 17:09:05 -0700
parents c18cbe5936b8
children 1d7922586cf6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
2 * Copyright (c) 2000, 2008, 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: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
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: 196
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.runtime;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.compiler.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.c1.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.oops.*;
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
36 import sun.jvm.hotspot.runtime.sparc.SPARCFrame;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 /** <P> A frame represents a physical stack frame (an activation).
a61af66fc99e Initial load
duke
parents:
diff changeset
41 Frames can be C or Java frames, and the Java frames can be
a61af66fc99e Initial load
duke
parents:
diff changeset
42 interpreted or compiled. In contrast, vframes represent
a61af66fc99e Initial load
duke
parents:
diff changeset
43 source-level activations, so that one physical frame can
a61af66fc99e Initial load
duke
parents:
diff changeset
44 correspond to multiple source level frames because of inlining.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 <P> NOTE that this is not a VMObject and does not wrap an Address
a61af66fc99e Initial load
duke
parents:
diff changeset
48 -- this is an actual port of the VM's Frame code to Java. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 <P> NOTE also that this is incomplete -- just trying to get
a61af66fc99e Initial load
duke
parents:
diff changeset
51 reading of interpreted frames working for now, so all non-core and
a61af66fc99e Initial load
duke
parents:
diff changeset
52 setter methods are removed for now. (FIXME) </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public abstract class Frame implements Cloneable {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 /** A raw stack pointer. The accessor getSP() will return a real (usable)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 stack pointer (e.g. from Thread::last_Java_sp) */
a61af66fc99e Initial load
duke
parents:
diff changeset
57 protected Address raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 /** Program counter (the next instruction after the call) */
a61af66fc99e Initial load
duke
parents:
diff changeset
60 protected Address pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 protected boolean deoptimized;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public Frame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 deoptimized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 });
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 /** Size of constMethodOopDesc for computing BCI from BCP (FIXME: hack) */
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private static long constMethodOopDescSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
77
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
78 private static int pcReturnOffset;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
79
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
80 public static int pcReturnOffset() {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
81 return pcReturnOffset;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
82 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
83
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 Type constMethodOopType = db.lookupType("constMethodOopDesc");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // FIXME: not sure whether alignment here is correct or how to
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // force it (round up to address size?)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 constMethodOopDescSize = constMethodOopType.getSize();
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
89
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
90 pcReturnOffset = db.lookupIntConstant("frame::pc_return_offset").intValue();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 protected int bcpToBci(Address bcp, ConstMethod cm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // bcp will be null for interpreter native methods
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // in addition depending on where we catch the system the value can
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // be a bcp or a bci.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (bcp == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 long bci = bcp.minus(null);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (bci >= 0 && bci < cm.getCodeSize()) return (int) bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return (int) (bcp.minus(cm.getHandle()) - constMethodOopDescSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 protected int bcpToBci(Address bcp, Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return bcpToBci(bcp, m.getConstMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public abstract Object clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 /** pc: Returns the pc at which this frame will continue normally.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 It must point at the beginning of the next instruction to
a61af66fc99e Initial load
duke
parents:
diff changeset
113 execute. */
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public Address getPC() { return pc; }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public void setPC(Address newpc) { pc = newpc; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public boolean isDeoptimized() { return deoptimized; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
118 public CodeBlob cb() {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
119 return VM.getVM().getCodeCache().findBlob(getPC());
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
120 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
121
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public abstract Address getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public abstract Address getID();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public abstract Address getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 /** testers -- platform dependent */
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public abstract boolean equals(Object arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 /** type testers */
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public boolean isInterpretedFrame() { return VM.getVM().getInterpreter().contains(getPC()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public boolean isJavaFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (isInterpretedFrame()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (isCompiledFrame()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 /** Java frame called from C? */
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public boolean isEntryFrame() { return VM.getVM().getStubRoutines().returnsToCallStub(getPC()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public boolean isNativeFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return (cb != null && cb.isNativeMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
145 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
150 public boolean isRicochetFrame() {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
151 CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
152 RicochetBlob rcb = VM.getVM().ricochetBlob();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
153 return (cb == rcb && rcb != null && rcb.returnsToBounceAddr(getPC()));
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
154 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
155
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public boolean isCompiledFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 Assert.that(!VM.getVM().isCore(), "noncore builds only");
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return (cb != null && cb.isJavaMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
164 public boolean isRuntimeFrame() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 Assert.that(!VM.getVM().isCore(), "noncore builds only");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
169 if (cb == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (cb.isRuntimeStub()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 else return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 /** oldest frame? (has no sender) FIXME: this is modified from the
a61af66fc99e Initial load
duke
parents:
diff changeset
177 C++ code to handle the debugging situation where we try to
a61af66fc99e Initial load
duke
parents:
diff changeset
178 traverse the stack for, for example, the signal thread, and
a61af66fc99e Initial load
duke
parents:
diff changeset
179 don't find any valid Java frames. Would really like to put the
a61af66fc99e Initial load
duke
parents:
diff changeset
180 second half of the conditional in some sort of debugging-only if
a61af66fc99e Initial load
duke
parents:
diff changeset
181 statement. */
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // *** FIXME: THE CALL TO isJavaFrame() IS WAY TOO EXPENSIVE!!!!! ***
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public boolean isFirstFrame() { return ((isEntryFrame() && entryFrameIsFirst()) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
184 (!isJavaFrame() && !hasSenderPD())); }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 /** same for Java frame */
a61af66fc99e Initial load
duke
parents:
diff changeset
186 public boolean isFirstJavaFrame() { throw new RuntimeException("not yet implemented"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 /** This is an addition for debugging purposes on platforms which
a61af66fc99e Initial load
duke
parents:
diff changeset
189 have the notion of signals. */
a61af66fc99e Initial load
duke
parents:
diff changeset
190 public abstract boolean isSignalHandlerFrameDbg();
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 /** If this is a signal handler frame (again, on a platform with a
a61af66fc99e Initial load
duke
parents:
diff changeset
193 notion of signals), get the signal number. */
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public abstract int getSignalNumberDbg();
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 /** If this is a signal handler frame (again, on a platform with a
a61af66fc99e Initial load
duke
parents:
diff changeset
197 notion of signals), get the name of the signal. */
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public abstract String getSignalNameDbg();
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 /** performs sanity checks on interpreted frames. */
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public abstract boolean isInterpretedFrameValid();
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 /** tells whether this frame is marked for deoptimization */
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public boolean shouldBeDeoptimized() { throw new RuntimeException("not yet implemented"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 /** tells whether this frame can be deoptimized */
a61af66fc99e Initial load
duke
parents:
diff changeset
207 public boolean canBeDeoptimized() { throw new RuntimeException("not yet implemented"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 /** returns the sending frame */
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public abstract Frame sender(RegisterMap map, CodeBlob nm);
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 /** equivalent to sender(map, null) */
a61af66fc99e Initial load
duke
parents:
diff changeset
213 public Frame sender(RegisterMap map) { return sender(map, null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 /** returns the sender, but skips conversion frames */
a61af66fc99e Initial load
duke
parents:
diff changeset
216 public Frame realSender(RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Frame result = sender(map);
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
219 while (result.isRuntimeFrame() ||
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
220 result.isRicochetFrame()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
221 result = result.sender(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return sender(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 /** Platform-dependent query indicating whether this frame has a
a61af66fc99e Initial load
duke
parents:
diff changeset
230 sender. Should return true if it is possible to call sender() at
a61af66fc99e Initial load
duke
parents:
diff changeset
231 all on this frame. (This is currently only needed for the
a61af66fc99e Initial load
duke
parents:
diff changeset
232 debugging system, if a stack trace is attempted for a Java
a61af66fc99e Initial load
duke
parents:
diff changeset
233 thread which has no Java frames, i.e., the signal thread; we
a61af66fc99e Initial load
duke
parents:
diff changeset
234 have to know to stop traversal at the bottom frame.) */
a61af66fc99e Initial load
duke
parents:
diff changeset
235 protected abstract boolean hasSenderPD();
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // All frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // A low-level interface for vframes:
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 /** Returns the address of the requested "slot" on the stack. Slots
a61af66fc99e Initial load
duke
parents:
diff changeset
242 are as wide as addresses, so are 32 bits wide on a 32-bit
a61af66fc99e Initial load
duke
parents:
diff changeset
243 machine and 64 bits wide on a 64-bit machine. */
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public Address addressOfStackSlot(int slot) { return getFP().addOffsetTo(slot * VM.getVM().getAddressSize()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 /** Fetches the OopHandle at the requested slot */
a61af66fc99e Initial load
duke
parents:
diff changeset
247 public OopHandle getOopHandleAt(int slot) { return addressOfStackSlot(slot).getOopHandleAt(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 /** Fetches the OopHandle at the slot, adjusted for compiler frames */
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // FIXME: looks like this is only used for compiled frames
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // public OopHandle getOopHandleAtAdjusted(MethodOop method, int slot) { return addressOfStackSlot(slot).getOopHandleAt(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // FIXME: Not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // public void setOopHandleAt(int slot, OopHandle value) { addressOfStackSlot(slot).setOopHandleAt(0, value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 /** Fetches the (Java) int at the requested slot */
a61af66fc99e Initial load
duke
parents:
diff changeset
255 public int getIntAt(int slot) { return addressOfStackSlot(slot).getJIntAt(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // FIXME: Not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // public void setIntAt(int slot, int value) { addressOfStackSlot(slot).setJIntAt(0, value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 /** returns the frame size in stack slots */
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public abstract long frameSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 /** Link (i.e., the pointer to the previous frame) */
a61af66fc99e Initial load
duke
parents:
diff changeset
263 public abstract Address getLink();
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // public abstract void setLink(Address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 /** Return address */
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public abstract Address getSenderPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // FIXME: currently unimplementable
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // public abstract void setSenderPC(Address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 /** The frame's original SP, before any extension by an interpreted
a61af66fc99e Initial load
duke
parents:
diff changeset
272 callee; used for packing debug info into vframeArray objects and
a61af66fc99e Initial load
duke
parents:
diff changeset
273 vframeArray lookup. */
a61af66fc99e Initial load
duke
parents:
diff changeset
274 public abstract Address getUnextendedSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 /** Returns the stack pointer of the calling frame */
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public abstract Address getSenderSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // Interpreter frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
281 //
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 public abstract Address addressOfInterpreterFrameLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public Address addressOfInterpreterFrameLocal(int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return addressOfInterpreterFrameLocals().getAddressAt(0).addOffsetTo(-slot * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // void interpreter_frame_set_locals(intptr_t* locs);
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // NOTE that the accessor "addressOfInterpreterFrameBCX" has
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // necessarily been eliminated. The byte code pointer is inherently
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // an interior pointer to a Method (the bytecodes follow the
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // methodOopDesc data structure) and therefore acquisition of it in
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // this system can not be allowed. All accesses to interpreter frame
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // byte codes are via the byte code index (BCI).
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 /** Byte code index. In the underlying frame, what is actually
a61af66fc99e Initial load
duke
parents:
diff changeset
300 stored is a byte code pointer (BCP), which is converted to a BCI
a61af66fc99e Initial load
duke
parents:
diff changeset
301 and back by the GC when methods are moved. In this system,
a61af66fc99e Initial load
duke
parents:
diff changeset
302 interior pointers are not allowed, so we must make the access to
a61af66fc99e Initial load
duke
parents:
diff changeset
303 the interpreter frame's BCI atomic with respect to GC. This may
a61af66fc99e Initial load
duke
parents:
diff changeset
304 mean implementation with an underlying call through native code
a61af66fc99e Initial load
duke
parents:
diff changeset
305 into the VM or a magic sequence in the compiler. (FIXME) */
a61af66fc99e Initial load
duke
parents:
diff changeset
306 public abstract int getInterpreterFrameBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // public abstract void setInterpreterFrameBCI(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // public abstract Address addressOfInterpreterCalleeReceiver(Symbol signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 /** Find receiver for an invoke when arguments are just pushed on
a61af66fc99e Initial load
duke
parents:
diff changeset
314 stack (i.e., callee stack-frame is not setup) */
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // public OopHandle getInterpreterCalleeReceiver(SymbolOop signature) { return addressOfInterpreterCalleeReceiver(signature).getOopHandleAt(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // Expression stack (may go up or down, direction == 1 or -1)
a61af66fc99e Initial load
duke
parents:
diff changeset
320 //
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 public abstract Address addressOfInterpreterFrameExpressionStack();
a61af66fc99e Initial load
duke
parents:
diff changeset
323 public abstract int getInterpreterFrameExpressionStackDirection();
a61af66fc99e Initial load
duke
parents:
diff changeset
324 public Address addressOfInterpreterFrameExpressionStackSlot(int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 return addressOfInterpreterFrameExpressionStack().addOffsetTo(-slot * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 /** Top of expression stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
329 public abstract Address addressOfInterpreterFrameTOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 /** Expression stack from top down */
a61af66fc99e Initial load
duke
parents:
diff changeset
332 public abstract Address addressOfInterpreterFrameTOSAt(int slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 /** FIXME: is this portable? */
a61af66fc99e Initial load
duke
parents:
diff changeset
335 public int getInterpreterFrameExpressionStackSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 return (int) (1 + (getInterpreterFrameExpressionStackDirection() *
a61af66fc99e Initial load
duke
parents:
diff changeset
337 (addressOfInterpreterFrameTOS().minus(addressOfInterpreterFrameExpressionStack()))));
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 public abstract Address getInterpreterFrameSenderSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // public abstract void setInterpreterFrameSenderSP(Address senderSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // BasicObjectLocks:
a61af66fc99e Initial load
duke
parents:
diff changeset
346 //
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 public abstract BasicObjectLock interpreterFrameMonitorBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 public abstract BasicObjectLock interpreterFrameMonitorEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 /** NOTE: this returns a size in BYTES in this system! */
a61af66fc99e Initial load
duke
parents:
diff changeset
351 public abstract int interpreterFrameMonitorSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 public BasicObjectLock nextMonitorInInterpreterFrame(BasicObjectLock cur) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 return new BasicObjectLock(cur.address().addOffsetTo(interpreterFrameMonitorSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355 public BasicObjectLock previousMonitorInInterpreterFrame(BasicObjectLock cur) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 return new BasicObjectLock(cur.address().addOffsetTo(-1 * interpreterFrameMonitorSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // interpreter_frame_monitor_begin is higher in memory than interpreter_frame_monitor_end
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // Interpreter_frame_monitor_begin points to one element beyond the oldest one,
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // interpreter_frame_monitor_end points to the youngest one, or if there are none,
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // it points to one beyond where the first element will be.
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // interpreter_frame_monitor_size reports the allocation size of a monitor in the interpreter stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // this value is >= BasicObjectLock::size(), and may be rounded up
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // FIXME: avoiding implementing this for now if possible
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // public void interpreter_frame_set_monitor_end(BasicObjectLock* value);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // public void interpreter_frame_verify_monitor(BasicObjectLock* value) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 //
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // Tells whether the current interpreter_frame frame pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // corresponds to the old compiled/deoptimized fp
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // The receiver used to be a top level frame
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // public boolean interpreter_frame_equals_unpacked_fp(intptr_t* fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // Method and constant pool cache:
a61af66fc99e Initial load
duke
parents:
diff changeset
377 //
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 /** Current method */
a61af66fc99e Initial load
duke
parents:
diff changeset
380 public abstract Address addressOfInterpreterFrameMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 /** Current method */
a61af66fc99e Initial load
duke
parents:
diff changeset
383 public Method getInterpreterFrameMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 return (Method) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameMethod().getOopHandleAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 /** Current method */
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // public void setInterpreterFrameMethod(Method method);
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 /** Constant pool cache */
a61af66fc99e Initial load
duke
parents:
diff changeset
392 public abstract Address addressOfInterpreterFrameCPCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
393 /** Constant pool cache */
a61af66fc99e Initial load
duke
parents:
diff changeset
394 public ConstantPoolCache getInterpreterFrameCPCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 return (ConstantPoolCache) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameCPCache().getOopHandleAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // Entry frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
400 //
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 public abstract JavaCallWrapper getEntryFrameCallWrapper();
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // FIXME: add
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // inline intptr_t* entry_frame_argument_at(int offset) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 /** Tells whether there is another chunk of Delta stack above */
a61af66fc99e Initial load
duke
parents:
diff changeset
409 public boolean entryFrameIsFirst() { return (getEntryFrameCallWrapper().getLastJavaSP() == null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
412 // Safepoints:
a61af66fc99e Initial load
duke
parents:
diff changeset
413 //
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 protected abstract Address addressOfSavedOopResult();
a61af66fc99e Initial load
duke
parents:
diff changeset
416 protected abstract Address addressOfSavedReceiver();
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 public OopHandle getSavedOopResult() {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 return addressOfSavedOopResult().getOopHandleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // public void setSavedOopResult(OopHandle obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 public OopHandle getSavedReceiver() {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 return addressOfSavedReceiver().getOopHandleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // public void setSavedReceiver(OopHandle obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
431
a61af66fc99e Initial load
duke
parents:
diff changeset
432 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // Oop traversals:
a61af66fc99e Initial load
duke
parents:
diff changeset
434 //
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 public void oopsInterpretedArgumentsDo(Symbol signature, boolean isStatic, AddressVisitor f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 ArgumentOopFinder finder = new ArgumentOopFinder(signature, isStatic, this, f);
a61af66fc99e Initial load
duke
parents:
diff changeset
438 finder.oopsDo();
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 /** Conversion from an VMReg::Name to physical stack location */
a61af66fc99e Initial load
duke
parents:
diff changeset
442 public Address oopMapRegToLocation(VMReg reg, RegisterMap regMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 VMReg stack0 = VM.getVM().getVMRegImplInfo().getStack0();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 if (reg.lessThan(stack0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // If it is passed in a register, it got spilled in the stub frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
446 return regMap.getLocation(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
448 long spOffset = VM.getVM().getAddressSize() * reg.minus(stack0);
a61af66fc99e Initial load
duke
parents:
diff changeset
449 return getUnextendedSP().addOffsetTo(spOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 public void oopsDo(AddressVisitor oopVisitor, RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 if (isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 oopsInterpretedDo(oopVisitor, map);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 } else if (isEntryFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 oopsEntryDo(oopVisitor, map);
a61af66fc99e Initial load
duke
parents:
diff changeset
458 } else if (VM.getVM().getCodeCache().contains(getPC())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 oopsCodeBlobDo(oopVisitor, map);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 Assert.that(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // Printing code
a61af66fc99e Initial load
duke
parents:
diff changeset
467 //
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 public void printValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 printValueOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 public void printValueOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // FIXME;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 }
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // FIXME;
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 public void interpreterFramePrintOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // FIXME;
a61af66fc99e Initial load
duke
parents:
diff changeset
487 }
a61af66fc99e Initial load
duke
parents:
diff changeset
488
a61af66fc99e Initial load
duke
parents:
diff changeset
489 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
490 // Get/set typed locals from a frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // Respects platform dependent word-ordering.
a61af66fc99e Initial load
duke
parents:
diff changeset
492 //
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // FIXME: avoiding implementing this for now if possible
a61af66fc99e Initial load
duke
parents:
diff changeset
494 //
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // Currently these work only for interpreted frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // Todo: make these work for compiled frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
497 //
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // oop get_local_object(jint slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // jint get_local_int (jint slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // jlong get_local_long (jint slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // jfloat get_local_float (jint slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // jdouble get_local_double(jint slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
503 //
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // void set_local_object(jint slot, oop obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // void set_local_int (jint slot, jint i);
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // void set_local_long (jint slot, jlong l);
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // void set_local_float (jint slot, jfloat f);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // void set_local_double(jint slot, jdouble d);
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // FIXME: add safepoint code, oops_do, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // FIXME: NOT FINISHED
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516
a61af66fc99e Initial load
duke
parents:
diff changeset
517 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
519 //
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // /** Helper method for better factored code in frame::sender */
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // private frame sender_for_entry_frame(RegisterMap* map) { throw new RuntimeException("not yet implemented"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // private frame sender_for_interpreter_frame(RegisterMap* map) { throw new RuntimeException("not yet implemented"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 //
a61af66fc99e Initial load
duke
parents:
diff changeset
526 // Oop iteration (FIXME: NOT FINISHED)
a61af66fc99e Initial load
duke
parents:
diff changeset
527 //
a61af66fc99e Initial load
duke
parents:
diff changeset
528
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 private static class InterpVisitor implements OopMapVisitor {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 private AddressVisitor addressVisitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 public InterpVisitor(AddressVisitor oopVisitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 setAddressVisitor(oopVisitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 public void setAddressVisitor(AddressVisitor addressVisitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 this.addressVisitor = addressVisitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
540
a61af66fc99e Initial load
duke
parents:
diff changeset
541 public void visitOopLocation(Address oopAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 addressVisitor.visitAddress(oopAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 public void visitDerivedOopLocation(Address baseOopAddr, Address derivedOopAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
546 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
547 Assert.that(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
548 } else if (VM.getVM().isServerCompiler() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
549 VM.getVM().useDerivedPointerTable()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 Assert.that(false, "FIXME: add derived pointer table");
a61af66fc99e Initial load
duke
parents:
diff changeset
551 }
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 public void visitValueLocation(Address valueAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
557 public void visitNarrowOopLocation(Address compOopAddr) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
558 addressVisitor.visitCompOopAddress(compOopAddr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
559 }
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561
a61af66fc99e Initial load
duke
parents:
diff changeset
562 private void oopsInterpretedDo(AddressVisitor oopVisitor, RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
563 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
564 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
565 }
a61af66fc99e Initial load
duke
parents:
diff changeset
566 Method m = getInterpreterFrameMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
567 int bci = getInterpreterFrameBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // FIXME: Seeing this sometimes
a61af66fc99e Initial load
duke
parents:
diff changeset
570 if (VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
571 if (bci < 0 || bci >= m.getCodeSize()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
572 }
a61af66fc99e Initial load
duke
parents:
diff changeset
573
a61af66fc99e Initial load
duke
parents:
diff changeset
574 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
575 // Assert.that(VM.getVM().getUniverse().heap().isIn(m), "method must be valid oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
576 Assert.that((m.isNative() && (bci == 0)) || ((bci >= 0) && (bci < m.getCodeSize())), "invalid bci value");
a61af66fc99e Initial load
duke
parents:
diff changeset
577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 // Handle the monitor elements in the activation
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // FIXME: monitor information not yet exposed
a61af66fc99e Initial load
duke
parents:
diff changeset
581 // for (
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // BasicObjectLock* current = interpreter_frame_monitor_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // current < interpreter_frame_monitor_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // current = next_monitor_in_interpreter_frame(current)
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
586 //#ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
587 // interpreter_frame_verify_monitor(current);
a61af66fc99e Initial load
duke
parents:
diff changeset
588 //#endif
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // current->oops_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
591
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // process fixed part
a61af66fc99e Initial load
duke
parents:
diff changeset
593 oopVisitor.visitAddress(addressOfInterpreterFrameMethod());
a61af66fc99e Initial load
duke
parents:
diff changeset
594 oopVisitor.visitAddress(addressOfInterpreterFrameCPCache());
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 // FIXME: expose interpreterFrameMirrorOffset
a61af66fc99e Initial load
duke
parents:
diff changeset
597 // if (m.isNative() && m.isStatic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 // oopVisitor.visitAddress(getFP().addOffsetTo(interpreterFrameMirrorOffset));
a61af66fc99e Initial load
duke
parents:
diff changeset
599 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
600
a61af66fc99e Initial load
duke
parents:
diff changeset
601 int maxLocals = (int) (m.isNative() ? m.getSizeOfParameters() : m.getMaxLocals());
a61af66fc99e Initial load
duke
parents:
diff changeset
602 InterpreterFrameClosure blk = new InterpreterFrameClosure(this, maxLocals, (int) m.getMaxStack(), oopVisitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // process locals & expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
605 OopMapCacheEntry mask = m.getMaskFor(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
606 mask.iterateOop(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
607
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // process a callee's arguments if we are at a call site
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // (i.e., if we are at an invoke bytecode)
a61af66fc99e Initial load
duke
parents:
diff changeset
610 if (map.getIncludeArgumentOops() && !m.isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 BytecodeInvoke call = BytecodeInvoke.atCheck(m, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
612 if (call != null && getInterpreterFrameExpressionStackSize() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
613 // we are at a call site & the expression stack is not empty
a61af66fc99e Initial load
duke
parents:
diff changeset
614 // => process callee's arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
615 //
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // Note: The expression stack can be empty if an exception
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // occured during method resolution/execution. In all
a61af66fc99e Initial load
duke
parents:
diff changeset
618 // cases we empty the expression stack completely be-
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // fore handling the exception (the exception handling
a61af66fc99e Initial load
duke
parents:
diff changeset
620 // code in the interpreter calls a blocking runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
621 // routine which can cause this code to be executed).
a61af66fc99e Initial load
duke
parents:
diff changeset
622 // (was bug gri 7/27/98)
a61af66fc99e Initial load
duke
parents:
diff changeset
623 oopsInterpretedArgumentsDo(call.signature(), call.isInvokestatic(), oopVisitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 private void oopsEntryDo (AddressVisitor oopVisitor, RegisterMap regMap) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
629 private void oopsCodeBlobDo (AddressVisitor oopVisitor, RegisterMap regMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
631 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
632 Assert.that(cb != null, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
634 if (cb == VM.getVM().ricochetBlob()) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
635 oopsRicochetDo(oopVisitor, regMap);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
636 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
637 if (cb.getOopMaps() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
638 OopMapSet.oopsDo(this, cb, regMap, oopVisitor, VM.getVM().isDebugging());
a61af66fc99e Initial load
duke
parents:
diff changeset
639
a61af66fc99e Initial load
duke
parents:
diff changeset
640 // FIXME: add in traversal of argument oops (skipping this for
a61af66fc99e Initial load
duke
parents:
diff changeset
641 // now until we have the other stuff tested)
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
644
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // FIXME: would add this in in non-debugging system
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // If we see an activation belonging to a non_entrant nmethod, we mark it.
a61af66fc99e Initial load
duke
parents:
diff changeset
648 // if (cb->is_nmethod() && ((nmethod *)cb)->is_not_entrant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 // ((nmethod*)cb)->mark_as_seen_on_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
650 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
651 }
a61af66fc99e Initial load
duke
parents:
diff changeset
652
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
653 private void oopsRicochetDo (AddressVisitor oopVisitor, RegisterMap regMap) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
654 // XXX Empty for now
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
655 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
656
0
a61af66fc99e Initial load
duke
parents:
diff changeset
657 // FIXME: implement the above routines, plus add
a61af66fc99e Initial load
duke
parents:
diff changeset
658 // oops_interpreted_arguments_do and oops_compiled_arguments_do
a61af66fc99e Initial load
duke
parents:
diff changeset
659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 //
a61af66fc99e Initial load
duke
parents:
diff changeset
662 // Only used internally, to iterate through oop slots in interpreted
a61af66fc99e Initial load
duke
parents:
diff changeset
663 // frames
a61af66fc99e Initial load
duke
parents:
diff changeset
664 //
a61af66fc99e Initial load
duke
parents:
diff changeset
665 class InterpreterFrameClosure implements OffsetClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 // Used for debugging this code
a61af66fc99e Initial load
duke
parents:
diff changeset
667 private static final boolean DEBUG = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
668
a61af66fc99e Initial load
duke
parents:
diff changeset
669 private Frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
670 private AddressVisitor f;
a61af66fc99e Initial load
duke
parents:
diff changeset
671 private int maxLocals;
a61af66fc99e Initial load
duke
parents:
diff changeset
672 private int maxStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674 InterpreterFrameClosure(Frame fr, int maxLocals, int maxStack, AddressVisitor f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
675 this.fr = fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
676 this.maxLocals = maxLocals;
a61af66fc99e Initial load
duke
parents:
diff changeset
677 this.maxStack = maxStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
678 this.f = f;
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 public void offsetDo(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
682 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
683 System.err.println("Visiting offset " + offset + ", maxLocals = " + maxLocals +
a61af66fc99e Initial load
duke
parents:
diff changeset
684 " for frame " + fr + ", method " +
a61af66fc99e Initial load
duke
parents:
diff changeset
685 fr.getInterpreterFrameMethod().getMethodHolder().getName().asString() +
a61af66fc99e Initial load
duke
parents:
diff changeset
686 fr.getInterpreterFrameMethod().getName().asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
687 }
a61af66fc99e Initial load
duke
parents:
diff changeset
688 Address addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
689 if (offset < maxLocals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
690 addr = fr.addressOfInterpreterFrameLocal(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
691 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
692 Assert.that(AddressOps.gte(addr, fr.getSP()), "must be inside the frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
693 }
a61af66fc99e Initial load
duke
parents:
diff changeset
694 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 System.err.println(" Visiting local at addr " + addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
697 f.visitAddress(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
698 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
699 addr = fr.addressOfInterpreterFrameExpressionStackSlot(offset - maxLocals);
a61af66fc99e Initial load
duke
parents:
diff changeset
700 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 System.err.println(" Address of expression stack slot: " + addr + ", TOS = " +
a61af66fc99e Initial load
duke
parents:
diff changeset
702 fr.addressOfInterpreterFrameTOS());
a61af66fc99e Initial load
duke
parents:
diff changeset
703 }
a61af66fc99e Initial load
duke
parents:
diff changeset
704 // In case of exceptions, the expression stack is invalid and the esp will be reset to express
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel).
a61af66fc99e Initial load
duke
parents:
diff changeset
706 boolean inStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
707 if (fr.getInterpreterFrameExpressionStackDirection() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
708 inStack = AddressOps.lte(addr, fr.addressOfInterpreterFrameTOS());
a61af66fc99e Initial load
duke
parents:
diff changeset
709 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 inStack = AddressOps.gte(addr, fr.addressOfInterpreterFrameTOS());
a61af66fc99e Initial load
duke
parents:
diff changeset
711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
712 if (inStack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
714 System.err.println(" In stack; visiting location.");
a61af66fc99e Initial load
duke
parents:
diff changeset
715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
716 f.visitAddress(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
717 } else if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 System.err.println(" *** WARNING: Address is out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
719 }
a61af66fc99e Initial load
duke
parents:
diff changeset
720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
723
a61af66fc99e Initial load
duke
parents:
diff changeset
724 // Only used internally, to find arguments in interpreted frames
a61af66fc99e Initial load
duke
parents:
diff changeset
725 class ArgumentOopFinder extends SignatureInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
726 private AddressVisitor f;
a61af66fc99e Initial load
duke
parents:
diff changeset
727 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
728 private boolean isStatic;
a61af66fc99e Initial load
duke
parents:
diff changeset
729 private Frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
730
a61af66fc99e Initial load
duke
parents:
diff changeset
731 protected void set(int size, int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
732 offset -= size;
a61af66fc99e Initial load
duke
parents:
diff changeset
733 if (type == BasicType.getTObject() || type == BasicType.getTArray()) oopOffsetDo();
a61af66fc99e Initial load
duke
parents:
diff changeset
734 }
a61af66fc99e Initial load
duke
parents:
diff changeset
735
a61af66fc99e Initial load
duke
parents:
diff changeset
736 private void oopOffsetDo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
737 f.visitAddress(fr.addressOfInterpreterFrameTOSAt(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
739
a61af66fc99e Initial load
duke
parents:
diff changeset
740 public ArgumentOopFinder(Symbol signature, boolean isStatic, Frame fr, AddressVisitor f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
741 super(signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
742
a61af66fc99e Initial load
duke
parents:
diff changeset
743 // compute size of arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
744 int argsSize = new ArgumentSizeComputer(signature).size() + (isStatic ? 0 : 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
745 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
746 Assert.that(!fr.isInterpretedFrame() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
747 argsSize <= fr.getInterpreterFrameExpressionStackSize(), "args cannot be on stack anymore");
a61af66fc99e Initial load
duke
parents:
diff changeset
748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // initialize ArgumentOopFinder
a61af66fc99e Initial load
duke
parents:
diff changeset
750 this.f = f;
a61af66fc99e Initial load
duke
parents:
diff changeset
751 this.fr = fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
752 this.offset = argsSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
753 this.isStatic = isStatic;
a61af66fc99e Initial load
duke
parents:
diff changeset
754 }
a61af66fc99e Initial load
duke
parents:
diff changeset
755
a61af66fc99e Initial load
duke
parents:
diff changeset
756 public void oopsDo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
757 if (!isStatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 --offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
759 oopOffsetDo();
a61af66fc99e Initial load
duke
parents:
diff changeset
760 }
a61af66fc99e Initial load
duke
parents:
diff changeset
761 iterateParameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
763 }