949 // involving class loaders. When we optimize a method handle invoke 950 // to a direct call we must cast the receiver and arguments to its 951 // actual types. 952 ciSignature* signature = target->signature(); 953 const int receiver_skip = target->is_static() ? 0 : 1; 954 // Cast receiver to its type. 955 if (!target->is_static()) { 956 Node* arg = kit.argument(0); 957 const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); 958 const Type* sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass()); 959 if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { 960 Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); 961 kit.set_argument(0, cast_obj); 962 } 963 } 964 // Cast reference arguments to its type. 965 for (int i = 0, j = 0; i < signature->count(); i++) { 966 ciType* t = signature->type_at(i); 967 if (t->is_klass()) { 968 Node* arg = kit.argument(receiver_skip + j); 969 const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); 970 const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass()); 971 if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { 972 Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); 973 kit.set_argument(receiver_skip + j, cast_obj); 974 } 975 } 976 j += t->size(); // long and double take two slots 977 } 978 979 // Try to get the most accurate receiver type 980 const bool is_virtual = (iid == vmIntrinsics::_linkToVirtual); 981 const bool is_virtual_or_interface = (is_virtual || iid == vmIntrinsics::_linkToInterface); 982 int vtable_index = Method::invalid_vtable_index; 983 bool call_does_dispatch = false; 984 985 ciKlass* speculative_receiver_type = NULL; 986 if (is_virtual_or_interface) { 987 ciInstanceKlass* klass = target->holder(); 988 Node* receiver_node = kit.argument(0); 989 const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr(); 990 // call_does_dispatch and vtable_index are out-parameters. They might be changed. 991 // optimize_virtual_call() takes 2 different holder 992 // arguments for a corner case that doesn't apply here (see 993 // Parse::do_call()) | 949 // involving class loaders. When we optimize a method handle invoke 950 // to a direct call we must cast the receiver and arguments to its 951 // actual types. 952 ciSignature* signature = target->signature(); 953 const int receiver_skip = target->is_static() ? 0 : 1; 954 // Cast receiver to its type. 955 if (!target->is_static()) { 956 Node* arg = kit.argument(0); 957 const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); 958 const Type* sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass()); 959 if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { 960 Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); 961 kit.set_argument(0, cast_obj); 962 } 963 } 964 // Cast reference arguments to its type. 965 for (int i = 0, j = 0; i < signature->count(); i++) { 966 ciType* t = signature->type_at(i); 967 if (t->is_klass()) { 968 Node* arg = kit.argument(receiver_skip + j); 969 const Type* arg_type = arg->bottom_type()->isa_ptr(); 970 const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass()); 971 if (t->is_valuetype()) { 972 if (arg_type->isa_valuetype() && t == kit.C->env()->___Value_klass()) { 973 assert(arg->is_ValueType(), "inconsistent"); 974 Node* vt = arg->as_ValueType()->store_to_memory(&kit); 975 kit.set_argument(receiver_skip + j, vt); 976 } else if (arg_type->isa_valuetypeptr() && t != kit.C->env()->___Value_klass()) { 977 const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass()); 978 Node* cast = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); 979 Node* vt = ValueTypeNode::make(gvn, kit.merged_memory(), cast); 980 kit.set_argument(receiver_skip + j, vt); 981 } 982 } else { 983 if (arg_type->isa_oopptr() && !arg_type->higher_equal(sig_type)) { 984 Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); 985 kit.set_argument(receiver_skip + j, cast_obj); 986 } 987 } 988 } 989 j += t->size(); // long and double take two slots 990 } 991 992 // Try to get the most accurate receiver type 993 const bool is_virtual = (iid == vmIntrinsics::_linkToVirtual); 994 const bool is_virtual_or_interface = (is_virtual || iid == vmIntrinsics::_linkToInterface); 995 int vtable_index = Method::invalid_vtable_index; 996 bool call_does_dispatch = false; 997 998 ciKlass* speculative_receiver_type = NULL; 999 if (is_virtual_or_interface) { 1000 ciInstanceKlass* klass = target->holder(); 1001 Node* receiver_node = kit.argument(0); 1002 const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr(); 1003 // call_does_dispatch and vtable_index are out-parameters. They might be changed. 1004 // optimize_virtual_call() takes 2 different holder 1005 // arguments for a corner case that doesn't apply here (see 1006 // Parse::do_call()) |