src/share/vm/opto/node.cpp

Print this page
rev 5726 : 8029025: PPC64 (part 203): opto: Move static _in_dump_cnt to Compile object.
Summary: Also introduces the compiler oracle 'option' feature for PrintAssembly.


1506   VectorSet old_space(area), new_space(area);
1507   Node* result = NULL;
1508   find_recur(Compile::current(), result, (Node*) this, idx, false, &old_space, &new_space );
1509   return result;
1510 }
1511 
1512 //------------------------------find_ctrl--------------------------------------
1513 // Find an ancestor to this node in the control history with given _idx
1514 Node* Node::find_ctrl(int idx) const {
1515   ResourceArea *area = Thread::current()->resource_area();
1516   VectorSet old_space(area), new_space(area);
1517   Node* result = NULL;
1518   find_recur(Compile::current(), result, (Node*) this, idx, true, &old_space, &new_space );
1519   return result;
1520 }
1521 #endif
1522 
1523 
1524 
1525 #ifndef PRODUCT
1526 int Node::_in_dump_cnt = 0;
1527 
1528 // -----------------------------Name-------------------------------------------
1529 extern const char *NodeClassNames[];
1530 const char *Node::Name() const { return NodeClassNames[Opcode()]; }
1531 
1532 static bool is_disconnected(const Node* n) {
1533   for (uint i = 0; i < n->req(); i++) {
1534     if (n->in(i) != NULL)  return false;
1535   }
1536   return true;
1537 }
1538 
1539 #ifdef ASSERT
1540 static void dump_orig(Node* orig, outputStream *st) {
1541   Compile* C = Compile::current();
1542   if (NotANode(orig)) orig = NULL;
1543   if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
1544   if (orig == NULL) return;
1545   st->print(" !orig=");
1546   Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops


1578   if (NotANode(orig))  orig = NULL;
1579   int trip = 10;
1580   while (orig != NULL) {
1581     if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
1582       tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d orig._idx=%d orig._debug_idx=%d",
1583                     this->_idx, this->debug_idx(), orig->_idx, orig->debug_idx());
1584       BREAKPOINT;
1585     }
1586     orig = orig->debug_orig();
1587     if (NotANode(orig))  orig = NULL;
1588     if (trip-- <= 0)  break;
1589   }
1590 }
1591 #endif //ASSERT
1592 
1593 //------------------------------dump------------------------------------------
1594 // Dump a Node
1595 void Node::dump(const char* suffix, outputStream *st) const {
1596   Compile* C = Compile::current();
1597   bool is_new = C->node_arena()->contains(this);
1598   _in_dump_cnt++;
1599   st->print("%c%d\t%s\t=== ", is_new ? ' ' : 'o', _idx, Name());
1600 
1601   // Dump the required and precedence inputs
1602   dump_req(st);
1603   dump_prec(st);
1604   // Dump the outputs
1605   dump_out(st);
1606 
1607   if (is_disconnected(this)) {
1608 #ifdef ASSERT
1609     st->print("  [%d]",debug_idx());
1610     dump_orig(debug_orig(), st);
1611 #endif
1612     st->cr();
1613     _in_dump_cnt--;
1614     return;                     // don't process dead nodes
1615   }
1616 
1617   // Dump node-specific info
1618   dump_spec(st);
1619 #ifdef ASSERT
1620   // Dump the non-reset _debug_idx
1621   if (Verbose && WizardMode) {
1622     st->print("  [%d]",debug_idx());
1623   }
1624 #endif
1625 
1626   const Type *t = bottom_type();
1627 
1628   if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
1629     const TypeInstPtr  *toop = t->isa_instptr();
1630     const TypeKlassPtr *tkls = t->isa_klassptr();
1631     ciKlass*           klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
1632     if (klass && klass->is_loaded() && klass->is_interface()) {
1633       st->print("  Interface:");


1645     if (t) {
1646       t->dump_on(st);
1647     } else {
1648       st->print("no type");
1649     }
1650   } else if (t->isa_vect() && this->is_MachSpillCopy()) {
1651     // Dump MachSpillcopy vector type.
1652     t->dump_on(st);
1653   }
1654   if (is_new) {
1655     debug_only(dump_orig(debug_orig(), st));
1656     Node_Notes* nn = C->node_notes_at(_idx);
1657     if (nn != NULL && !nn->is_clear()) {
1658       if (nn->jvms() != NULL) {
1659         st->print(" !jvms:");
1660         nn->jvms()->dump_spec(st);
1661       }
1662     }
1663   }
1664   if (suffix) st->print(suffix);
1665   _in_dump_cnt--;
1666 }
1667 
1668 //------------------------------dump_req--------------------------------------
1669 void Node::dump_req(outputStream *st) const {
1670   // Dump the required input edges
1671   for (uint i = 0; i < req(); i++) {    // For all required inputs
1672     Node* d = in(i);
1673     if (d == NULL) {
1674       st->print("_ ");
1675     } else if (NotANode(d)) {
1676       st->print("NotANode ");  // uninitialized, sentinel, garbage, etc.
1677     } else {
1678       st->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
1679     }
1680   }
1681 }
1682 
1683 
1684 //------------------------------dump_prec-------------------------------------
1685 void Node::dump_prec(outputStream *st) const {




1506   VectorSet old_space(area), new_space(area);
1507   Node* result = NULL;
1508   find_recur(Compile::current(), result, (Node*) this, idx, false, &old_space, &new_space );
1509   return result;
1510 }
1511 
1512 //------------------------------find_ctrl--------------------------------------
1513 // Find an ancestor to this node in the control history with given _idx
1514 Node* Node::find_ctrl(int idx) const {
1515   ResourceArea *area = Thread::current()->resource_area();
1516   VectorSet old_space(area), new_space(area);
1517   Node* result = NULL;
1518   find_recur(Compile::current(), result, (Node*) this, idx, true, &old_space, &new_space );
1519   return result;
1520 }
1521 #endif
1522 
1523 
1524 
1525 #ifndef PRODUCT

1526 
1527 // -----------------------------Name-------------------------------------------
1528 extern const char *NodeClassNames[];
1529 const char *Node::Name() const { return NodeClassNames[Opcode()]; }
1530 
1531 static bool is_disconnected(const Node* n) {
1532   for (uint i = 0; i < n->req(); i++) {
1533     if (n->in(i) != NULL)  return false;
1534   }
1535   return true;
1536 }
1537 
1538 #ifdef ASSERT
1539 static void dump_orig(Node* orig, outputStream *st) {
1540   Compile* C = Compile::current();
1541   if (NotANode(orig)) orig = NULL;
1542   if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
1543   if (orig == NULL) return;
1544   st->print(" !orig=");
1545   Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops


1577   if (NotANode(orig))  orig = NULL;
1578   int trip = 10;
1579   while (orig != NULL) {
1580     if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
1581       tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d orig._idx=%d orig._debug_idx=%d",
1582                     this->_idx, this->debug_idx(), orig->_idx, orig->debug_idx());
1583       BREAKPOINT;
1584     }
1585     orig = orig->debug_orig();
1586     if (NotANode(orig))  orig = NULL;
1587     if (trip-- <= 0)  break;
1588   }
1589 }
1590 #endif //ASSERT
1591 
1592 //------------------------------dump------------------------------------------
1593 // Dump a Node
1594 void Node::dump(const char* suffix, outputStream *st) const {
1595   Compile* C = Compile::current();
1596   bool is_new = C->node_arena()->contains(this);
1597   C->_in_dump_cnt++;
1598   st->print("%c%d\t%s\t=== ", is_new ? ' ' : 'o', _idx, Name());
1599 
1600   // Dump the required and precedence inputs
1601   dump_req(st);
1602   dump_prec(st);
1603   // Dump the outputs
1604   dump_out(st);
1605 
1606   if (is_disconnected(this)) {
1607 #ifdef ASSERT
1608     st->print("  [%d]",debug_idx());
1609     dump_orig(debug_orig(), st);
1610 #endif
1611     st->cr();
1612     C->_in_dump_cnt--;
1613     return;                     // don't process dead nodes
1614   }
1615 
1616   // Dump node-specific info
1617   dump_spec(st);
1618 #ifdef ASSERT
1619   // Dump the non-reset _debug_idx
1620   if (Verbose && WizardMode) {
1621     st->print("  [%d]",debug_idx());
1622   }
1623 #endif
1624 
1625   const Type *t = bottom_type();
1626 
1627   if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
1628     const TypeInstPtr  *toop = t->isa_instptr();
1629     const TypeKlassPtr *tkls = t->isa_klassptr();
1630     ciKlass*           klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
1631     if (klass && klass->is_loaded() && klass->is_interface()) {
1632       st->print("  Interface:");


1644     if (t) {
1645       t->dump_on(st);
1646     } else {
1647       st->print("no type");
1648     }
1649   } else if (t->isa_vect() && this->is_MachSpillCopy()) {
1650     // Dump MachSpillcopy vector type.
1651     t->dump_on(st);
1652   }
1653   if (is_new) {
1654     debug_only(dump_orig(debug_orig(), st));
1655     Node_Notes* nn = C->node_notes_at(_idx);
1656     if (nn != NULL && !nn->is_clear()) {
1657       if (nn->jvms() != NULL) {
1658         st->print(" !jvms:");
1659         nn->jvms()->dump_spec(st);
1660       }
1661     }
1662   }
1663   if (suffix) st->print(suffix);
1664   C->_in_dump_cnt--;
1665 }
1666 
1667 //------------------------------dump_req--------------------------------------
1668 void Node::dump_req(outputStream *st) const {
1669   // Dump the required input edges
1670   for (uint i = 0; i < req(); i++) {    // For all required inputs
1671     Node* d = in(i);
1672     if (d == NULL) {
1673       st->print("_ ");
1674     } else if (NotANode(d)) {
1675       st->print("NotANode ");  // uninitialized, sentinel, garbage, etc.
1676     } else {
1677       st->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
1678     }
1679   }
1680 }
1681 
1682 
1683 //------------------------------dump_prec-------------------------------------
1684 void Node::dump_prec(outputStream *st) const {