hotspot/src/share/vm/opto/node.cpp
changeset 8870 119881dc9d0b
parent 8324 a9933c6c5a95
child 8921 14bfe81f2a9d
equal deleted inserted replaced
8869:dd30e4318b8d 8870:119881dc9d0b
  1371 
  1371 
  1372 
  1372 
  1373 //------------------------------find------------------------------------------
  1373 //------------------------------find------------------------------------------
  1374 // Find a neighbor of this Node with the given _idx
  1374 // Find a neighbor of this Node with the given _idx
  1375 // If idx is negative, find its absolute value, following both _in and _out.
  1375 // If idx is negative, find its absolute value, following both _in and _out.
  1376 static void find_recur( Node* &result, Node *n, int idx, bool only_ctrl,
  1376 static void find_recur(Compile* C,  Node* &result, Node *n, int idx, bool only_ctrl,
  1377                         VectorSet &old_space, VectorSet &new_space ) {
  1377                         VectorSet* old_space, VectorSet* new_space ) {
  1378   int node_idx = (idx >= 0) ? idx : -idx;
  1378   int node_idx = (idx >= 0) ? idx : -idx;
  1379   if (NotANode(n))  return;  // Gracefully handle NULL, -1, 0xabababab, etc.
  1379   if (NotANode(n))  return;  // Gracefully handle NULL, -1, 0xabababab, etc.
  1380   // Contained in new_space or old_space?
  1380   // Contained in new_space or old_space?   Check old_arena first since it's mostly empty.
  1381   VectorSet *v = Compile::current()->node_arena()->contains(n) ? &new_space : &old_space;
  1381   VectorSet *v = C->old_arena()->contains(n) ? old_space : new_space;
  1382   if( v->test(n->_idx) ) return;
  1382   if( v->test(n->_idx) ) return;
  1383   if( (int)n->_idx == node_idx
  1383   if( (int)n->_idx == node_idx
  1384       debug_only(|| n->debug_idx() == node_idx) ) {
  1384       debug_only(|| n->debug_idx() == node_idx) ) {
  1385     if (result != NULL)
  1385     if (result != NULL)
  1386       tty->print("find: " INTPTR_FORMAT " and " INTPTR_FORMAT " both have idx==%d\n",
  1386       tty->print("find: " INTPTR_FORMAT " and " INTPTR_FORMAT " both have idx==%d\n",
  1388     result = n;
  1388     result = n;
  1389   }
  1389   }
  1390   v->set(n->_idx);
  1390   v->set(n->_idx);
  1391   for( uint i=0; i<n->len(); i++ ) {
  1391   for( uint i=0; i<n->len(); i++ ) {
  1392     if( only_ctrl && !(n->is_Region()) && (n->Opcode() != Op_Root) && (i != TypeFunc::Control) ) continue;
  1392     if( only_ctrl && !(n->is_Region()) && (n->Opcode() != Op_Root) && (i != TypeFunc::Control) ) continue;
  1393     find_recur( result, n->in(i), idx, only_ctrl, old_space, new_space );
  1393     find_recur(C, result, n->in(i), idx, only_ctrl, old_space, new_space );
  1394   }
  1394   }
  1395   // Search along forward edges also:
  1395   // Search along forward edges also:
  1396   if (idx < 0 && !only_ctrl) {
  1396   if (idx < 0 && !only_ctrl) {
  1397     for( uint j=0; j<n->outcnt(); j++ ) {
  1397     for( uint j=0; j<n->outcnt(); j++ ) {
  1398       find_recur( result, n->raw_out(j), idx, only_ctrl, old_space, new_space );
  1398       find_recur(C, result, n->raw_out(j), idx, only_ctrl, old_space, new_space );
  1399     }
  1399     }
  1400   }
  1400   }
  1401 #ifdef ASSERT
  1401 #ifdef ASSERT
  1402   // Search along debug_orig edges last:
  1402   // Search along debug_orig edges last, checking for cycles
  1403   for (Node* orig = n->debug_orig(); orig != NULL && n != orig; orig = orig->debug_orig()) {
  1403   Node* orig = n->debug_orig();
  1404     if (NotANode(orig))  break;
  1404   if (orig != NULL) {
  1405     find_recur( result, orig, idx, only_ctrl, old_space, new_space );
  1405     do {
       
  1406       if (NotANode(orig))  break;
       
  1407       find_recur(C, result, orig, idx, only_ctrl, old_space, new_space );
       
  1408       orig = orig->debug_orig();
       
  1409     } while (orig != NULL && orig != n->debug_orig());
  1406   }
  1410   }
  1407 #endif //ASSERT
  1411 #endif //ASSERT
  1408 }
  1412 }
  1409 
  1413 
  1410 // call this from debugger:
  1414 // call this from debugger:
  1415 //------------------------------find-------------------------------------------
  1419 //------------------------------find-------------------------------------------
  1416 Node* Node::find(int idx) const {
  1420 Node* Node::find(int idx) const {
  1417   ResourceArea *area = Thread::current()->resource_area();
  1421   ResourceArea *area = Thread::current()->resource_area();
  1418   VectorSet old_space(area), new_space(area);
  1422   VectorSet old_space(area), new_space(area);
  1419   Node* result = NULL;
  1423   Node* result = NULL;
  1420   find_recur( result, (Node*) this, idx, false, old_space, new_space );
  1424   find_recur(Compile::current(), result, (Node*) this, idx, false, &old_space, &new_space );
  1421   return result;
  1425   return result;
  1422 }
  1426 }
  1423 
  1427 
  1424 //------------------------------find_ctrl--------------------------------------
  1428 //------------------------------find_ctrl--------------------------------------
  1425 // Find an ancestor to this node in the control history with given _idx
  1429 // Find an ancestor to this node in the control history with given _idx
  1426 Node* Node::find_ctrl(int idx) const {
  1430 Node* Node::find_ctrl(int idx) const {
  1427   ResourceArea *area = Thread::current()->resource_area();
  1431   ResourceArea *area = Thread::current()->resource_area();
  1428   VectorSet old_space(area), new_space(area);
  1432   VectorSet old_space(area), new_space(area);
  1429   Node* result = NULL;
  1433   Node* result = NULL;
  1430   find_recur( result, (Node*) this, idx, true, old_space, new_space );
  1434   find_recur(Compile::current(), result, (Node*) this, idx, true, &old_space, &new_space );
  1431   return result;
  1435   return result;
  1432 }
  1436 }
  1433 #endif
  1437 #endif
  1434 
  1438 
  1435 
  1439