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 // Wait until after parsing for the type information to propagate from the casts 1707 assert(can_reshape, "Invalid during parsing"); 1708 const Type* phi_type = bottom_type(); 1709 assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type"); 1710 int opcode; 1711 if (phi_type->isa_int()) { 1712 opcode = Op_CastII; 1713 } else { 1714 const Type* uin_type = phase->type(uin); 1715 if (phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) { 1716 opcode = Op_CastPP; 1717 } else { 1718 opcode = Op_CheckCastPP; 1719 } 1720 } 1721 // Add a cast to carry the control dependency of the Phi that is 1722 // going away 1723 Node* cast = ConstraintCastNode::make_cast(opcode, r, uin, phi_type, true); 1724 cast = phase->transform(cast); 1725 // set all inputs to the new cast so the Phi is removed by Identity 1726 PhaseIterGVN* igvn = phase->is_IterGVN(); 1727 for (uint i = 1; i < req(); i++) { 1728 set_req_X(i, cast, igvn); 1729 } 1730 uin = cast; 1731 } 1732 1733 // One unique input. 1734 debug_only(Node* ident = Identity(phase)); 1735 // The unique input must eventually be detected by the Identity call. | 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_klassptr() && uin_type->isa_klassptr())) { 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. |