comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java @ 1433:efba53f86c4f

various fixes and enhancements * correct refmap->oopmap conversion (register numbering, stack slot numbering) * fixes for inlining (correct scoping in exception handler lookup, NPE in scope conversion) * support for "jump to runtime stub" (patching code needs to be aware of jmp instruction) * provide more information about methods (to allow inlining: has_balanced_monitors, etc.) * fixes to signature type lookup * isSubTypeOf: correct handling of array classes * RiType: componentType/arrayOf * prologue: inline cache check, icmiss stub * klass state check (resolved but not initialized) in newinstance * card table write barriers * c1x classes are optional (to allow running c1 without them) * correct for stored frame pointer in calling conventions (methods with arguments on stack) * getType(Class<?>) for some basic types, used for optimizations and folding * RiMethod/RiType: throw exception instead of silent failure on unsupported operations * RiType: resolved/unresolved array type support * refactoring: new on-demand template generation mechanism * optimizations: template specialization for no_null_check, given length, etc.
author Lukas Stadler <lukas.stadler@oracle.com>
date Thu, 16 Sep 2010 19:42:20 -0700
parents 760213a60e8b
children 72cfb36c6bb2
comparison
equal deleted inserted replaced
1432:b61a43cd1255 1433:efba53f86c4f
15 * 15 *
16 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. 16 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd.
17 */ 17 */
18 package com.sun.hotspot.c1x; 18 package com.sun.hotspot.c1x;
19 19
20 import java.io.ByteArrayOutputStream; 20 import java.io.*;
21 import java.lang.reflect.Constructor; 21 import java.lang.reflect.*;
22 import java.lang.reflect.Field; 22
23 import java.lang.reflect.Method; 23 import com.sun.cri.ci.*;
24
25 import com.sun.cri.ci.CiConstant;
26 import com.sun.cri.ci.CiMethodInvokeArguments;
27 import com.sun.cri.ci.CiTargetMethod;
28 import com.sun.cri.ci.CiTargetMethod.Call; 24 import com.sun.cri.ci.CiTargetMethod.Call;
29 import com.sun.cri.ci.CiTargetMethod.DataPatch; 25 import com.sun.cri.ci.CiTargetMethod.DataPatch;
30 import com.sun.cri.ci.CiTargetMethod.Safepoint; 26 import com.sun.cri.ci.CiTargetMethod.Safepoint;
31 import com.sun.cri.ri.RiConstantPool; 27 import com.sun.cri.ri.*;
32 import com.sun.cri.ri.RiField; 28 import com.sun.max.asm.*;
33 import com.sun.cri.ri.RiMethod; 29 import com.sun.max.asm.dis.*;
34 import com.sun.cri.ri.RiOsrFrame; 30 import com.sun.max.lang.*;
35 import com.sun.cri.ri.RiRuntime;
36 import com.sun.cri.ri.RiSnippets;
37 import com.sun.cri.ri.RiType;
38 import com.sun.max.asm.InstructionSet;
39 import com.sun.max.asm.dis.DisassembledObject;
40 import com.sun.max.asm.dis.Disassembler;
41 import com.sun.max.asm.dis.DisassemblyPrinter;
42 31
43 /** 32 /**
44 * CRI runtime implementation for the HotSpot VM. 33 * CRI runtime implementation for the HotSpot VM.
45 * 34 *
46 * @author Thomas Wuerthinger, Lukas Stadler 35 * @author Thomas Wuerthinger, Lukas Stadler
57 this.config = config; 46 this.config = config;
58 } 47 }
59 48
60 @Override 49 @Override
61 public int basicObjectLockOffsetInBytes() { 50 public int basicObjectLockOffsetInBytes() {
62 // TODO Auto-generated method stub
63 return 0; 51 return 0;
64 } 52 }
65 53
66 @Override 54 @Override
67 public int codeOffset() { 55 public int codeOffset() {
68 // TODO Auto-generated method stub
69 return 0; 56 return 0;
70 } 57 }
71 58
72 @Override 59 @Override
73 public String disassemble(byte[] code) { 60 public String disassemble(byte[] code) {
75 } 62 }
76 63
77 private String disassemble(byte[] code, DisassemblyPrinter disassemblyPrinter) { 64 private String disassemble(byte[] code, DisassemblyPrinter disassemblyPrinter) {
78 final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 65 final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
79 final InstructionSet instructionSet = InstructionSet.AMD64; 66 final InstructionSet instructionSet = InstructionSet.AMD64;
80 Disassembler.disassemble(byteArrayOutputStream, code, instructionSet, null, 0, null, disassemblyPrinter); 67 Disassembler.disassemble(byteArrayOutputStream, code, instructionSet, WordWidth.BITS_64, 0, null, disassemblyPrinter);
81 return byteArrayOutputStream.toString(); 68 return byteArrayOutputStream.toString();
82 } 69 }
83 70
84 @Override 71 @Override
85 public String disassemble(final CiTargetMethod targetMethod) { 72 public String disassemble(final CiTargetMethod targetMethod) {
146 return ((HotSpotTypeResolved) method.holder()).constantPool(); 133 return ((HotSpotTypeResolved) method.holder()).constantPool();
147 } 134 }
148 135
149 @Override 136 @Override
150 public RiOsrFrame getOsrFrame(RiMethod method, int bci) { 137 public RiOsrFrame getOsrFrame(RiMethod method, int bci) {
151 // TODO Auto-generated method stub
152 return null; 138 return null;
153 } 139 }
154 140
155 @Override 141 @Override
156 public RiType getRiType(Class<?> javaClass) { 142 public RiType getRiType(Class<?> javaClass) {
157 // TODO Auto-generated method stub 143 if (javaClass == Object[].class || javaClass == Long.class || javaClass == Integer.class || javaClass == Throwable.class) {
158 return null; 144 return Compiler.getVMEntries().getType(javaClass);
145 }
146 throw new UnsupportedOperationException("unexpected class in getRiType: " + javaClass);
159 } 147 }
160 148
161 @Override 149 @Override
162 public RiSnippets getSnippets() { 150 public RiSnippets getSnippets() {
163 // TODO Auto-generated method stub 151 throw new UnsupportedOperationException("getSnippets");
164 return null;
165 } 152 }
166 153
167 @Override 154 @Override
168 public boolean mustInline(RiMethod method) { 155 public boolean mustInline(RiMethod method) {
169 // TODO Auto-generated method stub
170 return false; 156 return false;
171 } 157 }
172 158
173 @Override 159 @Override
174 public boolean mustNotCompile(RiMethod method) { 160 public boolean mustNotCompile(RiMethod method) {
175 // TODO Auto-generated method stub
176 return false; 161 return false;
177 } 162 }
178 163
179 @Override 164 @Override
180 public boolean mustNotInline(RiMethod method) { 165 public boolean mustNotInline(RiMethod method) {
181 // TODO Auto-generated method stub 166 if (Modifier.isNative(method.accessFlags()))
167 return true;
182 return false; 168 return false;
183 } 169 }
184 170
185 @Override 171 @Override
186 public Object registerGlobalStub(CiTargetMethod targetMethod, String name) { 172 public Object registerGlobalStub(CiTargetMethod targetMethod, String name) {
193 return 0; 179 return 0;
194 } 180 }
195 181
196 @Override 182 @Override
197 public RiField getRiField(Field javaField) { 183 public RiField getRiField(Field javaField) {
198 // TODO Auto-generated method stub 184 throw new UnsupportedOperationException("getRiField");
185 }
186
187 @Override
188 public RiMethod getRiMethod(Method javaMethod) {
189 throw new UnsupportedOperationException("getRiMethod");
190 }
191
192 @Override
193 public RiMethod getRiMethod(Constructor<?> javaConstructor) {
194 throw new UnsupportedOperationException("getRiMethod");
195 }
196
197 @Override
198 public CiConstant invoke(RiMethod method, CiMethodInvokeArguments args) {
199 return null; 199 return null;
200 } 200 }
201 201
202 @Override 202 @Override
203 public RiMethod getRiMethod(Method javaMethod) {
204 // TODO Auto-generated method stub
205 return null;
206 }
207
208 @Override
209 public RiMethod getRiMethod(Constructor<?> javaConstructor) {
210 // TODO Auto-generated method stub
211 return null;
212 }
213
214 @Override
215 public CiConstant invoke(RiMethod method, CiMethodInvokeArguments args) {
216 // TODO Auto-generated method stub
217 return null;
218 }
219
220 @Override
221 public CiConstant foldWordOperation(int opcode, CiMethodInvokeArguments args) { 203 public CiConstant foldWordOperation(int opcode, CiMethodInvokeArguments args) {
222 // TODO Auto-generated method stub 204 throw new UnsupportedOperationException("foldWordOperation");
223 return null; 205 }
206
207 @Override
208 public boolean compareConstantObjects(Object x, Object y) {
209 if (x == null && y == null) {
210 return true;
211 } else if (x == null || y == null) {
212 return false;
213 } else if (x instanceof Long && y instanceof Long) {
214 return (Long) x == (long) (Long) y;
215 }
216 throw new UnsupportedOperationException("compareConstantObjects: " + x + ", " + y);
217 }
218
219 @Override
220 public boolean recordLeafMethodAssumption(RiMethod method) {
221 return false;
224 } 222 }
225 223
226 } 224 }