annotate agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1
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
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
71 public void visitNarrowOopLocation(Address narrowOopAddr) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
72 addressVisitor.visitCompOopAddress(narrowOopAddr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 initialize(VM.getVM().getTypeDataBase());
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
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 Type type = db.lookupType("OopMapSet");
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 omCountField = type.getCIntegerField("_om_count");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 omSizeField = type.getCIntegerField("_om_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 omDataField = type.getAddressField("_om_data");
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (VM.getVM().isServerCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("SAVED_ON_ENTRY_REG_COUNT").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
95 C_SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("C_SAVED_ON_ENTRY_REG_COUNT").intValue();
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
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public OopMapSet(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 /** Returns the number of OopMaps in this OopMapSet */
a61af66fc99e Initial load
duke
parents:
diff changeset
105 public long getSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return omCountField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 /** returns the OopMap at a given index */
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public OopMap getMapAt(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 Assert.that((index >= 0) && (index <= getSize()),"bad index");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 Address omDataAddr = omDataField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 Address oopMapAddr = omDataAddr.getAddressAt(index * VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (oopMapAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return new OopMap(oopMapAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public OopMap findMapAtOffset(long pcOffset, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 int len = (int) getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 Assert.that(len > 0, "must have pointer maps");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Scan through oopmaps. Stop when current offset is either equal or greater
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // than the one we are looking for.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 for (i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (getMapAt(i).getOffset() >= pcOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (!debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 Assert.that(i < len, "oopmap not found for pcOffset = " + pcOffset + "; len = " + len);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 Assert.that(getMapAt(i).getOffset() == pcOffset, "oopmap not found");
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (i == len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (DEBUG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 System.out.println("can't find oopmap at " + pcOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 System.out.print("Oopmap offsets are [ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for (i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 System.out.print(getMapAt(i).getOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 System.out.println("]");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 i = len - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return getMapAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 OopMap m = getMapAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 /** Visitation -- iterates through the frame for a compiled method.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 This is a very generic mechanism that requires the Address to be
a61af66fc99e Initial load
duke
parents:
diff changeset
163 dereferenced by the callee. Other, more specialized, visitation
a61af66fc99e Initial load
duke
parents:
diff changeset
164 mechanisms are given below. */
a61af66fc99e Initial load
duke
parents:
diff changeset
165 public static void oopsDo(Frame fr, CodeBlob cb, RegisterMap regMap, AddressVisitor oopVisitor, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 allDo(fr, cb, regMap, new MyVisitor(oopVisitor), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 /** Note that there are 4 required AddressVisitors: one for oops,
a61af66fc99e Initial load
duke
parents:
diff changeset
170 one for derived oops, one for values, and one for dead values */
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public static void allDo(Frame fr, CodeBlob cb, RegisterMap regMap, OopMapVisitor visitor, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 CodeBlob tmpCB = VM.getVM().getCodeCache().findBlob(fr.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
174 Assert.that(tmpCB != null && cb.equals(tmpCB), "wrong codeblob passed in");
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Assert.that(map != null, "no ptr map found");
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // handle derived pointers first (otherwise base pointer may be
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // changed before derived pointer offset has been collected)
a61af66fc99e Initial load
duke
parents:
diff changeset
185 OopMapValue omv;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 for (OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (VM.getVM().isClientCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Assert.that(false, "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 Address derivedLoc = loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 visitor.visitDerivedOopLocation(baseLoc, derivedLoc);
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
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
201 // We want narow oop, value and oop oop_types
0
a61af66fc99e Initial load
duke
parents:
diff changeset
202 OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[] {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
203 OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.NARROWOOP_VALUE
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204 };
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 for (OopMapStream oms = new OopMapStream(map, values); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (omv.getType() == OopMapValue.OopTypes.OOP_VALUE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // This assert commented out because this will be useful
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // to detect in the debugging system
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // assert(Universe::is_heap_or_null(*loc), "found non oop pointer");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 visitor.visitOopLocation(loc);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 } else if (omv.getType() == OopMapValue.OopTypes.VALUE_VALUE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 visitor.visitValueLocation(loc);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
218 } else if (omv.getType() == OopMapValue.OopTypes.NARROWOOP_VALUE) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
219 visitor.visitNarrowOopLocation(loc);
0
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
a61af66fc99e Initial load
duke
parents:
diff changeset
226 /** Update callee-saved register info for the following frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
227 Should only be called in non-core builds. */
a61af66fc99e Initial load
duke
parents:
diff changeset
228 public static void updateRegisterMap(Frame fr, CodeBlob cb, RegisterMap regMap, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 Assert.that(!VM.getVM().isCore(), "non-core builds only");
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 (!VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty OopMapSet for CodeBlob");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // Hack for some topmost frames that have been found with empty
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // OopMapSets. (Actually have not seen the null case, but don't
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // want to take any chances.) See HSDB.showThreadStackMemory().
a61af66fc99e Initial load
duke
parents:
diff changeset
242 OopMapSet maps = cb.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 if ((maps == null) || (maps.getSize() == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return;
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 // Check if caller must update oop argument
a61af66fc99e Initial load
duke
parents:
diff changeset
249 regMap.setIncludeArgumentOops(cb.callerMustGCArguments(regMap.getThread()));
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 int nofCallee = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 Address[] locs = new Address[2 * REG_COUNT + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
253 VMReg [] regs = new VMReg [2 * REG_COUNT + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // ("+1" because REG_COUNT might be zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Scan through oopmap and find location of all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // (we do not do update in place, since info could be overwritten)
a61af66fc99e Initial load
duke
parents:
diff changeset
258 OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 Assert.that(map != null, "no ptr map found");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 OopMapValue omv = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 for(OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE); !oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 Assert.that(nofCallee < 2 * REG_COUNT, "overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 regs[nofCallee] = omv.getContentReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
270 locs[nofCallee] = fr.oopMapRegToLocation(omv.getReg(), regMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 nofCallee++;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Check that runtime stubs save all callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // After adapter frames were deleted C2 doesn't use callee save registers at present
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if (VM.getVM().isServerCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 Assert.that(!cb.isRuntimeStub() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
279 (nofCallee >= SAVED_ON_ENTRY_REG_COUNT || nofCallee >= C_SAVED_ON_ENTRY_REG_COUNT),
a61af66fc99e Initial load
duke
parents:
diff changeset
280 "must save all");
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // Copy found callee-saved register to reg_map
a61af66fc99e Initial load
duke
parents:
diff changeset
285 for (int i = 0; i < nofCallee; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 regMap.setLocation(regs[i], locs[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }