comparison src/share/vm/graal/graalCompilerToVM.cpp @ 9584:4172233f32fd

make lookupConstantInPool use ConstantPool logic
author twisti
date Mon, 06 May 2013 15:15:09 -0700
parents c382fa74b1ee
children 404eb9b2c511 d5c2b20e9d73
comparison
equal deleted inserted replaced
9583:c382fa74b1ee 9584:4172233f32fd
389 389
390 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); 390 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants();
391 391
392 oop result = NULL; 392 oop result = NULL;
393 constantTag tag = cp->tag_at(index); 393 constantTag tag = cp->tag_at(index);
394 if (tag.is_int()) { 394
395 result = VMToCompiler::createConstant(Kind::Int(), cp->int_at(index), CHECK_0); 395 switch (tag.value()) {
396 } else if (tag.is_long()) { 396 case JVM_CONSTANT_Integer:
397 result = VMToCompiler::createConstant(Kind::Long(), cp->long_at(index), CHECK_0); 397 result = VMToCompiler::createConstant(Kind::Int(), cp->int_at(index), CHECK_NULL);
398 } else if (tag.is_float()) { 398 break;
399 result = VMToCompiler::createConstantFloat(cp->float_at(index), CHECK_0); 399
400 } else if (tag.is_double()) { 400 case JVM_CONSTANT_Long:
401 result = VMToCompiler::createConstantDouble(cp->double_at(index), CHECK_0); 401 result = VMToCompiler::createConstant(Kind::Long(), cp->long_at(index), CHECK_NULL);
402 } else if (tag.is_string()) { 402 break;
403 oop string = NULL; 403
404 if (cp->is_pseudo_string_at(index)) { 404 case JVM_CONSTANT_Float:
405 int obj_index = cp->cp_to_object_index(index); 405 result = VMToCompiler::createConstantFloat(cp->float_at(index), CHECK_NULL);
406 string = cp->pseudo_string_at(index, obj_index); 406 break;
407 } else { 407
408 string = cp->string_at(index, THREAD); 408 case JVM_CONSTANT_Double:
409 if (HAS_PENDING_EXCEPTION) { 409 result = VMToCompiler::createConstantDouble(cp->double_at(index), CHECK_NULL);
410 CLEAR_PENDING_EXCEPTION; 410 break;
411 // TODO: Gracefully exit compilation. 411
412 fatal("out of memory during compilation!"); 412 case JVM_CONSTANT_Class:
413 return NULL; 413 case JVM_CONSTANT_UnresolvedClass:
414 } 414 case JVM_CONSTANT_UnresolvedClassInError:
415 } 415 {
416 result = VMToCompiler::createConstantObject(string, CHECK_0); 416 Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL);
417 } else if (tag.is_klass() || tag.is_unresolved_klass()) { 417 result = type();
418 Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); 418 break;
419 result = type(); 419 }
420 } else { 420
421 tty->print("unknown constant pool tag (%s) at cpi %d in %s: ", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string()); 421 case JVM_CONSTANT_String:
422 ShouldNotReachHere(); 422 {
423 oop result_oop = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL);
424 result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL);
425 break;
426 }
427
428 case JVM_CONSTANT_MethodHandle:
429 case JVM_CONSTANT_MethodHandleInError:
430 case JVM_CONSTANT_MethodType:
431 case JVM_CONSTANT_MethodTypeInError:
432 {
433 oop result_oop = cp->resolve_constant_at(index, CHECK_NULL);
434 result = VMToCompiler::createConstantObject(result_oop, CHECK_NULL);
435 break;
436 }
437
438 default:
439 fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string()));
423 } 440 }
424 441
425 return JNIHandles::make_local(THREAD, result); 442 return JNIHandles::make_local(THREAD, result);
426 C2V_END 443 C2V_END
427 444