1 /*
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
51 public void setAddressVisitor(AddressVisitor addressVisitor) {
52 this.addressVisitor = addressVisitor;
53 }
54
55 public void visitOopLocation(Address oopAddr) {
56 addressVisitor.visitAddress(oopAddr);
57 }
58
59 public void visitDerivedOopLocation(Address baseOopAddr, Address derivedOopAddr) {
60 if (VM.getVM().isClientCompiler()) {
61 Assert.that(false, "should not reach here");
62 } else if (VM.getVM().isServerCompiler() &&
63 VM.getVM().useDerivedPointerTable()) {
64 Assert.that(false, "FIXME: add derived pointer table");
65 }
66 }
67
68 public void visitValueLocation(Address valueAddr) {
69 }
70
71 public void visitDeadLocation(Address deadAddr) {
72 }
73 }
74
75 static {
76 VM.registerVMInitializedObserver(new Observer() {
77 public void update(Observable o, Object data) {
78 initialize(VM.getVM().getTypeDataBase());
79 }
80 });
81 }
82
83 private static void initialize(TypeDataBase db) {
84 Type type = db.lookupType("OopMapSet");
85
86 omCountField = type.getCIntegerField("_om_count");
87 omSizeField = type.getCIntegerField("_om_size");
88 omDataField = type.getAddressField("_om_data");
89
90 if (!VM.getVM().isCore()) {
91 REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue();
180 }
181
182 // handle derived pointers first (otherwise base pointer may be
183 // changed before derived pointer offset has been collected)
184 OopMapValue omv;
185 {
186 for (OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE); !oms.isDone(); oms.next()) {
187 if (VM.getVM().isClientCompiler()) {
188 Assert.that(false, "should not reach here");
189 }
190 omv = oms.getCurrent();
191 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
192 if (loc != null) {
193 Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap);
194 Address derivedLoc = loc;
195 visitor.visitDerivedOopLocation(baseLoc, derivedLoc);
196 }
197 }
198 }
199
200 // We want dead, value and oop oop_types
201 OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[] {
202 OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.DEAD_VALUE
203 };
204
205 {
206 for (OopMapStream oms = new OopMapStream(map, values); !oms.isDone(); oms.next()) {
207 omv = oms.getCurrent();
208 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
209 if (loc != null) {
210 if (omv.getType() == OopMapValue.OopTypes.OOP_VALUE) {
211 // This assert commented out because this will be useful
212 // to detect in the debugging system
213 // assert(Universe::is_heap_or_null(*loc), "found non oop pointer");
214 visitor.visitOopLocation(loc);
215 } else if (omv.getType() == OopMapValue.OopTypes.VALUE_VALUE) {
216 visitor.visitValueLocation(loc);
217 } else if (omv.getType() == OopMapValue.OopTypes.DEAD_VALUE) {
218 visitor.visitDeadLocation(loc);
219 }
220 }
221 }
222 }
223 }
224
225 /** Update callee-saved register info for the following frame.
226 Should only be called in non-core builds. */
227 public static void updateRegisterMap(Frame fr, CodeBlob cb, RegisterMap regMap, boolean debugging) {
228 if (Assert.ASSERTS_ENABLED) {
229 Assert.that(!VM.getVM().isCore(), "non-core builds only");
230 }
231
232 if (!VM.getVM().isDebugging()) {
233 if (Assert.ASSERTS_ENABLED) {
234 OopMapSet maps = cb.getOopMaps();
235 Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty OopMapSet for CodeBlob");
236 }
237 } else {
238 // Hack for some topmost frames that have been found with empty
|
1 /*
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
51 public void setAddressVisitor(AddressVisitor addressVisitor) {
52 this.addressVisitor = addressVisitor;
53 }
54
55 public void visitOopLocation(Address oopAddr) {
56 addressVisitor.visitAddress(oopAddr);
57 }
58
59 public void visitDerivedOopLocation(Address baseOopAddr, Address derivedOopAddr) {
60 if (VM.getVM().isClientCompiler()) {
61 Assert.that(false, "should not reach here");
62 } else if (VM.getVM().isServerCompiler() &&
63 VM.getVM().useDerivedPointerTable()) {
64 Assert.that(false, "FIXME: add derived pointer table");
65 }
66 }
67
68 public void visitValueLocation(Address valueAddr) {
69 }
70
71 public void visitNarrowOopLocation(Address narrowOopAddr) {
72 addressVisitor.visitCompOopAddress(narrowOopAddr);
73 }
74 }
75
76 static {
77 VM.registerVMInitializedObserver(new Observer() {
78 public void update(Observable o, Object data) {
79 initialize(VM.getVM().getTypeDataBase());
80 }
81 });
82 }
83
84 private static void initialize(TypeDataBase db) {
85 Type type = db.lookupType("OopMapSet");
86
87 omCountField = type.getCIntegerField("_om_count");
88 omSizeField = type.getCIntegerField("_om_size");
89 omDataField = type.getAddressField("_om_data");
90
91 if (!VM.getVM().isCore()) {
92 REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue();
181 }
182
183 // handle derived pointers first (otherwise base pointer may be
184 // changed before derived pointer offset has been collected)
185 OopMapValue omv;
186 {
187 for (OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE); !oms.isDone(); oms.next()) {
188 if (VM.getVM().isClientCompiler()) {
189 Assert.that(false, "should not reach here");
190 }
191 omv = oms.getCurrent();
192 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
193 if (loc != null) {
194 Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap);
195 Address derivedLoc = loc;
196 visitor.visitDerivedOopLocation(baseLoc, derivedLoc);
197 }
198 }
199 }
200
201 // We want narow oop, value and oop oop_types
202 OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[] {
203 OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.NARROWOOP_VALUE
204 };
205
206 {
207 for (OopMapStream oms = new OopMapStream(map, values); !oms.isDone(); oms.next()) {
208 omv = oms.getCurrent();
209 Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap);
210 if (loc != null) {
211 if (omv.getType() == OopMapValue.OopTypes.OOP_VALUE) {
212 // This assert commented out because this will be useful
213 // to detect in the debugging system
214 // assert(Universe::is_heap_or_null(*loc), "found non oop pointer");
215 visitor.visitOopLocation(loc);
216 } else if (omv.getType() == OopMapValue.OopTypes.VALUE_VALUE) {
217 visitor.visitValueLocation(loc);
218 } else if (omv.getType() == OopMapValue.OopTypes.NARROWOOP_VALUE) {
219 visitor.visitNarrowOopLocation(loc);
220 }
221 }
222 }
223 }
224 }
225
226 /** Update callee-saved register info for the following frame.
227 Should only be called in non-core builds. */
228 public static void updateRegisterMap(Frame fr, CodeBlob cb, RegisterMap regMap, boolean debugging) {
229 if (Assert.ASSERTS_ENABLED) {
230 Assert.that(!VM.getVM().isCore(), "non-core builds only");
231 }
232
233 if (!VM.getVM().isDebugging()) {
234 if (Assert.ASSERTS_ENABLED) {
235 OopMapSet maps = cb.getOopMaps();
236 Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty OopMapSet for CodeBlob");
237 }
238 } else {
239 // Hack for some topmost frames that have been found with empty
|