comparison src/share/vm/graal/graalVMEntries.cpp @ 3649:5a8c44b5fb80

Remove ci usage on field lookup.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Nov 2011 16:46:32 +0100
parents 81ad8ab1f9fe
children 0e8a2a629afb
comparison
equal deleted inserted replaced
3648:81ad8ab1f9fe 3649:5a8c44b5fb80
532 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); 532 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index);
533 533
534 int nt_index = cp->name_and_type_ref_index_at(index); 534 int nt_index = cp->name_and_type_ref_index_at(index);
535 int sig_index = cp->signature_ref_index_at(nt_index); 535 int sig_index = cp->signature_ref_index_at(nt_index);
536 Symbol* signature = cp->symbol_at(sig_index); 536 Symbol* signature = cp->symbol_at(sig_index);
537 int name_index = cp->name_ref_index_at(nt_index);
538 Symbol* name = cp->symbol_at(name_index);
537 int holder_index = cp->klass_ref_index_at(index); 539 int holder_index = cp->klass_ref_index_at(index);
538 Handle holder = GraalCompiler::get_RiType(cp, holder_index, cp->pool_holder(), CHECK_NULL); 540 Handle holder = GraalCompiler::get_RiType(cp, holder_index, cp->pool_holder(), CHECK_NULL);
541 instanceKlassHandle holder_klass;
539 542
540 Bytecodes::Code code = (Bytecodes::Code)(((int) byteCode) & 0xFF); 543 Bytecodes::Code code = (Bytecodes::Code)(((int) byteCode) & 0xFF);
544 int offset = -1;
545 AccessFlags flags;
546 BasicType basic_type;
541 if (holder->klass() == SystemDictionary::HotSpotTypeResolved_klass()) { 547 if (holder->klass() == SystemDictionary::HotSpotTypeResolved_klass()) {
542 FieldAccessInfo result; 548 FieldAccessInfo result;
543 LinkResolver::resolve_field(result, cp, index, 549 LinkResolver::resolve_field(result, cp, index,
544 Bytecodes::java_code(code), 550 Bytecodes::java_code(code),
545 true, false, Thread::current()); 551 true, false, Thread::current());
546 if (HAS_PENDING_EXCEPTION) { 552 if (HAS_PENDING_EXCEPTION) {
547 CLEAR_PENDING_EXCEPTION; 553 CLEAR_PENDING_EXCEPTION;
548 } 554 }
549 //result.field_offset(); 555 offset = result.field_offset();
550 holder = GraalCompiler::get_RiType(result.klass(), CHECK_NULL); 556 flags = result.access_flags();
551 } 557 holder_klass = result.klass()->as_klassOop();
552 558 basic_type = result.field_type();
559 holder = GraalCompiler::get_RiType(holder_klass, CHECK_NULL);
560 }
561
553 Handle type = GraalCompiler::get_RiTypeFromSignature(cp, sig_index, cp->pool_holder(), CHECK_NULL); 562 Handle type = GraalCompiler::get_RiTypeFromSignature(cp, sig_index, cp->pool_holder(), CHECK_NULL);
554 Handle field_handle = GraalCompiler::get_RiField(field, loading_klass, holder, type, code, THREAD); 563 Handle field_handle = GraalCompiler::get_RiField(offset, flags.as_int(), name, holder, type, code, THREAD);
555 bool is_constant = field->is_constant(); 564
556 if (is_constant && field->is_static()) { 565 oop constant_object = NULL;
557 ciConstant constant = field->constant_value(); 566 // Check to see if the field is constant.
558 oop constant_object = NULL; 567 if (!holder_klass.is_null() && holder_klass->is_initialized() && flags.is_final() && flags.is_static()) {
559 switch (constant.basic_type()) { 568 // This field just may be constant. The only cases where it will
560 case T_OBJECT: 569 // not be constant are:
561 case T_ARRAY: 570 //
562 { 571 // 1. The field holds a non-perm-space oop. The field is, strictly
563 ciObject* obj = constant.as_object(); 572 // speaking, constant but we cannot embed non-perm-space oops into
564 if (obj->is_null_object()) { 573 // generated code. For the time being we need to consider the
565 constant_object = VMExits::createCiConstantObject(NULL, CHECK_0); 574 // field to be not constant.
566 } else if (obj->can_be_constant()) { 575 // 2. The field is a *special* static&final field whose value
567 constant_object = VMExits::createCiConstantObject(constant.as_object()->get_oop(), CHECK_0); 576 // may change. The three examples are java.lang.System.in,
568 } 577 // java.lang.System.out, and java.lang.System.err.
569 } 578
570 break; 579 bool ok = true;
571 case T_DOUBLE: 580 assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
572 constant_object = VMExits::createCiConstantDouble(constant.as_double(), CHECK_0); 581 if( holder_klass->as_klassOop() == SystemDictionary::System_klass() ) {
573 break; 582 // Check offsets for case 2: System.in, System.out, or System.err
574 case T_FLOAT: 583 if( offset == java_lang_System::in_offset_in_bytes() ||
575 constant_object = VMExits::createCiConstantFloat(constant.as_float(), CHECK_0); 584 offset == java_lang_System::out_offset_in_bytes() ||
576 break; 585 offset == java_lang_System::err_offset_in_bytes() ) {
577 case T_LONG: 586 ok = false;
578 constant_object = VMExits::createCiConstant(CiKind::Long(), constant.as_long(), CHECK_0); 587 }
579 break; 588 }
580 case T_INT: 589
581 constant_object = VMExits::createCiConstant(CiKind::Int(), constant.as_int(), CHECK_0); 590 if (ok) {
582 break; 591 Handle mirror = holder_klass->java_mirror();
583 case T_SHORT: 592 switch(basic_type) {
584 constant_object = VMExits::createCiConstant(CiKind::Short(), constant.as_int(), CHECK_0); 593 case T_OBJECT:
585 break; 594 case T_ARRAY:
586 case T_CHAR: 595 constant_object = VMExits::createCiConstantObject(mirror->obj_field(offset), CHECK_0);
587 constant_object = VMExits::createCiConstant(CiKind::Char(), constant.as_int(), CHECK_0); 596 break;
588 break; 597 case T_DOUBLE:
589 case T_BYTE: 598 constant_object = VMExits::createCiConstantDouble(mirror->double_field(offset), CHECK_0);
590 constant_object = VMExits::createCiConstant(CiKind::Byte(), constant.as_int(), CHECK_0); 599 break;
591 break; 600 case T_FLOAT:
592 case T_BOOLEAN: 601 constant_object = VMExits::createCiConstantFloat(mirror->float_field(offset), CHECK_0);
593 constant_object = VMExits::createCiConstant(CiKind::Boolean(), constant.as_int(), CHECK_0); 602 break;
594 break; 603 case T_LONG:
595 default: 604 constant_object = VMExits::createCiConstant(CiKind::Long(), mirror->long_field(offset), CHECK_0);
596 constant.print(); 605 break;
597 fatal("Unhandled constant"); 606 case T_INT:
598 break; 607 constant_object = VMExits::createCiConstant(CiKind::Int(), mirror->int_field(offset), CHECK_0);
599 } 608 break;
600 if (constant_object != NULL) { 609 case T_SHORT:
601 HotSpotField::set_constant(field_handle, constant_object); 610 constant_object = VMExits::createCiConstant(CiKind::Short(), mirror->short_field(offset), CHECK_0);
602 } 611 break;
612 case T_CHAR:
613 constant_object = VMExits::createCiConstant(CiKind::Char(), mirror->char_field(offset), CHECK_0);
614 break;
615 case T_BYTE:
616 constant_object = VMExits::createCiConstant(CiKind::Byte(), mirror->byte_field(offset), CHECK_0);
617 break;
618 case T_BOOLEAN:
619 constant_object = VMExits::createCiConstant(CiKind::Boolean(), mirror->bool_field(offset), CHECK_0);
620 break;
621 default:
622 fatal("Unhandled constant");
623 break;
624 }
625 }
626 }
627 if (constant_object != NULL) {
628 HotSpotField::set_constant(field_handle, constant_object);
603 } 629 }
604 return JNIHandles::make_local(THREAD, field_handle()); 630 return JNIHandles::make_local(THREAD, field_handle());
605 } 631 }
606 632
607 // public RiMethod RiType_resolveMethodImpl(HotSpotTypeResolved klass, String name, String signature); 633 // public RiMethod RiType_resolveMethodImpl(HotSpotTypeResolved klass, String name, String signature);