Mercurial > hg > truffle
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java @ 1421:6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Fri, 23 Jul 2010 15:53:02 -0700 |
parents | c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExits.java@44efca8a02d6 |
children | 3483ec571caf |
comparison
equal
deleted
inserted
replaced
1420:44efca8a02d6 | 1421:6223633ce7dd |
---|---|
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 that is | |
5 * described in this document. In particular, and without limitation, these intellectual property rights may include one | |
6 * or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent | |
7 * applications in the U.S. and in other countries. | |
8 * | |
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard | |
10 * license agreement and applicable provisions of the FAR and its supplements. | |
11 * | |
12 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or registered | |
13 * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and | |
14 * are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. | |
15 * | |
16 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. | |
17 */ | |
18 | |
19 package com.sun.hotspot.c1x; | |
20 | |
21 import com.sun.cri.ci.*; | |
22 import com.sun.cri.ri.*; | |
23 | |
24 /** | |
25 * | |
26 * @author Thomas Wuerthinger | |
27 * | |
28 * Exits from the HotSpot VM into Java code. | |
29 * | |
30 */ | |
31 public class VMExitsNative implements VMExits { | |
32 | |
33 @Override | |
34 public void compileMethod(RiMethod method, int entry_bci) { | |
35 try { | |
36 assert method instanceof RiMethod : "And YES, this assert is necessary and a potential life saver as this method is called from the VM ;-)"; | |
37 | |
38 Compiler compiler = Compiler.getInstance(); | |
39 CiResult result = compiler.getCompiler().compileMethod(method, null); | |
40 | |
41 if (result.bailout() != null) { | |
42 System.out.println("Bailout:"); | |
43 result.bailout().printStackTrace(); | |
44 } else { | |
45 System.out.println("Compilation result: "); | |
46 System.out.println(result.targetMethod()); | |
47 HotSpotTargetMethod.installCode(compiler.getConfig(), method, result.targetMethod()); | |
48 } | |
49 } catch (Throwable t) { | |
50 System.out.println("Compilation interrupted:"); | |
51 t.printStackTrace(); | |
52 if (t instanceof RuntimeException) { | |
53 throw (RuntimeException) t; | |
54 } | |
55 throw new RuntimeException(t); | |
56 } | |
57 } | |
58 | |
59 @Override | |
60 public RiMethod createRiMethod(Object methodOop) { | |
61 System.out.println("creating RiMethod object"); | |
62 RiMethod m = new HotSpotMethod(methodOop); | |
63 System.out.println("returning " + m); | |
64 return m; | |
65 } | |
66 | |
67 @Override | |
68 public RiSignature createRiSignature(Object symbolOop) { | |
69 System.out.println("Creating RiSignature object"); | |
70 String name = Compiler.getVMEntries().RiSignature_symbolToString(symbolOop); | |
71 System.out.println("Signature name: " + name); | |
72 return new HotSpotSignature(name); | |
73 } | |
74 | |
75 @Override | |
76 public RiField createRiField(RiType holder, Object nameSymbol, RiType type, int offset) { | |
77 System.out.println("creating RiField object"); | |
78 return new HotSpotField(holder, nameSymbol, type, offset); | |
79 } | |
80 | |
81 @Override | |
82 public RiType createRiType(Object klassOop) { | |
83 System.out.println("creating RiType object"); | |
84 return new HotSpotType(klassOop); | |
85 } | |
86 | |
87 @Override | |
88 public RiType createRiTypePrimitive(int basicType) { | |
89 System.out.println("Creating primitive type with basicType " + basicType); | |
90 CiKind kind = null; | |
91 switch (basicType) { | |
92 case 4: | |
93 kind = CiKind.Boolean; | |
94 break; | |
95 case 5: | |
96 kind = CiKind.Char; | |
97 break; | |
98 case 6: | |
99 kind = CiKind.Float; | |
100 break; | |
101 case 7: | |
102 kind = CiKind.Double; | |
103 break; | |
104 case 8: | |
105 kind = CiKind.Byte; | |
106 break; | |
107 case 9: | |
108 kind = CiKind.Short; | |
109 break; | |
110 case 10: | |
111 kind = CiKind.Int; | |
112 break; | |
113 case 11: | |
114 kind = CiKind.Long; | |
115 break; | |
116 case 14: | |
117 kind = CiKind.Void; | |
118 break; | |
119 default: | |
120 throw new IllegalArgumentException("Unknown basic type: " + basicType); | |
121 } | |
122 System.out.println("Chosen kind: " + kind); | |
123 return new HotSpotTypePrimitive(kind); | |
124 } | |
125 | |
126 @Override | |
127 public RiType createRiTypeUnresolved(Object symbolOop, Object accessingKlassOop) { | |
128 System.out.println("Creating unresolved RiType object"); | |
129 String name = Compiler.getVMEntries().RiSignature_symbolToString(symbolOop); | |
130 System.out.println("Class name: " + name); | |
131 return new HotSpotTypeUnresolved(name); | |
132 } | |
133 | |
134 @Override | |
135 public RiConstantPool createRiConstantPool(Object constantPoolOop) { | |
136 System.out.println("creating RiConstantPool object"); | |
137 return new HotSpotConstantPool(constantPoolOop); | |
138 } | |
139 | |
140 @Override | |
141 public CiConstant createCiConstantInt(int value) { | |
142 return CiConstant.forInt(value); | |
143 } | |
144 | |
145 @Override | |
146 public CiConstant createCiConstantLong(long value) { | |
147 return CiConstant.forLong(value); | |
148 } | |
149 | |
150 @Override | |
151 public CiConstant createCiConstantFloat(float value) { | |
152 return CiConstant.forFloat(value); | |
153 } | |
154 | |
155 @Override | |
156 public CiConstant createCiConstantDouble(double value) { | |
157 return CiConstant.forDouble(value); | |
158 } | |
159 | |
160 @Override | |
161 public CiConstant createCiConstantObject(Object value) { | |
162 return CiConstant.forObject(value); | |
163 } | |
164 | |
165 @Override | |
166 public void main(String[] args) throws InterruptedException { | |
167 System.out.println(C1XHotSpotTests.add(1, 2)); | |
168 Thread.sleep(5000); | |
169 System.out.println(C1XHotSpotTests.add(1, 2)); | |
170 } | |
171 } |