annotate agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java @ 4008:8187c94a9a87

7093690: JSR292: SA-JDI AssertionFailure: Expected raw sp likely got real sp, value was Reviewed-by: kvn, twisti
author never
date Mon, 17 Oct 2011 11:00:41 -0700
parents 7588156f5cf9
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: 218
diff changeset
2 * Copyright (c) 2000, 2006, 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: 218
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 218
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: 218
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.sparc;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.asm.sparc.*;
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.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.runtime.posix.*;
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 /** Specialization of and implementation of abstract methods of the
a61af66fc99e Initial load
duke
parents:
diff changeset
41 Frame class for the SPARC CPU. (FIXME: this is as quick a port as
a61af66fc99e Initial load
duke
parents:
diff changeset
42 possible to get things running; will have to do a better job right
a61af66fc99e Initial load
duke
parents:
diff changeset
43 away.) */
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public class SPARCFrame extends Frame {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // The pc value is the raw return address, plus 8 (pcReturnOffset()).
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // the value of sp and youngerSP that is stored in this object
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // is always, always, always the value that would be found in the
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // register (or window save area) while the target VM was executing.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // The caller of the constructor will alwasy know if has a biased or
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // unbiased version of the stack pointer and can convert real (unbiased)
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // value via a helper routine we supply.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Whenever we return sp or youngerSP values we do not return the internal
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // value but the real (unbiased) pointers since these are the true, usable
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // memory addresses. The outlier case is that of the null pointer. The current
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // mechanism makes null pointers always look null whether biased or not.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // This seems to cause no problems. In theory null real pointers could be biased
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // just like other values however this has impact on things like addOffsetTo()
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // to be able to take an Address that represents null and add an offset to it.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // This doesn't seem worth the bother and the impact on the rest of the code
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // when the biasSP and unbiasSP can make this invisible.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 //
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // The general rule in this code is that when we have a variable like FP, youngerSP, SP
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // that these are real (i.e. unbiased) addresses. The instance variables in a Frame are
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // always raw values. The other rule is that it except for the frame constructors and
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // the unBiasSP helper all methods accept parameters that are real addresses.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /** Optional next-younger SP (used to locate O7, the PC) */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private Address raw_youngerSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 /** Intepreter adjusts the stack pointer to make all locals contiguous */
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private long interpreterSPAdjustmentOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 /** Number of stack entries for longs */
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private static final int WORDS_PER_LONG = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 /** Normal SPARC return is 2 words past PC */
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public static final int PC_RETURN_OFFSET = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 /** Size of each block, in order of increasing address */
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public static final int REGISTER_SAVE_WORDS = 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // FIXME: read these from the remote process
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //#ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // callee_aggregate_return_pointer_words = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //#else
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // callee_aggregate_return_pointer_words = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 //#endif
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public static final int CALLEE_AGGREGATE_RETURN_POINTER_WORDS = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // offset of each block, in order of increasing address:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public static final int REGISTER_SAVE_WORDS_SP_OFFSET = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public static final int CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET = REGISTER_SAVE_WORDS_SP_OFFSET + REGISTER_SAVE_WORDS;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET = (CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET +
a61af66fc99e Initial load
duke
parents:
diff changeset
96 CALLEE_AGGREGATE_RETURN_POINTER_WORDS);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public static final int MEMORY_PARAMETER_WORD_SP_OFFSET = (CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET +
a61af66fc99e Initial load
duke
parents:
diff changeset
98 CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public static final int VARARGS_OFFSET = MEMORY_PARAMETER_WORD_SP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.sparc.SPARCFrame.DEBUG") != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public static Address unBiasSP(Address raw_sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (raw_sp != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return raw_sp.addOffsetTo(VM.getVM().getStackBias());
a61af66fc99e Initial load
duke
parents:
diff changeset
106 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public static Address biasSP(Address real_sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (real_sp != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 System.out.println("biasing realsp: " + real_sp + " biased: " + real_sp.addOffsetTo(-VM.getVM().getStackBias()) );
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return real_sp.addOffsetTo(-VM.getVM().getStackBias());
a61af66fc99e Initial load
duke
parents:
diff changeset
117 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 System.out.println("biasing null realsp");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 //
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // This is used to find the younger sp for a thread thatn has stopped but hasn't
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // conveniently told us the information where we can find the pc or the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // containing the pc that corresponds to last_java_sp. This method will walk
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // the frames trying to find the frame which we contains the data we need.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public static Address findYoungerSP(Address top, Address find) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // top and find are unBiased sp values
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // we return an unBiased value
a61af66fc99e Initial load
duke
parents:
diff changeset
133 Address findRaw = biasSP(find);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (top == null || find == null || findRaw == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 throw new RuntimeException("bad values for findYoungerSP top: " + top + " find: " + find);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // It would be unusual to find more than 20 native frames before we find the java frame
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // we are looking for.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 final int maxFrames = 20;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 Address search = top;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 Address next;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 Address pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 System.out.println("findYoungerSP top: " + top + " find: " + find + " findRaw: " + findRaw);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 while ( count != maxFrames && search != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 next = search.getAddressAt(SPARCRegisters.I6.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 pc = search.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 System.out.println("findYoungerSP next: " + next + " pc: " + pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (next.equals(findRaw)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return search;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 search = unBiasSP(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 System.out.println("findYoungerSP: never found younger, top: " + top + " find: " + find);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public Address getSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 System.out.println("getSP raw: " + raw_sp + " unbiased: " + unBiasSP(raw_sp));
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return unBiasSP(raw_sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public Address getID() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public Address getYoungerSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 System.out.println("getYoungerSP: " + raw_youngerSP + " unbiased: " + unBiasSP(raw_youngerSP));
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return unBiasSP(raw_youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 /** This constructor relies on the fact that the creator of a frame
a61af66fc99e Initial load
duke
parents:
diff changeset
183 has flushed register windows which the frame will refer to, and
a61af66fc99e Initial load
duke
parents:
diff changeset
184 that those register windows will not be reloaded until the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
185 is done reading and writing the stack. Moreover, if the
a61af66fc99e Initial load
duke
parents:
diff changeset
186 "younger_pc" argument points into the register save area of the
a61af66fc99e Initial load
duke
parents:
diff changeset
187 next younger frame (though it need not), the register window for
a61af66fc99e Initial load
duke
parents:
diff changeset
188 that next younger frame must also stay flushed. (The caller is
a61af66fc99e Initial load
duke
parents:
diff changeset
189 responsible for ensuring this.) */
a61af66fc99e Initial load
duke
parents:
diff changeset
190 public SPARCFrame(Address raw_sp, Address raw_youngerSP, boolean youngerFrameIsInterpreted) {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 System.out.println("Constructing frame(1) raw_sp: " + raw_sp + " raw_youngerSP: " + raw_youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null),
a61af66fc99e Initial load
duke
parents:
diff changeset
197 "Expected raw sp likely got real sp, value was " + raw_sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (raw_youngerSP != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 Assert.that((unBiasSP(raw_youngerSP).andWithMask(VM.getVM().getAddressSize() - 1) == null),
a61af66fc99e Initial load
duke
parents:
diff changeset
200 "Expected raw youngerSP likely got real youngerSP, value was " + raw_youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 this.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 this.raw_youngerSP = raw_youngerSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (raw_youngerSP == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // make a deficient frame which doesn't know where its PC is
a61af66fc99e Initial load
duke
parents:
diff changeset
207 pc = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 Address youngerSP = unBiasSP(raw_youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 pc = youngerSP.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow()).addOffsetTo(PC_RETURN_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 Assert.that(youngerSP.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()).
a61af66fc99e Initial load
duke
parents:
diff changeset
214 equals(raw_sp),
a61af66fc99e Initial load
duke
parents:
diff changeset
215 "youngerSP must be valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (youngerFrameIsInterpreted) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 long IsavedSP = SPARCRegisters.IsavedSP.spOffsetInSavedWindow();
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // compute adjustment to this frame's SP made by its interpreted callee
a61af66fc99e Initial load
duke
parents:
diff changeset
222 interpreterSPAdjustmentOffset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Address savedSP = unBiasSP(getYoungerSP().getAddressAt(IsavedSP));
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (savedSP == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if ( DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 System.out.println("WARNING: IsavedSP was null for frame " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 interpreterSPAdjustmentOffset = savedSP.minus(getSP());
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 interpreterSPAdjustmentOffset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if ( pc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // Look for a deopt pc and if it is deopted convert to original pc
a61af66fc99e Initial load
duke
parents:
diff changeset
236 CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 if (cb != null && cb.isJavaMethod()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 NMethod nm = (NMethod) cb;
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
239 if (pc.equals(nm.deoptHandlerBegin())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // adjust pc if frame is deoptimized.
a61af66fc99e Initial load
duke
parents:
diff changeset
241 pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
242 deoptimized = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 /** Make a deficient frame which doesn't know where its PC is (note
a61af66fc99e Initial load
duke
parents:
diff changeset
249 no youngerSP argument) */
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public SPARCFrame(Address raw_sp, Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 System.out.println("Constructing frame(2) raw_sp: " + raw_sp );
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 this.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null),
a61af66fc99e Initial load
duke
parents:
diff changeset
258 "Expected raw sp likely got real sp, value was " + raw_sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 raw_youngerSP = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 this.pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 interpreterSPAdjustmentOffset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 /** Only used internally */
a61af66fc99e Initial load
duke
parents:
diff changeset
266 private SPARCFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 public Object clone() {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 SPARCFrame frame = new SPARCFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 frame.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 frame.pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 frame.raw_youngerSP = raw_youngerSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 frame.interpreterSPAdjustmentOffset = interpreterSPAdjustmentOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 frame.deoptimized = deoptimized;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 public boolean equals(Object arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (arg == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 if (!(arg instanceof SPARCFrame)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 SPARCFrame other = (SPARCFrame) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 return (AddressOps.equal(getSP(), other.getSP()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
291 AddressOps.equal(getFP(), other.getFP()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
292 AddressOps.equal(getPC(), other.getPC()));
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public int hashCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (raw_sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return raw_sp.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 Address fp = getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 Address sp = getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Address youngerSP = getYoungerSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 return "sp: " + (sp == null? "null" : sp.toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
309 ", younger_sp: " + (youngerSP == null? "null" : youngerSP.toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
310 ", fp: " + (fp == null? "null" : fp.toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
311 ", pc: " + (pc == null? "null" : pc.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 /** <P> Identifies a signal handler frame on the stack. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 <P> There are a few different algorithms for doing this, and
a61af66fc99e Initial load
duke
parents:
diff changeset
317 they vary from platform to platform. For example, based on a
a61af66fc99e Initial load
duke
parents:
diff changeset
318 conversation with Dave Dice, Solaris/x86 will be substantially
a61af66fc99e Initial load
duke
parents:
diff changeset
319 simpler to handle than Solaris/SPARC because the signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
320 frame can be identified because of a program counter == -1. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 <P> The dbx group provided code and advice on these topics; the
a61af66fc99e Initial load
duke
parents:
diff changeset
323 code below evolved from theirs, but is not correct/robust.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 Without going into too many details, it seems that looking for
a61af66fc99e Initial load
duke
parents:
diff changeset
325 the incoming argument to the sigacthandler frame (which is what
a61af66fc99e Initial load
duke
parents:
diff changeset
326 this code identifies) is not guaranteed to be stable across
a61af66fc99e Initial load
duke
parents:
diff changeset
327 versions of Solaris, since that function is supplied by
a61af66fc99e Initial load
duke
parents:
diff changeset
328 libthread and is not guaranteed not to clobber I2 before it
a61af66fc99e Initial load
duke
parents:
diff changeset
329 calls __sighndlr later. From discussions, it sounds like a
a61af66fc99e Initial load
duke
parents:
diff changeset
330 robust algorithm which wouldn't require traversal of the
a61af66fc99e Initial load
duke
parents:
diff changeset
331 ucontext chain (used by dbx, but which Dave Dice thinks isn't
a61af66fc99e Initial load
duke
parents:
diff changeset
332 robust in the face of libthread -- need to follow up) would be
a61af66fc99e Initial load
duke
parents:
diff changeset
333 to be able to properly identify the __sighndlr frame, then get
a61af66fc99e Initial load
duke
parents:
diff changeset
334 I2 and treat that as a ucontext. To identify __sighndlr we would
a61af66fc99e Initial load
duke
parents:
diff changeset
335 need to look up that symbol in the remote process and look for a
a61af66fc99e Initial load
duke
parents:
diff changeset
336 program counter within a certain (small) distance. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 <P> If the underlying Debugger supports CDebugger interface, we
a61af66fc99e Initial load
duke
parents:
diff changeset
339 take the approach of __sighnldr symbol. This approach is more robust
a61af66fc99e Initial load
duke
parents:
diff changeset
340 compared to the original hueristic approach. Of course, if there
a61af66fc99e Initial load
duke
parents:
diff changeset
341 is no CDebugger support, we fallback to the hueristic approach. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 <P> The current implementation seems to work with Solaris 2.8.
a61af66fc99e Initial load
duke
parents:
diff changeset
344 A nice property of this system is that if we find a core file
a61af66fc99e Initial load
duke
parents:
diff changeset
345 this algorithm doesn't work on, we can change the code and try
a61af66fc99e Initial load
duke
parents:
diff changeset
346 again, so I'm putting this in as the current mechanism for
a61af66fc99e Initial load
duke
parents:
diff changeset
347 finding signal handler frames on Solaris/SPARC. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
348 public boolean isSignalHandlerFrameDbg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if (cdbg != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 LoadObject dso = cdbg.loadObjectContainingPC(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
352 if (dso != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 ClosestSymbol cs = dso.closestSymbolToPC(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (cs != null && cs.getName().equals("__sighndlr")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 if (getYoungerSP() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // System.err.println(" SPARCFrame.isSignalHandlerFrameDbg: youngerSP = " + getYoungerSP());
a61af66fc99e Initial load
duke
parents:
diff changeset
365 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
367 Address i2 = getSP().getAddressAt(SPARCRegisters.I2.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
368 if (i2 == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371 Address fp = getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // My (mistaken) understanding of the dbx group's code was that
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // the signal handler frame could be identified by testing the
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // incoming argument to see whether it was a certain distance
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // below the frame pointer; in fact, their code did substantially
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // more than this (traversal of the ucontext chain, which this
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // code can't do because the topmost ucontext is not currently
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // available via the proc_service APIs in dbx). The current code
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // appears to work, but is probably not robust.
a61af66fc99e Initial load
duke
parents:
diff changeset
380 int MAJOR_HACK_OFFSET = 8; // Difference between expected location of the ucontext and reality
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // System.err.println(" SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 +
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // ", fp = " + fp + ", raw_youngerSP = " + getYoungerSP());
a61af66fc99e Initial load
duke
parents:
diff changeset
383 boolean res = i2.equals(fp.addOffsetTo(VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET)));
a61af66fc99e Initial load
duke
parents:
diff changeset
384 if (res) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // Qualify this with another test (FIXME: this is a gross heuristic found while testing)
a61af66fc99e Initial load
duke
parents:
diff changeset
386 Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
387 if (sigInfoAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 System.err.println("Frame with fp = " + fp + " looked like a signal handler frame but wasn't");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 res = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public int getSignalNumberDbg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // From looking at the stack trace in dbx, it looks like the
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // siginfo* comes into sigacthandler in I5. It would be much more
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // robust to look at the __sighndlr frame instead, but we can't
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // currently identify that frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Read si_signo out of siginfo*
a61af66fc99e Initial load
duke
parents:
diff changeset
404 return (int) sigInfoAddr.getCIntegerAt(0, 4, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 public String getSignalNameDbg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 return POSIXSignals.getSignalName(getSignalNumberDbg());
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 public boolean isInterpretedFrameValid() {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 Assert.that(isInterpretedFrame(), "Not an interpreted frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // These are reasonable sanity checks
a61af66fc99e Initial load
duke
parents:
diff changeset
416 if (getFP() == null || (getFP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if (getSP() == null || (getSP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422 if (getFP().addOffsetTo(INTERPRETER_FRAME_VM_LOCAL_WORDS * VM.getVM().getAddressSize()).lessThan(getSP())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
423 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
425
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
426 OopHandle methodHandle = addressOfInterpreterFrameMethod().getOopHandleAt(0);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
427
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
428 if (VM.getVM().getObjectHeap().isValidMethod(methodHandle) == false) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
429 return false;
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
430 }
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
431
0
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // These are hacks to keep us out of trouble.
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // The problem with these is that they mask other problems
a61af66fc99e Initial load
duke
parents:
diff changeset
434 if (getFP().lessThanOrEqual(getSP())) { // this attempts to deal with unsigned comparison above
a61af66fc99e Initial load
duke
parents:
diff changeset
435 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) { // stack frames shouldn't be large.
a61af66fc99e Initial load
duke
parents:
diff changeset
438 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // for use in a non-debugging, or reflective, system. Need to
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // figure out how to express this.
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
443 Address bcx = addressOfInterpreterFrameBCX().getAddressAt(0);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
444
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
445 Method method;
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
446 try {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
447 method = (Method) VM.getVM().getObjectHeap().newOop(methodHandle);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
448 } catch (UnknownOopException ex) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
449 return false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
451 int bci = bcpToBci(bcx, method);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
452 //validate bci
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
453 if (bci < 0) return false;
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
454
0
a61af66fc99e Initial load
duke
parents:
diff changeset
455 return true;
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 // Accessors:
a61af66fc99e Initial load
duke
parents:
diff changeset
460 //
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 /** Accessors */
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 public long frameSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 public Address getLink() {
a61af66fc99e Initial load
duke
parents:
diff changeset
469 return unBiasSP(getFP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()));
a61af66fc99e Initial load
duke
parents:
diff changeset
470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // FIXME: not implementable yet
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // public void setLink(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // Assert.that(getLink().equals(addr), "frame nesting is controlled by hardware");
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 public Frame sender(RegisterMap regMap, CodeBlob cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 SPARCRegisterMap map = (SPARCRegisterMap) regMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // Default is we don't have to follow them. The sender_for_xxx
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // will update it accordingly
a61af66fc99e Initial load
duke
parents:
diff changeset
488 map.setIncludeArgumentOops(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
489
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
490 if (isEntryFrame()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
491 return senderForEntryFrame(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 Address youngerSP = getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
495 Address sp = getSenderSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 boolean isInterpreted = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // FIXME: this is a hack to get stackwalking to work in the face
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // of a signal like a SEGV. For debugging purposes it's important
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // that (a) we are able to traverse the stack if we take a signal
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // and (b) that we get the correct program counter in this
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // situation. If we are not using alternate signal stacks then (a)
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // seems to work all the time (on SPARC), but (b) is violated for
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // the frame just below the signal handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // The mechanism for finding the ucontext is not robust. In
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // addition, we may find that we need to be able to fetch more
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // registers from the ucontext than just the program counter,
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // since the register windows on the stack are "stale". This will
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // require substantial restructuring of this frame code, so has
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // been avoided for now.
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // It is difficult to find a clean solution for mixing debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // situations with VM frame traversal. One could consider
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // implementing generic frame traversal in the dbx style and only
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // using the VM's stack walking mechanism on a per-frame basis,
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // for example to traverse Java-level activations in a compiled
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // frame. However, this will probably not interact well with the
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // mechanism for finding oops on the stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 if (VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // If we are a signal handler frame, use a trick: make the
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // youngerSP of the caller frame point to the top of the
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // ucontext's contained register set. This should allow fetching
a61af66fc99e Initial load
duke
parents:
diff changeset
525 // of the registers for the frame just below the signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
526 // frame in the usual fashion.
a61af66fc99e Initial load
duke
parents:
diff changeset
527 if (isSignalHandlerFrameDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
528
a61af66fc99e Initial load
duke
parents:
diff changeset
529 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
530 System.out.println("SPARCFrame.sender: found signal handler frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // Try to give a valid SP and PC for a "deficient frame" since
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // we don't have a real register save area; making this class
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // work by reading its information from a ucontext as well as
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // a register save area is a major undertaking and has been
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // deferred for now. It is very important that the PC is
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // correct, which is why we don't just fall through to the
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // other code (which would read the PC from the stale register
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // window and thereby fail to get the actual location of the
a61af66fc99e Initial load
duke
parents:
diff changeset
541 // fault).
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 long offset = getMContextAreaOffsetInUContext();
a61af66fc99e Initial load
duke
parents:
diff changeset
544 Address fp = sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // System.out.println(" FP: " + fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
546 fp = fp.addOffsetTo(getUContextOffset() + getMContextAreaOffsetInUContext());
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // System.out.println(" start of mcontext: " + fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // FIXME: put these elsewhere. These are the register numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // in /usr/include/sys/regset.h. They might belong in
a61af66fc99e Initial load
duke
parents:
diff changeset
550 // SPARCReigsters.java, but we currently don't have that list
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // of numbers in the SA code (because all of the registers are
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // listed as instances of SPARCRegister) and it appears that
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // our numbering of the registers and this one don't match up.
a61af66fc99e Initial load
duke
parents:
diff changeset
554 int PC_OFFSET_IN_GREGSET = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
555 int SP_OFFSET_IN_GREGSET = 17;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 raw_sp = fp.getAddressAt(VM.getVM().getAddressSize() * SP_OFFSET_IN_GREGSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
557 Address pc = fp.getAddressAt(VM.getVM().getAddressSize() * PC_OFFSET_IN_GREGSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 return new SPARCFrame(raw_sp, pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 }
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
562 // Note: The version of this operation on any platform with callee-save
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
563 // registers must update the register map (if not null).
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
564 // In order to do this correctly, the various subtypes of
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
565 // of frame (interpreted, compiled, glue, native),
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
566 // must be distinguished. There is no need on SPARC for
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
567 // such distinctions, because all callee-save registers are
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
568 // preserved for all frames via SPARC-specific mechanisms.
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
569 //
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
570 // *** HOWEVER, *** if and when we make any floating-point
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
571 // registers callee-saved, then we will have to copy over
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
572 // the RegisterMap update logic from the Intel code.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
573
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
574 if (isRicochetFrame()) return senderForRicochetFrame(map);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
575
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
576 // The constructor of the sender must know whether this frame is interpreted so it can set the
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
577 // sender's _interpreter_sp_adjustment field.
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
578 if (VM.getVM().getInterpreter().contains(pc)) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
579 isInterpreted = true;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
580 map.makeIntegerRegsUnsaved();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
581 map.shiftWindow(sp, youngerSP);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
582 } else {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
583 // Find a CodeBlob containing this frame's pc or elide the lookup and use the
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
584 // supplied blob which is already known to be associated with this frame.
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
585 cb = VM.getVM().getCodeCache().findBlob(pc);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
586 if (cb != null) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
587 // Update the location of all implicitly saved registers
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
588 // as the address of these registers in the register save
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
589 // area (for %o registers we use the address of the %i
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
590 // register in the next younger frame)
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
591 map.shiftWindow(sp, youngerSP);
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
592 if (map.getUpdateMap()) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
593 if (cb.callerMustGCArguments()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
594 map.setIncludeArgumentOops(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
596 if (cb.getOopMaps() != null) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
597 OopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599 }
a61af66fc99e Initial load
duke
parents:
diff changeset
600 }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
601 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 return new SPARCFrame(biasSP(sp), biasSP(youngerSP), isInterpreted);
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 protected boolean hasSenderPD() {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // FIXME: should not happen!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
609 if (getSP() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
610 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
612 if ( unBiasSP(getSP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())) == null ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
613 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
615 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 } catch (RuntimeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
617 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
618 System.out.println("Bad frame " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 throw e;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
623
a61af66fc99e Initial load
duke
parents:
diff changeset
624 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
625 // Return address:
a61af66fc99e Initial load
duke
parents:
diff changeset
626 //
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 public Address getSenderPC() {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 return addressOfI7().getAddressAt(0).addOffsetTo(PC_RETURN_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
631
a61af66fc99e Initial load
duke
parents:
diff changeset
632 // FIXME: currently unimplementable
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // inline void frame::set_sender_pc(address addr) { *I7_addr() = addr - pc_return_offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
634
a61af66fc99e Initial load
duke
parents:
diff changeset
635 public Address getUnextendedSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
636 return getSP().addOffsetTo(interpreterSPAdjustmentOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 public Address getSenderSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
640 return getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 /** Given the next-younger sp for a given frame's sp, compute the
a61af66fc99e Initial load
duke
parents:
diff changeset
644 frame. We need the next-younger sp, because its register save
a61af66fc99e Initial load
duke
parents:
diff changeset
645 area holds the flushed copy of its I7, which is the PC of the
a61af66fc99e Initial load
duke
parents:
diff changeset
646 frame we are interested in. */
a61af66fc99e Initial load
duke
parents:
diff changeset
647 public SPARCFrame afterSave() {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 return new SPARCFrame(biasSP(getYoungerSP()), null);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 /** Accessors for the instance variables */
a61af66fc99e Initial load
duke
parents:
diff changeset
652 public Address getFP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 Address sp = getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
654 if (sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
655 System.out.println("SPARCFrame.getFP(): sp == null");
a61af66fc99e Initial load
duke
parents:
diff changeset
656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
657 Address fpAddr = sp.addOffsetTo(SPARCRegisters.FP.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
658 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
659 Address fp = unBiasSP(fpAddr.getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
660 if (fp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
661 System.out.println("SPARCFrame.getFP(): fp == null (&fp == " + fpAddr + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663 return fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 } catch (RuntimeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
665 System.out.println("SPARCFrame.getFP(): is bad (&fp == " + fpAddr + " sp = " + sp + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
666 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
667 }
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669
a61af66fc99e Initial load
duke
parents:
diff changeset
670 private Address addressOfFPSlot(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
671 return getFP().addOffsetTo(index * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
672 }
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674 // FIXME: temporarily elided
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // // All frames
a61af66fc99e Initial load
duke
parents:
diff changeset
676 //
a61af66fc99e Initial load
duke
parents:
diff changeset
677 // intptr_t* fp_addr_at(int index) const { return &fp()[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
678 // intptr_t* sp_addr_at(int index) const { return &sp()[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
679 // intptr_t fp_at( int index) const { return *fp_addr_at(index); }
a61af66fc99e Initial load
duke
parents:
diff changeset
680 // intptr_t sp_at( int index) const { return *sp_addr_at(index); }
a61af66fc99e Initial load
duke
parents:
diff changeset
681 //
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
683 // inline address* I7_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 // inline address* O7_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
685 //
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // inline address* I0_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // inline address* O0_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
688 //
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // public:
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // // access to SPARC arguments and argument registers
a61af66fc99e Initial load
duke
parents:
diff changeset
691 //
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // intptr_t* register_addr(Register reg) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // return sp_addr_at(reg.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
694 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // intptr_t* memory_param_addr(int param_ix, bool is_in) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 // int offset = callee_register_argument_save_area_sp_offset + param_ix;
a61af66fc99e Initial load
duke
parents:
diff changeset
697 // if (is_in)
a61af66fc99e Initial load
duke
parents:
diff changeset
698 // return fp_addr_at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // else
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // return sp_addr_at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
701 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
702 // intptr_t* param_addr(int param_ix, bool is_in) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
703 // if (param_ix >= callee_register_argument_save_area_words)
a61af66fc99e Initial load
duke
parents:
diff changeset
704 // return memory_param_addr(param_ix, is_in);
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // else if (is_in)
a61af66fc99e Initial load
duke
parents:
diff changeset
706 // return register_addr(Argument(param_ix, true).as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
707 // else {
a61af66fc99e Initial load
duke
parents:
diff changeset
708 // // the registers are stored in the next younger frame
a61af66fc99e Initial load
duke
parents:
diff changeset
709 // // %%% is this really necessary?
a61af66fc99e Initial load
duke
parents:
diff changeset
710 // frame next_younger = after_save();
a61af66fc99e Initial load
duke
parents:
diff changeset
711 // return next_younger.register_addr(Argument(param_ix, true).as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
712 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
713 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
714
a61af66fc99e Initial load
duke
parents:
diff changeset
715 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
716 // Interpreter frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
717 //
a61af66fc99e Initial load
duke
parents:
diff changeset
718
a61af66fc99e Initial load
duke
parents:
diff changeset
719 /** 2 words, also used to save float regs across calls to C */
a61af66fc99e Initial load
duke
parents:
diff changeset
720 public static final int INTERPRETER_FRAME_D_SCRATCH_FP_OFFSET = -2;
a61af66fc99e Initial load
duke
parents:
diff changeset
721 public static final int INTERPRETER_FRAME_L_SCRATCH_FP_OFFSET = -4;
a61af66fc99e Initial load
duke
parents:
diff changeset
722 /** For native calls only */
a61af66fc99e Initial load
duke
parents:
diff changeset
723 public static final int INTERPRETER_FRAME_PADDING_OFFSET = -5;
a61af66fc99e Initial load
duke
parents:
diff changeset
724 /** For native calls only */
a61af66fc99e Initial load
duke
parents:
diff changeset
725 public static final int INTERPRETER_FRAME_MIRROR_OFFSET = -6;
a61af66fc99e Initial load
duke
parents:
diff changeset
726 /** Should be same as above, and should be zero mod 8 */
a61af66fc99e Initial load
duke
parents:
diff changeset
727 public static final int INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET = -6;
a61af66fc99e Initial load
duke
parents:
diff changeset
728 public static final int INTERPRETER_FRAME_VM_LOCAL_WORDS = -INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
729
a61af66fc99e Initial load
duke
parents:
diff changeset
730 /** Interpreter frame set-up needs to save 2 extra words in outgoing
a61af66fc99e Initial load
duke
parents:
diff changeset
731 param area for class and jnienv arguments for native stubs (see
a61af66fc99e Initial load
duke
parents:
diff changeset
732 nativeStubGen_sparc.cpp) */
a61af66fc99e Initial load
duke
parents:
diff changeset
733 public static final int INTERPRETER_FRAME_EXTRA_OUTGOING_ARGUMENT_WORDS = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
736 //
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // // the compiler frame has many of the same fields as the interpreter frame
a61af66fc99e Initial load
duke
parents:
diff changeset
738 // // %%%%% factor out declarations of the shared fields
a61af66fc99e Initial load
duke
parents:
diff changeset
739 // enum compiler_frame_fixed_locals {
a61af66fc99e Initial load
duke
parents:
diff changeset
740 // compiler_frame_d_scratch_fp_offset = -2,
a61af66fc99e Initial load
duke
parents:
diff changeset
741 // compiler_frame_vm_locals_fp_offset = -2, // should be same as above
a61af66fc99e Initial load
duke
parents:
diff changeset
742 //
a61af66fc99e Initial load
duke
parents:
diff changeset
743 // compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
744 // };
a61af66fc99e Initial load
duke
parents:
diff changeset
745 //
a61af66fc99e Initial load
duke
parents:
diff changeset
746 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
747 //
a61af66fc99e Initial load
duke
parents:
diff changeset
748 // // where LcpoolCache is saved:
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // constantPoolCacheOop* interpreter_frame_cpoolcache_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
750 // return (constantPoolCacheOop*)sp_addr_at( LcpoolCache.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
751 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
752 //
a61af66fc99e Initial load
duke
parents:
diff changeset
753 // // where Lmonitors is saved:
a61af66fc99e Initial load
duke
parents:
diff changeset
754 // BasicObjectLock** interpreter_frame_monitors_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
755 // return (BasicObjectLock**) sp_addr_at( Lmonitors.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
756 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
757 // intptr_t** interpreter_frame_esp_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 // return (intptr_t**)sp_addr_at( Lesp.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
759 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
760 //
a61af66fc99e Initial load
duke
parents:
diff changeset
761 // inline void interpreter_frame_set_tos_address(intptr_t* x);
a61af66fc99e Initial load
duke
parents:
diff changeset
762 //
a61af66fc99e Initial load
duke
parents:
diff changeset
763 // // next two fns read and write Lmonitors value,
a61af66fc99e Initial load
duke
parents:
diff changeset
764 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
765 // BasicObjectLock* interpreter_frame_monitors() const { return *interpreter_frame_monitors_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
766 // void interpreter_frame_set_monitors(BasicObjectLock* monitors) { *interpreter_frame_monitors_addr() = monitors; }
a61af66fc99e Initial load
duke
parents:
diff changeset
767 //
a61af66fc99e Initial load
duke
parents:
diff changeset
768 //#ifndef CORE
a61af66fc99e Initial load
duke
parents:
diff changeset
769 //inline oop *frame::pd_compiled_argument_to_location(VMReg::Name reg, RegisterMap reg_map, int arg_size) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
770 // COMPILER1_ONLY(return (oop *) (arg_size - 1 - reg + sp() + memory_parameter_word_sp_offset); )
a61af66fc99e Initial load
duke
parents:
diff changeset
771 // COMPILER2_ONLY(return oopmapreg_to_location(reg, &reg_map); )
a61af66fc99e Initial load
duke
parents:
diff changeset
772 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
773 //#endif
a61af66fc99e Initial load
duke
parents:
diff changeset
774
a61af66fc99e Initial load
duke
parents:
diff changeset
775 // FIXME: NOT FINISHED
a61af66fc99e Initial load
duke
parents:
diff changeset
776 public Address addressOfInterpreterFrameLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
777 return getSP().addOffsetTo(SPARCRegisters.Llocals.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
778 }
a61af66fc99e Initial load
duke
parents:
diff changeset
779
a61af66fc99e Initial load
duke
parents:
diff changeset
780 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
781 // for use in a non-debugging, or reflective, system.
a61af66fc99e Initial load
duke
parents:
diff changeset
782 private Address addressOfInterpreterFrameBCX() {
a61af66fc99e Initial load
duke
parents:
diff changeset
783 // %%%%% reinterpreting Lbcp as a bcx
a61af66fc99e Initial load
duke
parents:
diff changeset
784 return getSP().addOffsetTo(SPARCRegisters.Lbcp.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786
a61af66fc99e Initial load
duke
parents:
diff changeset
787 public int getInterpreterFrameBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
789 // for use in a non-debugging, or reflective, system. Need to
a61af66fc99e Initial load
duke
parents:
diff changeset
790 // figure out how to express this.
a61af66fc99e Initial load
duke
parents:
diff changeset
791 Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
792 OopHandle methodHandle = addressOfInterpreterFrameMethod().getOopHandleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
793 Method method = (Method) VM.getVM().getObjectHeap().newOop(methodHandle);
a61af66fc99e Initial load
duke
parents:
diff changeset
794 return bcpToBci(bcp, method);
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 public Address addressOfInterpreterFrameExpressionStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
798 return addressOfInterpreterFrameMonitors().addOffsetTo(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
799 }
a61af66fc99e Initial load
duke
parents:
diff changeset
800
a61af66fc99e Initial load
duke
parents:
diff changeset
801 public int getInterpreterFrameExpressionStackDirection() {
a61af66fc99e Initial load
duke
parents:
diff changeset
802 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
803 }
a61af66fc99e Initial load
duke
parents:
diff changeset
804
a61af66fc99e Initial load
duke
parents:
diff changeset
805 /** Top of expression stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
806 public Address addressOfInterpreterFrameTOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
807 return getSP().getAddressAt(SPARCRegisters.Lesp.spOffsetInSavedWindow()).addOffsetTo(VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
808 }
a61af66fc99e Initial load
duke
parents:
diff changeset
809
a61af66fc99e Initial load
duke
parents:
diff changeset
810 /** Expression stack from top down */
a61af66fc99e Initial load
duke
parents:
diff changeset
811 public Address addressOfInterpreterFrameTOSAt(int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
812 return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
814
a61af66fc99e Initial load
duke
parents:
diff changeset
815 public Address getInterpreterFrameSenderSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
816 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
817 Assert.that(isInterpretedFrame(), "interpreted frame expected");
a61af66fc99e Initial load
duke
parents:
diff changeset
818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
819 return getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
821
a61af66fc99e Initial load
duke
parents:
diff changeset
822 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
823 //inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 // *interpreter_frame_esp_addr() = x - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
825 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
828 // Monitors:
a61af66fc99e Initial load
duke
parents:
diff changeset
829 //
a61af66fc99e Initial load
duke
parents:
diff changeset
830
a61af66fc99e Initial load
duke
parents:
diff changeset
831 private Address addressOfInterpreterFrameMonitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
832 return getSP().addOffsetTo(SPARCRegisters.Lmonitors.spOffsetInSavedWindow()).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
833 }
a61af66fc99e Initial load
duke
parents:
diff changeset
834
a61af66fc99e Initial load
duke
parents:
diff changeset
835 // Monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
836 public BasicObjectLock interpreterFrameMonitorBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
837 int roundedVMLocalWords = Bits.roundTo(INTERPRETER_FRAME_VM_LOCAL_WORDS, WORDS_PER_LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
838 return new BasicObjectLock(addressOfFPSlot(-1 * roundedVMLocalWords));
a61af66fc99e Initial load
duke
parents:
diff changeset
839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
840
a61af66fc99e Initial load
duke
parents:
diff changeset
841 public BasicObjectLock interpreterFrameMonitorEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
842 return new BasicObjectLock(addressOfInterpreterFrameMonitors());
a61af66fc99e Initial load
duke
parents:
diff changeset
843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
844
a61af66fc99e Initial load
duke
parents:
diff changeset
845 public int interpreterFrameMonitorSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
846 return Bits.roundTo(BasicObjectLock.size(), WORDS_PER_LONG * (int) VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
848
a61af66fc99e Initial load
duke
parents:
diff changeset
849 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
850 // // monitor elements
a61af66fc99e Initial load
duke
parents:
diff changeset
851 //
a61af66fc99e Initial load
duke
parents:
diff changeset
852 // // in keeping with Intel side: end is lower in memory than begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
853 // // and beginning element is oldest element
a61af66fc99e Initial load
duke
parents:
diff changeset
854 // // Also begin is one past last monitor.
a61af66fc99e Initial load
duke
parents:
diff changeset
855 //
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
857 // int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
858 // return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
860 //
a61af66fc99e Initial load
duke
parents:
diff changeset
861 // inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
862 // return interpreter_frame_monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
863 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
864 //
a61af66fc99e Initial load
duke
parents:
diff changeset
865 //
a61af66fc99e Initial load
duke
parents:
diff changeset
866 // inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
867 // interpreter_frame_set_monitors(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
868 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
869 //
a61af66fc99e Initial load
duke
parents:
diff changeset
870 //
a61af66fc99e Initial load
duke
parents:
diff changeset
871 // inline int frame::interpreter_frame_monitor_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
872 // return round_to(BasicObjectLock::size(), WordsPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
873 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
874
a61af66fc99e Initial load
duke
parents:
diff changeset
875 public Address addressOfInterpreterFrameMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
876 return getSP().addOffsetTo(SPARCRegisters.Lmethod.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
877 }
a61af66fc99e Initial load
duke
parents:
diff changeset
878
a61af66fc99e Initial load
duke
parents:
diff changeset
879 public Address addressOfInterpreterFrameCPCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
880 return getSP().addOffsetTo(SPARCRegisters.LcpoolCache.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
881 }
a61af66fc99e Initial load
duke
parents:
diff changeset
882
a61af66fc99e Initial load
duke
parents:
diff changeset
883 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
884 // Entry frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
885 //
a61af66fc99e Initial load
duke
parents:
diff changeset
886
a61af66fc99e Initial load
duke
parents:
diff changeset
887 public JavaCallWrapper getEntryFrameCallWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
888 // Note: adjust this code if the link argument in StubGenerator::call_stub() changes!
a61af66fc99e Initial load
duke
parents:
diff changeset
889 SPARCArgument link = new SPARCArgument(0, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
890 return (JavaCallWrapper) VMObjectFactory.newObject(JavaCallWrapper.class,
a61af66fc99e Initial load
duke
parents:
diff changeset
891 getSP().getAddressAt(link.asIn().asRegister().spOffsetInSavedWindow()));
a61af66fc99e Initial load
duke
parents:
diff changeset
892 }
a61af66fc99e Initial load
duke
parents:
diff changeset
893
a61af66fc99e Initial load
duke
parents:
diff changeset
894 //
a61af66fc99e Initial load
duke
parents:
diff changeset
895 //
a61af66fc99e Initial load
duke
parents:
diff changeset
896 // inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
897 // // note: adjust this code if the link argument in StubGenerator::call_stub() changes!
a61af66fc99e Initial load
duke
parents:
diff changeset
898 // const Argument link = Argument(0, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
899 // return (JavaCallWrapper*)sp()[link.as_in().as_register().sp_offset_in_saved_window()];
a61af66fc99e Initial load
duke
parents:
diff changeset
900 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
903 // Safepoints:
a61af66fc99e Initial load
duke
parents:
diff changeset
904 //
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 protected Address addressOfSavedOopResult() {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 return addressOfO0();
a61af66fc99e Initial load
duke
parents:
diff changeset
908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
909
a61af66fc99e Initial load
duke
parents:
diff changeset
910 protected Address addressOfSavedReceiver() {
a61af66fc99e Initial load
duke
parents:
diff changeset
911 return addressOfO0();
a61af66fc99e Initial load
duke
parents:
diff changeset
912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
913
a61af66fc99e Initial load
duke
parents:
diff changeset
914
a61af66fc99e Initial load
duke
parents:
diff changeset
915 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
916 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
917 //
a61af66fc99e Initial load
duke
parents:
diff changeset
918
a61af66fc99e Initial load
duke
parents:
diff changeset
919 private Address addressOfI7() {
a61af66fc99e Initial load
duke
parents:
diff changeset
920 return getSP().addOffsetTo(SPARCRegisters.I7.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
922
a61af66fc99e Initial load
duke
parents:
diff changeset
923 private Address addressOfO7() {
a61af66fc99e Initial load
duke
parents:
diff changeset
924 return afterSave().addressOfI7();
a61af66fc99e Initial load
duke
parents:
diff changeset
925 }
a61af66fc99e Initial load
duke
parents:
diff changeset
926
a61af66fc99e Initial load
duke
parents:
diff changeset
927 private Address addressOfI0() {
a61af66fc99e Initial load
duke
parents:
diff changeset
928 return getSP().addOffsetTo(SPARCRegisters.I0.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
929 }
a61af66fc99e Initial load
duke
parents:
diff changeset
930
a61af66fc99e Initial load
duke
parents:
diff changeset
931 private Address addressOfO0() {
a61af66fc99e Initial load
duke
parents:
diff changeset
932 return afterSave().addressOfI0();
a61af66fc99e Initial load
duke
parents:
diff changeset
933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
934
a61af66fc99e Initial load
duke
parents:
diff changeset
935 private static boolean addressesEqual(Address a1, Address a2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
936 if ((a1 == null) && (a2 == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
937 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
938 }
a61af66fc99e Initial load
duke
parents:
diff changeset
939
a61af66fc99e Initial load
duke
parents:
diff changeset
940 if ((a1 == null) || (a2 == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
941 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
942 }
a61af66fc99e Initial load
duke
parents:
diff changeset
943
a61af66fc99e Initial load
duke
parents:
diff changeset
944 return (a1.equals(a2));
a61af66fc99e Initial load
duke
parents:
diff changeset
945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
946
a61af66fc99e Initial load
duke
parents:
diff changeset
947
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
948 private Frame senderForRicochetFrame(SPARCRegisterMap map) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
949 if (DEBUG) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
950 System.out.println("senderForRicochetFrame");
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
951 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
952 //RicochetFrame* f = RicochetFrame::from_frame(fr);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
953 // Cf. is_interpreted_frame path of frame::sender
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
954 Address youngerSP = getSP();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
955 Address sp = getSenderSP();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
956 map.makeIntegerRegsUnsaved();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
957 map.shiftWindow(sp, youngerSP);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
958 boolean thisFrameAdjustedStack = true; // I5_savedSP is live in this RF
4008
8187c94a9a87 7093690: JSR292: SA-JDI AssertionFailure: Expected raw sp likely got real sp, value was
never
parents: 3908
diff changeset
959 return new SPARCFrame(biasSP(sp), biasSP(youngerSP), thisFrameAdjustedStack);
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
960 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
961
0
a61af66fc99e Initial load
duke
parents:
diff changeset
962 private Frame senderForEntryFrame(RegisterMap regMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
963 SPARCRegisterMap map = (SPARCRegisterMap) regMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
964
a61af66fc99e Initial load
duke
parents:
diff changeset
965 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
966 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
967 }
a61af66fc99e Initial load
duke
parents:
diff changeset
968 // Java frame called from C; skip all C frames and return top C
a61af66fc99e Initial load
duke
parents:
diff changeset
969 // frame of that chunk as the sender
a61af66fc99e Initial load
duke
parents:
diff changeset
970 JavaCallWrapper jcw = getEntryFrameCallWrapper();
a61af66fc99e Initial load
duke
parents:
diff changeset
971 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
972 Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
973 Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
974 }
a61af66fc99e Initial load
duke
parents:
diff changeset
975 Address lastJavaSP = jcw.getLastJavaSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
976 Address lastJavaPC = jcw.getLastJavaPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
977 map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
978
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
979 map.makeIntegerRegsUnsaved();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
980 map.shiftWindow(lastJavaSP, null);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
981
a61af66fc99e Initial load
duke
parents:
diff changeset
982 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
983 Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
a61af66fc99e Initial load
duke
parents:
diff changeset
984 }
a61af66fc99e Initial load
duke
parents:
diff changeset
985
a61af66fc99e Initial load
duke
parents:
diff changeset
986 if (lastJavaPC != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
987 return new SPARCFrame(biasSP(lastJavaSP), lastJavaPC);
a61af66fc99e Initial load
duke
parents:
diff changeset
988 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
989 Address youngerSP = getNextYoungerSP(lastJavaSP, getSP());
a61af66fc99e Initial load
duke
parents:
diff changeset
990 return new SPARCFrame(biasSP(lastJavaSP), biasSP(youngerSP), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
993
a61af66fc99e Initial load
duke
parents:
diff changeset
994 private static Address getNextYoungerSP(Address oldSP, Address youngSP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
995 Address sp = getNextYoungerSPOrNull(oldSP, youngSP, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
996 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
997 Assert.that(sp != null, "missed the SP");
a61af66fc99e Initial load
duke
parents:
diff changeset
998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
999 return sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1001
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 private static Address getNextYoungerSPOrNull(Address oldSP, Address youngSP, Address sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 if (youngSP == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 throw new RuntimeException("can not handle null youngSP in debugging system (seems to require register window flush)");
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1007
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 if (sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 sp = youngSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1011
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 Address previousSP = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1013
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 /** Minimum frame size is 16 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 int maxFrames = (int) (oldSP.minus(sp) / (16 * VM.getVM().getAddressSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1016
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 while(!sp.equals(oldSP) && spIsValid(oldSP, youngSP, sp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 if (maxFrames-- <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 // too many frames have gone by; invalid parameters given to this function
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 previousSP = sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 sp = unBiasSP(sp.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1025
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 return (sp.equals(oldSP) ? previousSP : null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1028
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 private static boolean spIsValid(Address oldSP, Address youngSP, Address sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 long mask = VM.getVM().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 mask = 2 * mask - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 return ((sp.andWithMask(mask) == null) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 (sp.lessThanOrEqual(oldSP)) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 (sp.greaterThanOrEqual(youngSP)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1036
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 // FIXME: this is a hopefully temporary hack (not sure what is going on)
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 public long getUContextOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 // FIXME: there is something I clearly don't understand about the
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 // way the signal handler frame is laid out, because I shouldn't need this extra offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 int MAJOR_HACK_OFFSET = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 // System.out.println(" SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 + ", fp = " + fp + ", youngerSP = " + youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 return VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1045
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 public long getMContextAreaOffsetInUContext() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 // From dbx-related sources:
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 // /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 // * struct sigframe is declaredf in the kernel sources in
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 // * .../uts/sun4c/os/machdep.c/sendsig()
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 // * unfortunately we only get a pointer to the 'uc' passed
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // * to the sighandler so we need to do this stuff to get
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 // * to 'rwin'.
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 // * Have to do it like this to take account of alignment.
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 // */
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 // static struct sigframe {
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 // struct rwindow rwin;
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 // ucontext_t uc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 // } sf_help;
a61af66fc99e Initial load
duke
parents:
diff changeset
1060
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 // From /usr/include/sys/ucontext.h:
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 // #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 // struct ucontext {
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 // #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 // struct __ucontext {
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 // #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // uint_t uc_flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 // ucontext_t *uc_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 // sigset_t uc_sigmask;
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 // stack_t uc_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 // mcontext_t uc_mcontext;
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 // #ifdef __sparcv9
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 // long uc_filler[4];
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 // #else /* __sparcv9 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 // long uc_filler[23];
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 // #endif /* __sparcv9 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 // };
a61af66fc99e Initial load
duke
parents:
diff changeset
1078
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 // This walks to the start of the gregs in the mcontext_t
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 // (first entry in that data structure). Really should read
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 // this from header file.
a61af66fc99e Initial load
duke
parents:
diff changeset
1082
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 // Also not sure exactly how alignment works...maybe should read these offsets from the target VM
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 // (When you have a hammer, everything looks like a nail)
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 long offset = VM.getVM().alignUp(4, VM.getVM().getAddressSize()); // uc_flags
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // uc_link plus
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 // doubleword alignment for structs?
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 offset += 16 + // uc_sigmask
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 2 * VM.getVM().getAddressSize() + 4; // uc_stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // doubleword alignment for structs?
a61af66fc99e Initial load
duke
parents:
diff changeset
1091
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 // System.out.println("SPARCFrame.getMContextAreaOffsetInUContext: offset = " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1093
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 }