Mercurial > hg > graal-compiler
annotate agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java @ 6266:1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
author | twisti |
---|---|
date | Tue, 24 Jul 2012 10:51:00 -0700 |
parents | 7588156f5cf9 |
children | 5a98bf7d847b |
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 isAdapterBlob() { return false; } |
0 | 97 |
98 // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod() | |
99 public boolean isJavaMethod() { return false; } | |
100 public boolean isNativeMethod() { return false; } | |
101 /** On-Stack Replacement method */ | |
102 public boolean isOSRMethod() { return false; } | |
103 | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
104 public NMethod asNMethodOrNull() { |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
105 if (isNMethod()) return (NMethod)this; |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
106 return null; |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
107 } |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
3388
diff
changeset
|
108 |
0 | 109 // Boundaries |
110 public Address headerBegin() { | |
111 return addr; | |
112 } | |
113 | |
114 public Address headerEnd() { | |
115 return addr.addOffsetTo(headerSizeField.getValue(addr)); | |
116 } | |
117 | |
118 // FIXME: add RelocInfo | |
119 // public RelocInfo relocationBegin(); | |
120 // public RelocInfo relocationEnd(); | |
121 | |
1748 | 122 public Address contentBegin() { |
123 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); | |
0 | 124 } |
125 | |
1748 | 126 public Address contentEnd() { |
127 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); | |
128 } | |
129 | |
130 public Address codeBegin() { | |
131 return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); | |
132 } | |
133 | |
134 public Address codeEnd() { | |
0 | 135 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); |
136 } | |
137 | |
138 public Address dataBegin() { | |
139 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); | |
140 } | |
141 | |
142 public Address dataEnd() { | |
143 return headerBegin().addOffsetTo(sizeField.getValue(addr)); | |
144 } | |
145 | |
146 // Offsets | |
1748 | 147 public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); } |
148 public int getContentOffset() { return (int) contentOffsetField.getValue(addr); } | |
149 public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); } | |
150 public int getDataOffset() { return (int) dataOffsetField .getValue(addr); } | |
0 | 151 |
152 // Sizes | |
1748 | 153 public int getSize() { return (int) sizeField .getValue(addr); } |
154 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } | |
0 | 155 // FIXME: add getRelocationSize() |
1748 | 156 public int getContentSize() { return (int) contentEnd().minus(contentBegin()); } |
157 public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); } | |
158 public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); } | |
0 | 159 |
160 // Containment | |
1748 | 161 public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } |
0 | 162 // FIXME: add relocationContains |
1748 | 163 public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); } |
164 public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); } | |
165 public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } | |
166 public boolean contains(Address addr) { return contentContains(addr); } | |
167 public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); } | |
0 | 168 |
169 // Reclamation support (really only used by the nmethods, but in order to get asserts to work | |
170 // in the CodeCache they are defined virtual here) | |
171 public boolean isZombie() { return false; } | |
172 public boolean isLockedByVM() { return false; } | |
173 | |
174 /** OopMap for frame; can return null if none available */ | |
175 public OopMapSet getOopMaps() { | |
176 Address oopMapsAddr = oopMapsField.getValue(addr); | |
177 if (oopMapsAddr == null) { | |
178 return null; | |
179 } | |
180 return new OopMapSet(oopMapsAddr); | |
181 } | |
182 // FIXME: not yet implementable | |
183 // void set_oop_maps(OopMapSet* p); | |
184 | |
185 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { | |
186 Address pc = returnAddress; | |
187 if (Assert.ASSERTS_ENABLED) { | |
188 Assert.that(getOopMaps() != null, "nope"); | |
189 } | |
1748 | 190 return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging); |
0 | 191 } |
192 | |
193 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } | |
194 // FIXME; | |
195 | |
196 /** NOTE: this returns a size in BYTES in this system! */ | |
197 public long getFrameSize() { | |
198 return VM.getVM().getAddressSize() * frameSizeField.getValue(addr); | |
199 } | |
200 | |
201 // 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
|
202 public boolean callerMustGCArguments() { return false; } |
0 | 203 |
204 public String getName() { | |
205 return CStringUtilities.getString(nameField.getValue(addr)); | |
206 } | |
207 | |
208 // FIXME: NOT FINISHED | |
209 | |
210 // FIXME: add more accessors | |
211 | |
212 public void print() { | |
213 printOn(System.out); | |
214 } | |
215 | |
216 public void printOn(PrintStream tty) { | |
217 tty.print(getName()); | |
218 printComponentsOn(tty); | |
219 } | |
220 | |
221 protected void printComponentsOn(PrintStream tty) { | |
1748 | 222 tty.println(" content: [" + contentBegin() + ", " + contentEnd() + "), " + |
223 " code: [" + codeBegin() + ", " + codeEnd() + "), " + | |
0 | 224 " data: [" + dataBegin() + ", " + dataEnd() + "), " + |
225 " frame size: " + getFrameSize()); | |
226 } | |
227 } |