annotate agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java @ 6972:bd7a7ce2e264

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