< prev index next >

src/hotspot/share/opto/doCall.cpp

Print this page
   1 /*
   2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 628   if (!stopped()) {
 629     // This was some sort of virtual call, which did a null check for us.
 630     // Now we can assert receiver-not-null, on the normal return path.
 631     if (receiver != NULL && cg->is_virtual()) {
 632       Node* cast = cast_not_null(receiver);
 633       // %%% assert(receiver == cast, "should already have cast the receiver");
 634     }
 635 
 636     // Round double result after a call from strict to non-strict code
 637     round_double_result(cg->method());
 638 
 639     ciType* rtype = cg->method()->return_type();
 640     ciType* ctype = declared_signature->return_type();
 641 
 642     if (rtype->basic_type() == T_VALUETYPE) {
 643       Node* retnode = peek();
 644       if (!retnode->is_ValueType()) {
 645         pop();
 646         assert(!cg->is_inline(), "should have ValueTypeNode result");
 647         ciValueKlass* vk = _gvn.type(retnode)->value_klass();
 648         // We will deoptimize if the return value is null and then need to continue execution after the call
 649         ValueTypeNode* vt = ValueTypeNode::make_from_oop(this, retnode, vk, /* buffer_check */ false, /* null2default */ false, iter().next_bci());
 650         push_node(T_VALUETYPE, vt);
 651       }
 652     }
 653 
 654     if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
 655       // Be careful here with return types.
 656       if (ctype != rtype) {
 657         BasicType rt = rtype->basic_type();
 658         BasicType ct = ctype->basic_type();
 659         if (ct == T_VOID) {
 660           // It's OK for a method to return a value that is discarded.
 661           // The discarding does not require any special action from the caller.
 662           // The Java code knows this, at VerifyType.isNullConversion.
 663           pop_node(rt);  // whatever it was, pop it
 664         } else if (rt == T_INT || is_subword_type(rt)) {
 665           // Nothing.  These cases are handled in lambda form bytecode.
 666           assert(ct == T_INT || is_subword_type(ct), "must match: rt=%s, ct=%s", type2name(rt), type2name(ct));
 667         } else if (rt == T_OBJECT || rt == T_ARRAY) {
 668           assert(ct == T_OBJECT || ct == T_ARRAY || ct == T_VALUETYPE, "rt=%s, ct=%s", type2name(rt), type2name(ct));
 669           if (ctype->is_loaded()) {
 670             const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
 671             const Type*       sig_type = TypeOopPtr::make_from_klass(ctype->as_klass());
 672             if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 673               Node* retnode = pop();
 674               Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type));
 675               if (ct == T_VALUETYPE) {
 676                 // We will deoptimize if the return value is null and then need to continue execution after the call
 677                 cast_obj = ValueTypeNode::make_from_oop(this, cast_obj, ctype->as_value_klass(), /* buffer_check */ false, /* null2default */ false, iter().next_bci());
 678               }
 679               push(cast_obj);
 680             }
 681           }
 682         } else if (rt == T_VALUETYPE) {
 683           assert(ct == T_OBJECT, "object expected but got ct=%s", type2name(ct));
 684           ValueTypeNode* vt = pop()->as_ValueType();
 685           vt = vt->allocate(this)->as_ValueType();
 686           Node* vtptr = ValueTypePtrNode::make_from_value_type(_gvn, vt);
 687           push(vtptr);
 688         } else {
 689           assert(rt == ct, "unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct));
 690           // push a zero; it's better than getting an oop/int mismatch
 691           pop_node(rt);
 692           Node* retnode = zerocon(ct);
 693           push_node(ct, retnode);
 694         }
 695         // Now that the value is well-behaved, continue with the call-site type.
 696         rtype = ctype;
 697       }


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 628   if (!stopped()) {
 629     // This was some sort of virtual call, which did a null check for us.
 630     // Now we can assert receiver-not-null, on the normal return path.
 631     if (receiver != NULL && cg->is_virtual()) {
 632       Node* cast = cast_not_null(receiver);
 633       // %%% assert(receiver == cast, "should already have cast the receiver");
 634     }
 635 
 636     // Round double result after a call from strict to non-strict code
 637     round_double_result(cg->method());
 638 
 639     ciType* rtype = cg->method()->return_type();
 640     ciType* ctype = declared_signature->return_type();
 641 
 642     if (rtype->basic_type() == T_VALUETYPE) {
 643       Node* retnode = peek();
 644       if (!retnode->is_ValueType()) {
 645         pop();
 646         assert(!cg->is_inline(), "should have ValueTypeNode result");
 647         ciValueKlass* vk = _gvn.type(retnode)->value_klass();
 648         ValueTypeNode* vt = ValueTypeNode::make_from_returned_oop(this, retnode, vk);

 649         push_node(T_VALUETYPE, vt);
 650       }
 651     }
 652 
 653     if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) {
 654       // Be careful here with return types.
 655       if (ctype != rtype) {
 656         BasicType rt = rtype->basic_type();
 657         BasicType ct = ctype->basic_type();
 658         if (ct == T_VOID) {
 659           // It's OK for a method to return a value that is discarded.
 660           // The discarding does not require any special action from the caller.
 661           // The Java code knows this, at VerifyType.isNullConversion.
 662           pop_node(rt);  // whatever it was, pop it
 663         } else if (rt == T_INT || is_subword_type(rt)) {
 664           // Nothing.  These cases are handled in lambda form bytecode.
 665           assert(ct == T_INT || is_subword_type(ct), "must match: rt=%s, ct=%s", type2name(rt), type2name(ct));
 666         } else if (rt == T_OBJECT || rt == T_ARRAY) {
 667           assert(ct == T_OBJECT || ct == T_ARRAY || ct == T_VALUETYPE, "rt=%s, ct=%s", type2name(rt), type2name(ct));
 668           if (ctype->is_loaded()) {
 669             const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass());
 670             const Type*       sig_type = TypeOopPtr::make_from_klass(ctype->as_klass())->join_speculative(TypePtr::NOTNULL);
 671             if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
 672               Node* retnode = pop();
 673               Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type));
 674               if (ct == T_VALUETYPE) {
 675                 cast_obj = ValueTypeNode::make_from_returned_oop(this, cast_obj, ctype->as_value_klass());

 676               }
 677               push(cast_obj);
 678             }
 679           }
 680         } else if (rt == T_VALUETYPE) {
 681           assert(ct == T_OBJECT, "object expected but got ct=%s", type2name(ct));
 682           ValueTypeNode* vt = pop()->as_ValueType();
 683           vt = vt->allocate(this)->as_ValueType();
 684           Node* vtptr = ValueTypePtrNode::make_from_value_type(_gvn, vt);
 685           push(vtptr);
 686         } else {
 687           assert(rt == ct, "unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct));
 688           // push a zero; it's better than getting an oop/int mismatch
 689           pop_node(rt);
 690           Node* retnode = zerocon(ct);
 691           push_node(ct, retnode);
 692         }
 693         // Now that the value is well-behaved, continue with the call-site type.
 694         rtype = ctype;
 695       }


< prev index next >