1626 if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1627 return NULL; // No change
1628
1629 // If all inputs are value types, push the value type node down through the
1630 // phi because value type nodes should be merged through their input values.
1631 if (req() > 2 && in(1) != NULL && in(1)->is_ValueTypeBase() && (can_reshape || in(1)->is_ValueType())) {
1632 int opcode = in(1)->Opcode();
1633 uint i = 2;
1634 for (; i < req() && in(i) && in(i)->is_ValueTypeBase(); i++) {
1635 assert(in(i)->Opcode() == opcode, "mixing pointers and values?");
1636 }
1637 if (i == req()) {
1638 ValueTypeBaseNode* vt = in(1)->as_ValueTypeBase()->clone_with_phis(phase, in(0));
1639 for (uint i = 2; i < req(); ++i) {
1640 vt->merge_with(phase, in(i)->as_ValueTypeBase(), i, i == (req()-1));
1641 }
1642 return vt;
1643 }
1644 }
1645
1646 Node *top = phase->C->top();
1647 bool new_phi = (outcnt() == 0); // transforming new Phi
1648 // No change for igvn if new phi is not hooked
1649 if (new_phi && can_reshape)
1650 return NULL;
1651
1652 // The are 2 situations when only one valid phi's input is left
1653 // (in addition to Region input).
1654 // One: region is not loop - replace phi with this input.
1655 // Two: region is loop - replace phi with top since this data path is dead
1656 // and we need to break the dead data loop.
1657 Node* progress = NULL; // Record if any progress made
1658 for( uint j = 1; j < req(); ++j ){ // For all paths in
1659 // Check unreachable control paths
1660 Node* rc = r->in(j);
1661 Node* n = in(j); // Get the input
1662 if (rc == NULL || phase->type(rc) == Type::TOP) {
1663 if (n != top) { // Not already top?
1664 PhaseIterGVN *igvn = phase->is_IterGVN();
1665 if (can_reshape && igvn != NULL) {
2328 return in(0)->in(0);
2329 }
2330
2331
2332 #ifndef PRODUCT
2333 void CatchProjNode::dump_spec(outputStream *st) const {
2334 ProjNode::dump_spec(st);
2335 st->print("@bci %d ",_handler_bci);
2336 }
2337 #endif
2338
2339 //=============================================================================
2340 //------------------------------Identity---------------------------------------
2341 // Check for CreateEx being Identity.
2342 Node* CreateExNode::Identity(PhaseGVN* phase) {
2343 if( phase->type(in(1)) == Type::TOP ) return in(1);
2344 if( phase->type(in(0)) == Type::TOP ) return in(0);
2345 // We only come from CatchProj, unless the CatchProj goes away.
2346 // If the CatchProj is optimized away, then we just carry the
2347 // exception oop through.
2348 CallNode *call = in(1)->in(0)->as_Call();
2349
2350 return ( in(0)->is_CatchProj() && in(0)->in(0)->in(1) == in(1) )
2351 ? this
2352 : call->in(TypeFunc::Parms);
2353 }
2354
2355 //=============================================================================
2356 //------------------------------Value------------------------------------------
2357 // Check for being unreachable.
2358 const Type* NeverBranchNode::Value(PhaseGVN* phase) const {
2359 if (!in(0) || in(0)->is_top()) return Type::TOP;
2360 return bottom_type();
2361 }
2362
2363 //------------------------------Ideal------------------------------------------
2364 // Check for no longer being part of a loop
2365 Node *NeverBranchNode::Ideal(PhaseGVN *phase, bool can_reshape) {
2366 if (can_reshape && !in(0)->is_Loop()) {
2367 // Dead code elimination can sometimes delete this projection so
|
1626 if( phase->type_or_null(r) == Type::TOP ) // Dead code?
1627 return NULL; // No change
1628
1629 // If all inputs are value types, push the value type node down through the
1630 // phi because value type nodes should be merged through their input values.
1631 if (req() > 2 && in(1) != NULL && in(1)->is_ValueTypeBase() && (can_reshape || in(1)->is_ValueType())) {
1632 int opcode = in(1)->Opcode();
1633 uint i = 2;
1634 for (; i < req() && in(i) && in(i)->is_ValueTypeBase(); i++) {
1635 assert(in(i)->Opcode() == opcode, "mixing pointers and values?");
1636 }
1637 if (i == req()) {
1638 ValueTypeBaseNode* vt = in(1)->as_ValueTypeBase()->clone_with_phis(phase, in(0));
1639 for (uint i = 2; i < req(); ++i) {
1640 vt->merge_with(phase, in(i)->as_ValueTypeBase(), i, i == (req()-1));
1641 }
1642 return vt;
1643 }
1644 }
1645
1646 if (type()->isa_valuetypeptr() && can_reshape) {
1647 const TypeValueTypePtr* vtptr = NULL;
1648 for (uint i = 1; i < req(); i++) {
1649 if (in(i) != NULL && in(i)->is_ValueTypePtr()) {
1650 const TypeValueTypePtr* t = phase->type(in(i))->is_valuetypeptr();
1651 if (vtptr == NULL) {
1652 vtptr = t;
1653 } else {
1654 assert(vtptr == t, "Phi should merge identical value types");
1655 }
1656 } else {
1657 assert(in(i) == NULL || vtptr == NULL || phase->type(in(i))->higher_equal(vtptr) || phase->type(in(i)) == Type::TOP ||
1658 phase->type(in(i))->is_valuetypeptr()->value_type()->value_klass() == phase->C->env()->___Value_klass(), "bad type");
1659 }
1660 }
1661 if (vtptr != NULL) {
1662 // One input is a value type. All inputs must have the same
1663 // type.
1664 bool progress = false;
1665 PhaseIterGVN* igvn = phase->is_IterGVN();
1666 for (uint i = 1; i < req(); i++) {
1667 if (in(i) != NULL && !phase->type(in(i))->higher_equal(vtptr)) {
1668 // Can't transform because CheckCastPPNode::Identity can
1669 // push the cast up through another Phi and cause this same
1670 // transformation to run again, indefinitely
1671 Node* cast = igvn->register_new_node_with_optimizer(new CheckCastPPNode(NULL, in(i), vtptr));
1672 set_req(i, cast);
1673 progress = true;
1674 }
1675 }
1676 if (progress) {
1677 return this;
1678 }
1679 }
1680 }
1681
1682 Node *top = phase->C->top();
1683 bool new_phi = (outcnt() == 0); // transforming new Phi
1684 // No change for igvn if new phi is not hooked
1685 if (new_phi && can_reshape)
1686 return NULL;
1687
1688 // The are 2 situations when only one valid phi's input is left
1689 // (in addition to Region input).
1690 // One: region is not loop - replace phi with this input.
1691 // Two: region is loop - replace phi with top since this data path is dead
1692 // and we need to break the dead data loop.
1693 Node* progress = NULL; // Record if any progress made
1694 for( uint j = 1; j < req(); ++j ){ // For all paths in
1695 // Check unreachable control paths
1696 Node* rc = r->in(j);
1697 Node* n = in(j); // Get the input
1698 if (rc == NULL || phase->type(rc) == Type::TOP) {
1699 if (n != top) { // Not already top?
1700 PhaseIterGVN *igvn = phase->is_IterGVN();
1701 if (can_reshape && igvn != NULL) {
2364 return in(0)->in(0);
2365 }
2366
2367
2368 #ifndef PRODUCT
2369 void CatchProjNode::dump_spec(outputStream *st) const {
2370 ProjNode::dump_spec(st);
2371 st->print("@bci %d ",_handler_bci);
2372 }
2373 #endif
2374
2375 //=============================================================================
2376 //------------------------------Identity---------------------------------------
2377 // Check for CreateEx being Identity.
2378 Node* CreateExNode::Identity(PhaseGVN* phase) {
2379 if( phase->type(in(1)) == Type::TOP ) return in(1);
2380 if( phase->type(in(0)) == Type::TOP ) return in(0);
2381 // We only come from CatchProj, unless the CatchProj goes away.
2382 // If the CatchProj is optimized away, then we just carry the
2383 // exception oop through.
2384 if (in(1)->is_Phi()) return this;
2385 CallNode *call = in(1)->in(0)->as_Call();
2386
2387 return ( in(0)->is_CatchProj() && in(0)->in(0)->in(1) == in(1) )
2388 ? this
2389 : call->in(TypeFunc::Parms);
2390 }
2391
2392 //=============================================================================
2393 //------------------------------Value------------------------------------------
2394 // Check for being unreachable.
2395 const Type* NeverBranchNode::Value(PhaseGVN* phase) const {
2396 if (!in(0) || in(0)->is_top()) return Type::TOP;
2397 return bottom_type();
2398 }
2399
2400 //------------------------------Ideal------------------------------------------
2401 // Check for no longer being part of a loop
2402 Node *NeverBranchNode::Ideal(PhaseGVN *phase, bool can_reshape) {
2403 if (can_reshape && !in(0)->is_Loop()) {
2404 // Dead code elimination can sometimes delete this projection so
|