582 } 583 584 // Round double result after a call from strict to non-strict code 585 round_double_result(cg->method()); 586 587 ciType* rtype = cg->method()->return_type(); 588 ciType* ctype = declared_signature->return_type(); 589 590 if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) { 591 // Be careful here with return types. 592 if (ctype != rtype) { 593 BasicType rt = rtype->basic_type(); 594 BasicType ct = ctype->basic_type(); 595 if (ct == T_VOID) { 596 // It's OK for a method to return a value that is discarded. 597 // The discarding does not require any special action from the caller. 598 // The Java code knows this, at VerifyType.isNullConversion. 599 pop_node(rt); // whatever it was, pop it 600 } else if (rt == T_INT || is_subword_type(rt)) { 601 // Nothing. These cases are handled in lambda form bytecode. 602 assert(ct == T_INT || is_subword_type(ct), err_msg_res("must match: rt=%s, ct=%s", type2name(rt), type2name(ct))); 603 } else if (rt == T_OBJECT || rt == T_ARRAY) { 604 assert(ct == T_OBJECT || ct == T_ARRAY, err_msg_res("rt=%s, ct=%s", type2name(rt), type2name(ct))); 605 if (ctype->is_loaded()) { 606 const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass()); 607 const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass()); 608 if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { 609 Node* retnode = pop(); 610 Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type)); 611 push(cast_obj); 612 } 613 } 614 } else { 615 assert(rt == ct, err_msg_res("unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct))); 616 // push a zero; it's better than getting an oop/int mismatch 617 pop_node(rt); 618 Node* retnode = zerocon(ct); 619 push_node(ct, retnode); 620 } 621 // Now that the value is well-behaved, continue with the call-site type. 622 rtype = ctype; 623 } 624 } else { 625 // Symbolic resolution enforces the types to be the same. 626 // NOTE: We must relax the assert for unloaded types because two 627 // different ciType instances of the same unloaded class type 628 // can appear to be "loaded" by different loaders (depending on 629 // the accessing class). 630 assert(!rtype->is_loaded() || !ctype->is_loaded() || rtype == ctype, 631 err_msg_res("mismatched return types: rtype=%s, ctype=%s", rtype->name(), ctype->name())); 632 } 633 634 // If the return type of the method is not loaded, assert that the 635 // value we got is a null. Otherwise, we need to recompile. 636 if (!rtype->is_loaded()) { 637 #ifndef PRODUCT 638 if (PrintOpto && (Verbose || WizardMode)) { 639 method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci()); 640 cg->method()->print_name(); tty->cr(); 641 } 642 #endif 643 if (C->log() != NULL) { 644 C->log()->elem("assert_null reason='return' klass='%d'", 645 C->log()->identify(rtype)); 646 } 647 // If there is going to be a trap, put it at the next bytecode: 648 set_bci(iter().next_bci()); 649 null_assert(peek()); 650 set_bci(iter().cur_bci()); // put it back 651 } | 582 } 583 584 // Round double result after a call from strict to non-strict code 585 round_double_result(cg->method()); 586 587 ciType* rtype = cg->method()->return_type(); 588 ciType* ctype = declared_signature->return_type(); 589 590 if (Bytecodes::has_optional_appendix(iter().cur_bc_raw()) || is_signature_polymorphic) { 591 // Be careful here with return types. 592 if (ctype != rtype) { 593 BasicType rt = rtype->basic_type(); 594 BasicType ct = ctype->basic_type(); 595 if (ct == T_VOID) { 596 // It's OK for a method to return a value that is discarded. 597 // The discarding does not require any special action from the caller. 598 // The Java code knows this, at VerifyType.isNullConversion. 599 pop_node(rt); // whatever it was, pop it 600 } else if (rt == T_INT || is_subword_type(rt)) { 601 // Nothing. These cases are handled in lambda form bytecode. 602 assert(ct == T_INT || is_subword_type(ct), "must match: rt=%s, ct=%s", type2name(rt), type2name(ct)); 603 } else if (rt == T_OBJECT || rt == T_ARRAY) { 604 assert(ct == T_OBJECT || ct == T_ARRAY, "rt=%s, ct=%s", type2name(rt), type2name(ct)); 605 if (ctype->is_loaded()) { 606 const TypeOopPtr* arg_type = TypeOopPtr::make_from_klass(rtype->as_klass()); 607 const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass()); 608 if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { 609 Node* retnode = pop(); 610 Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type)); 611 push(cast_obj); 612 } 613 } 614 } else { 615 assert(rt == ct, "unexpected mismatch: rt=%s, ct=%s", type2name(rt), type2name(ct)); 616 // push a zero; it's better than getting an oop/int mismatch 617 pop_node(rt); 618 Node* retnode = zerocon(ct); 619 push_node(ct, retnode); 620 } 621 // Now that the value is well-behaved, continue with the call-site type. 622 rtype = ctype; 623 } 624 } else { 625 // Symbolic resolution enforces the types to be the same. 626 // NOTE: We must relax the assert for unloaded types because two 627 // different ciType instances of the same unloaded class type 628 // can appear to be "loaded" by different loaders (depending on 629 // the accessing class). 630 assert(!rtype->is_loaded() || !ctype->is_loaded() || rtype == ctype, 631 "mismatched return types: rtype=%s, ctype=%s", rtype->name(), ctype->name()); 632 } 633 634 // If the return type of the method is not loaded, assert that the 635 // value we got is a null. Otherwise, we need to recompile. 636 if (!rtype->is_loaded()) { 637 #ifndef PRODUCT 638 if (PrintOpto && (Verbose || WizardMode)) { 639 method()->print_name(); tty->print_cr(" asserting nullness of result at bci: %d", bci()); 640 cg->method()->print_name(); tty->cr(); 641 } 642 #endif 643 if (C->log() != NULL) { 644 C->log()->elem("assert_null reason='return' klass='%d'", 645 C->log()->identify(rtype)); 646 } 647 // If there is going to be a trap, put it at the next bytecode: 648 set_bci(iter().next_bci()); 649 null_assert(peek()); 650 set_bci(iter().cur_bci()); // put it back 651 } |