Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCompiler.cpp @ 5554:70f715dfbb41
Bring Java renamings and restructurings to the C++ part.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 10 Jun 2012 01:17:48 +0200 |
parents | 65f832e7476b |
children | 310ed6650682 |
comparison
equal
deleted
inserted
replaced
5553:511612d1b5c1 | 5554:70f715dfbb41 |
---|---|
160 assert(_initialized, "must already be initialized"); | 160 assert(_initialized, "must already be initialized"); |
161 ResourceMark rm; | 161 ResourceMark rm; |
162 ciEnv* current_env = JavaThread::current()->env(); | 162 ciEnv* current_env = JavaThread::current()->env(); |
163 JavaThread::current()->set_env(NULL); | 163 JavaThread::current()->set_env(NULL); |
164 JavaThread::current()->set_compiling(true); | 164 JavaThread::current()->set_compiling(true); |
165 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK); | 165 Handle hotspot_method = GraalCompiler::createHotSpotResolvedJavaMethod(method, CHECK); |
166 jboolean success = VMToCompiler::compileMethod(hotspot_method, entry_bci, blocking, method->graal_priority()); | 166 jboolean success = VMToCompiler::compileMethod(hotspot_method, entry_bci, blocking, method->graal_priority()); |
167 JavaThread::current()->set_compiling(false); | 167 JavaThread::current()->set_compiling(false); |
168 JavaThread::current()->set_env(current_env); | 168 JavaThread::current()->set_env(current_env); |
169 if (success != JNI_TRUE) { | 169 if (success != JNI_TRUE) { |
170 method->clear_queued_for_compilation(); | 170 method->clear_queued_for_compilation(); |
186 // Print compilation timers and statistics | 186 // Print compilation timers and statistics |
187 void GraalCompiler::print_timers() { | 187 void GraalCompiler::print_timers() { |
188 TRACE_graal_1("GraalCompiler::print_timers"); | 188 TRACE_graal_1("GraalCompiler::print_timers"); |
189 } | 189 } |
190 | 190 |
191 Handle GraalCompiler::get_RiType(Symbol* klass_name, TRAPS) { | 191 Handle GraalCompiler::get_JavaType(Symbol* klass_name, TRAPS) { |
192 return VMToCompiler::createRiTypeUnresolved(VmIds::toString<Handle>(klass_name, THREAD), THREAD); | 192 return VMToCompiler::createJavaType(VmIds::toString<Handle>(klass_name, THREAD), THREAD); |
193 } | 193 } |
194 | 194 |
195 Handle GraalCompiler::get_RiTypeFromSignature(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { | 195 Handle GraalCompiler::get_JavaTypeFromSignature(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { |
196 | 196 |
197 Symbol* signature = cp->symbol_at(index); | 197 Symbol* signature = cp->symbol_at(index); |
198 BasicType field_type = FieldType::basic_type(signature); | 198 BasicType field_type = FieldType::basic_type(signature); |
199 // If the field is a pointer type, get the klass of the | 199 // If the field is a pointer type, get the klass of the |
200 // field. | 200 // field. |
201 if (field_type == T_OBJECT || field_type == T_ARRAY) { | 201 if (field_type == T_OBJECT || field_type == T_ARRAY) { |
202 KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false); | 202 KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false); |
203 if (handle.is_null()) { | 203 if (handle.is_null()) { |
204 return get_RiType(signature, CHECK_NULL); | 204 return get_JavaType(signature, CHECK_NULL); |
205 } else { | 205 } else { |
206 return get_RiType(handle, CHECK_NULL); | 206 return get_JavaType(handle, CHECK_NULL); |
207 } | 207 } |
208 } else { | 208 } else { |
209 return VMToCompiler::createRiTypePrimitive(field_type, CHECK_NULL); | 209 return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NULL); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 Handle GraalCompiler::get_RiType(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { | 213 Handle GraalCompiler::get_JavaType(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { |
214 bool is_accessible = false; | 214 bool is_accessible = false; |
215 | 215 |
216 KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); | 216 KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); |
217 oop catch_class = NULL; | 217 oop catch_class = NULL; |
218 if (klass.is_null()) { | 218 if (klass.is_null()) { |
223 Symbol* klass_name = NULL; | 223 Symbol* klass_name = NULL; |
224 constantTag tag = cp->tag_at(index); | 224 constantTag tag = cp->tag_at(index); |
225 if (tag.is_klass()) { | 225 if (tag.is_klass()) { |
226 // The klass has been inserted into the constant pool | 226 // The klass has been inserted into the constant pool |
227 // very recently. | 227 // very recently. |
228 return GraalCompiler::get_RiType(cp->resolved_klass_at(index), CHECK_NULL); | 228 return GraalCompiler::get_JavaType(cp->resolved_klass_at(index), CHECK_NULL); |
229 } else if (tag.is_symbol()) { | 229 } else if (tag.is_symbol()) { |
230 klass_name = cp->symbol_at(index); | 230 klass_name = cp->symbol_at(index); |
231 } else { | 231 } else { |
232 assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); | 232 assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); |
233 klass_name = cp->unresolved_klass_at(index); | 233 klass_name = cp->unresolved_klass_at(index); |
234 } | 234 } |
235 return GraalCompiler::get_RiType(klass_name, CHECK_NULL); | 235 return GraalCompiler::get_JavaType(klass_name, CHECK_NULL); |
236 } else { | 236 } else { |
237 return GraalCompiler::get_RiType(klass, CHECK_NULL); | 237 return GraalCompiler::get_JavaType(klass, CHECK_NULL); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 Handle GraalCompiler::get_RiType(KlassHandle klass, TRAPS) { | 241 Handle GraalCompiler::get_JavaType(KlassHandle klass, TRAPS) { |
242 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); | 242 Handle name = VmIds::toString<Handle>(klass->name(), THREAD); |
243 return createHotSpotTypeResolved(klass, name, CHECK_NULL); | 243 return createHotSpotResolvedJavaType(klass, name, CHECK_NULL); |
244 } | 244 } |
245 | 245 |
246 Handle GraalCompiler::get_RiField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS) { | 246 Handle GraalCompiler::get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS) { |
247 Handle name = VmIds::toString<Handle>(field_name, CHECK_NULL); | 247 Handle name = VmIds::toString<Handle>(field_name, CHECK_NULL); |
248 return VMToCompiler::createRiField(field_holder, name, field_type, offset, flags, CHECK_NULL); | 248 return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, CHECK_NULL); |
249 } | 249 } |
250 | 250 |
251 Handle GraalCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { | 251 Handle GraalCompiler::createHotSpotResolvedJavaType(KlassHandle klass, Handle name, TRAPS) { |
252 ObjectLocker ol(klass, THREAD); | 252 ObjectLocker ol(klass, THREAD); |
253 | 253 |
254 if (klass->graal_mirror() != NULL) { | 254 if (klass->graal_mirror() != NULL) { |
255 return klass->graal_mirror(); | 255 return klass->graal_mirror(); |
256 } | 256 } |
257 | 257 |
258 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL); | 258 instanceKlass::cast(HotSpotResolvedJavaType::klass())->initialize(CHECK_NULL); |
259 Handle obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL); | 259 Handle obj = instanceKlass::cast(HotSpotResolvedJavaType::klass())->allocate_instance(CHECK_NULL); |
260 assert(obj() != NULL, "must succeed in allocating instance"); | 260 assert(obj() != NULL, "must succeed in allocating instance"); |
261 | 261 |
262 if (klass->oop_is_instance()) { | 262 if (klass->oop_is_instance()) { |
263 ResourceMark rm; | 263 ResourceMark rm; |
264 instanceKlass* ik = (instanceKlass*)klass()->klass_part(); | 264 instanceKlass* ik = (instanceKlass*)klass()->klass_part(); |
265 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL); | 265 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL); |
266 HotSpotType::set_name(obj, full_name()); | 266 HotSpotJavaType::set_name(obj, full_name()); |
267 } else { | 267 } else { |
268 HotSpotType::set_name(obj, name()); | 268 HotSpotJavaType::set_name(obj, name()); |
269 } | 269 } |
270 | 270 |
271 HotSpotTypeResolved::set_javaMirror(obj, klass->java_mirror()); | 271 HotSpotResolvedJavaType::set_javaMirror(obj, klass->java_mirror()); |
272 HotSpotTypeResolved::set_simpleName(obj, name()); | 272 HotSpotResolvedJavaType::set_simpleName(obj, name()); |
273 HotSpotTypeResolved::set_accessFlags(obj, klass->access_flags().as_int()); | 273 HotSpotResolvedJavaType::set_accessFlags(obj, klass->access_flags().as_int()); |
274 HotSpotTypeResolved::set_isInterface(obj, klass->is_interface()); | 274 HotSpotResolvedJavaType::set_isInterface(obj, klass->is_interface()); |
275 HotSpotTypeResolved::set_superCheckOffset(obj, klass->super_check_offset()); | 275 HotSpotResolvedJavaType::set_superCheckOffset(obj, klass->super_check_offset()); |
276 HotSpotTypeResolved::set_isInstanceClass(obj, klass->oop_is_instance()); | 276 HotSpotResolvedJavaType::set_isInstanceClass(obj, klass->oop_is_instance()); |
277 | 277 |
278 if (klass->oop_is_javaArray()) { | 278 if (klass->oop_is_javaArray()) { |
279 HotSpotTypeResolved::set_isArrayClass(obj, true); | 279 HotSpotResolvedJavaType::set_isArrayClass(obj, true); |
280 } else { | 280 } else { |
281 HotSpotTypeResolved::set_isArrayClass(obj, false); | 281 HotSpotResolvedJavaType::set_isArrayClass(obj, false); |
282 HotSpotTypeResolved::set_instanceSize(obj, instanceKlass::cast(klass())->size_helper() * HeapWordSize); | 282 HotSpotResolvedJavaType::set_instanceSize(obj, instanceKlass::cast(klass())->size_helper() * HeapWordSize); |
283 HotSpotTypeResolved::set_hasFinalizer(obj, klass->has_finalizer()); | 283 HotSpotResolvedJavaType::set_hasFinalizer(obj, klass->has_finalizer()); |
284 } | 284 } |
285 | 285 |
286 // TODO replace these with correct values | 286 // TODO replace these with correct values |
287 HotSpotTypeResolved::set_hasFinalizableSubclass(obj, false); | 287 HotSpotResolvedJavaType::set_hasFinalizableSubclass(obj, false); |
288 | 288 |
289 klass->set_graal_mirror(obj()); | 289 klass->set_graal_mirror(obj()); |
290 | 290 |
291 return obj; | 291 return obj; |
292 } | 292 } |
293 | 293 |
294 Handle GraalCompiler::createHotSpotMethodResolved(methodHandle method, TRAPS) { | 294 Handle GraalCompiler::createHotSpotResolvedJavaMethod(methodHandle method, TRAPS) { |
295 if (method->graal_mirror() != NULL) { | 295 if (method->graal_mirror() != NULL) { |
296 assert(method->graal_mirror()->is_a(HotSpotMethodResolved::klass()), "unexpected class..."); | 296 assert(method->graal_mirror()->is_a(HotSpotResolvedJavaMethod::klass()), "unexpected class..."); |
297 return method->graal_mirror(); | 297 return method->graal_mirror(); |
298 } | 298 } |
299 Handle name = VmIds::toString<Handle>(method->name(), CHECK_NULL); | 299 Handle name = VmIds::toString<Handle>(method->name(), CHECK_NULL); |
300 | 300 |
301 instanceKlass::cast(HotSpotMethodResolved::klass())->initialize(CHECK_NULL); | 301 instanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK_NULL); |
302 Handle obj = instanceKlass::cast(HotSpotMethodResolved::klass())->allocate_instance(CHECK_NULL); | 302 Handle obj = instanceKlass::cast(HotSpotResolvedJavaMethod::klass())->allocate_instance(CHECK_NULL); |
303 assert(obj() != NULL, "must succeed in allocating instance"); | 303 assert(obj() != NULL, "must succeed in allocating instance"); |
304 | 304 |
305 // (thomaswue) Cannot use reflection here, because the compiler thread could dead lock with the running application. | 305 // (thomaswue) Cannot use reflection here, because the compiler thread could dead lock with the running application. |
306 // oop reflected = getReflectedMethod(method(), CHECK_NULL); | 306 // oop reflected = getReflectedMethod(method(), CHECK_NULL); |
307 HotSpotMethodResolved::set_javaMirror(obj, method()); | 307 HotSpotResolvedJavaMethod::set_javaMirror(obj, method()); |
308 HotSpotMethodResolved::set_name(obj, name()); | 308 HotSpotResolvedJavaMethod::set_name(obj, name()); |
309 | 309 |
310 KlassHandle klass = method->method_holder(); | 310 KlassHandle klass = method->method_holder(); |
311 Handle holder_name = VmIds::toString<Handle>(klass->name(), CHECK_NULL); | 311 Handle holder_name = VmIds::toString<Handle>(klass->name(), CHECK_NULL); |
312 Handle holder = GraalCompiler::createHotSpotTypeResolved(klass, holder_name, CHECK_NULL); | 312 Handle holder = GraalCompiler::createHotSpotResolvedJavaType(klass, holder_name, CHECK_NULL); |
313 HotSpotMethodResolved::set_holder(obj, holder()); | 313 HotSpotResolvedJavaMethod::set_holder(obj, holder()); |
314 | 314 |
315 HotSpotMethodResolved::set_codeSize(obj, method->code_size()); | 315 HotSpotResolvedJavaMethod::set_codeSize(obj, method->code_size()); |
316 HotSpotMethodResolved::set_accessFlags(obj, method->access_flags().as_int()); | 316 HotSpotResolvedJavaMethod::set_accessFlags(obj, method->access_flags().as_int()); |
317 HotSpotMethodResolved::set_maxLocals(obj, method->max_locals()); | 317 HotSpotResolvedJavaMethod::set_maxLocals(obj, method->max_locals()); |
318 HotSpotMethodResolved::set_maxStackSize(obj, method->max_stack()); | 318 HotSpotResolvedJavaMethod::set_maxStackSize(obj, method->max_stack()); |
319 HotSpotMethodResolved::set_canBeInlined(obj, !method->is_not_compilable() && !CompilerOracle::should_not_inline(method)); | 319 HotSpotResolvedJavaMethod::set_canBeInlined(obj, !method->is_not_compilable() && !CompilerOracle::should_not_inline(method)); |
320 | 320 |
321 method->set_graal_mirror(obj()); | 321 method->set_graal_mirror(obj()); |
322 return obj; | 322 return obj; |
323 } | 323 } |
324 | 324 |
352 case 'd': return T_DOUBLE; | 352 case 'd': return T_DOUBLE; |
353 case 'a': return T_OBJECT; | 353 case 'a': return T_OBJECT; |
354 case 'r': return T_ADDRESS; | 354 case 'r': return T_ADDRESS; |
355 case '-': return T_ILLEGAL; | 355 case '-': return T_ILLEGAL; |
356 default: | 356 default: |
357 fatal(err_msg("unexpected CiKind: %c", ch)); | 357 fatal(err_msg("unexpected Kind: %c", ch)); |
358 break; | 358 break; |
359 } | 359 } |
360 return T_ILLEGAL; | 360 return T_ILLEGAL; |
361 } | 361 } |