comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java @ 1416:1b41af477605

Added HotSpotVM project Java source files.
author Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
date Wed, 23 Jun 2010 16:36:58 +0200
parents
children 2c41834aa270
comparison
equal deleted inserted replaced
1415:712c7ff1afc1 1416:1b41af477605
1 /*
2 * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
5 * that is described in this document. In particular, and without limitation, these intellectual property
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
7 * more additional patents or pending patent applications in the U.S. and in other countries.
8 *
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
11 * supplements.
12 *
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
16 * U.S. and other countries.
17 *
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
19 * Company, Ltd.
20 */
21 package com.sun.hotspot.c1x;
22
23 import java.io.ByteArrayOutputStream;
24 import java.io.OutputStream;
25 import java.lang.reflect.Constructor;
26 import java.lang.reflect.Field;
27 import java.lang.reflect.Method;
28
29 import com.sun.cri.ci.CiConstant;
30 import com.sun.cri.ci.CiMethodInvokeArguments;
31 import com.sun.cri.ci.CiTargetMethod;
32 import com.sun.cri.ci.CiTargetMethod.Call;
33 import com.sun.cri.ci.CiTargetMethod.DataPatch;
34 import com.sun.cri.ci.CiTargetMethod.Safepoint;
35 import com.sun.cri.ri.RiConstantPool;
36 import com.sun.cri.ri.RiField;
37 import com.sun.cri.ri.RiMethod;
38 import com.sun.cri.ri.RiOsrFrame;
39 import com.sun.cri.ri.RiRuntime;
40 import com.sun.cri.ri.RiSnippets;
41 import com.sun.cri.ri.RiType;
42 import com.sun.max.asm.InstructionSet;
43 import com.sun.max.asm.dis.DisassembledObject;
44 import com.sun.max.asm.dis.Disassembler;
45 import com.sun.max.asm.dis.DisassemblyPrinter;
46
47 /**
48 *
49 * @author Thomas Wuerthinger
50 *
51 * CRI runtime implementation for the HotSpot VM.
52 *
53 */
54 public class HotSpotRuntime implements RiRuntime {
55
56 @Override
57 public int basicObjectLockOffsetInBytes() {
58 // TODO Auto-generated method stub
59 return 0;
60 }
61
62 @Override
63 public int codeOffset() {
64 // TODO Auto-generated method stub
65 return 0;
66 }
67
68 @Override
69 public void codePrologue(RiMethod method, OutputStream out) {
70 // TODO Auto-generated method stub
71
72 }
73
74 @Override
75 public String disassemble(byte[] code) {
76 return disassemble(code, new DisassemblyPrinter(false));
77 }
78
79 private String disassemble(byte[] code, DisassemblyPrinter disassemblyPrinter) {
80 final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
81 final InstructionSet instructionSet = InstructionSet.AMD64;
82 //Disassembler.disassemble(byteArrayOutputStream, code, instructionSet, null, 0, null, disassemblyPrinter);
83 return byteArrayOutputStream.toString();
84 }
85
86 @Override
87 public String disassemble(final CiTargetMethod targetMethod) {
88
89 final DisassemblyPrinter disassemblyPrinter = new DisassemblyPrinter(false) {
90
91 private String toString(Call call) {
92 if (call.runtimeCall != null) {
93 return "{" + call.runtimeCall.name() + "}";
94 } else if (call.symbol != null) {
95 return "{" + call.symbol + "}";
96 } else if (call.globalStubID != null) {
97 return "{" + call.globalStubID + "}";
98 } else {
99 return "{" + call.method + "}";
100 }
101 }
102
103 private String siteInfo(int pcOffset) {
104 for (Call call : targetMethod.directCalls) {
105 if (call.pcOffset == pcOffset) {
106 return toString(call);
107 }
108 }
109 for (Call call : targetMethod.indirectCalls) {
110 if (call.pcOffset == pcOffset) {
111 return toString(call);
112 }
113 }
114 for (Safepoint site : targetMethod.safepoints) {
115 if (site.pcOffset == pcOffset) {
116 return "{safepoint}";
117 }
118 }
119 for (DataPatch site : targetMethod.dataReferences) {
120 if (site.pcOffset == pcOffset) {
121 return "{" + site.data + "}";
122 }
123 }
124 return null;
125 }
126
127 @Override
128 protected String disassembledObjectString(Disassembler disassembler, DisassembledObject disassembledObject) {
129 final String string = super.disassembledObjectString(disassembler, disassembledObject);
130
131 String site = siteInfo(disassembledObject.startPosition());
132 if (site != null) {
133 return string + " " + site;
134 }
135 return string;
136 }
137 };
138 return disassemble(targetMethod.targetCode(), disassemblyPrinter);
139 }
140
141 @Override
142 public String disassemble(RiMethod method) {
143 return "No disassembler available";
144 }
145
146 @Override
147 public RiConstantPool getConstantPool(RiMethod method) {
148 return VMEntries.RiRuntime_getConstantPool(((HotSpotType)method.holder()).klassOop);
149 }
150
151 @Override
152 public RiOsrFrame getOsrFrame(RiMethod method, int bci) {
153 // TODO Auto-generated method stub
154 return null;
155 }
156
157 @Override
158 public RiType getRiType(Class<?> javaClass) {
159 // TODO Auto-generated method stub
160 return null;
161 }
162
163 @Override
164 public RiSnippets getSnippets() {
165 // TODO Auto-generated method stub
166 return null;
167 }
168
169 @Override
170 public boolean mustInline(RiMethod method) {
171 // TODO Auto-generated method stub
172 return false;
173 }
174
175 @Override
176 public boolean mustNotCompile(RiMethod method) {
177 // TODO Auto-generated method stub
178 return false;
179 }
180
181 @Override
182 public boolean mustNotInline(RiMethod method) {
183 // TODO Auto-generated method stub
184 return false;
185 }
186
187 @Override
188 public Object registerTargetMethod(CiTargetMethod targetMethod, String name) {
189 // TODO Auto-generated method stub
190 return null;
191 }
192
193 @Override
194 public int sizeofBasicObjectLock() {
195 // TODO Auto-generated method stub
196 return 0;
197 }
198
199 @Override
200 public int threadExceptionOffset() {
201 // TODO Auto-generated method stub
202 return 0;
203 }
204
205 @Override
206 public RiField getRiField(Field javaField) {
207 // TODO Auto-generated method stub
208 return null;
209 }
210
211 @Override
212 public RiMethod getRiMethod(Method javaMethod) {
213 // TODO Auto-generated method stub
214 return null;
215 }
216
217 @Override
218 public RiMethod getRiMethod(Constructor<?> javaConstructor) {
219 // TODO Auto-generated method stub
220 return null;
221 }
222
223 @Override
224 public CiConstant invoke(RiMethod method, CiMethodInvokeArguments args) {
225 // TODO Auto-generated method stub
226 return null;
227 }
228
229 }