src/share/vm/ci/bcEscapeAnalyzer.cpp

changeset 4021
7f813940ac35
parent 3969
1d7922586cf6
child 4037
da91efe96a93
     1.1 --- a/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Aug 27 15:17:17 2012 -0700
     1.2 +++ b/src/share/vm/ci/bcEscapeAnalyzer.cpp	Tue Aug 28 15:24:39 2012 -0700
     1.3 @@ -236,12 +236,16 @@
     1.4    ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
     1.5    ciInstanceKlass* actual_recv = callee_holder;
     1.6  
     1.7 -  // some methods are obviously bindable without any type checks so
     1.8 -  // convert them directly to an invokespecial.
     1.9 +  // Some methods are obviously bindable without any type checks so
    1.10 +  // convert them directly to an invokespecial or invokestatic.
    1.11    if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) {
    1.12      switch (code) {
    1.13 -    case Bytecodes::_invokevirtual:  code = Bytecodes::_invokespecial;  break;
    1.14 -    case Bytecodes::_invokehandle:   code = Bytecodes::_invokestatic;   break;
    1.15 +    case Bytecodes::_invokevirtual:
    1.16 +      code = Bytecodes::_invokespecial;
    1.17 +      break;
    1.18 +    case Bytecodes::_invokehandle:
    1.19 +      code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial;
    1.20 +      break;
    1.21      }
    1.22    }
    1.23  
    1.24 @@ -826,8 +830,8 @@
    1.25          break;
    1.26        case Bytecodes::_getstatic:
    1.27        case Bytecodes::_getfield:
    1.28 -        { bool will_link;
    1.29 -          ciField* field = s.get_field(will_link);
    1.30 +        { bool ignored_will_link;
    1.31 +          ciField* field = s.get_field(ignored_will_link);
    1.32            BasicType field_type = field->type()->basic_type();
    1.33            if (s.cur_bc() != Bytecodes::_getstatic) {
    1.34              set_method_escape(state.apop());
    1.35 @@ -865,16 +869,21 @@
    1.36        case Bytecodes::_invokestatic:
    1.37        case Bytecodes::_invokedynamic:
    1.38        case Bytecodes::_invokeinterface:
    1.39 -        { bool will_link;
    1.40 -          ciMethod* target = s.get_method(will_link);
    1.41 -          ciKlass* holder = s.get_declared_method_holder();
    1.42 +        { bool ignored_will_link;
    1.43 +          ciSignature* declared_signature = NULL;
    1.44 +          ciMethod* target = s.get_method(ignored_will_link, &declared_signature);
    1.45 +          ciKlass*  holder = s.get_declared_method_holder();
    1.46 +          assert(declared_signature != NULL, "cannot be null");
    1.47            // Push appendix argument, if one.
    1.48            if (s.has_appendix()) {
    1.49              state.apush(unknown_obj);
    1.50            }
    1.51            // Pass in raw bytecode because we need to see invokehandle instructions.
    1.52            invoke(state, s.cur_bc_raw(), target, holder);
    1.53 -          ciType* return_type = target->return_type();
    1.54 +          // We are using the return type of the declared signature here because
    1.55 +          // it might be a more concrete type than the one from the target (for
    1.56 +          // e.g. invokedynamic and invokehandle).
    1.57 +          ciType* return_type = declared_signature->return_type();
    1.58            if (!return_type->is_primitive_type()) {
    1.59              state.apush(unknown_obj);
    1.60            } else if (return_type->is_one_word()) {

mercurial