src/share/vm/opto/postaloc.cpp

changeset 3405
5da7201222d5
parent 3140
2209834ccb59
child 3882
8c92982cbbc4
     1.1 --- a/src/share/vm/opto/postaloc.cpp	Fri Jan 06 20:09:20 2012 -0800
     1.2 +++ b/src/share/vm/opto/postaloc.cpp	Sat Jan 07 10:39:23 2012 -0800
     1.3 @@ -89,32 +89,62 @@
     1.4    return blk_adjust;
     1.5  }
     1.6  
     1.7 +#ifdef ASSERT
     1.8 +static bool expected_yanked_node(Node *old, Node *orig_old) {
     1.9 +  // This code is expected only next original nodes:
    1.10 +  // - load from constant table node which may have next data input nodes:
    1.11 +  //     MachConstantBase, Phi, MachTemp, MachSpillCopy
    1.12 +  // - load constant node which may have next data input nodes:
    1.13 +  //     MachTemp, MachSpillCopy
    1.14 +  // - MachSpillCopy
    1.15 +  // - MachProj and Copy dead nodes
    1.16 +  if (old->is_MachSpillCopy()) {
    1.17 +    return true;
    1.18 +  } else if (old->is_Con()) {
    1.19 +    return true;
    1.20 +  } else if (old->is_MachProj()) { // Dead kills projection of Con node
    1.21 +    return (old == orig_old);
    1.22 +  } else if (old->is_Copy()) {     // Dead copy of a callee-save value
    1.23 +    return (old == orig_old);
    1.24 +  } else if (old->is_MachTemp()) {
    1.25 +    return orig_old->is_Con();
    1.26 +  } else if (old->is_Phi() || old->is_MachConstantBase()) {
    1.27 +    return (orig_old->is_Con() && orig_old->is_MachConstant());
    1.28 +  }
    1.29 +  return false;
    1.30 +}
    1.31 +#endif
    1.32 +
    1.33  //------------------------------yank_if_dead-----------------------------------
    1.34 -// Removed an edge from 'old'.  Yank if dead.  Return adjustment counts to
    1.35 +// Removed edges from 'old'.  Yank if dead.  Return adjustment counts to
    1.36  // iterators in the current block.
    1.37 -int PhaseChaitin::yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
    1.38 +int PhaseChaitin::yank_if_dead_recurse(Node *old, Node *orig_old, Block *current_block,
    1.39 +                                       Node_List *value, Node_List *regnd) {
    1.40    int blk_adjust=0;
    1.41 -  while (old->outcnt() == 0 && old != C->top()) {
    1.42 +  if (old->outcnt() == 0 && old != C->top()) {
    1.43 +#ifdef ASSERT
    1.44 +    if (!expected_yanked_node(old, orig_old)) {
    1.45 +      tty->print_cr("==============================================");
    1.46 +      tty->print_cr("orig_old:");
    1.47 +      orig_old->dump();
    1.48 +      tty->print_cr("old:");
    1.49 +      old->dump();
    1.50 +      assert(false, "unexpected yanked node");
    1.51 +    }
    1.52 +    if (old->is_Con())
    1.53 +      orig_old = old; // Reset to satisfy expected nodes checks.
    1.54 +#endif
    1.55      blk_adjust += yank(old, current_block, value, regnd);
    1.56  
    1.57 -    Node *tmp = NULL;
    1.58      for (uint i = 1; i < old->req(); i++) {
    1.59 -      if (old->in(i)->is_MachTemp()) {
    1.60 -        // handle TEMP inputs
    1.61 -        Node* machtmp = old->in(i);
    1.62 -        if (machtmp->outcnt() == 1) {
    1.63 -          assert(machtmp->unique_out() == old, "sanity");
    1.64 -          blk_adjust += yank(machtmp, current_block, value, regnd);
    1.65 -          machtmp->disconnect_inputs(NULL);
    1.66 -        }
    1.67 -      } else {
    1.68 -        assert(tmp == NULL, "can't handle more non MachTemp inputs");
    1.69 -        tmp = old->in(i);
    1.70 +      Node* n = old->in(i);
    1.71 +      if (n != NULL) {
    1.72 +        old->set_req(i, NULL);
    1.73 +        blk_adjust += yank_if_dead_recurse(n, orig_old, current_block, value, regnd);
    1.74        }
    1.75      }
    1.76 +    // Disconnect control and remove precedence edges if any exist
    1.77      old->disconnect_inputs(NULL);
    1.78 -    if( !tmp ) break;
    1.79 -    old = tmp;
    1.80    }
    1.81    return blk_adjust;
    1.82  }

mercurial