Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java @ 3945:8ed53447f690
Merge
author | iveresov |
---|---|
date | Thu, 15 Sep 2011 12:44:09 -0700 |
parents | 7588156f5cf9 |
children | 1d7922586cf6 |
rev | line source |
---|---|
0 | 1 /* |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
1748
diff
changeset
|
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.code; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 | |
30 import sun.jvm.hotspot.asm.x86.*; | |
31 import sun.jvm.hotspot.compiler.*; | |
32 import sun.jvm.hotspot.debugger.*; | |
33 import sun.jvm.hotspot.runtime.*; | |
34 import sun.jvm.hotspot.types.*; | |
35 import sun.jvm.hotspot.utilities.*; | |
36 | |
37 public class CodeBlob extends VMObject { | |
38 private static AddressField nameField; | |
39 private static CIntegerField sizeField; | |
40 private static CIntegerField headerSizeField; | |
41 private static CIntegerField relocationSizeField; | |
1748 | 42 private static CIntegerField contentOffsetField; |
43 private static CIntegerField codeOffsetField; | |
0 | 44 private static CIntegerField frameCompleteOffsetField; |
45 private static CIntegerField dataOffsetField; | |
46 private static CIntegerField frameSizeField; | |
47 private static AddressField oopMapsField; | |
48 | |
49 // Only used by server compiler on x86; computed over in SA rather | |
50 // than relying on computation in target VM | |
51 private static final int NOT_YET_COMPUTED = -2; | |
52 private static final int UNDEFINED = -1; | |
53 private int linkOffset = NOT_YET_COMPUTED; | |
54 private static int matcherInterpreterFramePointerReg; | |
55 | |
56 static { | |
57 VM.registerVMInitializedObserver(new Observer() { | |
58 public void update(Observable o, Object data) { | |
59 initialize(VM.getVM().getTypeDataBase()); | |
60 } | |
61 }); | |
62 } | |
63 | |
64 private static void initialize(TypeDataBase db) { | |
65 Type type = db.lookupType("CodeBlob"); | |
66 | |
67 nameField = type.getAddressField("_name"); | |
68 sizeField = type.getCIntegerField("_size"); | |
69 headerSizeField = type.getCIntegerField("_header_size"); | |
70 relocationSizeField = type.getCIntegerField("_relocation_size"); | |
71 frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset"); | |
1748 | 72 contentOffsetField = type.getCIntegerField("_content_offset"); |
73 codeOffsetField = type.getCIntegerField("_code_offset"); | |
0 | 74 dataOffsetField = type.getCIntegerField("_data_offset"); |
75 frameSizeField = type.getCIntegerField("_frame_size"); | |
76 oopMapsField = type.getAddressField("_oop_maps"); | |
77 | |
78 if (VM.getVM().isServerCompiler()) { | |
79 matcherInterpreterFramePointerReg = | |
80 db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue(); | |
81 } | |
82 } | |
83 | |
84 public CodeBlob(Address addr) { | |
85 super(addr); | |
86 } | |
87 | |
88 // Typing | |
89 public boolean isBufferBlob() { return false; } | |
90 public boolean isNMethod() { return false; } | |
91 public boolean isRuntimeStub() { return false; } | |
92 public boolean isDeoptimizationStub() { return false; } | |
93 public boolean isUncommonTrapStub() { return false; } | |
94 public boolean isExceptionStub() { return false; } | |
95 public boolean isSafepointStub() { return false; } | |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
1748
diff
changeset
|
96 public boolean isRicochetBlob() { return false; } |
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
1748
diff
changeset
|
97 public boolean isAdapterBlob() { return false; } |
0 | 98 |
99 // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod() | |
100 public boolean isJavaMethod() { return false; } | |
101 public boolean isNativeMethod() { return false; } | |
102 /** On-Stack Replacement method */ | |
103 public boolean isOSRMethod() { return false; } | |
104 | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
105 public NMethod asNMethodOrNull() { |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
106 if (isNMethod()) return (NMethod)this; |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
107 return null; |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
108 } |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
109 |
0 | 110 // Boundaries |
111 public Address headerBegin() { | |
112 return addr; | |
113 } | |
114 | |
115 public Address headerEnd() { | |
116 return addr.addOffsetTo(headerSizeField.getValue(addr)); | |
117 } | |
118 | |
119 // FIXME: add RelocInfo | |
120 // public RelocInfo relocationBegin(); | |
121 // public RelocInfo relocationEnd(); | |
122 | |
1748 | 123 public Address contentBegin() { |
124 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); | |
0 | 125 } |
126 | |
1748 | 127 public Address contentEnd() { |
128 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); | |
129 } | |
130 | |
131 public Address codeBegin() { | |
132 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); | |
133 } | |
134 | |
135 public Address codeEnd() { | |
0 | 136 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
137 } | |
138 | |
139 public Address dataBegin() { | |
140 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); | |
141 } | |
142 | |
143 public Address dataEnd() { | |
144 return headerBegin().addOffsetTo(sizeField.getValue(addr)); | |
145 } | |
146 | |
147 // Offsets | |
1748 | 148 public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); } |
149 public int getContentOffset() { return (int) contentOffsetField.getValue(addr); } | |
150 public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); } | |
151 public int getDataOffset() { return (int) dataOffsetField .getValue(addr); } | |
0 | 152 |
153 // Sizes | |
1748 | 154 public int getSize() { return (int) sizeField .getValue(addr); } |
155 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } | |
0 | 156 // FIXME: add getRelocationSize() |
1748 | 157 public int getContentSize() { return (int) contentEnd().minus(contentBegin()); } |
158 public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); } | |
159 public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); } | |
0 | 160 |
161 // Containment | |
1748 | 162 public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
0 | 163 // FIXME: add relocationContains |
1748 | 164 public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); } |
165 public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); } | |
166 public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } | |
167 public boolean contains(Address addr) { return contentContains(addr); } | |
168 public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); } | |
0 | 169 |
170 // Reclamation support (really only used by the nmethods, but in order to get asserts to work | |
171 // in the CodeCache they are defined virtual here) | |
172 public boolean isZombie() { return false; } | |
173 public boolean isLockedByVM() { return false; } | |
174 | |
175 /** OopMap for frame; can return null if none available */ | |
176 public OopMapSet getOopMaps() { | |
177 Address oopMapsAddr = oopMapsField.getValue(addr); | |
178 if (oopMapsAddr == null) { | |
179 return null; | |
180 } | |
181 return new OopMapSet(oopMapsAddr); | |
182 } | |
183 // FIXME: not yet implementable | |
184 // void set_oop_maps(OopMapSet* p); | |
185 | |
186 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { | |
187 Address pc = returnAddress; | |
188 if (Assert.ASSERTS_ENABLED) { | |
189 Assert.that(getOopMaps() != null, "nope"); | |
190 } | |
1748 | 191 return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging); |
0 | 192 } |
193 | |
194 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } | |
195 // FIXME; | |
196 | |
197 /** NOTE: this returns a size in BYTES in this system! */ | |
198 public long getFrameSize() { | |
199 return VM.getVM().getAddressSize() * frameSizeField.getValue(addr); | |
200 } | |
201 | |
202 // Returns true, if the next frame is responsible for GC'ing oops passed as arguments | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
203 public boolean callerMustGCArguments() { return false; } |
0 | 204 |
205 public String getName() { | |
206 return CStringUtilities.getString(nameField.getValue(addr)); | |
207 } | |
208 | |
209 // FIXME: NOT FINISHED | |
210 | |
211 // FIXME: add more accessors | |
212 | |
213 public void print() { | |
214 printOn(System.out); | |
215 } | |
216 | |
217 public void printOn(PrintStream tty) { | |
218 tty.print(getName()); | |
219 printComponentsOn(tty); | |
220 } | |
221 | |
222 protected void printComponentsOn(PrintStream tty) { | |
1748 | 223 tty.println(" content: [" + contentBegin() + ", " + contentEnd() + "), " + |
224 " code: [" + codeBegin() + ", " + codeEnd() + "), " + | |
0 | 225 " data: [" + dataBegin() + ", " + dataEnd() + "), " + |
226 " frame size: " + getFrameSize()); | |
227 } | |
228 } |