< prev index next >

src/share/vm/opto/callGenerator.cpp

Print this page




 850         const TypeOopPtr* oop_ptr = member_name->bottom_type()->is_oopptr();
 851         ciMethod* target = oop_ptr->const_oop()->as_member_name()->get_vmtarget();
 852 
 853         // In lambda forms we erase signature types to avoid resolving issues
 854         // involving class loaders.  When we optimize a method handle invoke
 855         // to a direct call we must cast the receiver and arguments to its
 856         // actual types.
 857         ciSignature* signature = target->signature();
 858         const int receiver_skip = target->is_static() ? 0 : 1;
 859         // Cast receiver to its type.
 860         if (!target->is_static()) {
 861           Node* arg = kit.argument(0);
 862           const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
 863           const Type*       sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass());
 864           if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 865             Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type));
 866             kit.set_argument(0, cast_obj);
 867           }
 868         }
 869         // Cast reference arguments to its type.
 870         for (int i = 0; i < signature->count(); i++) {
 871           ciType* t = signature->type_at(i);
 872           if (t->is_klass()) {
 873             Node* arg = kit.argument(receiver_skip + i);
 874             const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
 875             const Type*       sig_type = TypeOopPtr::make_from_klass(t->as_klass());
 876             if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 877               Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type));
 878               kit.set_argument(receiver_skip + i, cast_obj);
 879             }
 880           }

 881         }
 882 
 883         // Try to get the most accurate receiver type
 884         const bool is_virtual              = (iid == vmIntrinsics::_linkToVirtual);
 885         const bool is_virtual_or_interface = (is_virtual || iid == vmIntrinsics::_linkToInterface);
 886         int  vtable_index       = Method::invalid_vtable_index;
 887         bool call_does_dispatch = false;
 888 
 889         ciKlass* speculative_receiver_type = NULL;
 890         if (is_virtual_or_interface) {
 891           ciInstanceKlass* klass = target->holder();
 892           Node*             receiver_node = kit.argument(0);
 893           const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr();
 894           // call_does_dispatch and vtable_index are out-parameters.  They might be changed.
 895           // optimize_virtual_call() takes 2 different holder
 896           // arguments for a corner case that doesn't apply here (see
 897           // Parse::do_call())
 898           target = C->optimize_virtual_call(caller, jvms->bci(), klass, klass,
 899                                             target, receiver_type, is_virtual,
 900                                             call_does_dispatch, vtable_index, // out-parameters




 850         const TypeOopPtr* oop_ptr = member_name->bottom_type()->is_oopptr();
 851         ciMethod* target = oop_ptr->const_oop()->as_member_name()->get_vmtarget();
 852 
 853         // In lambda forms we erase signature types to avoid resolving issues
 854         // involving class loaders.  When we optimize a method handle invoke
 855         // to a direct call we must cast the receiver and arguments to its
 856         // actual types.
 857         ciSignature* signature = target->signature();
 858         const int receiver_skip = target->is_static() ? 0 : 1;
 859         // Cast receiver to its type.
 860         if (!target->is_static()) {
 861           Node* arg = kit.argument(0);
 862           const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
 863           const Type*       sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass());
 864           if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 865             Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type));
 866             kit.set_argument(0, cast_obj);
 867           }
 868         }
 869         // Cast reference arguments to its type.
 870         for (int i = 0, j = 0; i < signature->count(); i++) {
 871           ciType* t = signature->type_at(i);
 872           if (t->is_klass()) {
 873             Node* arg = kit.argument(receiver_skip + j);
 874             const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
 875             const Type*       sig_type = TypeOopPtr::make_from_klass(t->as_klass());
 876             if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 877               Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type));
 878               kit.set_argument(receiver_skip + j, cast_obj);
 879             }
 880           }
 881           j += t->size();  // long and double take two slots
 882         }
 883 
 884         // Try to get the most accurate receiver type
 885         const bool is_virtual              = (iid == vmIntrinsics::_linkToVirtual);
 886         const bool is_virtual_or_interface = (is_virtual || iid == vmIntrinsics::_linkToInterface);
 887         int  vtable_index       = Method::invalid_vtable_index;
 888         bool call_does_dispatch = false;
 889 
 890         ciKlass* speculative_receiver_type = NULL;
 891         if (is_virtual_or_interface) {
 892           ciInstanceKlass* klass = target->holder();
 893           Node*             receiver_node = kit.argument(0);
 894           const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr();
 895           // call_does_dispatch and vtable_index are out-parameters.  They might be changed.
 896           // optimize_virtual_call() takes 2 different holder
 897           // arguments for a corner case that doesn't apply here (see
 898           // Parse::do_call())
 899           target = C->optimize_virtual_call(caller, jvms->bci(), klass, klass,
 900                                             target, receiver_type, is_virtual,
 901                                             call_does_dispatch, vtable_index, // out-parameters


< prev index next >