annotate agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.compiler;
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.code.*;
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.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public class OopMapSet extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.compiler.OopMapSet.DEBUG") != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static CIntegerField omCountField;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static CIntegerField omSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static AddressField omDataField;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static int REG_COUNT;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private static int SAVED_ON_ENTRY_REG_COUNT;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static int C_SAVED_ON_ENTRY_REG_COUNT;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static class MyVisitor implements OopMapVisitor {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private AddressVisitor addressVisitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public MyVisitor(AddressVisitor oopVisitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 setAddressVisitor(oopVisitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public void setAddressVisitor(AddressVisitor addressVisitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 this.addressVisitor = addressVisitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 public void visitOopLocation(Address oopAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 addressVisitor.visitAddress(oopAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public void visitDerivedOopLocation(Address baseOopAddr, Address derivedOopAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 Assert.that(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 } else if (VM.getVM().isServerCompiler() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
63 VM.getVM().useDerivedPointerTable()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Assert.that(false, "FIXME: add derived pointer table");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 public void visitValueLocation(Address valueAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 public void visitDeadLocation(Address deadAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 });
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 Type type = db.lookupType("OopMapSet");
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 omCountField = type.getCIntegerField("_om_count");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 omSizeField = type.getCIntegerField("_om_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 omDataField = type.getAddressField("_om_data");
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (VM.getVM().isServerCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("SAVED_ON_ENTRY_REG_COUNT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 C_SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("C_SAVED_ON_ENTRY_REG_COUNT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public OopMapSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 /** Returns the number of OopMaps in this OopMapSet */
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public long getSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return omCountField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 /** returns the OopMap at a given index */
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public OopMap getMapAt(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 Assert.that((index >= 0) && (index <= getSize()),"bad index");
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 Address omDataAddr = omDataField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 Address oopMapAddr = omDataAddr.getAddressAt(index * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (oopMapAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return new OopMap(oopMapAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public OopMap findMapAtOffset(long pcOffset, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int len = (int) getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 Assert.that(len > 0, "must have pointer maps");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Scan through oopmaps. Stop when current offset is either equal or greater
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // than the one we are looking for.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 for (i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (getMapAt(i).getOffset() >= pcOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (!debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 Assert.that(i < len, "oopmap not found for pcOffset = " + pcOffset + "; len = " + len);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 Assert.that(getMapAt(i).getOffset() == pcOffset, "oopmap not found");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (i == len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 System.out.println("can't find oopmap at " + pcOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 System.out.print("Oopmap offsets are [ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 for (i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 System.out.print(getMapAt(i).getOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 System.out.println("]");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 i = len - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return getMapAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 OopMap m = getMapAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 /** Visitation -- iterates through the frame for a compiled method.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 This is a very generic mechanism that requires the Address to be
a61af66fc99e Initial load
duke
parents:
diff changeset
162 dereferenced by the callee. Other, more specialized, visitation
a61af66fc99e Initial load
duke
parents:
diff changeset
163 mechanisms are given below. */
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public static void oopsDo(Frame fr, CodeBlob cb, RegisterMap regMap, AddressVisitor oopVisitor, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 allDo(fr, cb, regMap, new MyVisitor(oopVisitor), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 /** Note that there are 4 required AddressVisitors: one for oops,
a61af66fc99e Initial load
duke
parents:
diff changeset
169 one for derived oops, one for values, and one for dead values */
a61af66fc99e Initial load
duke
parents:
diff changeset
170 public static void allDo(Frame fr, CodeBlob cb, RegisterMap regMap, OopMapVisitor visitor, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 CodeBlob tmpCB = VM.getVM().getCodeCache().findBlob(fr.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Assert.that(tmpCB != null && cb.equals(tmpCB), "wrong codeblob passed in");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 Assert.that(map != null, "no ptr map found");
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // handle derived pointers first (otherwise base pointer may be
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // changed before derived pointer offset has been collected)
a61af66fc99e Initial load
duke
parents:
diff changeset
184 OopMapValue omv;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 for (OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 Assert.that(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
191 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 Address derivedLoc = loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 visitor.visitDerivedOopLocation(baseLoc, derivedLoc);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // We want dead, value and oop oop_types
a61af66fc99e Initial load
duke
parents:
diff changeset
201 OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[] {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.DEAD_VALUE
a61af66fc99e Initial load
duke
parents:
diff changeset
203 };
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 for (OopMapStream oms = new OopMapStream(map, values); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (omv.getType() == OopMapValue.OopTypes.OOP_VALUE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // This assert commented out because this will be useful
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // to detect in the debugging system
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // assert(Universe::is_heap_or_null(*loc), "found non oop pointer");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 visitor.visitOopLocation(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 } else if (omv.getType() == OopMapValue.OopTypes.VALUE_VALUE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 visitor.visitValueLocation(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 } else if (omv.getType() == OopMapValue.OopTypes.DEAD_VALUE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 visitor.visitDeadLocation(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 /** Update callee-saved register info for the following frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
226 Should only be called in non-core builds. */
a61af66fc99e Initial load
duke
parents:
diff changeset
227 public static void updateRegisterMap(Frame fr, CodeBlob cb, RegisterMap regMap, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 Assert.that(!VM.getVM().isCore(), "non-core builds only");
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (!VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty OopMapSet for CodeBlob");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Hack for some topmost frames that have been found with empty
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // OopMapSets. (Actually have not seen the null case, but don't
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // want to take any chances.) See HSDB.showThreadStackMemory().
a61af66fc99e Initial load
duke
parents:
diff changeset
241 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if ((maps == null) || (maps.getSize() == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return;
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 // Check if caller must update oop argument
a61af66fc99e Initial load
duke
parents:
diff changeset
248 regMap.setIncludeArgumentOops(cb.callerMustGCArguments(regMap.getThread()));
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 int nofCallee = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 Address[] locs = new Address[2 * REG_COUNT + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
252 VMReg [] regs = new VMReg [2 * REG_COUNT + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // ("+1" because REG_COUNT might be zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Scan through oopmap and find location of all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // (we do not do update in place, since info could be overwritten)
a61af66fc99e Initial load
duke
parents:
diff changeset
257 OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 Assert.that(map != null, "no ptr map found");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 OopMapValue omv = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 for(OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Assert.that(nofCallee < 2 * REG_COUNT, "overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 regs[nofCallee] = omv.getContentReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
269 locs[nofCallee] = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 nofCallee++;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // Check that runtime stubs save all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // After adapter frames were deleted C2 doesn't use callee save registers at present
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (VM.getVM().isServerCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 Assert.that(!cb.isRuntimeStub() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
278 (nofCallee >= SAVED_ON_ENTRY_REG_COUNT || nofCallee >= C_SAVED_ON_ENTRY_REG_COUNT),
a61af66fc99e Initial load
duke
parents:
diff changeset
279 "must save all");
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 // Copy found callee-saved register to reg_map
a61af66fc99e Initial load
duke
parents:
diff changeset
284 for (int i = 0; i < nofCallee; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 regMap.setLocation(regs[i], locs[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }