src/hotspot/share/opto/doCall.cpp
changeset 50735 2f2af62dfac7
parent 47216 71c04702a3d5
child 51444 3e5d28e6de32
equal deleted inserted replaced
50734:0828a0f6676b 50735:2f2af62dfac7
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   503                                       receiver_type, is_virtual,
   503                                       receiver_type, is_virtual,
   504                                       call_does_dispatch, vtable_index);  // out-parameters
   504                                       call_does_dispatch, vtable_index);  // out-parameters
   505     speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
   505     speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
   506   }
   506   }
   507 
   507 
   508   // invoke-super-special
   508   // Additional receiver subtype checks for interface calls via invokespecial or invokeinterface.
       
   509   ciKlass* receiver_constraint = NULL;
   509   if (iter().cur_bc_raw() == Bytecodes::_invokespecial && !orig_callee->is_object_initializer()) {
   510   if (iter().cur_bc_raw() == Bytecodes::_invokespecial && !orig_callee->is_object_initializer()) {
   510     ciInstanceKlass* calling_klass = method()->holder();
   511     ciInstanceKlass* calling_klass = method()->holder();
   511     ciInstanceKlass* sender_klass =
   512     ciInstanceKlass* sender_klass =
   512         calling_klass->is_anonymous() ? calling_klass->host_klass() :
   513         calling_klass->is_anonymous() ? calling_klass->host_klass() :
   513                                         calling_klass;
   514                                         calling_klass;
   514     if (sender_klass->is_interface()) {
   515     if (sender_klass->is_interface()) {
   515       Node* receiver_node = stack(sp() - nargs);
   516       receiver_constraint = sender_klass;
   516       Node* cls_node = makecon(TypeKlassPtr::make(sender_klass));
   517     }
   517       Node* bad_type_ctrl = NULL;
   518   } else if (iter().cur_bc_raw() == Bytecodes::_invokeinterface && orig_callee->is_private()) {
   518       Node* casted_receiver = gen_checkcast(receiver_node, cls_node, &bad_type_ctrl);
   519     assert(holder->is_interface(), "How did we get a non-interface method here!");
   519       if (bad_type_ctrl != NULL) {
   520     receiver_constraint = holder;
   520         PreserveJVMState pjvms(this);
   521   }
   521         set_control(bad_type_ctrl);
   522 
   522         uncommon_trap(Deoptimization::Reason_class_check,
   523   if (receiver_constraint != NULL) {
   523                       Deoptimization::Action_none);
   524     Node* receiver_node = stack(sp() - nargs);
   524       }
   525     Node* cls_node = makecon(TypeKlassPtr::make(receiver_constraint));
   525       if (stopped()) {
   526     Node* bad_type_ctrl = NULL;
   526         return; // MUST uncommon-trap?
   527     Node* casted_receiver = gen_checkcast(receiver_node, cls_node, &bad_type_ctrl);
   527       }
   528     if (bad_type_ctrl != NULL) {
   528       set_stack(sp() - nargs, casted_receiver);
   529       PreserveJVMState pjvms(this);
   529     }
   530       set_control(bad_type_ctrl);
       
   531       uncommon_trap(Deoptimization::Reason_class_check,
       
   532                     Deoptimization::Action_none);
       
   533     }
       
   534     if (stopped()) {
       
   535       return; // MUST uncommon-trap?
       
   536     }
       
   537     set_stack(sp() - nargs, casted_receiver);
   530   }
   538   }
   531 
   539 
   532   // Note:  It's OK to try to inline a virtual call.
   540   // Note:  It's OK to try to inline a virtual call.
   533   // The call generator will not attempt to inline a polymorphic call
   541   // The call generator will not attempt to inline a polymorphic call
   534   // unless it knows how to optimize the receiver dispatch.
   542   // unless it knows how to optimize the receiver dispatch.