comparison src/share/vm/graal/graalVMToCompiler.cpp @ 4220:5c80ccb80036

Renaming of VMExits and VMEntries part 1.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 04 Jan 2012 20:59:11 +0100
parents src/share/vm/graal/graalVMExits.cpp@feb590a8497f
children e0a4668c57a2
comparison
equal deleted inserted replaced
4214:35b05867c94a 4220:5c80ccb80036
1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "graal/graalVMToCompiler.hpp"
26
27 // this is a *global* handle
28 jobject VMToCompiler::_compilerPermObject = NULL;
29 jobject VMToCompiler::_vmExitsPermObject = NULL;
30 jobject VMToCompiler::_vmExitsPermKlass = NULL;
31
32 KlassHandle VMToCompiler::vmExitsKlass() {
33 if (JNIHandles::resolve(_vmExitsPermKlass) == NULL) {
34 klassOop result = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_VMExits(), SystemDictionary::java_system_loader(), NULL, Thread::current());
35 check_not_null(result, "Couldn't find class com.oracle.max.graal.hotspot.bridge.VMToCompiler");
36 _vmExitsPermKlass = JNIHandles::make_global(result);
37 }
38 return KlassHandle((klassOop)JNIHandles::resolve_non_null(_vmExitsPermKlass));
39 }
40
41 Handle VMToCompiler::compilerInstance() {
42 if (JNIHandles::resolve(_compilerPermObject) == NULL) {
43 KlassHandle compilerImplKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_CompilerImpl(), SystemDictionary::java_system_loader(), NULL, Thread::current());
44 check_not_null(compilerImplKlass(), "Couldn't find class com.sun.hotspot.graal.CompilerImpl");
45
46 JavaValue result(T_OBJECT);
47 JavaCalls::call_static(&result, compilerImplKlass, vmSymbols::getInstance_name(), vmSymbols::getInstance_signature(), Thread::current());
48 check_pending_exception("Couldn't get Compiler");
49 _compilerPermObject = JNIHandles::make_global((oop) result.get_jobject());
50 }
51 return Handle(JNIHandles::resolve_non_null(_compilerPermObject));
52 }
53
54 Handle VMToCompiler::instance() {
55 if (JNIHandles::resolve(_vmExitsPermObject) == NULL) {
56 KlassHandle compilerKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current());
57 check_not_null(compilerKlass(), "Couldn't find class com.sun.hotspot.graal.Compiler");
58
59 JavaValue result(T_OBJECT);
60 JavaCallArguments args;
61 args.set_receiver(compilerInstance());
62 JavaCalls::call_interface(&result, compilerKlass, vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current());
63 check_pending_exception("Couldn't get VMExits");
64 _vmExitsPermObject = JNIHandles::make_global((oop) result.get_jobject());
65 }
66 return Handle(JNIHandles::resolve_non_null(_vmExitsPermObject));
67 }
68
69 void VMToCompiler::initializeCompiler() {
70 KlassHandle compilerImplKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_CompilerImpl(), SystemDictionary::java_system_loader(), NULL, Thread::current());
71 check_not_null(compilerImplKlass(), "Couldn't find class com.sun.hotspot.graal.CompilerImpl");
72
73 JavaValue result(T_VOID);
74 JavaCalls::call_static(&result, compilerImplKlass, vmSymbols::initialize_name(), vmSymbols::void_method_signature(), Thread::current());
75 check_pending_exception("Couldn't initialize compiler");
76 }
77
78 jboolean VMToCompiler::setOption(Handle option) {
79 assert(!option.is_null(), "");
80 KlassHandle compilerKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_HotSpotOptions(), SystemDictionary::java_system_loader(), NULL, Thread::current());
81 check_not_null(compilerKlass(), "Couldn't find class com.sun.hotspot.graal.HotSpotOptions");
82
83 Thread* THREAD = Thread::current();
84 JavaValue result(T_BOOLEAN);
85 JavaCalls::call_static(&result, compilerKlass, vmSymbols::setOption_name(), vmSymbols::setOption_signature(), option, THREAD);
86 check_pending_exception("Error while calling setOption");
87 return result.get_jboolean();
88 }
89
90 void VMToCompiler::setDefaultOptions() {
91 KlassHandle compilerKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_graal_HotSpotOptions(), SystemDictionary::java_system_loader(), NULL, Thread::current());
92 check_not_null(compilerKlass(), "Couldn't find class com.sun.hotspot.graal.HotSpotOptions");
93
94 Thread* THREAD = Thread::current();
95 JavaValue result(T_VOID);
96 JavaCalls::call_static(&result, compilerKlass, vmSymbols::setDefaultOptions_name(), vmSymbols::void_method_signature(), THREAD);
97 check_pending_exception("Error while calling setDefaultOptions");
98 }
99
100 void VMToCompiler::compileMethod(Handle hotspot_method, int entry_bci, jboolean blocking) {
101 assert(!hotspot_method.is_null(), "just checking");
102 Thread* THREAD = Thread::current();
103 JavaValue result(T_VOID);
104 JavaCallArguments args;
105 args.push_oop(instance());
106 args.push_oop(hotspot_method);
107 args.push_int(entry_bci);
108 args.push_int(blocking);
109 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
110 check_pending_exception("Error while calling compileMethod");
111 }
112
113 void VMToCompiler::shutdownCompiler() {
114 if (_compilerPermObject != NULL) {
115 HandleMark hm;
116 JavaThread* THREAD = JavaThread::current();
117 JavaValue result(T_VOID);
118 JavaCallArguments args;
119 args.push_oop(instance());
120 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::shutdownCompiler_name(), vmSymbols::void_method_signature(), &args, THREAD);
121 check_pending_exception("Error while calling shutdownCompiler");
122
123 JNIHandles::destroy_global(_compilerPermObject);
124 JNIHandles::destroy_global(_vmExitsPermObject);
125 JNIHandles::destroy_global(_vmExitsPermKlass);
126
127 _compilerPermObject = NULL;
128 _vmExitsPermObject = NULL;
129 _vmExitsPermKlass = NULL;
130 }
131 }
132
133 void VMToCompiler::startCompiler() {
134 JavaThread* THREAD = JavaThread::current();
135 JavaValue result(T_VOID);
136 JavaCallArguments args;
137 args.push_oop(instance());
138 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::startCompiler_name(), vmSymbols::void_method_signature(), &args, THREAD);
139 check_pending_exception("Error while calling startCompiler");
140 }
141
142 void VMToCompiler::bootstrap() {
143 JavaThread* THREAD = JavaThread::current();
144 JavaValue result(T_VOID);
145 JavaCallArguments args;
146 args.push_oop(instance());
147 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::bootstrap_name(), vmSymbols::void_method_signature(), &args, THREAD);
148 check_pending_exception("Error while calling boostrap");
149 }
150
151 oop VMToCompiler::createRiMethodResolved(jlong vmId, Handle name, TRAPS) {
152 assert(!name.is_null(), "just checking");
153 JavaValue result(T_OBJECT);
154 JavaCallArguments args;
155 args.push_oop(instance());
156 args.push_long(vmId);
157 args.push_oop(name);
158 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiMethodResolved_name(), vmSymbols::createRiMethodResolved_signature(), &args, THREAD);
159 check_pending_exception("Error while calling createRiMethodResolved");
160 return (oop) result.get_jobject();
161 }
162
163 oop VMToCompiler::createRiMethodUnresolved(Handle name, Handle signature, Handle holder, TRAPS) {
164 assert(!name.is_null(), "just checking");
165 JavaValue result(T_OBJECT);
166 JavaCallArguments args;
167 args.push_oop(instance());
168 args.push_oop(name);
169 args.push_oop(signature);
170 args.push_oop(holder);
171 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiMethodUnresolved_name(), vmSymbols::createRiMethodUnresolved_signature(), &args, THREAD);
172 check_pending_exception("Error while calling createRiMethodUnresolved");
173 return (oop) result.get_jobject();
174 }
175
176 oop VMToCompiler::createRiField(Handle holder, Handle name, Handle type, int index, int flags, TRAPS) {
177 assert(!holder.is_null(), "just checking");
178 assert(!name.is_null(), "just checking");
179 assert(!type.is_null(), "just checking");
180 JavaValue result(T_OBJECT);
181 JavaCallArguments args;
182 args.push_oop(instance());
183 args.push_oop(holder);
184 args.push_oop(name);
185 args.push_oop(type);
186 args.push_int(index);
187 args.push_int(flags);
188 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiField_name(), vmSymbols::createRiField_signature(), &args, THREAD);
189 check_pending_exception("Error while calling createRiField");
190 assert(result.get_type() == T_OBJECT, "just checking");
191 return (oop) result.get_jobject();
192 }
193
194 oop VMToCompiler::createRiType(jlong vmId, Handle name, TRAPS) {
195 assert(!name.is_null(), "just checking");
196 JavaValue result(T_OBJECT);
197 JavaCallArguments args;
198 args.push_oop(instance());
199 args.push_long(vmId);
200 args.push_oop(name);
201 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiType_name(), vmSymbols::createRiType_signature(), &args, THREAD);
202 check_pending_exception("Error while calling createRiType");
203 return (oop) result.get_jobject();
204 }
205
206 oop VMToCompiler::createRiTypePrimitive(int basic_type, TRAPS) {
207 JavaValue result(T_OBJECT);
208 JavaCallArguments args;
209 args.push_oop(instance());
210 args.push_int(basic_type);
211 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypePrimitive_name(), vmSymbols::createRiTypePrimitive_signature(), &args, THREAD);
212 check_pending_exception("Error while calling createRiTypePrimitive");
213 return (oop) result.get_jobject();
214 }
215
216 oop VMToCompiler::createRiTypeUnresolved(Handle name, TRAPS) {
217 assert(!name.is_null(), "just checking");
218 JavaValue result(T_OBJECT);
219 JavaCallArguments args;
220 args.push_oop(instance());
221 args.push_oop(name);
222 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiTypeUnresolved_name(), vmSymbols::createRiTypeUnresolved_signature(), &args, THREAD);
223 check_pending_exception("Error while calling createRiTypeUnresolved");
224 return (oop) result.get_jobject();
225 }
226
227 oop VMToCompiler::createRiSignature(Handle name, TRAPS) {
228 assert(!name.is_null(), "just checking");
229 JavaValue result(T_OBJECT);
230 JavaCallArguments args;
231 args.push_oop(instance());
232 args.push_oop(name);
233 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createRiSignature_name(), vmSymbols::createRiSignature_signature(), &args, THREAD);
234 check_pending_exception("Error while calling createRiSignature");
235 return (oop) result.get_jobject();
236 }
237
238 oop VMToCompiler::createCiConstant(Handle kind, jlong value, TRAPS) {
239 JavaValue result(T_OBJECT);
240 JavaCallArguments args;
241 args.push_oop(instance());
242 args.push_oop(kind());
243 args.push_long(value);
244 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstant_name(), vmSymbols::createCiConstant_signature(), &args, THREAD);
245 check_pending_exception("Error while calling createCiConstantFloat");
246 return (oop) result.get_jobject();
247
248 }
249
250 oop VMToCompiler::createCiConstantFloat(jfloat value, TRAPS) {
251 JavaValue result(T_OBJECT);
252 JavaCallArguments args;
253 args.push_oop(instance());
254 args.push_float(value);
255 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantFloat_name(), vmSymbols::createCiConstantFloat_signature(), &args, THREAD);
256 check_pending_exception("Error while calling createCiConstantFloat");
257 return (oop) result.get_jobject();
258
259 }
260
261 oop VMToCompiler::createCiConstantDouble(jdouble value, TRAPS) {
262 JavaValue result(T_OBJECT);
263 JavaCallArguments args;
264 args.push_oop(instance());
265 args.push_double(value);
266 JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantDouble_name(), vmSymbols::createCiConstantDouble_signature(), &args, THREAD);
267 check_pending_exception("Error while calling createCiConstantDouble");
268 return (oop) result.get_jobject();
269 }
270
271 oop VMToCompiler::createCiConstantObject(Handle object, TRAPS) {
272 JavaValue result(T_OBJECT);
273 JavaCallArguments args;
274 KlassHandle klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_cri_ci_CiConstant(), SystemDictionary::java_system_loader(), NULL, Thread::current());
275 JavaCalls::call_static(&result, klass(), vmSymbols::forObject_name(), vmSymbols::createCiConstantObject_signature(), object, THREAD);
276 check_pending_exception("Error while calling CiConstant.forObject");
277 return (oop) result.get_jobject();
278 }
279