1504 Unique_Node_List worklist;
1505 worklist.push(C->root());
1506
1507 // Pull from worklist; compute new value; push changes out.
1508 // This loop is the meat of CCP.
1509 while( worklist.size() ) {
1510 Node *n = worklist.pop();
1511 const Type *t = n->Value(this);
1512 if (t != type(n)) {
1513 assert(ccp_type_widens(t, type(n)), "ccp type must widen");
1514 #ifndef PRODUCT
1515 if( TracePhaseCCP ) {
1516 t->dump();
1517 do { tty->print("\t"); } while (tty->position() < 16);
1518 n->dump();
1519 }
1520 #endif
1521 set_type(n, t);
1522 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1523 Node* m = n->fast_out(i); // Get user
1524 if( m->is_Region() ) { // New path to Region? Must recheck Phis too
1525 for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1526 Node* p = m->fast_out(i2); // Propagate changes to uses
1527 if( p->bottom_type() != type(p) ) // If not already bottomed out
1528 worklist.push(p); // Propagate change to user
1529 }
1530 }
1531 // If we changed the receiver type to a call, we need to revisit
1532 // the Catch following the call. It's looking for a non-NULL
1533 // receiver to know when to enable the regular fall-through path
1534 // in addition to the NullPtrException path
1535 if (m->is_Call()) {
1536 for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1537 Node* p = m->fast_out(i2); // Propagate changes to uses
1538 if (p->is_Proj() && p->as_Proj()->_con == TypeFunc::Control && p->outcnt() == 1)
1539 worklist.push(p->unique_out());
1540 }
1541 }
1542 if( m->bottom_type() != type(m) ) // If not already bottomed out
1543 worklist.push(m); // Propagate change to user
1544 }
1545 }
1546 }
1547 }
1548
1549 //------------------------------do_transform-----------------------------------
1550 // Top level driver for the recursive transformer
1551 void PhaseCCP::do_transform() {
1552 // Correct leaves of new-space Nodes; they point to old-space.
1553 C->set_root( transform(C->root())->as_Root() );
1554 assert( C->top(), "missing TOP node" );
1555 assert( C->root(), "missing root" );
1556 }
1557
1558 //------------------------------transform--------------------------------------
1559 // Given a Node in old-space, clone him into new-space.
1560 // Convert any of his old-space children into new-space children.
1561 Node *PhaseCCP::transform( Node *n ) {
1562 Node *new_node = _nodes[n->_idx]; // Check for transformed node
1563 if( new_node != NULL )
1564 return new_node; // Been there, done that, return old answer
|
1504 Unique_Node_List worklist;
1505 worklist.push(C->root());
1506
1507 // Pull from worklist; compute new value; push changes out.
1508 // This loop is the meat of CCP.
1509 while( worklist.size() ) {
1510 Node *n = worklist.pop();
1511 const Type *t = n->Value(this);
1512 if (t != type(n)) {
1513 assert(ccp_type_widens(t, type(n)), "ccp type must widen");
1514 #ifndef PRODUCT
1515 if( TracePhaseCCP ) {
1516 t->dump();
1517 do { tty->print("\t"); } while (tty->position() < 16);
1518 n->dump();
1519 }
1520 #endif
1521 set_type(n, t);
1522 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
1523 Node* m = n->fast_out(i); // Get user
1524 if (m->is_Region()) { // New path to Region? Must recheck Phis too
1525 for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1526 Node* p = m->fast_out(i2); // Propagate changes to uses
1527 if (p->bottom_type() != type(p)) { // If not already bottomed out
1528 worklist.push(p); // Propagate change to user
1529 }
1530 }
1531 }
1532 // If we changed the receiver type to a call, we need to revisit
1533 // the Catch following the call. It's looking for a non-NULL
1534 // receiver to know when to enable the regular fall-through path
1535 // in addition to the NullPtrException path
1536 if (m->is_Call()) {
1537 for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1538 Node* p = m->fast_out(i2); // Propagate changes to uses
1539 if (p->is_Proj() && p->as_Proj()->_con == TypeFunc::Control && p->outcnt() == 1) {
1540 worklist.push(p->unique_out());
1541 }
1542 }
1543 }
1544 if (m->bottom_type() != type(m)) { // If not already bottomed out
1545 worklist.push(m); // Propagate change to user
1546 }
1547
1548 // CmpU nodes can get their type information from two nodes up in the
1549 // graph (instead of from the nodes immediately above). Make sure they
1550 // are added to the worklist if nodes they depend on are updated, since
1551 // they could be missed and get wrong types otherwise.
1552 uint m_op = m->Opcode();
1553 if (m_op == Op_AddI || m_op == Op_SubI) {
1554 for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1555 Node* p = m->fast_out(i2); // Propagate changes to uses
1556 if (p->Opcode() == Op_CmpU) {
1557 // Got a CmpU which might need the new type information from node n.
1558 if(p->bottom_type() != type(p)) { // If not already bottomed out
1559 worklist.push(p); // Propagate change to user
1560 }
1561 }
1562 }
1563 }
1564 }
1565 }
1566 }
1567 }
1568
1569 //------------------------------do_transform-----------------------------------
1570 // Top level driver for the recursive transformer
1571 void PhaseCCP::do_transform() {
1572 // Correct leaves of new-space Nodes; they point to old-space.
1573 C->set_root( transform(C->root())->as_Root() );
1574 assert( C->top(), "missing TOP node" );
1575 assert( C->root(), "missing root" );
1576 }
1577
1578 //------------------------------transform--------------------------------------
1579 // Given a Node in old-space, clone him into new-space.
1580 // Convert any of his old-space children into new-space children.
1581 Node *PhaseCCP::transform( Node *n ) {
1582 Node *new_node = _nodes[n->_idx]; // Check for transformed node
1583 if( new_node != NULL )
1584 return new_node; // Been there, done that, return old answer
|