1 /* |
1 /* |
2 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
37 public class CodeBlob extends VMObject { |
37 public class CodeBlob extends VMObject { |
38 private static AddressField nameField; |
38 private static AddressField nameField; |
39 private static CIntegerField sizeField; |
39 private static CIntegerField sizeField; |
40 private static CIntegerField headerSizeField; |
40 private static CIntegerField headerSizeField; |
41 private static CIntegerField relocationSizeField; |
41 private static CIntegerField relocationSizeField; |
42 private static CIntegerField instructionsOffsetField; |
42 private static CIntegerField contentOffsetField; |
|
43 private static CIntegerField codeOffsetField; |
43 private static CIntegerField frameCompleteOffsetField; |
44 private static CIntegerField frameCompleteOffsetField; |
44 private static CIntegerField dataOffsetField; |
45 private static CIntegerField dataOffsetField; |
45 private static CIntegerField frameSizeField; |
46 private static CIntegerField frameSizeField; |
46 private static AddressField oopMapsField; |
47 private static AddressField oopMapsField; |
47 |
48 |
66 nameField = type.getAddressField("_name"); |
67 nameField = type.getAddressField("_name"); |
67 sizeField = type.getCIntegerField("_size"); |
68 sizeField = type.getCIntegerField("_size"); |
68 headerSizeField = type.getCIntegerField("_header_size"); |
69 headerSizeField = type.getCIntegerField("_header_size"); |
69 relocationSizeField = type.getCIntegerField("_relocation_size"); |
70 relocationSizeField = type.getCIntegerField("_relocation_size"); |
70 frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset"); |
71 frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset"); |
71 instructionsOffsetField = type.getCIntegerField("_instructions_offset"); |
72 contentOffsetField = type.getCIntegerField("_content_offset"); |
|
73 codeOffsetField = type.getCIntegerField("_code_offset"); |
72 dataOffsetField = type.getCIntegerField("_data_offset"); |
74 dataOffsetField = type.getCIntegerField("_data_offset"); |
73 frameSizeField = type.getCIntegerField("_frame_size"); |
75 frameSizeField = type.getCIntegerField("_frame_size"); |
74 oopMapsField = type.getAddressField("_oop_maps"); |
76 oopMapsField = type.getAddressField("_oop_maps"); |
75 |
77 |
76 if (VM.getVM().isServerCompiler()) { |
78 if (VM.getVM().isServerCompiler()) { |
109 |
111 |
110 // FIXME: add RelocInfo |
112 // FIXME: add RelocInfo |
111 // public RelocInfo relocationBegin(); |
113 // public RelocInfo relocationBegin(); |
112 // public RelocInfo relocationEnd(); |
114 // public RelocInfo relocationEnd(); |
113 |
115 |
114 public Address instructionsBegin() { |
116 public Address contentBegin() { |
115 return headerBegin().addOffsetTo(instructionsOffsetField.getValue(addr)); |
117 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); |
116 } |
118 } |
117 |
119 |
118 public Address instructionsEnd() { |
120 public Address contentEnd() { |
|
121 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
|
122 } |
|
123 |
|
124 public Address codeBegin() { |
|
125 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); |
|
126 } |
|
127 |
|
128 public Address codeEnd() { |
119 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
129 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
120 } |
130 } |
121 |
131 |
122 public Address dataBegin() { |
132 public Address dataBegin() { |
123 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
133 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
126 public Address dataEnd() { |
136 public Address dataEnd() { |
127 return headerBegin().addOffsetTo(sizeField.getValue(addr)); |
137 return headerBegin().addOffsetTo(sizeField.getValue(addr)); |
128 } |
138 } |
129 |
139 |
130 // Offsets |
140 // Offsets |
131 public int getRelocationOffset() { return (int) headerSizeField.getValue(addr); } |
141 public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); } |
132 public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); } |
142 public int getContentOffset() { return (int) contentOffsetField.getValue(addr); } |
133 public int getDataOffset() { return (int) dataOffsetField.getValue(addr); } |
143 public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); } |
|
144 public int getDataOffset() { return (int) dataOffsetField .getValue(addr); } |
134 |
145 |
135 // Sizes |
146 // Sizes |
136 public int getSize() { return (int) sizeField.getValue(addr); } |
147 public int getSize() { return (int) sizeField .getValue(addr); } |
137 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } |
148 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } |
138 // FIXME: add getRelocationSize() |
149 // FIXME: add getRelocationSize() |
139 public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); } |
150 public int getContentSize() { return (int) contentEnd().minus(contentBegin()); } |
140 public int getDataSize() { return (int) dataEnd().minus(dataBegin()); } |
151 public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); } |
|
152 public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); } |
141 |
153 |
142 // Containment |
154 // Containment |
143 public boolean blobContains(Address addr) { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); } |
155 public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
144 // FIXME: add relocationContains |
156 // FIXME: add relocationContains |
145 public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); } |
157 public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); } |
146 public boolean dataContains(Address addr) { return dataBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); } |
158 public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); } |
147 public boolean contains(Address addr) { return instructionsContains(addr); } |
159 public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
148 public boolean isFrameCompleteAt(Address a) { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); } |
160 public boolean contains(Address addr) { return contentContains(addr); } |
|
161 public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); } |
149 |
162 |
150 // Reclamation support (really only used by the nmethods, but in order to get asserts to work |
163 // Reclamation support (really only used by the nmethods, but in order to get asserts to work |
151 // in the CodeCache they are defined virtual here) |
164 // in the CodeCache they are defined virtual here) |
152 public boolean isZombie() { return false; } |
165 public boolean isZombie() { return false; } |
153 public boolean isLockedByVM() { return false; } |
166 public boolean isLockedByVM() { return false; } |
166 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { |
179 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { |
167 Address pc = returnAddress; |
180 Address pc = returnAddress; |
168 if (Assert.ASSERTS_ENABLED) { |
181 if (Assert.ASSERTS_ENABLED) { |
169 Assert.that(getOopMaps() != null, "nope"); |
182 Assert.that(getOopMaps() != null, "nope"); |
170 } |
183 } |
171 return getOopMaps().findMapAtOffset(pc.minus(instructionsBegin()), debugging); |
184 return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging); |
172 } |
185 } |
173 |
186 |
174 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } |
187 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } |
175 // FIXME; |
188 // FIXME; |
176 |
189 |
198 tty.print(getName()); |
211 tty.print(getName()); |
199 printComponentsOn(tty); |
212 printComponentsOn(tty); |
200 } |
213 } |
201 |
214 |
202 protected void printComponentsOn(PrintStream tty) { |
215 protected void printComponentsOn(PrintStream tty) { |
203 tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " + |
216 tty.println(" content: [" + contentBegin() + ", " + contentEnd() + "), " + |
|
217 " code: [" + codeBegin() + ", " + codeEnd() + "), " + |
204 " data: [" + dataBegin() + ", " + dataEnd() + "), " + |
218 " data: [" + dataBegin() + ", " + dataEnd() + "), " + |
205 " frame size: " + getFrameSize()); |
219 " frame size: " + getFrameSize()); |
206 } |
220 } |
207 } |
221 } |