comparison src/share/vm/ci/bcEscapeAnalyzer.cpp @ 6634:7f813940ac35

7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites Reviewed-by: kvn
author twisti
date Tue, 28 Aug 2012 15:24:39 -0700
parents 1d7922586cf6
children da91efe96a93
comparison
equal deleted inserted replaced
6633:a5dd6e3ef9f3 6634:7f813940ac35
234 ciInstanceKlass* klass = target->holder(); 234 ciInstanceKlass* klass = target->holder();
235 ciInstanceKlass* calling_klass = method()->holder(); 235 ciInstanceKlass* calling_klass = method()->holder();
236 ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder); 236 ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder);
237 ciInstanceKlass* actual_recv = callee_holder; 237 ciInstanceKlass* actual_recv = callee_holder;
238 238
239 // some methods are obviously bindable without any type checks so 239 // Some methods are obviously bindable without any type checks so
240 // convert them directly to an invokespecial. 240 // convert them directly to an invokespecial or invokestatic.
241 if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) { 241 if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) {
242 switch (code) { 242 switch (code) {
243 case Bytecodes::_invokevirtual: code = Bytecodes::_invokespecial; break; 243 case Bytecodes::_invokevirtual:
244 case Bytecodes::_invokehandle: code = Bytecodes::_invokestatic; break; 244 code = Bytecodes::_invokespecial;
245 break;
246 case Bytecodes::_invokehandle:
247 code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial;
248 break;
245 } 249 }
246 } 250 }
247 251
248 // compute size of arguments 252 // compute size of arguments
249 int arg_size = target->invoke_arg_size(code); 253 int arg_size = target->invoke_arg_size(code);
824 set_returned(state.apop()); 828 set_returned(state.apop());
825 fall_through = false; 829 fall_through = false;
826 break; 830 break;
827 case Bytecodes::_getstatic: 831 case Bytecodes::_getstatic:
828 case Bytecodes::_getfield: 832 case Bytecodes::_getfield:
829 { bool will_link; 833 { bool ignored_will_link;
830 ciField* field = s.get_field(will_link); 834 ciField* field = s.get_field(ignored_will_link);
831 BasicType field_type = field->type()->basic_type(); 835 BasicType field_type = field->type()->basic_type();
832 if (s.cur_bc() != Bytecodes::_getstatic) { 836 if (s.cur_bc() != Bytecodes::_getstatic) {
833 set_method_escape(state.apop()); 837 set_method_escape(state.apop());
834 } 838 }
835 if (field_type == T_OBJECT || field_type == T_ARRAY) { 839 if (field_type == T_OBJECT || field_type == T_ARRAY) {
863 case Bytecodes::_invokevirtual: 867 case Bytecodes::_invokevirtual:
864 case Bytecodes::_invokespecial: 868 case Bytecodes::_invokespecial:
865 case Bytecodes::_invokestatic: 869 case Bytecodes::_invokestatic:
866 case Bytecodes::_invokedynamic: 870 case Bytecodes::_invokedynamic:
867 case Bytecodes::_invokeinterface: 871 case Bytecodes::_invokeinterface:
868 { bool will_link; 872 { bool ignored_will_link;
869 ciMethod* target = s.get_method(will_link); 873 ciSignature* declared_signature = NULL;
870 ciKlass* holder = s.get_declared_method_holder(); 874 ciMethod* target = s.get_method(ignored_will_link, &declared_signature);
875 ciKlass* holder = s.get_declared_method_holder();
876 assert(declared_signature != NULL, "cannot be null");
871 // Push appendix argument, if one. 877 // Push appendix argument, if one.
872 if (s.has_appendix()) { 878 if (s.has_appendix()) {
873 state.apush(unknown_obj); 879 state.apush(unknown_obj);
874 } 880 }
875 // Pass in raw bytecode because we need to see invokehandle instructions. 881 // Pass in raw bytecode because we need to see invokehandle instructions.
876 invoke(state, s.cur_bc_raw(), target, holder); 882 invoke(state, s.cur_bc_raw(), target, holder);
877 ciType* return_type = target->return_type(); 883 // We are using the return type of the declared signature here because
884 // it might be a more concrete type than the one from the target (for
885 // e.g. invokedynamic and invokehandle).
886 ciType* return_type = declared_signature->return_type();
878 if (!return_type->is_primitive_type()) { 887 if (!return_type->is_primitive_type()) {
879 state.apush(unknown_obj); 888 state.apush(unknown_obj);
880 } else if (return_type->is_one_word()) { 889 } else if (return_type->is_one_word()) {
881 state.spush(); 890 state.spush();
882 } else if (return_type->is_two_word()) { 891 } else if (return_type->is_two_word()) {