1646 1647 if (type()->isa_valuetypeptr() && can_reshape) { 1648 // If the Phi merges the result from a mix of constant and non 1649 // constant method handles, only some of its inputs are 1650 // ValueTypePtr nodes and we can't push the ValueTypePtr node down 1651 // to remove the need for allocations. This if fixed by transforming: 1652 // 1653 // (Phi ValueTypePtr#1 Node#2) to (Phi ValueTypePtr#1 CheckCastPP#2) 1654 // 1655 // Then pushing the CheckCastPP up through Phis until it reaches 1656 // the non constant method handle call. The type of the return 1657 // value is then known from the type of the CheckCastPP. A 1658 // ValueTypePtr can be created by adding projections to the call 1659 // for all values being returned. See 1660 // CheckCastPPNode::Ideal(). That ValueTypePtr node can then be 1661 // pushed down through Phis. 1662 const TypeValueTypePtr* vtptr = NULL; 1663 for (uint i = 1; i < req(); i++) { 1664 if (in(i) != NULL && in(i)->is_ValueTypePtr()) { 1665 const TypeValueTypePtr* t = phase->type(in(i))->is_valuetypeptr(); 1666 if (vtptr == NULL) { 1667 vtptr = t; 1668 } else { 1669 assert(vtptr == t, "Phi should merge identical value types"); 1670 } 1671 } else { 1672 assert(in(i) == NULL || vtptr == NULL || phase->type(in(i))->higher_equal(vtptr) || phase->type(in(i)) == Type::TOP || 1673 phase->type(in(i))->is_valuetypeptr()->value_type()->value_klass() == phase->C->env()->___Value_klass(), "bad type"); 1674 } 1675 } 1676 if (vtptr != NULL) { 1677 // One input is a value type. All inputs must have the same type. 1678 bool progress = false; 1679 PhaseIterGVN* igvn = phase->is_IterGVN(); 1680 for (uint i = 1; i < req(); i++) { 1681 if (in(i) != NULL && !phase->type(in(i))->higher_equal(vtptr)) { 1682 // Can't transform because CheckCastPPNode::Identity can 1683 // push the cast up through another Phi and cause this same 1684 // transformation to run again, indefinitely 1685 Node* cast = igvn->register_new_node_with_optimizer(new CheckCastPPNode(NULL, in(i), vtptr)); 1686 set_req(i, cast); 1687 progress = true; 1688 } 1689 } 1690 if (progress) { 1691 return this; 1692 } 1693 } 1694 } 1695 1696 Node *top = phase->C->top(); 1697 bool new_phi = (outcnt() == 0); // transforming new Phi 1698 // No change for igvn if new phi is not hooked 1699 if (new_phi && can_reshape) 1700 return NULL; 1701 | 1646 1647 if (type()->isa_valuetypeptr() && can_reshape) { 1648 // If the Phi merges the result from a mix of constant and non 1649 // constant method handles, only some of its inputs are 1650 // ValueTypePtr nodes and we can't push the ValueTypePtr node down 1651 // to remove the need for allocations. This if fixed by transforming: 1652 // 1653 // (Phi ValueTypePtr#1 Node#2) to (Phi ValueTypePtr#1 CheckCastPP#2) 1654 // 1655 // Then pushing the CheckCastPP up through Phis until it reaches 1656 // the non constant method handle call. The type of the return 1657 // value is then known from the type of the CheckCastPP. A 1658 // ValueTypePtr can be created by adding projections to the call 1659 // for all values being returned. See 1660 // CheckCastPPNode::Ideal(). That ValueTypePtr node can then be 1661 // pushed down through Phis. 1662 const TypeValueTypePtr* vtptr = NULL; 1663 for (uint i = 1; i < req(); i++) { 1664 if (in(i) != NULL && in(i)->is_ValueTypePtr()) { 1665 const TypeValueTypePtr* t = phase->type(in(i))->is_valuetypeptr(); 1666 t = t->cast_to_ptr_type(TypePtr::BotPTR)->is_valuetypeptr(); 1667 if (vtptr == NULL) { 1668 vtptr = t; 1669 } else { 1670 assert(vtptr == t, "Phi should merge identical value types"); 1671 } 1672 } else { 1673 assert(in(i) == NULL || vtptr == NULL || phase->type(in(i))->higher_equal(vtptr) || phase->type(in(i)) == Type::TOP || 1674 phase->type(in(i))->is_valuetypeptr()->is__Value(), "bad type"); 1675 } 1676 } 1677 if (vtptr != NULL) { 1678 // One input is a value type. All inputs must have the same type. 1679 bool progress = false; 1680 PhaseIterGVN* igvn = phase->is_IterGVN(); 1681 for (uint i = 1; i < req(); i++) { 1682 if (in(i) != NULL && !in(i)->is_Con() && !phase->type(in(i))->higher_equal(vtptr)) { 1683 // Can't transform because CheckCastPPNode::Identity can 1684 // push the cast up through another Phi and cause this same 1685 // transformation to run again, indefinitely 1686 Node* cast = igvn->register_new_node_with_optimizer(new CheckCastPPNode(NULL, in(i), vtptr)); 1687 set_req(i, cast); 1688 progress = true; 1689 } 1690 } 1691 if (progress) { 1692 return this; 1693 } 1694 } 1695 } 1696 1697 Node *top = phase->C->top(); 1698 bool new_phi = (outcnt() == 0); // transforming new Phi 1699 // No change for igvn if new phi is not hooked 1700 if (new_phi && can_reshape) 1701 return NULL; 1702 |