< prev index next >

src/share/vm/opto/cfgnode.cpp

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


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           if (phi_type->join(TypePtr::NOTNULL) == phi_type->remove_speculative() &&
1722               uin_type->join(TypePtr::NOTNULL) != uin_type->remove_speculative()) {
1723             cast = ConstraintCastNode::make_cast(Op_CastPP, r, uin, TypePtr::NOTNULL, true);
1724           }
1725           if (phi_type->join_speculative(TypePtr::NOTNULL) != uin_type->join_speculative(TypePtr::NOTNULL)) {
1726             Node* n = uin;
1727             if (cast != NULL) {
1728               cast = phase->transform(cast);
1729               n = cast;
1730             }
1731             cast = ConstraintCastNode::make_cast(Op_CheckCastPP, r, n, phi_type, true);
1732           }
1733           if (cast == NULL) {
1734             cast = ConstraintCastNode::make_cast(Op_CastPP, r, uin, phi_type, true);
1735           }
1736         }
1737       }
1738       assert(cast != NULL, "cast should be set");
1739       // set all inputs to the new cast(s) so the Phi is removed by Identity
1740       PhaseIterGVN* igvn = phase->is_IterGVN();
1741       for (uint i = 1; i < req(); i++) {
1742         set_req_X(i, cast, igvn);
1743       }
1744       uin = cast;
1745     }
1746 
1747     // One unique input.
1748     debug_only(Node* ident = Identity(phase));
1749     // The unique input must eventually be detected by the Identity call.
1750 #ifdef ASSERT
1751     if (ident != uin && !ident->is_top()) {
1752       // print this output before failing assert
1753       r->dump(3);
1754       this->dump(3);
1755       ident->dump();
1756       uin->dump();
1757     }
1758 #endif
1759     assert(ident == uin || ident->is_top(), "Identity must clean this up");


< prev index next >