comparison src/share/vm/graal/graalCompilerToVM.cpp @ 6346:908e40db1d94

Remove redundant code that discovers static final fields constant values
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 07 Sep 2012 21:24:26 +0200
parents 2691e320d37c
children a73fcf1639fc ad97777056ec
comparison
equal deleted inserted replaced
6345:a9b8d664dddd 6346:908e40db1d94
476 } 476 }
477 477
478 Handle type = GraalCompiler::get_JavaTypeFromSignature(cp, sig_index, cp->pool_holder(), CHECK_NULL); 478 Handle type = GraalCompiler::get_JavaTypeFromSignature(cp, sig_index, cp->pool_holder(), CHECK_NULL);
479 Handle field_handle = GraalCompiler::get_JavaField(offset, flags.as_int(), name, holder, type, code, THREAD); 479 Handle field_handle = GraalCompiler::get_JavaField(offset, flags.as_int(), name, holder, type, code, THREAD);
480 480
481 oop constant_object = NULL;
482 // Check to see if the field is constant.
483 if (!holder_klass.is_null() && holder_klass->is_initialized() && flags.is_final() && flags.is_static()) {
484 // This field just may be constant. The only cases where it will
485 // not be constant are:
486 //
487 // 1. The field holds a non-perm-space oop. The field is, strictly
488 // speaking, constant but we cannot embed non-perm-space oops into
489 // generated code. For the time being we need to consider the
490 // field to be not constant.
491 // 2. The field is a *special* static&final field whose value
492 // may change. The three examples are java.lang.System.in,
493 // java.lang.System.out, and java.lang.System.err.
494
495 bool ok = true;
496 assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
497 if( holder_klass->as_klassOop() == SystemDictionary::System_klass() ) {
498 // Check offsets for case 2: System.in, System.out, or System.err
499 if( offset == java_lang_System::in_offset_in_bytes() ||
500 offset == java_lang_System::out_offset_in_bytes() ||
501 offset == java_lang_System::err_offset_in_bytes() ) {
502 ok = false;
503 }
504 }
505
506 if (ok) {
507 Handle mirror = holder_klass->java_mirror();
508 switch(basic_type) {
509 case T_OBJECT:
510 case T_ARRAY:
511 constant_object = VMToCompiler::createConstantObject(mirror->obj_field(offset), CHECK_0);
512 break;
513 case T_DOUBLE:
514 constant_object = VMToCompiler::createConstantDouble(mirror->double_field(offset), CHECK_0);
515 break;
516 case T_FLOAT:
517 constant_object = VMToCompiler::createConstantFloat(mirror->float_field(offset), CHECK_0);
518 break;
519 case T_LONG:
520 constant_object = VMToCompiler::createConstant(Kind::Long(), mirror->long_field(offset), CHECK_0);
521 break;
522 case T_INT:
523 constant_object = VMToCompiler::createConstant(Kind::Int(), mirror->int_field(offset), CHECK_0);
524 break;
525 case T_SHORT:
526 constant_object = VMToCompiler::createConstant(Kind::Short(), mirror->short_field(offset), CHECK_0);
527 break;
528 case T_CHAR:
529 constant_object = VMToCompiler::createConstant(Kind::Char(), mirror->char_field(offset), CHECK_0);
530 break;
531 case T_BYTE:
532 constant_object = VMToCompiler::createConstant(Kind::Byte(), mirror->byte_field(offset), CHECK_0);
533 break;
534 case T_BOOLEAN:
535 constant_object = VMToCompiler::createConstant(Kind::Boolean(), mirror->bool_field(offset), CHECK_0);
536 break;
537 default:
538 fatal("Unhandled constant");
539 break;
540 }
541 }
542 }
543 if (constant_object != NULL) {
544 HotSpotResolvedJavaField::set_constant(field_handle, constant_object);
545 }
546 return JNIHandles::make_local(THREAD, field_handle()); 481 return JNIHandles::make_local(THREAD, field_handle());
547 } 482 }
548 483
549 // public JavaMethod JavaType_resolveMethodImpl(HotSpotResolvedJavaType klass, String name, String signature); 484 // public JavaMethod JavaType_resolveMethodImpl(HotSpotResolvedJavaType klass, String name, String signature);
550 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_JavaType_3resolveMethodImpl(JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature) { 485 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_JavaType_3resolveMethodImpl(JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature) {