< prev index next >

src/share/vm/opto/cfgnode.cpp

Print this page
rev 11702 : 8161652: Crash with assert(ft == _type) failed in PhiNode::Value()
Summary: PhiNode::Ideal() unique input logic creates CheckCastPP for null input
Reviewed-by:
rev 11703 : review


1686       // is removed in PhaseIdealLoop::Dominators().
1687       assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
1688       bool is_loop = (r->is_Loop() && r->req() == 3);
1689       // Then, check if there is a data loop when phi references itself directly
1690       // or through other data nodes.
1691       if (is_loop && !uin->eqv_uncast(in(LoopNode::EntryControl)) ||
1692          !is_loop && is_unsafe_data_reference(uin)) {
1693         // Break this data loop to avoid creation of a dead loop.
1694         if (can_reshape) {
1695           return top;
1696         } else {
1697           // We can't return top if we are in Parse phase - cut inputs only
1698           // let Identity to handle the case.
1699           replace_edge(uin, top);
1700           return NULL;
1701         }
1702       }
1703     }
1704 
1705     if (uncasted) {
1706       // Add a cast node between the phi to be removed and its unique input.
1707       // Wait until after parsing for the type information to propagate from the casts.
1708       assert(can_reshape, "Invalid during parsing");
1709       const Type* phi_type = bottom_type();
1710       assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
1711       int opcode;
1712       // Determine the type of cast to be added.

1713       if (phi_type->isa_int()) {
1714         opcode = Op_CastII;
1715       } else {
1716         const Type* uin_type = phase->type(uin);
1717         if ((phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) ||
1718             (!phi_type->isa_oopptr() && !uin_type->isa_oopptr())) {
1719           opcode = Op_CastPP;
1720         } else {
1721           opcode = Op_CheckCastPP;
1722         }







1723       }
1724       // Add a cast to carry the control dependency of the Phi that is
1725       // going away
1726       Node* cast = ConstraintCastNode::make_cast(opcode, r, uin, phi_type, true);




1727       cast = phase->transform(cast);
1728       // set all inputs to the new cast so the Phi is removed by Identity










1729       PhaseIterGVN* igvn = phase->is_IterGVN();
1730       for (uint i = 1; i < req(); i++) {
1731         set_req_X(i, cast, igvn);
1732       }
1733       uin = cast;
1734     }
1735 
1736     // One unique input.
1737     debug_only(Node* ident = Identity(phase));
1738     // The unique input must eventually be detected by the Identity call.
1739 #ifdef ASSERT
1740     if (ident != uin && !ident->is_top()) {
1741       // print this output before failing assert
1742       r->dump(3);
1743       this->dump(3);
1744       ident->dump();
1745       uin->dump();
1746     }
1747 #endif
1748     assert(ident == uin || ident->is_top(), "Identity must clean this up");




1686       // is removed in PhaseIdealLoop::Dominators().
1687       assert(!r->is_Loop() || r->req() <= 3, "Loop node should have 3 or less inputs");
1688       bool is_loop = (r->is_Loop() && r->req() == 3);
1689       // Then, check if there is a data loop when phi references itself directly
1690       // or through other data nodes.
1691       if (is_loop && !uin->eqv_uncast(in(LoopNode::EntryControl)) ||
1692          !is_loop && is_unsafe_data_reference(uin)) {
1693         // Break this data loop to avoid creation of a dead loop.
1694         if (can_reshape) {
1695           return top;
1696         } else {
1697           // We can't return top if we are in Parse phase - cut inputs only
1698           // let Identity to handle the case.
1699           replace_edge(uin, top);
1700           return NULL;
1701         }
1702       }
1703     }
1704 
1705     if (uncasted) {
1706       // Add cast nodes between the phi to be removed and its unique input.
1707       // Wait until after parsing for the type information to propagate from the casts.
1708       assert(can_reshape, "Invalid during parsing");
1709       const Type* phi_type = bottom_type();
1710       assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
1711       // Add casts to carry the control dependency of the Phi that is
1712       // going away
1713       Node* cast = NULL;
1714       if (phi_type->isa_int()) {
1715         cast = ConstraintCastNode::make_cast(Op_CastII, r, uin, phi_type, true);
1716       } else {
1717         const Type* uin_type = phase->type(uin);
1718         if (!phi_type->isa_oopptr() && !uin_type->isa_oopptr()) {
1719           cast = ConstraintCastNode::make_cast(Op_CastPP, r, uin, phi_type, true);

1720         } else {
1721           // Use a CastPP for a cast to not null and a CheckCastPP for
1722           // a cast to a new klass (and both if both null-ness and
1723           // klass change).
1724 
1725           // If the type of phi is not null but the type of uin may be
1726           // null, uin's type must be casted to not null
1727           if (phi_type->join(TypePtr::NOTNULL) == phi_type->remove_speculative() &&
1728               uin_type->join(TypePtr::NOTNULL) != uin_type->remove_speculative()) {
1729             cast = ConstraintCastNode::make_cast(Op_CastPP, r, uin, TypePtr::NOTNULL, true);
1730           }
1731           
1732           // If the type of phi and uin, both casted to not null,
1733           // differ the klass of uin must be (check)cast'ed to match
1734           // that of phi
1735           if (phi_type->join_speculative(TypePtr::NOTNULL) != uin_type->join_speculative(TypePtr::NOTNULL)) {
1736             Node* n = uin;
1737             if (cast != NULL) {
1738               cast = phase->transform(cast);
1739               n = cast;
1740             }
1741             cast = ConstraintCastNode::make_cast(Op_CheckCastPP, r, n, phi_type, true);
1742           }
1743           if (cast == NULL) {
1744             cast = ConstraintCastNode::make_cast(Op_CastPP, r, uin, phi_type, true);
1745           }
1746         }
1747       }
1748       assert(cast != NULL, "cast should be set");
1749       // set all inputs to the new cast(s) so the Phi is removed by Identity
1750       PhaseIterGVN* igvn = phase->is_IterGVN();
1751       for (uint i = 1; i < req(); i++) {
1752         set_req_X(i, cast, igvn);
1753       }
1754       uin = cast;
1755     }
1756 
1757     // One unique input.
1758     debug_only(Node* ident = Identity(phase));
1759     // The unique input must eventually be detected by the Identity call.
1760 #ifdef ASSERT
1761     if (ident != uin && !ident->is_top()) {
1762       // print this output before failing assert
1763       r->dump(3);
1764       this->dump(3);
1765       ident->dump();
1766       uin->dump();
1767     }
1768 #endif
1769     assert(ident == uin || ident->is_top(), "Identity must clean this up");


< prev index next >