annotate agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 1d7922586cf6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 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
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
426 Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);
218
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 {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
447 method = (Method)Metadata.instantiateWrapperFor(methodHandle);
218
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 // 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
575 // sender's _interpreter_sp_adjustment field.
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
576 if (VM.getVM().getInterpreter().contains(pc)) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
577 isInterpreted = true;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
578 map.makeIntegerRegsUnsaved();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
579 map.shiftWindow(sp, youngerSP);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
580 } else {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
581 // 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
582 // 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
583 cb = VM.getVM().getCodeCache().findBlob(pc);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
584 if (cb != null) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
585 // Update the location of all implicitly saved registers
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
586 // 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
587 // 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
588 // register in the next younger frame)
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
589 map.shiftWindow(sp, youngerSP);
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
590 if (map.getUpdateMap()) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
591 if (cb.callerMustGCArguments()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
592 map.setIncludeArgumentOops(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
594 if (cb.getOopMaps() != null) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
595 OopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
599 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
600
a61af66fc99e Initial load
duke
parents:
diff changeset
601 return new SPARCFrame(biasSP(sp), biasSP(youngerSP), isInterpreted);
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 protected boolean hasSenderPD() {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // FIXME: should not happen!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
607 if (getSP() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
608 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610 if ( unBiasSP(getSP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())) == null ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
614 } catch (RuntimeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
615 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 System.out.println("Bad frame " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
618 throw e;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Return address:
a61af66fc99e Initial load
duke
parents:
diff changeset
624 //
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 public Address getSenderPC() {
a61af66fc99e Initial load
duke
parents:
diff changeset
627 return addressOfI7().getAddressAt(0).addOffsetTo(PC_RETURN_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
629
a61af66fc99e Initial load
duke
parents:
diff changeset
630 // FIXME: currently unimplementable
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // inline void frame::set_sender_pc(address addr) { *I7_addr() = addr - pc_return_offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633 public Address getUnextendedSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
634 return getSP().addOffsetTo(interpreterSPAdjustmentOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636
a61af66fc99e Initial load
duke
parents:
diff changeset
637 public Address getSenderSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
638 return getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
640
a61af66fc99e Initial load
duke
parents:
diff changeset
641 /** Given the next-younger sp for a given frame's sp, compute the
a61af66fc99e Initial load
duke
parents:
diff changeset
642 frame. We need the next-younger sp, because its register save
a61af66fc99e Initial load
duke
parents:
diff changeset
643 area holds the flushed copy of its I7, which is the PC of the
a61af66fc99e Initial load
duke
parents:
diff changeset
644 frame we are interested in. */
a61af66fc99e Initial load
duke
parents:
diff changeset
645 public SPARCFrame afterSave() {
a61af66fc99e Initial load
duke
parents:
diff changeset
646 return new SPARCFrame(biasSP(getYoungerSP()), null);
a61af66fc99e Initial load
duke
parents:
diff changeset
647 }
a61af66fc99e Initial load
duke
parents:
diff changeset
648
a61af66fc99e Initial load
duke
parents:
diff changeset
649 /** Accessors for the instance variables */
a61af66fc99e Initial load
duke
parents:
diff changeset
650 public Address getFP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 Address sp = getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
652 if (sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 System.out.println("SPARCFrame.getFP(): sp == null");
a61af66fc99e Initial load
duke
parents:
diff changeset
654 }
a61af66fc99e Initial load
duke
parents:
diff changeset
655 Address fpAddr = sp.addOffsetTo(SPARCRegisters.FP.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
656 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 Address fp = unBiasSP(fpAddr.getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
658 if (fp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
659 System.out.println("SPARCFrame.getFP(): fp == null (&fp == " + fpAddr + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 } catch (RuntimeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 System.out.println("SPARCFrame.getFP(): is bad (&fp == " + fpAddr + " sp = " + sp + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
664 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
667
a61af66fc99e Initial load
duke
parents:
diff changeset
668 private Address addressOfFPSlot(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
669 return getFP().addOffsetTo(index * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // FIXME: temporarily elided
a61af66fc99e Initial load
duke
parents:
diff changeset
673 // // All frames
a61af66fc99e Initial load
duke
parents:
diff changeset
674 //
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // intptr_t* fp_addr_at(int index) const { return &fp()[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // intptr_t* sp_addr_at(int index) const { return &sp()[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
677 // intptr_t fp_at( int index) const { return *fp_addr_at(index); }
a61af66fc99e Initial load
duke
parents:
diff changeset
678 // intptr_t sp_at( int index) const { return *sp_addr_at(index); }
a61af66fc99e Initial load
duke
parents:
diff changeset
679 //
a61af66fc99e Initial load
duke
parents:
diff changeset
680 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
681 // inline address* I7_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // inline address* O7_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
683 //
a61af66fc99e Initial load
duke
parents:
diff changeset
684 // inline address* I0_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // inline address* O0_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
686 //
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // public:
a61af66fc99e Initial load
duke
parents:
diff changeset
688 // // access to SPARC arguments and argument registers
a61af66fc99e Initial load
duke
parents:
diff changeset
689 //
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // intptr_t* register_addr(Register reg) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 // return sp_addr_at(reg.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // intptr_t* memory_param_addr(int param_ix, bool is_in) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 // int offset = callee_register_argument_save_area_sp_offset + param_ix;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // if (is_in)
a61af66fc99e Initial load
duke
parents:
diff changeset
696 // return fp_addr_at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
697 // else
a61af66fc99e Initial load
duke
parents:
diff changeset
698 // return sp_addr_at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
699 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // intptr_t* param_addr(int param_ix, bool is_in) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 // if (param_ix >= callee_register_argument_save_area_words)
a61af66fc99e Initial load
duke
parents:
diff changeset
702 // return memory_param_addr(param_ix, is_in);
a61af66fc99e Initial load
duke
parents:
diff changeset
703 // else if (is_in)
a61af66fc99e Initial load
duke
parents:
diff changeset
704 // return register_addr(Argument(param_ix, true).as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // else {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 // // the registers are stored in the next younger frame
a61af66fc99e Initial load
duke
parents:
diff changeset
707 // // %%% is this really necessary?
a61af66fc99e Initial load
duke
parents:
diff changeset
708 // frame next_younger = after_save();
a61af66fc99e Initial load
duke
parents:
diff changeset
709 // return next_younger.register_addr(Argument(param_ix, true).as_register());
a61af66fc99e Initial load
duke
parents:
diff changeset
710 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
711 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
712
a61af66fc99e Initial load
duke
parents:
diff changeset
713 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
714 // Interpreter frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
715 //
a61af66fc99e Initial load
duke
parents:
diff changeset
716
a61af66fc99e Initial load
duke
parents:
diff changeset
717 /** 2 words, also used to save float regs across calls to C */
a61af66fc99e Initial load
duke
parents:
diff changeset
718 public static final int INTERPRETER_FRAME_D_SCRATCH_FP_OFFSET = -2;
a61af66fc99e Initial load
duke
parents:
diff changeset
719 public static final int INTERPRETER_FRAME_L_SCRATCH_FP_OFFSET = -4;
a61af66fc99e Initial load
duke
parents:
diff changeset
720 /** For native calls only */
a61af66fc99e Initial load
duke
parents:
diff changeset
721 public static final int INTERPRETER_FRAME_PADDING_OFFSET = -5;
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_MIRROR_OFFSET = -6;
a61af66fc99e Initial load
duke
parents:
diff changeset
724 /** Should be same as above, and should be zero mod 8 */
a61af66fc99e Initial load
duke
parents:
diff changeset
725 public static final int INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET = -6;
a61af66fc99e Initial load
duke
parents:
diff changeset
726 public static final int INTERPRETER_FRAME_VM_LOCAL_WORDS = -INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 /** Interpreter frame set-up needs to save 2 extra words in outgoing
a61af66fc99e Initial load
duke
parents:
diff changeset
729 param area for class and jnienv arguments for native stubs (see
a61af66fc99e Initial load
duke
parents:
diff changeset
730 nativeStubGen_sparc.cpp) */
a61af66fc99e Initial load
duke
parents:
diff changeset
731 public static final int INTERPRETER_FRAME_EXTRA_OUTGOING_ARGUMENT_WORDS = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
732
a61af66fc99e Initial load
duke
parents:
diff changeset
733 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
734 //
a61af66fc99e Initial load
duke
parents:
diff changeset
735 // // the compiler frame has many of the same fields as the interpreter frame
a61af66fc99e Initial load
duke
parents:
diff changeset
736 // // %%%%% factor out declarations of the shared fields
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // enum compiler_frame_fixed_locals {
a61af66fc99e Initial load
duke
parents:
diff changeset
738 // compiler_frame_d_scratch_fp_offset = -2,
a61af66fc99e Initial load
duke
parents:
diff changeset
739 // compiler_frame_vm_locals_fp_offset = -2, // should be same as above
a61af66fc99e Initial load
duke
parents:
diff changeset
740 //
a61af66fc99e Initial load
duke
parents:
diff changeset
741 // compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
742 // };
a61af66fc99e Initial load
duke
parents:
diff changeset
743 //
a61af66fc99e Initial load
duke
parents:
diff changeset
744 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
745 //
a61af66fc99e Initial load
duke
parents:
diff changeset
746 // // where LcpoolCache is saved:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
747 // ConstantPoolCache** interpreter_frame_cpoolcache_addr() const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
748 // return (ConstantPoolCache**)sp_addr_at( LcpoolCache.sp_offset_in_saved_window());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
750 //
a61af66fc99e Initial load
duke
parents:
diff changeset
751 // // where Lmonitors is saved:
a61af66fc99e Initial load
duke
parents:
diff changeset
752 // BasicObjectLock** interpreter_frame_monitors_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
753 // return (BasicObjectLock**) sp_addr_at( Lmonitors.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
754 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
755 // intptr_t** interpreter_frame_esp_addr() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
756 // return (intptr_t**)sp_addr_at( Lesp.sp_offset_in_saved_window());
a61af66fc99e Initial load
duke
parents:
diff changeset
757 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
758 //
a61af66fc99e Initial load
duke
parents:
diff changeset
759 // inline void interpreter_frame_set_tos_address(intptr_t* x);
a61af66fc99e Initial load
duke
parents:
diff changeset
760 //
a61af66fc99e Initial load
duke
parents:
diff changeset
761 // // next two fns read and write Lmonitors value,
a61af66fc99e Initial load
duke
parents:
diff changeset
762 // private:
a61af66fc99e Initial load
duke
parents:
diff changeset
763 // BasicObjectLock* interpreter_frame_monitors() const { return *interpreter_frame_monitors_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
764 // void interpreter_frame_set_monitors(BasicObjectLock* monitors) { *interpreter_frame_monitors_addr() = monitors; }
a61af66fc99e Initial load
duke
parents:
diff changeset
765 //
a61af66fc99e Initial load
duke
parents:
diff changeset
766 //#ifndef CORE
a61af66fc99e Initial load
duke
parents:
diff changeset
767 //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
768 // COMPILER1_ONLY(return (oop *) (arg_size - 1 - reg + sp() + memory_parameter_word_sp_offset); )
a61af66fc99e Initial load
duke
parents:
diff changeset
769 // COMPILER2_ONLY(return oopmapreg_to_location(reg, &reg_map); )
a61af66fc99e Initial load
duke
parents:
diff changeset
770 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
771 //#endif
a61af66fc99e Initial load
duke
parents:
diff changeset
772
a61af66fc99e Initial load
duke
parents:
diff changeset
773 // FIXME: NOT FINISHED
a61af66fc99e Initial load
duke
parents:
diff changeset
774 public Address addressOfInterpreterFrameLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
775 return getSP().addOffsetTo(SPARCRegisters.Llocals.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777
a61af66fc99e Initial load
duke
parents:
diff changeset
778 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // for use in a non-debugging, or reflective, system.
a61af66fc99e Initial load
duke
parents:
diff changeset
780 private Address addressOfInterpreterFrameBCX() {
a61af66fc99e Initial load
duke
parents:
diff changeset
781 // %%%%% reinterpreting Lbcp as a bcx
a61af66fc99e Initial load
duke
parents:
diff changeset
782 return getSP().addOffsetTo(SPARCRegisters.Lbcp.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
784
a61af66fc99e Initial load
duke
parents:
diff changeset
785 public int getInterpreterFrameBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
786 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
787 // for use in a non-debugging, or reflective, system. Need to
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // figure out how to express this.
a61af66fc99e Initial load
duke
parents:
diff changeset
789 Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
790 Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
791 Method method = (Method)Metadata.instantiateWrapperFor(methodHandle);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
792 return bcpToBci(bcp, method);
a61af66fc99e Initial load
duke
parents:
diff changeset
793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
794
a61af66fc99e Initial load
duke
parents:
diff changeset
795 public Address addressOfInterpreterFrameExpressionStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
796 return addressOfInterpreterFrameMonitors().addOffsetTo(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
798
a61af66fc99e Initial load
duke
parents:
diff changeset
799 public int getInterpreterFrameExpressionStackDirection() {
a61af66fc99e Initial load
duke
parents:
diff changeset
800 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
802
a61af66fc99e Initial load
duke
parents:
diff changeset
803 /** Top of expression stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
804 public Address addressOfInterpreterFrameTOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
805 return getSP().getAddressAt(SPARCRegisters.Lesp.spOffsetInSavedWindow()).addOffsetTo(VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
806 }
a61af66fc99e Initial load
duke
parents:
diff changeset
807
a61af66fc99e Initial load
duke
parents:
diff changeset
808 /** Expression stack from top down */
a61af66fc99e Initial load
duke
parents:
diff changeset
809 public Address addressOfInterpreterFrameTOSAt(int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
810 return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
812
a61af66fc99e Initial load
duke
parents:
diff changeset
813 public Address getInterpreterFrameSenderSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
814 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
815 Assert.that(isInterpretedFrame(), "interpreted frame expected");
a61af66fc99e Initial load
duke
parents:
diff changeset
816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
817 return getFP();
a61af66fc99e Initial load
duke
parents:
diff changeset
818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
819
a61af66fc99e Initial load
duke
parents:
diff changeset
820 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
821 //inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
822 // *interpreter_frame_esp_addr() = x - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
823 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
824
a61af66fc99e Initial load
duke
parents:
diff changeset
825 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
826 // Monitors:
a61af66fc99e Initial load
duke
parents:
diff changeset
827 //
a61af66fc99e Initial load
duke
parents:
diff changeset
828
a61af66fc99e Initial load
duke
parents:
diff changeset
829 private Address addressOfInterpreterFrameMonitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
830 return getSP().addOffsetTo(SPARCRegisters.Lmonitors.spOffsetInSavedWindow()).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
832
a61af66fc99e Initial load
duke
parents:
diff changeset
833 // Monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
834 public BasicObjectLock interpreterFrameMonitorBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 int roundedVMLocalWords = Bits.roundTo(INTERPRETER_FRAME_VM_LOCAL_WORDS, WORDS_PER_LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
836 return new BasicObjectLock(addressOfFPSlot(-1 * roundedVMLocalWords));
a61af66fc99e Initial load
duke
parents:
diff changeset
837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
838
a61af66fc99e Initial load
duke
parents:
diff changeset
839 public BasicObjectLock interpreterFrameMonitorEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
840 return new BasicObjectLock(addressOfInterpreterFrameMonitors());
a61af66fc99e Initial load
duke
parents:
diff changeset
841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
842
a61af66fc99e Initial load
duke
parents:
diff changeset
843 public int interpreterFrameMonitorSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
844 return Bits.roundTo(BasicObjectLock.size(), WORDS_PER_LONG * (int) VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
846
a61af66fc99e Initial load
duke
parents:
diff changeset
847 // FIXME: elided for now
a61af66fc99e Initial load
duke
parents:
diff changeset
848 // // monitor elements
a61af66fc99e Initial load
duke
parents:
diff changeset
849 //
a61af66fc99e Initial load
duke
parents:
diff changeset
850 // // in keeping with Intel side: end is lower in memory than begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
851 // // and beginning element is oldest element
a61af66fc99e Initial load
duke
parents:
diff changeset
852 // // Also begin is one past last monitor.
a61af66fc99e Initial load
duke
parents:
diff changeset
853 //
a61af66fc99e Initial load
duke
parents:
diff changeset
854 // inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
855 // int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
857 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
858 //
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
860 // return interpreter_frame_monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
861 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
862 //
a61af66fc99e Initial load
duke
parents:
diff changeset
863 //
a61af66fc99e Initial load
duke
parents:
diff changeset
864 // inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
865 // interpreter_frame_set_monitors(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
866 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
867 //
a61af66fc99e Initial load
duke
parents:
diff changeset
868 //
a61af66fc99e Initial load
duke
parents:
diff changeset
869 // inline int frame::interpreter_frame_monitor_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
870 // return round_to(BasicObjectLock::size(), WordsPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
871 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
872
a61af66fc99e Initial load
duke
parents:
diff changeset
873 public Address addressOfInterpreterFrameMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
874 return getSP().addOffsetTo(SPARCRegisters.Lmethod.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
876
a61af66fc99e Initial load
duke
parents:
diff changeset
877 public Address addressOfInterpreterFrameCPCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
878 return getSP().addOffsetTo(SPARCRegisters.LcpoolCache.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
880
a61af66fc99e Initial load
duke
parents:
diff changeset
881 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
882 // Entry frames:
a61af66fc99e Initial load
duke
parents:
diff changeset
883 //
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 public JavaCallWrapper getEntryFrameCallWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
886 // Note: adjust this code if the link argument in StubGenerator::call_stub() changes!
a61af66fc99e Initial load
duke
parents:
diff changeset
887 SPARCArgument link = new SPARCArgument(0, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
888 return (JavaCallWrapper) VMObjectFactory.newObject(JavaCallWrapper.class,
a61af66fc99e Initial load
duke
parents:
diff changeset
889 getSP().getAddressAt(link.asIn().asRegister().spOffsetInSavedWindow()));
a61af66fc99e Initial load
duke
parents:
diff changeset
890 }
a61af66fc99e Initial load
duke
parents:
diff changeset
891
a61af66fc99e Initial load
duke
parents:
diff changeset
892 //
a61af66fc99e Initial load
duke
parents:
diff changeset
893 //
a61af66fc99e Initial load
duke
parents:
diff changeset
894 // inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
895 // // note: adjust this code if the link argument in StubGenerator::call_stub() changes!
a61af66fc99e Initial load
duke
parents:
diff changeset
896 // const Argument link = Argument(0, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
897 // return (JavaCallWrapper*)sp()[link.as_in().as_register().sp_offset_in_saved_window()];
a61af66fc99e Initial load
duke
parents:
diff changeset
898 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
899
a61af66fc99e Initial load
duke
parents:
diff changeset
900 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
901 // Safepoints:
a61af66fc99e Initial load
duke
parents:
diff changeset
902 //
a61af66fc99e Initial load
duke
parents:
diff changeset
903
a61af66fc99e Initial load
duke
parents:
diff changeset
904 protected Address addressOfSavedOopResult() {
a61af66fc99e Initial load
duke
parents:
diff changeset
905 return addressOfO0();
a61af66fc99e Initial load
duke
parents:
diff changeset
906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
907
a61af66fc99e Initial load
duke
parents:
diff changeset
908 protected Address addressOfSavedReceiver() {
a61af66fc99e Initial load
duke
parents:
diff changeset
909 return addressOfO0();
a61af66fc99e Initial load
duke
parents:
diff changeset
910 }
a61af66fc99e Initial load
duke
parents:
diff changeset
911
a61af66fc99e Initial load
duke
parents:
diff changeset
912
a61af66fc99e Initial load
duke
parents:
diff changeset
913 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
914 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
915 //
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917 private Address addressOfI7() {
a61af66fc99e Initial load
duke
parents:
diff changeset
918 return getSP().addOffsetTo(SPARCRegisters.I7.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
919 }
a61af66fc99e Initial load
duke
parents:
diff changeset
920
a61af66fc99e Initial load
duke
parents:
diff changeset
921 private Address addressOfO7() {
a61af66fc99e Initial load
duke
parents:
diff changeset
922 return afterSave().addressOfI7();
a61af66fc99e Initial load
duke
parents:
diff changeset
923 }
a61af66fc99e Initial load
duke
parents:
diff changeset
924
a61af66fc99e Initial load
duke
parents:
diff changeset
925 private Address addressOfI0() {
a61af66fc99e Initial load
duke
parents:
diff changeset
926 return getSP().addOffsetTo(SPARCRegisters.I0.spOffsetInSavedWindow());
a61af66fc99e Initial load
duke
parents:
diff changeset
927 }
a61af66fc99e Initial load
duke
parents:
diff changeset
928
a61af66fc99e Initial load
duke
parents:
diff changeset
929 private Address addressOfO0() {
a61af66fc99e Initial load
duke
parents:
diff changeset
930 return afterSave().addressOfI0();
a61af66fc99e Initial load
duke
parents:
diff changeset
931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
932
a61af66fc99e Initial load
duke
parents:
diff changeset
933 private static boolean addressesEqual(Address a1, Address a2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
934 if ((a1 == null) && (a2 == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
935 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
936 }
a61af66fc99e Initial load
duke
parents:
diff changeset
937
a61af66fc99e Initial load
duke
parents:
diff changeset
938 if ((a1 == null) || (a2 == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
939 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
941
a61af66fc99e Initial load
duke
parents:
diff changeset
942 return (a1.equals(a2));
a61af66fc99e Initial load
duke
parents:
diff changeset
943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
944
a61af66fc99e Initial load
duke
parents:
diff changeset
945
a61af66fc99e Initial load
duke
parents:
diff changeset
946 private Frame senderForEntryFrame(RegisterMap regMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
947 SPARCRegisterMap map = (SPARCRegisterMap) regMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
948
a61af66fc99e Initial load
duke
parents:
diff changeset
949 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
950 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
951 }
a61af66fc99e Initial load
duke
parents:
diff changeset
952 // Java frame called from C; skip all C frames and return top C
a61af66fc99e Initial load
duke
parents:
diff changeset
953 // frame of that chunk as the sender
a61af66fc99e Initial load
duke
parents:
diff changeset
954 JavaCallWrapper jcw = getEntryFrameCallWrapper();
a61af66fc99e Initial load
duke
parents:
diff changeset
955 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
956 Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
957 Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
958 }
a61af66fc99e Initial load
duke
parents:
diff changeset
959 Address lastJavaSP = jcw.getLastJavaSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
960 Address lastJavaPC = jcw.getLastJavaPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
961 map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
962
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
963 map.makeIntegerRegsUnsaved();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1552
diff changeset
964 map.shiftWindow(lastJavaSP, null);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
965
a61af66fc99e Initial load
duke
parents:
diff changeset
966 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
967 Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
a61af66fc99e Initial load
duke
parents:
diff changeset
968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
969
a61af66fc99e Initial load
duke
parents:
diff changeset
970 if (lastJavaPC != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
971 return new SPARCFrame(biasSP(lastJavaSP), lastJavaPC);
a61af66fc99e Initial load
duke
parents:
diff changeset
972 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
973 Address youngerSP = getNextYoungerSP(lastJavaSP, getSP());
a61af66fc99e Initial load
duke
parents:
diff changeset
974 return new SPARCFrame(biasSP(lastJavaSP), biasSP(youngerSP), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
975 }
a61af66fc99e Initial load
duke
parents:
diff changeset
976 }
a61af66fc99e Initial load
duke
parents:
diff changeset
977
a61af66fc99e Initial load
duke
parents:
diff changeset
978 private static Address getNextYoungerSP(Address oldSP, Address youngSP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
979 Address sp = getNextYoungerSPOrNull(oldSP, youngSP, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
980 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
981 Assert.that(sp != null, "missed the SP");
a61af66fc99e Initial load
duke
parents:
diff changeset
982 }
a61af66fc99e Initial load
duke
parents:
diff changeset
983 return sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
984 }
a61af66fc99e Initial load
duke
parents:
diff changeset
985
a61af66fc99e Initial load
duke
parents:
diff changeset
986 private static Address getNextYoungerSPOrNull(Address oldSP, Address youngSP, Address sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
987 if (youngSP == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
988 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
989 throw new RuntimeException("can not handle null youngSP in debugging system (seems to require register window flush)");
a61af66fc99e Initial load
duke
parents:
diff changeset
990 }
a61af66fc99e Initial load
duke
parents:
diff changeset
991
a61af66fc99e Initial load
duke
parents:
diff changeset
992 if (sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
993 sp = youngSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
995
a61af66fc99e Initial load
duke
parents:
diff changeset
996 Address previousSP = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998 /** Minimum frame size is 16 */
a61af66fc99e Initial load
duke
parents:
diff changeset
999 int maxFrames = (int) (oldSP.minus(sp) / (16 * VM.getVM().getAddressSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1000
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 while(!sp.equals(oldSP) && spIsValid(oldSP, youngSP, sp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 if (maxFrames-- <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 // too many frames have gone by; invalid parameters given to this function
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 previousSP = sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 sp = unBiasSP(sp.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1009
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 return (sp.equals(oldSP) ? previousSP : null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1012
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 private static boolean spIsValid(Address oldSP, Address youngSP, Address sp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 long mask = VM.getVM().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 mask = 2 * mask - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 return ((sp.andWithMask(mask) == null) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 (sp.lessThanOrEqual(oldSP)) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 (sp.greaterThanOrEqual(youngSP)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1020
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 // FIXME: this is a hopefully temporary hack (not sure what is going on)
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 public long getUContextOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 // FIXME: there is something I clearly don't understand about the
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 // way the signal handler frame is laid out, because I shouldn't need this extra offset
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 int MAJOR_HACK_OFFSET = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 // System.out.println(" SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 + ", fp = " + fp + ", youngerSP = " + youngerSP);
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 return VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1029
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 public long getMContextAreaOffsetInUContext() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 // From dbx-related sources:
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 // /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 // * struct sigframe is declaredf in the kernel sources in
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 // * .../uts/sun4c/os/machdep.c/sendsig()
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 // * unfortunately we only get a pointer to the 'uc' passed
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 // * to the sighandler so we need to do this stuff to get
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 // * to 'rwin'.
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 // * Have to do it like this to take account of alignment.
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 // */
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 // static struct sigframe {
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 // struct rwindow rwin;
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 // ucontext_t uc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 // } sf_help;
a61af66fc99e Initial load
duke
parents:
diff changeset
1044
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 // From /usr/include/sys/ucontext.h:
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 // #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 // struct ucontext {
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 // #else
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 // struct __ucontext {
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 // #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 // uint_t uc_flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 // ucontext_t *uc_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 // sigset_t uc_sigmask;
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 // stack_t uc_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 // mcontext_t uc_mcontext;
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 // #ifdef __sparcv9
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 // long uc_filler[4];
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 // #else /* __sparcv9 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 // long uc_filler[23];
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 // #endif /* __sparcv9 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 // };
a61af66fc99e Initial load
duke
parents:
diff changeset
1062
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 // This walks to the start of the gregs in the mcontext_t
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 // (first entry in that data structure). Really should read
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 // this from header file.
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // Also not sure exactly how alignment works...maybe should read these offsets from the target VM
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 // (When you have a hammer, everything looks like a nail)
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 long offset = VM.getVM().alignUp(4, VM.getVM().getAddressSize()); // uc_flags
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // uc_link plus
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 // doubleword alignment for structs?
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 offset += 16 + // uc_sigmask
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 2 * VM.getVM().getAddressSize() + 4; // uc_stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // doubleword alignment for structs?
a61af66fc99e Initial load
duke
parents:
diff changeset
1075
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 // System.out.println("SPARCFrame.getMContextAreaOffsetInUContext: offset = " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1077
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 return offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 }