annotate agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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.amd64;
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 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.compiler.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 /** Specialization of and implementation of abstract methods of the
a61af66fc99e Initial load
duke
parents:
diff changeset
37 Frame class for the amd64 CPU. */
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public class AMD64Frame extends Frame {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static final boolean DEBUG;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 DEBUG = System.getProperty("sun.jvm.hotspot.runtime.amd64.AMD64Frame.DEBUG") != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // refer to frame_amd64.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static final int PC_RETURN_OFFSET = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // All frames
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static final int LINK_OFFSET = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static final int RETURN_ADDR_OFFSET = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static final int SENDER_SP_OFFSET = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Interpreter frames
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static final int INTERPRETER_FRAME_MIRROR_OFFSET = 2; // for native calls only
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static final int INTERPRETER_FRAME_SENDER_SP_OFFSET = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private static final int INTERPRETER_FRAME_LAST_SP_OFFSET = INTERPRETER_FRAME_SENDER_SP_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private static final int INTERPRETER_FRAME_METHOD_OFFSET = INTERPRETER_FRAME_LAST_SP_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static int INTERPRETER_FRAME_MDX_OFFSET; // Non-core builds only
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private static int INTERPRETER_FRAME_CACHE_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private static int INTERPRETER_FRAME_LOCALS_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private static int INTERPRETER_FRAME_BCX_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private static int INTERPRETER_FRAME_INITIAL_SP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 private static int INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Entry frames
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private static final int ENTRY_FRAME_CALL_WRAPPER_OFFSET = -6;
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Native frames
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 });
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 INTERPRETER_FRAME_MDX_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 INTERPRETER_FRAME_LOCALS_OFFSET = INTERPRETER_FRAME_CACHE_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 INTERPRETER_FRAME_BCX_OFFSET = INTERPRETER_FRAME_LOCALS_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 INTERPRETER_FRAME_INITIAL_SP_OFFSET = INTERPRETER_FRAME_BCX_OFFSET - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // an additional field beyond sp and pc:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 Address raw_fp; // frame pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private Address raw_unextendedSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private AMD64Frame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private void adjustForDeopt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if ( pc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Look for a deopt pc and if it is deopted convert to original pc
a61af66fc99e Initial load
duke
parents:
diff changeset
103 CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (cb != null && cb.isJavaMethod()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 NMethod nm = (NMethod) cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (pc.equals(nm.deoptBegin())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // adjust pc if frame is deoptimized.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Assert.that(this.getUnextendedSP() != null, "null SP in Java frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
112 deoptimized = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public AMD64Frame(Address raw_sp, Address raw_fp, Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 this.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 this.raw_unextendedSP = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 this.raw_fp = raw_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 this.pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Frame must be fully constructed before this call
a61af66fc99e Initial load
duke
parents:
diff changeset
125 adjustForDeopt();
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 System.out.println("AMD64Frame(sp, fp, pc): " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 dumpStack();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public AMD64Frame(Address raw_sp, Address raw_fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 this.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 this.raw_unextendedSP = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 this.raw_fp = raw_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Frame must be fully constructed before this call
a61af66fc99e Initial load
duke
parents:
diff changeset
140 adjustForDeopt();
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 System.out.println("AMD64Frame(sp, fp): " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 dumpStack();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // This constructor should really take the unextended SP as an arg
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // but then the constructor is ambiguous with constructor that takes
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // a PC so take an int and convert it.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public AMD64Frame(Address raw_sp, Address raw_fp, long extension) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 this.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if ( raw_sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 this.raw_unextendedSP = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 this.raw_unextendedSP = raw_sp.addOffsetTo(extension);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 this.raw_fp = raw_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Frame must be fully constructed before this call
a61af66fc99e Initial load
duke
parents:
diff changeset
162 adjustForDeopt();
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 System.out.println("AMD64Frame(sp, fp, extension): " + this);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 dumpStack();
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
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 Object clone() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 AMD64Frame frame = new AMD64Frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 frame.raw_sp = raw_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 frame.raw_unextendedSP = raw_unextendedSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 frame.raw_fp = raw_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 frame.pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 frame.deoptimized = deoptimized;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public boolean equals(Object arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (arg == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (!(arg instanceof AMD64Frame)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 AMD64Frame other = (AMD64Frame) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return (AddressOps.equal(getSP(), other.getSP()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
193 AddressOps.equal(getFP(), other.getFP()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
194 AddressOps.equal(getUnextendedSP(), other.getUnextendedSP()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
195 AddressOps.equal(getPC(), other.getPC()));
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public int hashCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 if (raw_sp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return raw_sp.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return "sp: " + (getSP() == null? "null" : getSP().toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
208 ", unextendedSP: " + (getUnextendedSP() == null? "null" : getUnextendedSP().toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
209 ", fp: " + (getFP() == null? "null" : getFP().toString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ", pc: " + (pc == null? "null" : pc.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // accessors for the instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
214 public Address getFP() { return raw_fp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 public Address getSP() { return raw_sp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 public Address getID() { return raw_sp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // FIXME: not implemented yet (should be done for Solaris/AMD64)
a61af66fc99e Initial load
duke
parents:
diff changeset
219 public boolean isSignalHandlerFrameDbg() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 public int getSignalNumberDbg() { return 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 public String getSignalNameDbg() { return null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 public boolean isInterpretedFrameValid() {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 Assert.that(isInterpretedFrame(), "Not an interpreted frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // These are reasonable sanity checks
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (getFP() == null || getFP().andWithMask(0x3) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (getSP() == null || getSP().andWithMask(0x3) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 if (getFP().addOffsetTo(INTERPRETER_FRAME_INITIAL_SP_OFFSET * VM.getVM().getAddressSize()).lessThan(getSP())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // These are hacks to keep us out of trouble.
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // The problem with these is that they mask other problems
a61af66fc99e Initial load
duke
parents:
diff changeset
243 if (getFP().lessThanOrEqual(getSP())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // this attempts to deal with unsigned comparison above
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // stack frames shouldn't be large.
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // FIXME: not applicable in current system
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // void patch_pc(Thread* thread, address pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 public Frame sender(RegisterMap regMap, CodeBlob cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 AMD64RegisterMap map = (AMD64RegisterMap) regMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // Default is we done have to follow them. The sender_for_xxx will
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // update it accordingly
a61af66fc99e Initial load
duke
parents:
diff changeset
268 map.setIncludeArgumentOops(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (isEntryFrame()) return senderForEntryFrame(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 if (isInterpretedFrame()) return senderForInterpreterFrame(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if(cb == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 cb = VM.getVM().getCodeCache().findBlob(getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
277 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 Assert.that(cb.equals(VM.getVM().getCodeCache().findBlob(getPC())), "Must be the same");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (cb != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return senderForCompiledFrame(map, cb);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Must be native-compiled frame, i.e. the marshaling code for native
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // methods that exists in the core system.
a61af66fc99e Initial load
duke
parents:
diff changeset
290 return new AMD64Frame(getSenderSP(), getLink(), getSenderPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 private Frame senderForEntryFrame(AMD64RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // Java frame called from C; skip all C frames and return top C
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // frame of that chunk as the sender
a61af66fc99e Initial load
duke
parents:
diff changeset
299 AMD64JavaCallWrapper jcw = (AMD64JavaCallWrapper) getEntryFrameCallWrapper();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
302 Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 AMD64Frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (jcw.getLastJavaPC() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP(), jcw.getLastJavaPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
307 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP());
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 private Frame senderForInterpreterFrame(AMD64RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 Address unextendedSP = addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 Address sp = addressOfStackSlot(SENDER_SP_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // We do not need to update the callee-save register mapping because above
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // us is either another interpreter frame or a converter-frame, but never
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // directly a compiled frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // 11/24/04 SFG. This is no longer true after adapter were removed. However at the moment
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // C2 no longer uses callee save register for java calls so there are no callee register
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // to find.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 return new AMD64Frame(sp, getLink(), unextendedSP.minus(sp));
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 private Frame senderForCompiledFrame(AMD64RegisterMap map, CodeBlob cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 //
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // NOTE: some of this code is (unfortunately) duplicated in AMD64CurrentFrameGuess
a61af66fc99e Initial load
duke
parents:
diff changeset
332 //
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 Assert.that(map != null, "map must be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
336 }
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // frame owned by optimizing compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
339 Address sender_sp = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 sender_sp = addressOfStackSlot(SENDER_SP_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
344 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 Assert.that(cb.getFrameSize() >= 0, "Compiled by Compiler1: do not use");
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 sender_sp = getUnextendedSP().addOffsetTo(cb.getFrameSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // On Intel the return_address is always the word on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
352 Address sender_pc = sender_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (map.getUpdateMap() && cb.getOopMaps() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 OopMapSet.updateRegisterMap(this, cb, map, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // Move this here for C1 and collecting oops in arguments (According to Rene)
a61af66fc99e Initial load
duke
parents:
diff changeset
360 map.setIncludeArgumentOops(cb.callerMustGCArguments(map.getThread()));
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 Address saved_fp = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
364 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 saved_fp = getFP().getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 } else if (VM.getVM().isServerCompiler() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
367 (VM.getVM().getInterpreter().contains(sender_pc) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
368 VM.getVM().getStubRoutines().returnsToCallStub(sender_pc))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // C2 prologue saves EBP in the usual place.
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // however only use it if the sender had link infomration in it.
a61af66fc99e Initial load
duke
parents:
diff changeset
371 saved_fp = sender_sp.getAddressAt(-2 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 return new AMD64Frame(sender_sp, saved_fp, sender_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 protected boolean hasSenderPD() {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // Check for null ebp? Need to do some tests.
a61af66fc99e Initial load
duke
parents:
diff changeset
380 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 public long frameSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 public Address getLink() {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 return addressOfStackSlot(LINK_OFFSET).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // FIXME: not implementable yet
a61af66fc99e Initial load
duke
parents:
diff changeset
392 //inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 public Address getUnextendedSP() { return raw_unextendedSP; }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Return address:
a61af66fc99e Initial load
duke
parents:
diff changeset
397 public Address getSenderPCAddr() { return addressOfStackSlot(RETURN_ADDR_OFFSET); }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 public Address getSenderPC() { return getSenderPCAddr().getAddressAt(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // return address of param, zero origin index.
a61af66fc99e Initial load
duke
parents:
diff changeset
401 public Address getNativeParamAddr(int idx) {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 return addressOfStackSlot(NATIVE_FRAME_INITIAL_PARAM_OFFSET + idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 public Address getSenderSP() { return addressOfStackSlot(SENDER_SP_OFFSET); }
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 public Address compiledArgumentToLocationPD(VMReg reg, RegisterMap regMap, int argSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 if (VM.getVM().isCore() || VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 throw new RuntimeException("Should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 return oopMapRegToLocation(reg, regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 public Address addressOfInterpreterFrameLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 private Address addressOfInterpreterFrameBCX() {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 return addressOfStackSlot(INTERPRETER_FRAME_BCX_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 public int getInterpreterFrameBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // FIXME: this is not atomic with respect to GC and is unsuitable
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // for use in a non-debugging, or reflective, system. Need to
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // figure out how to express this.
a61af66fc99e Initial load
duke
parents:
diff changeset
427 Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 OopHandle methodHandle = addressOfInterpreterFrameMethod().getOopHandleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
429 Method method = (Method) VM.getVM().getObjectHeap().newOop(methodHandle);
a61af66fc99e Initial load
duke
parents:
diff changeset
430 return (int) bcpToBci(bcp, method);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 }
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 public Address addressOfInterpreterFrameMDX() {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 return addressOfStackSlot(INTERPRETER_FRAME_MDX_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
438 //inline int frame::interpreter_frame_monitor_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // return BasicObjectLock::size();
a61af66fc99e Initial load
duke
parents:
diff changeset
440 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // (the max_stack arguments are used by the GC; see class FrameClosure)
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 public Address addressOfInterpreterFrameExpressionStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 Address monitorEnd = interpreterFrameMonitorEnd().address();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 return monitorEnd.addOffsetTo(-1 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 public int getInterpreterFrameExpressionStackDirection() { return -1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // top of expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
453 public Address addressOfInterpreterFrameTOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 return getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457 /** Expression stack from top down */
a61af66fc99e Initial load
duke
parents:
diff changeset
458 public Address addressOfInterpreterFrameTOSAt(int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 public Address getInterpreterFrameSenderSP() {
a61af66fc99e Initial load
duke
parents:
diff changeset
463 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 Assert.that(isInterpretedFrame(), "interpreted frame expected");
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466 return addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // Monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
470 public BasicObjectLock interpreterFrameMonitorBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
471 return new BasicObjectLock(addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET));
a61af66fc99e Initial load
duke
parents:
diff changeset
472 }
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 public BasicObjectLock interpreterFrameMonitorEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 Address result = addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET).getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
476 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // make sure the pointer points inside the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
478 Assert.that(AddressOps.gt(getFP(), result), "result must < than frame pointer");
a61af66fc99e Initial load
duke
parents:
diff changeset
479 Assert.that(AddressOps.lte(getSP(), result), "result must >= than stack pointer");
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 return new BasicObjectLock(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 public int interpreterFrameMonitorSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 return BasicObjectLock.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // Method
a61af66fc99e Initial load
duke
parents:
diff changeset
489 public Address addressOfInterpreterFrameMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 return addressOfStackSlot(INTERPRETER_FRAME_METHOD_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // Constant pool cache
a61af66fc99e Initial load
duke
parents:
diff changeset
494 public Address addressOfInterpreterFrameCPCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 return addressOfStackSlot(INTERPRETER_FRAME_CACHE_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // Entry frames
a61af66fc99e Initial load
duke
parents:
diff changeset
499 public JavaCallWrapper getEntryFrameCallWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
500 return new AMD64JavaCallWrapper(addressOfStackSlot(ENTRY_FRAME_CALL_WRAPPER_OFFSET).getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503 protected Address addressOfSavedOopResult() {
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // offset is 2 for compiler2 and 3 for compiler1
a61af66fc99e Initial load
duke
parents:
diff changeset
505 return getSP().addOffsetTo((VM.getVM().isClientCompiler() ? 2 : 3) *
a61af66fc99e Initial load
duke
parents:
diff changeset
506 VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 protected Address addressOfSavedReceiver() {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 return getSP().addOffsetTo(-4 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 private void dumpStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (getFP() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
516 AddressOps.lte(addr, getFP().addOffsetTo(5 * VM.getVM().getAddressSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
517 addr = addr.addOffsetTo(VM.getVM().getAddressSize())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 System.out.println(addr + ": " + addr.getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
521 for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
522 AddressOps.lte(addr, getSP().addOffsetTo(20 * VM.getVM().getAddressSize()));
a61af66fc99e Initial load
duke
parents:
diff changeset
523 addr = addr.addOffsetTo(VM.getVM().getAddressSize())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 System.out.println(addr + ": " + addr.getAddressAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
527 }
a61af66fc99e Initial load
duke
parents:
diff changeset
528 }