src/share/vm/opto/node.cpp

changeset 435
a61af66fc99e
child 459
953939ef62ab
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/node.cpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,1919 @@
     1.4 +/*
     1.5 + * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "incls/_precompiled.incl"
    1.29 +#include "incls/_node.cpp.incl"
    1.30 +
    1.31 +class RegMask;
    1.32 +// #include "phase.hpp"
    1.33 +class PhaseTransform;
    1.34 +class PhaseGVN;
    1.35 +
    1.36 +// Arena we are currently building Nodes in
    1.37 +const uint Node::NotAMachineReg = 0xffff0000;
    1.38 +
    1.39 +#ifndef PRODUCT
    1.40 +extern int nodes_created;
    1.41 +#endif
    1.42 +
    1.43 +#ifdef ASSERT
    1.44 +
    1.45 +//-------------------------- construct_node------------------------------------
    1.46 +// Set a breakpoint here to identify where a particular node index is built.
    1.47 +void Node::verify_construction() {
    1.48 +  _debug_orig = NULL;
    1.49 +  int old_debug_idx = Compile::debug_idx();
    1.50 +  int new_debug_idx = old_debug_idx+1;
    1.51 +  if (new_debug_idx > 0) {
    1.52 +    // Arrange that the lowest five decimal digits of _debug_idx
    1.53 +    // will repeat thos of _idx.  In case this is somehow pathological,
    1.54 +    // we continue to assign negative numbers (!) consecutively.
    1.55 +    const int mod = 100000;
    1.56 +    int bump = (int)(_idx - new_debug_idx) % mod;
    1.57 +    if (bump < 0)  bump += mod;
    1.58 +    assert(bump >= 0 && bump < mod, "");
    1.59 +    new_debug_idx += bump;
    1.60 +  }
    1.61 +  Compile::set_debug_idx(new_debug_idx);
    1.62 +  set_debug_idx( new_debug_idx );
    1.63 +  assert(Compile::current()->unique() < (uint)MaxNodeLimit, "Node limit exceeded");
    1.64 +  if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
    1.65 +    tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
    1.66 +    BREAKPOINT;
    1.67 +  }
    1.68 +#if OPTO_DU_ITERATOR_ASSERT
    1.69 +  _last_del = NULL;
    1.70 +  _del_tick = 0;
    1.71 +#endif
    1.72 +  _hash_lock = 0;
    1.73 +}
    1.74 +
    1.75 +
    1.76 +// #ifdef ASSERT ...
    1.77 +
    1.78 +#if OPTO_DU_ITERATOR_ASSERT
    1.79 +void DUIterator_Common::sample(const Node* node) {
    1.80 +  _vdui     = VerifyDUIterators;
    1.81 +  _node     = node;
    1.82 +  _outcnt   = node->_outcnt;
    1.83 +  _del_tick = node->_del_tick;
    1.84 +  _last     = NULL;
    1.85 +}
    1.86 +
    1.87 +void DUIterator_Common::verify(const Node* node, bool at_end_ok) {
    1.88 +  assert(_node     == node, "consistent iterator source");
    1.89 +  assert(_del_tick == node->_del_tick, "no unexpected deletions allowed");
    1.90 +}
    1.91 +
    1.92 +void DUIterator_Common::verify_resync() {
    1.93 +  // Ensure that the loop body has just deleted the last guy produced.
    1.94 +  const Node* node = _node;
    1.95 +  // Ensure that at least one copy of the last-seen edge was deleted.
    1.96 +  // Note:  It is OK to delete multiple copies of the last-seen edge.
    1.97 +  // Unfortunately, we have no way to verify that all the deletions delete
    1.98 +  // that same edge.  On this point we must use the Honor System.
    1.99 +  assert(node->_del_tick >= _del_tick+1, "must have deleted an edge");
   1.100 +  assert(node->_last_del == _last, "must have deleted the edge just produced");
   1.101 +  // We liked this deletion, so accept the resulting outcnt and tick.
   1.102 +  _outcnt   = node->_outcnt;
   1.103 +  _del_tick = node->_del_tick;
   1.104 +}
   1.105 +
   1.106 +void DUIterator_Common::reset(const DUIterator_Common& that) {
   1.107 +  if (this == &that)  return;  // ignore assignment to self
   1.108 +  if (!_vdui) {
   1.109 +    // We need to initialize everything, overwriting garbage values.
   1.110 +    _last = that._last;
   1.111 +    _vdui = that._vdui;
   1.112 +  }
   1.113 +  // Note:  It is legal (though odd) for an iterator over some node x
   1.114 +  // to be reassigned to iterate over another node y.  Some doubly-nested
   1.115 +  // progress loops depend on being able to do this.
   1.116 +  const Node* node = that._node;
   1.117 +  // Re-initialize everything, except _last.
   1.118 +  _node     = node;
   1.119 +  _outcnt   = node->_outcnt;
   1.120 +  _del_tick = node->_del_tick;
   1.121 +}
   1.122 +
   1.123 +void DUIterator::sample(const Node* node) {
   1.124 +  DUIterator_Common::sample(node);      // Initialize the assertion data.
   1.125 +  _refresh_tick = 0;                    // No refreshes have happened, as yet.
   1.126 +}
   1.127 +
   1.128 +void DUIterator::verify(const Node* node, bool at_end_ok) {
   1.129 +  DUIterator_Common::verify(node, at_end_ok);
   1.130 +  assert(_idx      <  node->_outcnt + (uint)at_end_ok, "idx in range");
   1.131 +}
   1.132 +
   1.133 +void DUIterator::verify_increment() {
   1.134 +  if (_refresh_tick & 1) {
   1.135 +    // We have refreshed the index during this loop.
   1.136 +    // Fix up _idx to meet asserts.
   1.137 +    if (_idx > _outcnt)  _idx = _outcnt;
   1.138 +  }
   1.139 +  verify(_node, true);
   1.140 +}
   1.141 +
   1.142 +void DUIterator::verify_resync() {
   1.143 +  // Note:  We do not assert on _outcnt, because insertions are OK here.
   1.144 +  DUIterator_Common::verify_resync();
   1.145 +  // Make sure we are still in sync, possibly with no more out-edges:
   1.146 +  verify(_node, true);
   1.147 +}
   1.148 +
   1.149 +void DUIterator::reset(const DUIterator& that) {
   1.150 +  if (this == &that)  return;  // self assignment is always a no-op
   1.151 +  assert(that._refresh_tick == 0, "assign only the result of Node::outs()");
   1.152 +  assert(that._idx          == 0, "assign only the result of Node::outs()");
   1.153 +  assert(_idx               == that._idx, "already assigned _idx");
   1.154 +  if (!_vdui) {
   1.155 +    // We need to initialize everything, overwriting garbage values.
   1.156 +    sample(that._node);
   1.157 +  } else {
   1.158 +    DUIterator_Common::reset(that);
   1.159 +    if (_refresh_tick & 1) {
   1.160 +      _refresh_tick++;                  // Clear the "was refreshed" flag.
   1.161 +    }
   1.162 +    assert(_refresh_tick < 2*100000, "DU iteration must converge quickly");
   1.163 +  }
   1.164 +}
   1.165 +
   1.166 +void DUIterator::refresh() {
   1.167 +  DUIterator_Common::sample(_node);     // Re-fetch assertion data.
   1.168 +  _refresh_tick |= 1;                   // Set the "was refreshed" flag.
   1.169 +}
   1.170 +
   1.171 +void DUIterator::verify_finish() {
   1.172 +  // If the loop has killed the node, do not require it to re-run.
   1.173 +  if (_node->_outcnt == 0)  _refresh_tick &= ~1;
   1.174 +  // If this assert triggers, it means that a loop used refresh_out_pos
   1.175 +  // to re-synch an iteration index, but the loop did not correctly
   1.176 +  // re-run itself, using a "while (progress)" construct.
   1.177 +  // This iterator enforces the rule that you must keep trying the loop
   1.178 +  // until it "runs clean" without any need for refreshing.
   1.179 +  assert(!(_refresh_tick & 1), "the loop must run once with no refreshing");
   1.180 +}
   1.181 +
   1.182 +
   1.183 +void DUIterator_Fast::verify(const Node* node, bool at_end_ok) {
   1.184 +  DUIterator_Common::verify(node, at_end_ok);
   1.185 +  Node** out    = node->_out;
   1.186 +  uint   cnt    = node->_outcnt;
   1.187 +  assert(cnt == _outcnt, "no insertions allowed");
   1.188 +  assert(_outp >= out && _outp <= out + cnt - !at_end_ok, "outp in range");
   1.189 +  // This last check is carefully designed to work for NO_OUT_ARRAY.
   1.190 +}
   1.191 +
   1.192 +void DUIterator_Fast::verify_limit() {
   1.193 +  const Node* node = _node;
   1.194 +  verify(node, true);
   1.195 +  assert(_outp == node->_out + node->_outcnt, "limit still correct");
   1.196 +}
   1.197 +
   1.198 +void DUIterator_Fast::verify_resync() {
   1.199 +  const Node* node = _node;
   1.200 +  if (_outp == node->_out + _outcnt) {
   1.201 +    // Note that the limit imax, not the pointer i, gets updated with the
   1.202 +    // exact count of deletions.  (For the pointer it's always "--i".)
   1.203 +    assert(node->_outcnt+node->_del_tick == _outcnt+_del_tick, "no insertions allowed with deletion(s)");
   1.204 +    // This is a limit pointer, with a name like "imax".
   1.205 +    // Fudge the _last field so that the common assert will be happy.
   1.206 +    _last = (Node*) node->_last_del;
   1.207 +    DUIterator_Common::verify_resync();
   1.208 +  } else {
   1.209 +    assert(node->_outcnt < _outcnt, "no insertions allowed with deletion(s)");
   1.210 +    // A normal internal pointer.
   1.211 +    DUIterator_Common::verify_resync();
   1.212 +    // Make sure we are still in sync, possibly with no more out-edges:
   1.213 +    verify(node, true);
   1.214 +  }
   1.215 +}
   1.216 +
   1.217 +void DUIterator_Fast::verify_relimit(uint n) {
   1.218 +  const Node* node = _node;
   1.219 +  assert((int)n > 0, "use imax -= n only with a positive count");
   1.220 +  // This must be a limit pointer, with a name like "imax".
   1.221 +  assert(_outp == node->_out + node->_outcnt, "apply -= only to a limit (imax)");
   1.222 +  // The reported number of deletions must match what the node saw.
   1.223 +  assert(node->_del_tick == _del_tick + n, "must have deleted n edges");
   1.224 +  // Fudge the _last field so that the common assert will be happy.
   1.225 +  _last = (Node*) node->_last_del;
   1.226 +  DUIterator_Common::verify_resync();
   1.227 +}
   1.228 +
   1.229 +void DUIterator_Fast::reset(const DUIterator_Fast& that) {
   1.230 +  assert(_outp              == that._outp, "already assigned _outp");
   1.231 +  DUIterator_Common::reset(that);
   1.232 +}
   1.233 +
   1.234 +void DUIterator_Last::verify(const Node* node, bool at_end_ok) {
   1.235 +  // at_end_ok means the _outp is allowed to underflow by 1
   1.236 +  _outp += at_end_ok;
   1.237 +  DUIterator_Fast::verify(node, at_end_ok);  // check _del_tick, etc.
   1.238 +  _outp -= at_end_ok;
   1.239 +  assert(_outp == (node->_out + node->_outcnt) - 1, "pointer must point to end of nodes");
   1.240 +}
   1.241 +
   1.242 +void DUIterator_Last::verify_limit() {
   1.243 +  // Do not require the limit address to be resynched.
   1.244 +  //verify(node, true);
   1.245 +  assert(_outp == _node->_out, "limit still correct");
   1.246 +}
   1.247 +
   1.248 +void DUIterator_Last::verify_step(uint num_edges) {
   1.249 +  assert((int)num_edges > 0, "need non-zero edge count for loop progress");
   1.250 +  _outcnt   -= num_edges;
   1.251 +  _del_tick += num_edges;
   1.252 +  // Make sure we are still in sync, possibly with no more out-edges:
   1.253 +  const Node* node = _node;
   1.254 +  verify(node, true);
   1.255 +  assert(node->_last_del == _last, "must have deleted the edge just produced");
   1.256 +}
   1.257 +
   1.258 +#endif //OPTO_DU_ITERATOR_ASSERT
   1.259 +
   1.260 +
   1.261 +#endif //ASSERT
   1.262 +
   1.263 +
   1.264 +// This constant used to initialize _out may be any non-null value.
   1.265 +// The value NULL is reserved for the top node only.
   1.266 +#define NO_OUT_ARRAY ((Node**)-1)
   1.267 +
   1.268 +// This funny expression handshakes with Node::operator new
   1.269 +// to pull Compile::current out of the new node's _out field,
   1.270 +// and then calls a subroutine which manages most field
   1.271 +// initializations.  The only one which is tricky is the
   1.272 +// _idx field, which is const, and so must be initialized
   1.273 +// by a return value, not an assignment.
   1.274 +//
   1.275 +// (Aren't you thankful that Java finals don't require so many tricks?)
   1.276 +#define IDX_INIT(req) this->Init((req), (Compile*) this->_out)
   1.277 +#ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355
   1.278 +#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
   1.279 +#endif
   1.280 +
   1.281 +// Out-of-line code from node constructors.
   1.282 +// Executed only when extra debug info. is being passed around.
   1.283 +static void init_node_notes(Compile* C, int idx, Node_Notes* nn) {
   1.284 +  C->set_node_notes_at(idx, nn);
   1.285 +}
   1.286 +
   1.287 +// Shared initialization code.
   1.288 +inline int Node::Init(int req, Compile* C) {
   1.289 +  assert(Compile::current() == C, "must use operator new(Compile*)");
   1.290 +  int idx = C->next_unique();
   1.291 +
   1.292 +  // If there are default notes floating around, capture them:
   1.293 +  Node_Notes* nn = C->default_node_notes();
   1.294 +  if (nn != NULL)  init_node_notes(C, idx, nn);
   1.295 +
   1.296 +  // Note:  At this point, C is dead,
   1.297 +  // and we begin to initialize the new Node.
   1.298 +
   1.299 +  _cnt = _max = req;
   1.300 +  _outcnt = _outmax = 0;
   1.301 +  _class_id = Class_Node;
   1.302 +  _flags = 0;
   1.303 +  _out = NO_OUT_ARRAY;
   1.304 +  return idx;
   1.305 +}
   1.306 +
   1.307 +//------------------------------Node-------------------------------------------
   1.308 +// Create a Node, with a given number of required edges.
   1.309 +Node::Node(uint req)
   1.310 +  : _idx(IDX_INIT(req))
   1.311 +{
   1.312 +  assert( req < (uint)(MaxNodeLimit - NodeLimitFudgeFactor), "Input limit exceeded" );
   1.313 +  debug_only( verify_construction() );
   1.314 +  NOT_PRODUCT(nodes_created++);
   1.315 +  if (req == 0) {
   1.316 +    assert( _in == (Node**)this, "Must not pass arg count to 'new'" );
   1.317 +    _in = NULL;
   1.318 +  } else {
   1.319 +    assert( _in[req-1] == this, "Must pass arg count to 'new'" );
   1.320 +    Node** to = _in;
   1.321 +    for(uint i = 0; i < req; i++) {
   1.322 +      to[i] = NULL;
   1.323 +    }
   1.324 +  }
   1.325 +}
   1.326 +
   1.327 +//------------------------------Node-------------------------------------------
   1.328 +Node::Node(Node *n0)
   1.329 +  : _idx(IDX_INIT(1))
   1.330 +{
   1.331 +  debug_only( verify_construction() );
   1.332 +  NOT_PRODUCT(nodes_created++);
   1.333 +  // Assert we allocated space for input array already
   1.334 +  assert( _in[0] == this, "Must pass arg count to 'new'" );
   1.335 +  assert( is_not_dead(n0), "can not use dead node");
   1.336 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.337 +}
   1.338 +
   1.339 +//------------------------------Node-------------------------------------------
   1.340 +Node::Node(Node *n0, Node *n1)
   1.341 +  : _idx(IDX_INIT(2))
   1.342 +{
   1.343 +  debug_only( verify_construction() );
   1.344 +  NOT_PRODUCT(nodes_created++);
   1.345 +  // Assert we allocated space for input array already
   1.346 +  assert( _in[1] == this, "Must pass arg count to 'new'" );
   1.347 +  assert( is_not_dead(n0), "can not use dead node");
   1.348 +  assert( is_not_dead(n1), "can not use dead node");
   1.349 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.350 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.351 +}
   1.352 +
   1.353 +//------------------------------Node-------------------------------------------
   1.354 +Node::Node(Node *n0, Node *n1, Node *n2)
   1.355 +  : _idx(IDX_INIT(3))
   1.356 +{
   1.357 +  debug_only( verify_construction() );
   1.358 +  NOT_PRODUCT(nodes_created++);
   1.359 +  // Assert we allocated space for input array already
   1.360 +  assert( _in[2] == this, "Must pass arg count to 'new'" );
   1.361 +  assert( is_not_dead(n0), "can not use dead node");
   1.362 +  assert( is_not_dead(n1), "can not use dead node");
   1.363 +  assert( is_not_dead(n2), "can not use dead node");
   1.364 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.365 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.366 +  _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
   1.367 +}
   1.368 +
   1.369 +//------------------------------Node-------------------------------------------
   1.370 +Node::Node(Node *n0, Node *n1, Node *n2, Node *n3)
   1.371 +  : _idx(IDX_INIT(4))
   1.372 +{
   1.373 +  debug_only( verify_construction() );
   1.374 +  NOT_PRODUCT(nodes_created++);
   1.375 +  // Assert we allocated space for input array already
   1.376 +  assert( _in[3] == this, "Must pass arg count to 'new'" );
   1.377 +  assert( is_not_dead(n0), "can not use dead node");
   1.378 +  assert( is_not_dead(n1), "can not use dead node");
   1.379 +  assert( is_not_dead(n2), "can not use dead node");
   1.380 +  assert( is_not_dead(n3), "can not use dead node");
   1.381 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.382 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.383 +  _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
   1.384 +  _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
   1.385 +}
   1.386 +
   1.387 +//------------------------------Node-------------------------------------------
   1.388 +Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4)
   1.389 +  : _idx(IDX_INIT(5))
   1.390 +{
   1.391 +  debug_only( verify_construction() );
   1.392 +  NOT_PRODUCT(nodes_created++);
   1.393 +  // Assert we allocated space for input array already
   1.394 +  assert( _in[4] == this, "Must pass arg count to 'new'" );
   1.395 +  assert( is_not_dead(n0), "can not use dead node");
   1.396 +  assert( is_not_dead(n1), "can not use dead node");
   1.397 +  assert( is_not_dead(n2), "can not use dead node");
   1.398 +  assert( is_not_dead(n3), "can not use dead node");
   1.399 +  assert( is_not_dead(n4), "can not use dead node");
   1.400 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.401 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.402 +  _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
   1.403 +  _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
   1.404 +  _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
   1.405 +}
   1.406 +
   1.407 +//------------------------------Node-------------------------------------------
   1.408 +Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
   1.409 +                     Node *n4, Node *n5)
   1.410 +  : _idx(IDX_INIT(6))
   1.411 +{
   1.412 +  debug_only( verify_construction() );
   1.413 +  NOT_PRODUCT(nodes_created++);
   1.414 +  // Assert we allocated space for input array already
   1.415 +  assert( _in[5] == this, "Must pass arg count to 'new'" );
   1.416 +  assert( is_not_dead(n0), "can not use dead node");
   1.417 +  assert( is_not_dead(n1), "can not use dead node");
   1.418 +  assert( is_not_dead(n2), "can not use dead node");
   1.419 +  assert( is_not_dead(n3), "can not use dead node");
   1.420 +  assert( is_not_dead(n4), "can not use dead node");
   1.421 +  assert( is_not_dead(n5), "can not use dead node");
   1.422 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.423 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.424 +  _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
   1.425 +  _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
   1.426 +  _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
   1.427 +  _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
   1.428 +}
   1.429 +
   1.430 +//------------------------------Node-------------------------------------------
   1.431 +Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
   1.432 +                     Node *n4, Node *n5, Node *n6)
   1.433 +  : _idx(IDX_INIT(7))
   1.434 +{
   1.435 +  debug_only( verify_construction() );
   1.436 +  NOT_PRODUCT(nodes_created++);
   1.437 +  // Assert we allocated space for input array already
   1.438 +  assert( _in[6] == this, "Must pass arg count to 'new'" );
   1.439 +  assert( is_not_dead(n0), "can not use dead node");
   1.440 +  assert( is_not_dead(n1), "can not use dead node");
   1.441 +  assert( is_not_dead(n2), "can not use dead node");
   1.442 +  assert( is_not_dead(n3), "can not use dead node");
   1.443 +  assert( is_not_dead(n4), "can not use dead node");
   1.444 +  assert( is_not_dead(n5), "can not use dead node");
   1.445 +  assert( is_not_dead(n6), "can not use dead node");
   1.446 +  _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
   1.447 +  _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
   1.448 +  _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
   1.449 +  _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
   1.450 +  _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
   1.451 +  _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
   1.452 +  _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this);
   1.453 +}
   1.454 +
   1.455 +
   1.456 +//------------------------------clone------------------------------------------
   1.457 +// Clone a Node.
   1.458 +Node *Node::clone() const {
   1.459 +  Compile *compile = Compile::current();
   1.460 +  uint s = size_of();           // Size of inherited Node
   1.461 +  Node *n = (Node*)compile->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
   1.462 +  Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
   1.463 +  // Set the new input pointer array
   1.464 +  n->_in = (Node**)(((char*)n)+s);
   1.465 +  // Cannot share the old output pointer array, so kill it
   1.466 +  n->_out = NO_OUT_ARRAY;
   1.467 +  // And reset the counters to 0
   1.468 +  n->_outcnt = 0;
   1.469 +  n->_outmax = 0;
   1.470 +  // Unlock this guy, since he is not in any hash table.
   1.471 +  debug_only(n->_hash_lock = 0);
   1.472 +  // Walk the old node's input list to duplicate its edges
   1.473 +  uint i;
   1.474 +  for( i = 0; i < len(); i++ ) {
   1.475 +    Node *x = in(i);
   1.476 +    n->_in[i] = x;
   1.477 +    if (x != NULL) x->add_out(n);
   1.478 +  }
   1.479 +  if (is_macro())
   1.480 +    compile->add_macro_node(n);
   1.481 +
   1.482 +  n->set_idx(compile->next_unique()); // Get new unique index as well
   1.483 +  debug_only( n->verify_construction() );
   1.484 +  NOT_PRODUCT(nodes_created++);
   1.485 +  // Do not patch over the debug_idx of a clone, because it makes it
   1.486 +  // impossible to break on the clone's moment of creation.
   1.487 +  //debug_only( n->set_debug_idx( debug_idx() ) );
   1.488 +
   1.489 +  compile->copy_node_notes_to(n, (Node*) this);
   1.490 +
   1.491 +  // MachNode clone
   1.492 +  uint nopnds;
   1.493 +  if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
   1.494 +    MachNode *mach  = n->as_Mach();
   1.495 +    MachNode *mthis = this->as_Mach();
   1.496 +    // Get address of _opnd_array.
   1.497 +    // It should be the same offset since it is the clone of this node.
   1.498 +    MachOper **from = mthis->_opnds;
   1.499 +    MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
   1.500 +                    pointer_delta((const void*)from,
   1.501 +                                  (const void*)(&mthis->_opnds), 1));
   1.502 +    mach->_opnds = to;
   1.503 +    for ( uint i = 0; i < nopnds; ++i ) {
   1.504 +      to[i] = from[i]->clone(compile);
   1.505 +    }
   1.506 +  }
   1.507 +  // cloning CallNode may need to clone JVMState
   1.508 +  if (n->is_Call()) {
   1.509 +    CallNode *call = n->as_Call();
   1.510 +    call->clone_jvms();
   1.511 +  }
   1.512 +  return n;                     // Return the clone
   1.513 +}
   1.514 +
   1.515 +//---------------------------setup_is_top--------------------------------------
   1.516 +// Call this when changing the top node, to reassert the invariants
   1.517 +// required by Node::is_top.  See Compile::set_cached_top_node.
   1.518 +void Node::setup_is_top() {
   1.519 +  if (this == (Node*)Compile::current()->top()) {
   1.520 +    // This node has just become top.  Kill its out array.
   1.521 +    _outcnt = _outmax = 0;
   1.522 +    _out = NULL;                           // marker value for top
   1.523 +    assert(is_top(), "must be top");
   1.524 +  } else {
   1.525 +    if (_out == NULL)  _out = NO_OUT_ARRAY;
   1.526 +    assert(!is_top(), "must not be top");
   1.527 +  }
   1.528 +}
   1.529 +
   1.530 +
   1.531 +//------------------------------~Node------------------------------------------
   1.532 +// Fancy destructor; eagerly attempt to reclaim Node numberings and storage
   1.533 +extern int reclaim_idx ;
   1.534 +extern int reclaim_in  ;
   1.535 +extern int reclaim_node;
   1.536 +void Node::destruct() {
   1.537 +  // Eagerly reclaim unique Node numberings
   1.538 +  Compile* compile = Compile::current();
   1.539 +  if ((uint)_idx+1 == compile->unique()) {
   1.540 +    compile->set_unique(compile->unique()-1);
   1.541 +#ifdef ASSERT
   1.542 +    reclaim_idx++;
   1.543 +#endif
   1.544 +  }
   1.545 +  // Clear debug info:
   1.546 +  Node_Notes* nn = compile->node_notes_at(_idx);
   1.547 +  if (nn != NULL)  nn->clear();
   1.548 +  // Walk the input array, freeing the corresponding output edges
   1.549 +  _cnt = _max;  // forget req/prec distinction
   1.550 +  uint i;
   1.551 +  for( i = 0; i < _max; i++ ) {
   1.552 +    set_req(i, NULL);
   1.553 +    //assert(def->out(def->outcnt()-1) == (Node *)this,"bad def-use hacking in reclaim");
   1.554 +  }
   1.555 +  assert(outcnt() == 0, "deleting a node must not leave a dangling use");
   1.556 +  // See if the input array was allocated just prior to the object
   1.557 +  int edge_size = _max*sizeof(void*);
   1.558 +  int out_edge_size = _outmax*sizeof(void*);
   1.559 +  char *edge_end = ((char*)_in) + edge_size;
   1.560 +  char *out_array = (char*)(_out == NO_OUT_ARRAY? NULL: _out);
   1.561 +  char *out_edge_end = out_array + out_edge_size;
   1.562 +  int node_size = size_of();
   1.563 +
   1.564 +  // Free the output edge array
   1.565 +  if (out_edge_size > 0) {
   1.566 +#ifdef ASSERT
   1.567 +    if( out_edge_end == compile->node_arena()->hwm() )
   1.568 +      reclaim_in  += out_edge_size;  // count reclaimed out edges with in edges
   1.569 +#endif
   1.570 +    compile->node_arena()->Afree(out_array, out_edge_size);
   1.571 +  }
   1.572 +
   1.573 +  // Free the input edge array and the node itself
   1.574 +  if( edge_end == (char*)this ) {
   1.575 +#ifdef ASSERT
   1.576 +    if( edge_end+node_size == compile->node_arena()->hwm() ) {
   1.577 +      reclaim_in  += edge_size;
   1.578 +      reclaim_node+= node_size;
   1.579 +    }
   1.580 +#else
   1.581 +    // It was; free the input array and object all in one hit
   1.582 +    compile->node_arena()->Afree(_in,edge_size+node_size);
   1.583 +#endif
   1.584 +  } else {
   1.585 +
   1.586 +    // Free just the input array
   1.587 +#ifdef ASSERT
   1.588 +    if( edge_end == compile->node_arena()->hwm() )
   1.589 +      reclaim_in  += edge_size;
   1.590 +#endif
   1.591 +    compile->node_arena()->Afree(_in,edge_size);
   1.592 +
   1.593 +    // Free just the object
   1.594 +#ifdef ASSERT
   1.595 +    if( ((char*)this) + node_size == compile->node_arena()->hwm() )
   1.596 +      reclaim_node+= node_size;
   1.597 +#else
   1.598 +    compile->node_arena()->Afree(this,node_size);
   1.599 +#endif
   1.600 +  }
   1.601 +  if (is_macro()) {
   1.602 +    compile->remove_macro_node(this);
   1.603 +  }
   1.604 +#ifdef ASSERT
   1.605 +  // We will not actually delete the storage, but we'll make the node unusable.
   1.606 +  *(address*)this = badAddress;  // smash the C++ vtbl, probably
   1.607 +  _in = _out = (Node**) badAddress;
   1.608 +  _max = _cnt = _outmax = _outcnt = 0;
   1.609 +#endif
   1.610 +}
   1.611 +
   1.612 +//------------------------------grow-------------------------------------------
   1.613 +// Grow the input array, making space for more edges
   1.614 +void Node::grow( uint len ) {
   1.615 +  Arena* arena = Compile::current()->node_arena();
   1.616 +  uint new_max = _max;
   1.617 +  if( new_max == 0 ) {
   1.618 +    _max = 4;
   1.619 +    _in = (Node**)arena->Amalloc(4*sizeof(Node*));
   1.620 +    Node** to = _in;
   1.621 +    to[0] = NULL;
   1.622 +    to[1] = NULL;
   1.623 +    to[2] = NULL;
   1.624 +    to[3] = NULL;
   1.625 +    return;
   1.626 +  }
   1.627 +  while( new_max <= len ) new_max <<= 1; // Find next power-of-2
   1.628 +  // Trimming to limit allows a uint8 to handle up to 255 edges.
   1.629 +  // Previously I was using only powers-of-2 which peaked at 128 edges.
   1.630 +  //if( new_max >= limit ) new_max = limit-1;
   1.631 +  _in = (Node**)arena->Arealloc(_in, _max*sizeof(Node*), new_max*sizeof(Node*));
   1.632 +  Copy::zero_to_bytes(&_in[_max], (new_max-_max)*sizeof(Node*)); // NULL all new space
   1.633 +  _max = new_max;               // Record new max length
   1.634 +  // This assertion makes sure that Node::_max is wide enough to
   1.635 +  // represent the numerical value of new_max.
   1.636 +  assert(_max == new_max && _max > len, "int width of _max is too small");
   1.637 +}
   1.638 +
   1.639 +//-----------------------------out_grow----------------------------------------
   1.640 +// Grow the input array, making space for more edges
   1.641 +void Node::out_grow( uint len ) {
   1.642 +  assert(!is_top(), "cannot grow a top node's out array");
   1.643 +  Arena* arena = Compile::current()->node_arena();
   1.644 +  uint new_max = _outmax;
   1.645 +  if( new_max == 0 ) {
   1.646 +    _outmax = 4;
   1.647 +    _out = (Node **)arena->Amalloc(4*sizeof(Node*));
   1.648 +    return;
   1.649 +  }
   1.650 +  while( new_max <= len ) new_max <<= 1; // Find next power-of-2
   1.651 +  // Trimming to limit allows a uint8 to handle up to 255 edges.
   1.652 +  // Previously I was using only powers-of-2 which peaked at 128 edges.
   1.653 +  //if( new_max >= limit ) new_max = limit-1;
   1.654 +  assert(_out != NULL && _out != NO_OUT_ARRAY, "out must have sensible value");
   1.655 +  _out = (Node**)arena->Arealloc(_out,_outmax*sizeof(Node*),new_max*sizeof(Node*));
   1.656 +  //Copy::zero_to_bytes(&_out[_outmax], (new_max-_outmax)*sizeof(Node*)); // NULL all new space
   1.657 +  _outmax = new_max;               // Record new max length
   1.658 +  // This assertion makes sure that Node::_max is wide enough to
   1.659 +  // represent the numerical value of new_max.
   1.660 +  assert(_outmax == new_max && _outmax > len, "int width of _outmax is too small");
   1.661 +}
   1.662 +
   1.663 +#ifdef ASSERT
   1.664 +//------------------------------is_dead----------------------------------------
   1.665 +bool Node::is_dead() const {
   1.666 +  // Mach and pinch point nodes may look like dead.
   1.667 +  if( is_top() || is_Mach() || (Opcode() == Op_Node && _outcnt > 0) )
   1.668 +    return false;
   1.669 +  for( uint i = 0; i < _max; i++ )
   1.670 +    if( _in[i] != NULL )
   1.671 +      return false;
   1.672 +  dump();
   1.673 +  return true;
   1.674 +}
   1.675 +#endif
   1.676 +
   1.677 +//------------------------------add_req----------------------------------------
   1.678 +// Add a new required input at the end
   1.679 +void Node::add_req( Node *n ) {
   1.680 +  assert( is_not_dead(n), "can not use dead node");
   1.681 +
   1.682 +  // Look to see if I can move precedence down one without reallocating
   1.683 +  if( (_cnt >= _max) || (in(_max-1) != NULL) )
   1.684 +    grow( _max+1 );
   1.685 +
   1.686 +  // Find a precedence edge to move
   1.687 +  if( in(_cnt) != NULL ) {       // Next precedence edge is busy?
   1.688 +    uint i;
   1.689 +    for( i=_cnt; i<_max; i++ )
   1.690 +      if( in(i) == NULL )       // Find the NULL at end of prec edge list
   1.691 +        break;                  // There must be one, since we grew the array
   1.692 +    _in[i] = in(_cnt);          // Move prec over, making space for req edge
   1.693 +  }
   1.694 +  _in[_cnt++] = n;            // Stuff over old prec edge
   1.695 +  if (n != NULL) n->add_out((Node *)this);
   1.696 +}
   1.697 +
   1.698 +//---------------------------add_req_batch-------------------------------------
   1.699 +// Add a new required input at the end
   1.700 +void Node::add_req_batch( Node *n, uint m ) {
   1.701 +  assert( is_not_dead(n), "can not use dead node");
   1.702 +  // check various edge cases
   1.703 +  if ((int)m <= 1) {
   1.704 +    assert((int)m >= 0, "oob");
   1.705 +    if (m != 0)  add_req(n);
   1.706 +    return;
   1.707 +  }
   1.708 +
   1.709 +  // Look to see if I can move precedence down one without reallocating
   1.710 +  if( (_cnt+m) > _max || _in[_max-m] )
   1.711 +    grow( _max+m );
   1.712 +
   1.713 +  // Find a precedence edge to move
   1.714 +  if( _in[_cnt] != NULL ) {     // Next precedence edge is busy?
   1.715 +    uint i;
   1.716 +    for( i=_cnt; i<_max; i++ )
   1.717 +      if( _in[i] == NULL )      // Find the NULL at end of prec edge list
   1.718 +        break;                  // There must be one, since we grew the array
   1.719 +    // Slide all the precs over by m positions (assume #prec << m).
   1.720 +    Copy::conjoint_words_to_higher((HeapWord*)&_in[_cnt], (HeapWord*)&_in[_cnt+m], ((i-_cnt)*sizeof(Node*)));
   1.721 +  }
   1.722 +
   1.723 +  // Stuff over the old prec edges
   1.724 +  for(uint i=0; i<m; i++ ) {
   1.725 +    _in[_cnt++] = n;
   1.726 +  }
   1.727 +
   1.728 +  // Insert multiple out edges on the node.
   1.729 +  if (n != NULL && !n->is_top()) {
   1.730 +    for(uint i=0; i<m; i++ ) {
   1.731 +      n->add_out((Node *)this);
   1.732 +    }
   1.733 +  }
   1.734 +}
   1.735 +
   1.736 +//------------------------------del_req----------------------------------------
   1.737 +// Delete the required edge and compact the edge array
   1.738 +void Node::del_req( uint idx ) {
   1.739 +  // First remove corresponding def-use edge
   1.740 +  Node *n = in(idx);
   1.741 +  if (n != NULL) n->del_out((Node *)this);
   1.742 +  _in[idx] = in(--_cnt);  // Compact the array
   1.743 +  _in[_cnt] = NULL;       // NULL out emptied slot
   1.744 +}
   1.745 +
   1.746 +//------------------------------ins_req----------------------------------------
   1.747 +// Insert a new required input at the end
   1.748 +void Node::ins_req( uint idx, Node *n ) {
   1.749 +  assert( is_not_dead(n), "can not use dead node");
   1.750 +  add_req(NULL);                // Make space
   1.751 +  assert( idx < _max, "Must have allocated enough space");
   1.752 +  // Slide over
   1.753 +  if(_cnt-idx-1 > 0) {
   1.754 +    Copy::conjoint_words_to_higher((HeapWord*)&_in[idx], (HeapWord*)&_in[idx+1], ((_cnt-idx-1)*sizeof(Node*)));
   1.755 +  }
   1.756 +  _in[idx] = n;                            // Stuff over old required edge
   1.757 +  if (n != NULL) n->add_out((Node *)this); // Add reciprocal def-use edge
   1.758 +}
   1.759 +
   1.760 +//-----------------------------find_edge---------------------------------------
   1.761 +int Node::find_edge(Node* n) {
   1.762 +  for (uint i = 0; i < len(); i++) {
   1.763 +    if (_in[i] == n)  return i;
   1.764 +  }
   1.765 +  return -1;
   1.766 +}
   1.767 +
   1.768 +//----------------------------replace_edge-------------------------------------
   1.769 +int Node::replace_edge(Node* old, Node* neww) {
   1.770 +  if (old == neww)  return 0;  // nothing to do
   1.771 +  uint nrep = 0;
   1.772 +  for (uint i = 0; i < len(); i++) {
   1.773 +    if (in(i) == old) {
   1.774 +      if (i < req())
   1.775 +        set_req(i, neww);
   1.776 +      else
   1.777 +        set_prec(i, neww);
   1.778 +      nrep++;
   1.779 +    }
   1.780 +  }
   1.781 +  return nrep;
   1.782 +}
   1.783 +
   1.784 +//-------------------------disconnect_inputs-----------------------------------
   1.785 +// NULL out all inputs to eliminate incoming Def-Use edges.
   1.786 +// Return the number of edges between 'n' and 'this'
   1.787 +int Node::disconnect_inputs(Node *n) {
   1.788 +  int edges_to_n = 0;
   1.789 +
   1.790 +  uint cnt = req();
   1.791 +  for( uint i = 0; i < cnt; ++i ) {
   1.792 +    if( in(i) == 0 ) continue;
   1.793 +    if( in(i) == n ) ++edges_to_n;
   1.794 +    set_req(i, NULL);
   1.795 +  }
   1.796 +  // Remove precedence edges if any exist
   1.797 +  // Note: Safepoints may have precedence edges, even during parsing
   1.798 +  if( (req() != len()) && (in(req()) != NULL) ) {
   1.799 +    uint max = len();
   1.800 +    for( uint i = 0; i < max; ++i ) {
   1.801 +      if( in(i) == 0 ) continue;
   1.802 +      if( in(i) == n ) ++edges_to_n;
   1.803 +      set_prec(i, NULL);
   1.804 +    }
   1.805 +  }
   1.806 +
   1.807 +  // Node::destruct requires all out edges be deleted first
   1.808 +  // debug_only(destruct();)   // no reuse benefit expected
   1.809 +  return edges_to_n;
   1.810 +}
   1.811 +
   1.812 +//-----------------------------uncast---------------------------------------
   1.813 +// %%% Temporary, until we sort out CheckCastPP vs. CastPP.
   1.814 +// Strip away casting.  (It is depth-limited.)
   1.815 +Node* Node::uncast() const {
   1.816 +  // Should be inline:
   1.817 +  //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
   1.818 +  if (is_ConstraintCast() ||
   1.819 +      (is_Type() && req() == 2 && Opcode() == Op_CheckCastPP))
   1.820 +    return uncast_helper(this);
   1.821 +  else
   1.822 +    return (Node*) this;
   1.823 +}
   1.824 +
   1.825 +//---------------------------uncast_helper-------------------------------------
   1.826 +Node* Node::uncast_helper(const Node* p) {
   1.827 +  uint max_depth = 3;
   1.828 +  for (uint i = 0; i < max_depth; i++) {
   1.829 +    if (p == NULL || p->req() != 2) {
   1.830 +      break;
   1.831 +    } else if (p->is_ConstraintCast()) {
   1.832 +      p = p->in(1);
   1.833 +    } else if (p->is_Type() && p->Opcode() == Op_CheckCastPP) {
   1.834 +      p = p->in(1);
   1.835 +    } else {
   1.836 +      break;
   1.837 +    }
   1.838 +  }
   1.839 +  return (Node*) p;
   1.840 +}
   1.841 +
   1.842 +//------------------------------add_prec---------------------------------------
   1.843 +// Add a new precedence input.  Precedence inputs are unordered, with
   1.844 +// duplicates removed and NULLs packed down at the end.
   1.845 +void Node::add_prec( Node *n ) {
   1.846 +  assert( is_not_dead(n), "can not use dead node");
   1.847 +
   1.848 +  // Check for NULL at end
   1.849 +  if( _cnt >= _max || in(_max-1) )
   1.850 +    grow( _max+1 );
   1.851 +
   1.852 +  // Find a precedence edge to move
   1.853 +  uint i = _cnt;
   1.854 +  while( in(i) != NULL ) i++;
   1.855 +  _in[i] = n;                                // Stuff prec edge over NULL
   1.856 +  if ( n != NULL) n->add_out((Node *)this);  // Add mirror edge
   1.857 +}
   1.858 +
   1.859 +//------------------------------rm_prec----------------------------------------
   1.860 +// Remove a precedence input.  Precedence inputs are unordered, with
   1.861 +// duplicates removed and NULLs packed down at the end.
   1.862 +void Node::rm_prec( uint j ) {
   1.863 +
   1.864 +  // Find end of precedence list to pack NULLs
   1.865 +  uint i;
   1.866 +  for( i=j; i<_max; i++ )
   1.867 +    if( !_in[i] )               // Find the NULL at end of prec edge list
   1.868 +      break;
   1.869 +  if (_in[j] != NULL) _in[j]->del_out((Node *)this);
   1.870 +  _in[j] = _in[--i];            // Move last element over removed guy
   1.871 +  _in[i] = NULL;                // NULL out last element
   1.872 +}
   1.873 +
   1.874 +//------------------------------size_of----------------------------------------
   1.875 +uint Node::size_of() const { return sizeof(*this); }
   1.876 +
   1.877 +//------------------------------ideal_reg--------------------------------------
   1.878 +uint Node::ideal_reg() const { return 0; }
   1.879 +
   1.880 +//------------------------------jvms-------------------------------------------
   1.881 +JVMState* Node::jvms() const { return NULL; }
   1.882 +
   1.883 +#ifdef ASSERT
   1.884 +//------------------------------jvms-------------------------------------------
   1.885 +bool Node::verify_jvms(const JVMState* using_jvms) const {
   1.886 +  for (JVMState* jvms = this->jvms(); jvms != NULL; jvms = jvms->caller()) {
   1.887 +    if (jvms == using_jvms)  return true;
   1.888 +  }
   1.889 +  return false;
   1.890 +}
   1.891 +
   1.892 +//------------------------------init_NodeProperty------------------------------
   1.893 +void Node::init_NodeProperty() {
   1.894 +  assert(_max_classes <= max_jushort, "too many NodeProperty classes");
   1.895 +  assert(_max_flags <= max_jushort, "too many NodeProperty flags");
   1.896 +}
   1.897 +#endif
   1.898 +
   1.899 +//------------------------------format-----------------------------------------
   1.900 +// Print as assembly
   1.901 +void Node::format( PhaseRegAlloc *, outputStream *st ) const {}
   1.902 +//------------------------------emit-------------------------------------------
   1.903 +// Emit bytes starting at parameter 'ptr'.
   1.904 +void Node::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {}
   1.905 +//------------------------------size-------------------------------------------
   1.906 +// Size of instruction in bytes
   1.907 +uint Node::size(PhaseRegAlloc *ra_) const { return 0; }
   1.908 +
   1.909 +//------------------------------CFG Construction-------------------------------
   1.910 +// Nodes that end basic blocks, e.g. IfTrue/IfFalse, JumpProjNode, Root,
   1.911 +// Goto and Return.
   1.912 +const Node *Node::is_block_proj() const { return 0; }
   1.913 +
   1.914 +// Minimum guaranteed type
   1.915 +const Type *Node::bottom_type() const { return Type::BOTTOM; }
   1.916 +
   1.917 +
   1.918 +//------------------------------raise_bottom_type------------------------------
   1.919 +// Get the worst-case Type output for this Node.
   1.920 +void Node::raise_bottom_type(const Type* new_type) {
   1.921 +  if (is_Type()) {
   1.922 +    TypeNode *n = this->as_Type();
   1.923 +    if (VerifyAliases) {
   1.924 +      assert(new_type->higher_equal(n->type()), "new type must refine old type");
   1.925 +    }
   1.926 +    n->set_type(new_type);
   1.927 +  } else if (is_Load()) {
   1.928 +    LoadNode *n = this->as_Load();
   1.929 +    if (VerifyAliases) {
   1.930 +      assert(new_type->higher_equal(n->type()), "new type must refine old type");
   1.931 +    }
   1.932 +    n->set_type(new_type);
   1.933 +  }
   1.934 +}
   1.935 +
   1.936 +//------------------------------Identity---------------------------------------
   1.937 +// Return a node that the given node is equivalent to.
   1.938 +Node *Node::Identity( PhaseTransform * ) {
   1.939 +  return this;                  // Default to no identities
   1.940 +}
   1.941 +
   1.942 +//------------------------------Value------------------------------------------
   1.943 +// Compute a new Type for a node using the Type of the inputs.
   1.944 +const Type *Node::Value( PhaseTransform * ) const {
   1.945 +  return bottom_type();         // Default to worst-case Type
   1.946 +}
   1.947 +
   1.948 +//------------------------------Ideal------------------------------------------
   1.949 +//
   1.950 +// 'Idealize' the graph rooted at this Node.
   1.951 +//
   1.952 +// In order to be efficient and flexible there are some subtle invariants
   1.953 +// these Ideal calls need to hold.  Running with '+VerifyIterativeGVN' checks
   1.954 +// these invariants, although its too slow to have on by default.  If you are
   1.955 +// hacking an Ideal call, be sure to test with +VerifyIterativeGVN!
   1.956 +//
   1.957 +// The Ideal call almost arbitrarily reshape the graph rooted at the 'this'
   1.958 +// pointer.  If ANY change is made, it must return the root of the reshaped
   1.959 +// graph - even if the root is the same Node.  Example: swapping the inputs
   1.960 +// to an AddINode gives the same answer and same root, but you still have to
   1.961 +// return the 'this' pointer instead of NULL.
   1.962 +//
   1.963 +// You cannot return an OLD Node, except for the 'this' pointer.  Use the
   1.964 +// Identity call to return an old Node; basically if Identity can find
   1.965 +// another Node have the Ideal call make no change and return NULL.
   1.966 +// Example: AddINode::Ideal must check for add of zero; in this case it
   1.967 +// returns NULL instead of doing any graph reshaping.
   1.968 +//
   1.969 +// You cannot modify any old Nodes except for the 'this' pointer.  Due to
   1.970 +// sharing there may be other users of the old Nodes relying on their current
   1.971 +// semantics.  Modifying them will break the other users.
   1.972 +// Example: when reshape "(X+3)+4" into "X+7" you must leave the Node for
   1.973 +// "X+3" unchanged in case it is shared.
   1.974 +//
   1.975 +// If you modify the 'this' pointer's inputs, you must use 'set_req' with
   1.976 +// def-use info.  If you are making a new Node (either as the new root or
   1.977 +// some new internal piece) you must NOT use set_req with def-use info.
   1.978 +// You can make a new Node with either 'new' or 'clone'.  In either case,
   1.979 +// def-use info is (correctly) not generated.
   1.980 +// Example: reshape "(X+3)+4" into "X+7":
   1.981 +//    set_req(1,in(1)->in(1) /* grab X */, du /* must use DU on 'this' */);
   1.982 +//    set_req(2,phase->intcon(7),du);
   1.983 +//    return this;
   1.984 +// Example: reshape "X*4" into "X<<1"
   1.985 +//    return new (C,3) LShiftINode( in(1), phase->intcon(1) );
   1.986 +//
   1.987 +// You must call 'phase->transform(X)' on any new Nodes X you make, except
   1.988 +// for the returned root node.  Example: reshape "X*31" with "(X<<5)-1".
   1.989 +//    Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
   1.990 +//    return new (C,3) AddINode(shift, phase->intcon(-1));
   1.991 +//
   1.992 +// When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
   1.993 +// These forms are faster than 'phase->transform(new (C,1) ConNode())' and Do
   1.994 +// The Right Thing with def-use info.
   1.995 +//
   1.996 +// You cannot bury the 'this' Node inside of a graph reshape.  If the reshaped
   1.997 +// graph uses the 'this' Node it must be the root.  If you want a Node with
   1.998 +// the same Opcode as the 'this' pointer use 'clone'.
   1.999 +//
  1.1000 +Node *Node::Ideal(PhaseGVN *phase, bool can_reshape) {
  1.1001 +  return NULL;                  // Default to being Ideal already
  1.1002 +}
  1.1003 +
  1.1004 +// Some nodes have specific Ideal subgraph transformations only if they are
  1.1005 +// unique users of specific nodes. Such nodes should be put on IGVN worklist
  1.1006 +// for the transformations to happen.
  1.1007 +bool Node::has_special_unique_user() const {
  1.1008 +  assert(outcnt() == 1, "match only for unique out");
  1.1009 +  Node* n = unique_out();
  1.1010 +  int op  = Opcode();
  1.1011 +  if( this->is_Store() ) {
  1.1012 +    // Condition for back-to-back stores folding.
  1.1013 +    return n->Opcode() == op && n->in(MemNode::Memory) == this;
  1.1014 +  } else if( op == Op_AddL ) {
  1.1015 +    // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
  1.1016 +    return n->Opcode() == Op_ConvL2I && n->in(1) == this;
  1.1017 +  } else if( op == Op_SubI || op == Op_SubL ) {
  1.1018 +    // Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
  1.1019 +    return n->Opcode() == op && n->in(2) == this;
  1.1020 +  }
  1.1021 +  return false;
  1.1022 +};
  1.1023 +
  1.1024 +//------------------------------remove_dead_region-----------------------------
  1.1025 +// This control node is dead.  Follow the subgraph below it making everything
  1.1026 +// using it dead as well.  This will happen normally via the usual IterGVN
  1.1027 +// worklist but this call is more efficient.  Do not update use-def info
  1.1028 +// inside the dead region, just at the borders.
  1.1029 +static bool kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
  1.1030 +  // Con's are a popular node to re-hit in the hash table again.
  1.1031 +  if( dead->is_Con() ) return false;
  1.1032 +
  1.1033 +  // Can't put ResourceMark here since igvn->_worklist uses the same arena
  1.1034 +  // for verify pass with +VerifyOpto and we add/remove elements in it here.
  1.1035 +  Node_List  nstack(Thread::current()->resource_area());
  1.1036 +
  1.1037 +  Node *top = igvn->C->top();
  1.1038 +  bool progress = false;
  1.1039 +  nstack.push(dead);
  1.1040 +
  1.1041 +  while (nstack.size() > 0) {
  1.1042 +    dead = nstack.pop();
  1.1043 +    if (dead->outcnt() > 0) {
  1.1044 +      // Keep dead node on stack until all uses are processed.
  1.1045 +      nstack.push(dead);
  1.1046 +      // For all Users of the Dead...    ;-)
  1.1047 +      for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
  1.1048 +        Node* use = dead->last_out(k);
  1.1049 +        igvn->hash_delete(use);       // Yank from hash table prior to mod
  1.1050 +        if (use->in(0) == dead) {     // Found another dead node
  1.1051 +          assert (!use->is_Con(), "Control for Con node should be Root node.")
  1.1052 +          use->set_req(0, top);       // Cut dead edge to prevent processing
  1.1053 +          nstack.push(use);           // the dead node again.
  1.1054 +        } else {                      // Else found a not-dead user
  1.1055 +          for (uint j = 1; j < use->req(); j++) {
  1.1056 +            if (use->in(j) == dead) { // Turn all dead inputs into TOP
  1.1057 +              use->set_req(j, top);
  1.1058 +            }
  1.1059 +          }
  1.1060 +          igvn->_worklist.push(use);
  1.1061 +        }
  1.1062 +        // Refresh the iterator, since any number of kills might have happened.
  1.1063 +        k = dead->last_outs(kmin);
  1.1064 +      }
  1.1065 +    } else { // (dead->outcnt() == 0)
  1.1066 +      // Done with outputs.
  1.1067 +      igvn->hash_delete(dead);
  1.1068 +      igvn->_worklist.remove(dead);
  1.1069 +      igvn->set_type(dead, Type::TOP);
  1.1070 +      if (dead->is_macro()) {
  1.1071 +        igvn->C->remove_macro_node(dead);
  1.1072 +      }
  1.1073 +      // Kill all inputs to the dead guy
  1.1074 +      for (uint i=0; i < dead->req(); i++) {
  1.1075 +        Node *n = dead->in(i);      // Get input to dead guy
  1.1076 +        if (n != NULL && !n->is_top()) { // Input is valid?
  1.1077 +          progress = true;
  1.1078 +          dead->set_req(i, top);    // Smash input away
  1.1079 +          if (n->outcnt() == 0) {   // Input also goes dead?
  1.1080 +            if (!n->is_Con())
  1.1081 +              nstack.push(n);       // Clear it out as well
  1.1082 +          } else if (n->outcnt() == 1 &&
  1.1083 +                     n->has_special_unique_user()) {
  1.1084 +            igvn->add_users_to_worklist( n );
  1.1085 +          } else if (n->outcnt() <= 2 && n->is_Store()) {
  1.1086 +            // Push store's uses on worklist to enable folding optimization for
  1.1087 +            // store/store and store/load to the same address.
  1.1088 +            // The restriction (outcnt() <= 2) is the same as in set_req_X()
  1.1089 +            // and remove_globally_dead_node().
  1.1090 +            igvn->add_users_to_worklist( n );
  1.1091 +          }
  1.1092 +        }
  1.1093 +      }
  1.1094 +    } // (dead->outcnt() == 0)
  1.1095 +  }   // while (nstack.size() > 0) for outputs
  1.1096 +  return progress;
  1.1097 +}
  1.1098 +
  1.1099 +//------------------------------remove_dead_region-----------------------------
  1.1100 +bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
  1.1101 +  Node *n = in(0);
  1.1102 +  if( !n ) return false;
  1.1103 +  // Lost control into this guy?  I.e., it became unreachable?
  1.1104 +  // Aggressively kill all unreachable code.
  1.1105 +  if (can_reshape && n->is_top()) {
  1.1106 +    return kill_dead_code(this, phase->is_IterGVN());
  1.1107 +  }
  1.1108 +
  1.1109 +  if( n->is_Region() && n->as_Region()->is_copy() ) {
  1.1110 +    Node *m = n->nonnull_req();
  1.1111 +    set_req(0, m);
  1.1112 +    return true;
  1.1113 +  }
  1.1114 +  return false;
  1.1115 +}
  1.1116 +
  1.1117 +//------------------------------Ideal_DU_postCCP-------------------------------
  1.1118 +// Idealize graph, using DU info.  Must clone result into new-space
  1.1119 +Node *Node::Ideal_DU_postCCP( PhaseCCP * ) {
  1.1120 +  return NULL;                 // Default to no change
  1.1121 +}
  1.1122 +
  1.1123 +//------------------------------hash-------------------------------------------
  1.1124 +// Hash function over Nodes.
  1.1125 +uint Node::hash() const {
  1.1126 +  uint sum = 0;
  1.1127 +  for( uint i=0; i<_cnt; i++ )  // Add in all inputs
  1.1128 +    sum = (sum<<1)-(uintptr_t)in(i);        // Ignore embedded NULLs
  1.1129 +  return (sum>>2) + _cnt + Opcode();
  1.1130 +}
  1.1131 +
  1.1132 +//------------------------------cmp--------------------------------------------
  1.1133 +// Compare special parts of simple Nodes
  1.1134 +uint Node::cmp( const Node &n ) const {
  1.1135 +  return 1;                     // Must be same
  1.1136 +}
  1.1137 +
  1.1138 +//------------------------------rematerialize-----------------------------------
  1.1139 +// Should we clone rather than spill this instruction?
  1.1140 +bool Node::rematerialize() const {
  1.1141 +  if ( is_Mach() )
  1.1142 +    return this->as_Mach()->rematerialize();
  1.1143 +  else
  1.1144 +    return (_flags & Flag_rematerialize) != 0;
  1.1145 +}
  1.1146 +
  1.1147 +//------------------------------needs_anti_dependence_check---------------------
  1.1148 +// Nodes which use memory without consuming it, hence need antidependences.
  1.1149 +bool Node::needs_anti_dependence_check() const {
  1.1150 +  if( req() < 2 || (_flags & Flag_needs_anti_dependence_check) == 0 )
  1.1151 +    return false;
  1.1152 +  else
  1.1153 +    return in(1)->bottom_type()->has_memory();
  1.1154 +}
  1.1155 +
  1.1156 +
  1.1157 +// Get an integer constant from a ConNode (or CastIINode).
  1.1158 +// Return a default value if there is no apparent constant here.
  1.1159 +const TypeInt* Node::find_int_type() const {
  1.1160 +  if (this->is_Type()) {
  1.1161 +    return this->as_Type()->type()->isa_int();
  1.1162 +  } else if (this->is_Con()) {
  1.1163 +    assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode");
  1.1164 +    return this->bottom_type()->isa_int();
  1.1165 +  }
  1.1166 +  return NULL;
  1.1167 +}
  1.1168 +
  1.1169 +// Get a pointer constant from a ConstNode.
  1.1170 +// Returns the constant if it is a pointer ConstNode
  1.1171 +intptr_t Node::get_ptr() const {
  1.1172 +  assert( Opcode() == Op_ConP, "" );
  1.1173 +  return ((ConPNode*)this)->type()->is_ptr()->get_con();
  1.1174 +}
  1.1175 +
  1.1176 +// Get a long constant from a ConNode.
  1.1177 +// Return a default value if there is no apparent constant here.
  1.1178 +const TypeLong* Node::find_long_type() const {
  1.1179 +  if (this->is_Type()) {
  1.1180 +    return this->as_Type()->type()->isa_long();
  1.1181 +  } else if (this->is_Con()) {
  1.1182 +    assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode");
  1.1183 +    return this->bottom_type()->isa_long();
  1.1184 +  }
  1.1185 +  return NULL;
  1.1186 +}
  1.1187 +
  1.1188 +// Get a double constant from a ConstNode.
  1.1189 +// Returns the constant if it is a double ConstNode
  1.1190 +jdouble Node::getd() const {
  1.1191 +  assert( Opcode() == Op_ConD, "" );
  1.1192 +  return ((ConDNode*)this)->type()->is_double_constant()->getd();
  1.1193 +}
  1.1194 +
  1.1195 +// Get a float constant from a ConstNode.
  1.1196 +// Returns the constant if it is a float ConstNode
  1.1197 +jfloat Node::getf() const {
  1.1198 +  assert( Opcode() == Op_ConF, "" );
  1.1199 +  return ((ConFNode*)this)->type()->is_float_constant()->getf();
  1.1200 +}
  1.1201 +
  1.1202 +#ifndef PRODUCT
  1.1203 +
  1.1204 +//----------------------------NotANode----------------------------------------
  1.1205 +// Used in debugging code to avoid walking across dead or uninitialized edges.
  1.1206 +static inline bool NotANode(const Node* n) {
  1.1207 +  if (n == NULL)                   return true;
  1.1208 +  if (((intptr_t)n & 1) != 0)      return true;  // uninitialized, etc.
  1.1209 +  if (*(address*)n == badAddress)  return true;  // kill by Node::destruct
  1.1210 +  return false;
  1.1211 +}
  1.1212 +
  1.1213 +
  1.1214 +//------------------------------find------------------------------------------
  1.1215 +// Find a neighbor of this Node with the given _idx
  1.1216 +// If idx is negative, find its absolute value, following both _in and _out.
  1.1217 +static void find_recur( Node* &result, Node *n, int idx, bool only_ctrl,
  1.1218 +                        VectorSet &old_space, VectorSet &new_space ) {
  1.1219 +  int node_idx = (idx >= 0) ? idx : -idx;
  1.1220 +  if (NotANode(n))  return;  // Gracefully handle NULL, -1, 0xabababab, etc.
  1.1221 +  // Contained in new_space or old_space?
  1.1222 +  VectorSet *v = Compile::current()->node_arena()->contains(n) ? &new_space : &old_space;
  1.1223 +  if( v->test(n->_idx) ) return;
  1.1224 +  if( (int)n->_idx == node_idx
  1.1225 +      debug_only(|| n->debug_idx() == node_idx) ) {
  1.1226 +    if (result != NULL)
  1.1227 +      tty->print("find: " INTPTR_FORMAT " and " INTPTR_FORMAT " both have idx==%d\n",
  1.1228 +                 (uintptr_t)result, (uintptr_t)n, node_idx);
  1.1229 +    result = n;
  1.1230 +  }
  1.1231 +  v->set(n->_idx);
  1.1232 +  for( uint i=0; i<n->len(); i++ ) {
  1.1233 +    if( only_ctrl && !(n->is_Region()) && (n->Opcode() != Op_Root) && (i != TypeFunc::Control) ) continue;
  1.1234 +    find_recur( result, n->in(i), idx, only_ctrl, old_space, new_space );
  1.1235 +  }
  1.1236 +  // Search along forward edges also:
  1.1237 +  if (idx < 0 && !only_ctrl) {
  1.1238 +    for( uint j=0; j<n->outcnt(); j++ ) {
  1.1239 +      find_recur( result, n->raw_out(j), idx, only_ctrl, old_space, new_space );
  1.1240 +    }
  1.1241 +  }
  1.1242 +#ifdef ASSERT
  1.1243 +  // Search along debug_orig edges last:
  1.1244 +  for (Node* orig = n->debug_orig(); orig != NULL; orig = orig->debug_orig()) {
  1.1245 +    if (NotANode(orig))  break;
  1.1246 +    find_recur( result, orig, idx, only_ctrl, old_space, new_space );
  1.1247 +  }
  1.1248 +#endif //ASSERT
  1.1249 +}
  1.1250 +
  1.1251 +// call this from debugger:
  1.1252 +Node* find_node(Node* n, int idx) {
  1.1253 +  return n->find(idx);
  1.1254 +}
  1.1255 +
  1.1256 +//------------------------------find-------------------------------------------
  1.1257 +Node* Node::find(int idx) const {
  1.1258 +  ResourceArea *area = Thread::current()->resource_area();
  1.1259 +  VectorSet old_space(area), new_space(area);
  1.1260 +  Node* result = NULL;
  1.1261 +  find_recur( result, (Node*) this, idx, false, old_space, new_space );
  1.1262 +  return result;
  1.1263 +}
  1.1264 +
  1.1265 +//------------------------------find_ctrl--------------------------------------
  1.1266 +// Find an ancestor to this node in the control history with given _idx
  1.1267 +Node* Node::find_ctrl(int idx) const {
  1.1268 +  ResourceArea *area = Thread::current()->resource_area();
  1.1269 +  VectorSet old_space(area), new_space(area);
  1.1270 +  Node* result = NULL;
  1.1271 +  find_recur( result, (Node*) this, idx, true, old_space, new_space );
  1.1272 +  return result;
  1.1273 +}
  1.1274 +#endif
  1.1275 +
  1.1276 +
  1.1277 +
  1.1278 +#ifndef PRODUCT
  1.1279 +int Node::_in_dump_cnt = 0;
  1.1280 +
  1.1281 +// -----------------------------Name-------------------------------------------
  1.1282 +extern const char *NodeClassNames[];
  1.1283 +const char *Node::Name() const { return NodeClassNames[Opcode()]; }
  1.1284 +
  1.1285 +static bool is_disconnected(const Node* n) {
  1.1286 +  for (uint i = 0; i < n->req(); i++) {
  1.1287 +    if (n->in(i) != NULL)  return false;
  1.1288 +  }
  1.1289 +  return true;
  1.1290 +}
  1.1291 +
  1.1292 +#ifdef ASSERT
  1.1293 +static void dump_orig(Node* orig) {
  1.1294 +  Compile* C = Compile::current();
  1.1295 +  if (NotANode(orig))  orig = NULL;
  1.1296 +  if (orig != NULL && !C->node_arena()->contains(orig))  orig = NULL;
  1.1297 +  if (orig == NULL)  return;
  1.1298 +  tty->print(" !orig=");
  1.1299 +  Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops
  1.1300 +  if (NotANode(fast))  fast = NULL;
  1.1301 +  while (orig != NULL) {
  1.1302 +    bool discon = is_disconnected(orig);  // if discon, print [123] else 123
  1.1303 +    if (discon)  tty->print("[");
  1.1304 +    if (!Compile::current()->node_arena()->contains(orig))
  1.1305 +      tty->print("o");
  1.1306 +    tty->print("%d", orig->_idx);
  1.1307 +    if (discon)  tty->print("]");
  1.1308 +    orig = orig->debug_orig();
  1.1309 +    if (NotANode(orig))  orig = NULL;
  1.1310 +    if (orig != NULL && !C->node_arena()->contains(orig))  orig = NULL;
  1.1311 +    if (orig != NULL)  tty->print(",");
  1.1312 +    if (fast != NULL) {
  1.1313 +      // Step fast twice for each single step of orig:
  1.1314 +      fast = fast->debug_orig();
  1.1315 +      if (NotANode(fast))  fast = NULL;
  1.1316 +      if (fast != NULL && fast != orig) {
  1.1317 +        fast = fast->debug_orig();
  1.1318 +        if (NotANode(fast))  fast = NULL;
  1.1319 +      }
  1.1320 +      if (fast == orig) {
  1.1321 +        tty->print("...");
  1.1322 +        break;
  1.1323 +      }
  1.1324 +    }
  1.1325 +  }
  1.1326 +}
  1.1327 +
  1.1328 +void Node::set_debug_orig(Node* orig) {
  1.1329 +  _debug_orig = orig;
  1.1330 +  if (BreakAtNode == 0)  return;
  1.1331 +  if (NotANode(orig))  orig = NULL;
  1.1332 +  int trip = 10;
  1.1333 +  while (orig != NULL) {
  1.1334 +    if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
  1.1335 +      tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d orig._idx=%d orig._debug_idx=%d",
  1.1336 +                    this->_idx, this->debug_idx(), orig->_idx, orig->debug_idx());
  1.1337 +      BREAKPOINT;
  1.1338 +    }
  1.1339 +    orig = orig->debug_orig();
  1.1340 +    if (NotANode(orig))  orig = NULL;
  1.1341 +    if (trip-- <= 0)  break;
  1.1342 +  }
  1.1343 +}
  1.1344 +#endif //ASSERT
  1.1345 +
  1.1346 +//------------------------------dump------------------------------------------
  1.1347 +// Dump a Node
  1.1348 +void Node::dump() const {
  1.1349 +  Compile* C = Compile::current();
  1.1350 +  bool is_new = C->node_arena()->contains(this);
  1.1351 +  _in_dump_cnt++;
  1.1352 +  tty->print("%c%d\t%s\t=== ",
  1.1353 +             is_new ? ' ' : 'o', _idx, Name());
  1.1354 +
  1.1355 +  // Dump the required and precedence inputs
  1.1356 +  dump_req();
  1.1357 +  dump_prec();
  1.1358 +  // Dump the outputs
  1.1359 +  dump_out();
  1.1360 +
  1.1361 +  if (is_disconnected(this)) {
  1.1362 +#ifdef ASSERT
  1.1363 +    tty->print("  [%d]",debug_idx());
  1.1364 +    dump_orig(debug_orig());
  1.1365 +#endif
  1.1366 +    tty->cr();
  1.1367 +    _in_dump_cnt--;
  1.1368 +    return;                     // don't process dead nodes
  1.1369 +  }
  1.1370 +
  1.1371 +  // Dump node-specific info
  1.1372 +  dump_spec(tty);
  1.1373 +#ifdef ASSERT
  1.1374 +  // Dump the non-reset _debug_idx
  1.1375 +  if( Verbose && WizardMode ) {
  1.1376 +    tty->print("  [%d]",debug_idx());
  1.1377 +  }
  1.1378 +#endif
  1.1379 +
  1.1380 +  const Type *t = bottom_type();
  1.1381 +
  1.1382 +  if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
  1.1383 +    const TypeInstPtr  *toop = t->isa_instptr();
  1.1384 +    const TypeKlassPtr *tkls = t->isa_klassptr();
  1.1385 +    ciKlass*           klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
  1.1386 +    if( klass && klass->is_loaded() && klass->is_interface() ) {
  1.1387 +      tty->print("  Interface:");
  1.1388 +    } else if( toop ) {
  1.1389 +      tty->print("  Oop:");
  1.1390 +    } else if( tkls ) {
  1.1391 +      tty->print("  Klass:");
  1.1392 +    }
  1.1393 +    t->dump();
  1.1394 +  } else if( t == Type::MEMORY ) {
  1.1395 +    tty->print("  Memory:");
  1.1396 +    MemNode::dump_adr_type(this, adr_type(), tty);
  1.1397 +  } else if( Verbose || WizardMode ) {
  1.1398 +    tty->print("  Type:");
  1.1399 +    if( t ) {
  1.1400 +      t->dump();
  1.1401 +    } else {
  1.1402 +      tty->print("no type");
  1.1403 +    }
  1.1404 +  }
  1.1405 +  if (is_new) {
  1.1406 +    debug_only(dump_orig(debug_orig()));
  1.1407 +    Node_Notes* nn = C->node_notes_at(_idx);
  1.1408 +    if (nn != NULL && !nn->is_clear()) {
  1.1409 +      if (nn->jvms() != NULL) {
  1.1410 +        tty->print(" !jvms:");
  1.1411 +        nn->jvms()->dump_spec(tty);
  1.1412 +      }
  1.1413 +    }
  1.1414 +  }
  1.1415 +  tty->cr();
  1.1416 +  _in_dump_cnt--;
  1.1417 +}
  1.1418 +
  1.1419 +//------------------------------dump_req--------------------------------------
  1.1420 +void Node::dump_req() const {
  1.1421 +  // Dump the required input edges
  1.1422 +  for (uint i = 0; i < req(); i++) {    // For all required inputs
  1.1423 +    Node* d = in(i);
  1.1424 +    if (d == NULL) {
  1.1425 +      tty->print("_ ");
  1.1426 +    } else if (NotANode(d)) {
  1.1427 +      tty->print("NotANode ");  // uninitialized, sentinel, garbage, etc.
  1.1428 +    } else {
  1.1429 +      tty->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
  1.1430 +    }
  1.1431 +  }
  1.1432 +}
  1.1433 +
  1.1434 +
  1.1435 +//------------------------------dump_prec-------------------------------------
  1.1436 +void Node::dump_prec() const {
  1.1437 +  // Dump the precedence edges
  1.1438 +  int any_prec = 0;
  1.1439 +  for (uint i = req(); i < len(); i++) {       // For all precedence inputs
  1.1440 +    Node* p = in(i);
  1.1441 +    if (p != NULL) {
  1.1442 +      if( !any_prec++ ) tty->print(" |");
  1.1443 +      if (NotANode(p)) { tty->print("NotANode "); continue; }
  1.1444 +      tty->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
  1.1445 +    }
  1.1446 +  }
  1.1447 +}
  1.1448 +
  1.1449 +//------------------------------dump_out--------------------------------------
  1.1450 +void Node::dump_out() const {
  1.1451 +  // Delimit the output edges
  1.1452 +  tty->print(" [[");
  1.1453 +  // Dump the output edges
  1.1454 +  for (uint i = 0; i < _outcnt; i++) {    // For all outputs
  1.1455 +    Node* u = _out[i];
  1.1456 +    if (u == NULL) {
  1.1457 +      tty->print("_ ");
  1.1458 +    } else if (NotANode(u)) {
  1.1459 +      tty->print("NotANode ");
  1.1460 +    } else {
  1.1461 +      tty->print("%c%d ", Compile::current()->node_arena()->contains(u) ? ' ' : 'o', u->_idx);
  1.1462 +    }
  1.1463 +  }
  1.1464 +  tty->print("]] ");
  1.1465 +}
  1.1466 +
  1.1467 +//------------------------------dump_nodes-------------------------------------
  1.1468 +
  1.1469 +// Helper class  for dump_nodes. Wraps an old and new VectorSet.
  1.1470 +class OldNewVectorSet : public StackObj {
  1.1471 +   Arena*    _node_arena;
  1.1472 +   VectorSet _old_vset, _new_vset;
  1.1473 +   VectorSet* select(Node* n) {
  1.1474 +     return _node_arena->contains(n) ? &_new_vset : &_old_vset;
  1.1475 +   }
  1.1476 +  public:
  1.1477 +  OldNewVectorSet(Arena* node_arena, ResourceArea* area) :
  1.1478 +     _node_arena(node_arena),
  1.1479 +     _old_vset(area), _new_vset(area) {}
  1.1480 +
  1.1481 +  void set(Node* n)      { select(n)->set(n->_idx); }
  1.1482 +  bool test_set(Node* n) { return select(n)->test_set(n->_idx) != 0; }
  1.1483 +  bool test(Node* n)     { return select(n)->test(n->_idx) != 0; }
  1.1484 +  void del(Node* n)      { (*select(n)) >>= n->_idx; }
  1.1485 +};
  1.1486 +
  1.1487 +
  1.1488 +static void dump_nodes(const Node* start, int d, bool only_ctrl) {
  1.1489 +  Node* s = (Node*)start; // remove const
  1.1490 +  if (NotANode(s)) return;
  1.1491 +
  1.1492 +  Compile* C = Compile::current();
  1.1493 +  ResourceArea *area = Thread::current()->resource_area();
  1.1494 +  Node_Stack      stack(area, MIN2((uint)ABS(d), C->unique() >> 1));
  1.1495 +  OldNewVectorSet visited(C->node_arena(), area);
  1.1496 +  OldNewVectorSet on_stack(C->node_arena(), area);
  1.1497 +
  1.1498 +  visited.set(s);
  1.1499 +  on_stack.set(s);
  1.1500 +  stack.push(s, 0);
  1.1501 +  if (d < 0) s->dump();
  1.1502 +
  1.1503 +  // Do a depth first walk over edges
  1.1504 +  while (stack.is_nonempty()) {
  1.1505 +    Node* tp  = stack.node();
  1.1506 +    uint  idx = stack.index();
  1.1507 +    uint  limit = d > 0 ? tp->len() : tp->outcnt();
  1.1508 +    if (idx >= limit) {
  1.1509 +      // no more arcs to visit
  1.1510 +      if (d > 0) tp->dump();
  1.1511 +      on_stack.del(tp);
  1.1512 +      stack.pop();
  1.1513 +    } else {
  1.1514 +      // process the "idx"th arc
  1.1515 +      stack.set_index(idx + 1);
  1.1516 +      Node* n = d > 0 ? tp->in(idx) : tp->raw_out(idx);
  1.1517 +
  1.1518 +      if (NotANode(n))  continue;
  1.1519 +      // do not recurse through top or the root (would reach unrelated stuff)
  1.1520 +      if (n->is_Root() || n->is_top())  continue;
  1.1521 +      if (only_ctrl && !n->is_CFG()) continue;
  1.1522 +
  1.1523 +      if (!visited.test_set(n)) {  // forward arc
  1.1524 +        // Limit depth
  1.1525 +        if (stack.size() < (uint)ABS(d)) {
  1.1526 +          if (d < 0) n->dump();
  1.1527 +          stack.push(n, 0);
  1.1528 +          on_stack.set(n);
  1.1529 +        }
  1.1530 +      } else {  // back or cross arc
  1.1531 +        if (on_stack.test(n)) {  // back arc
  1.1532 +          // print loop if there are no phis or regions in the mix
  1.1533 +          bool found_loop_breaker = false;
  1.1534 +          int k;
  1.1535 +          for (k = stack.size() - 1; k >= 0; k--) {
  1.1536 +            Node* m = stack.node_at(k);
  1.1537 +            if (m->is_Phi() || m->is_Region() || m->is_Root() || m->is_Start()) {
  1.1538 +              found_loop_breaker = true;
  1.1539 +              break;
  1.1540 +            }
  1.1541 +            if (m == n) // Found loop head
  1.1542 +              break;
  1.1543 +          }
  1.1544 +          assert(k >= 0, "n must be on stack");
  1.1545 +
  1.1546 +          if (!found_loop_breaker) {
  1.1547 +            tty->print("# %s LOOP FOUND:", only_ctrl ? "CONTROL" : "DATA");
  1.1548 +            for (int i = stack.size() - 1; i >= k; i--) {
  1.1549 +              Node* m = stack.node_at(i);
  1.1550 +              bool mnew = C->node_arena()->contains(m);
  1.1551 +              tty->print(" %s%d:%s", (mnew? "": "o"), m->_idx, m->Name());
  1.1552 +              if (i != 0) tty->print(d > 0? " <-": " ->");
  1.1553 +            }
  1.1554 +            tty->cr();
  1.1555 +          }
  1.1556 +        }
  1.1557 +      }
  1.1558 +    }
  1.1559 +  }
  1.1560 +}
  1.1561 +
  1.1562 +//------------------------------dump-------------------------------------------
  1.1563 +void Node::dump(int d) const {
  1.1564 +  dump_nodes(this, d, false);
  1.1565 +}
  1.1566 +
  1.1567 +//------------------------------dump_ctrl--------------------------------------
  1.1568 +// Dump a Node's control history to depth
  1.1569 +void Node::dump_ctrl(int d) const {
  1.1570 +  dump_nodes(this, d, true);
  1.1571 +}
  1.1572 +
  1.1573 +// VERIFICATION CODE
  1.1574 +// For each input edge to a node (ie - for each Use-Def edge), verify that
  1.1575 +// there is a corresponding Def-Use edge.
  1.1576 +//------------------------------verify_edges-----------------------------------
  1.1577 +void Node::verify_edges(Unique_Node_List &visited) {
  1.1578 +  uint i, j, idx;
  1.1579 +  int  cnt;
  1.1580 +  Node *n;
  1.1581 +
  1.1582 +  // Recursive termination test
  1.1583 +  if (visited.member(this))  return;
  1.1584 +  visited.push(this);
  1.1585 +
  1.1586 +  // Walk over all input edges, checking for correspondance
  1.1587 +  for( i = 0; i < len(); i++ ) {
  1.1588 +    n = in(i);
  1.1589 +    if (n != NULL && !n->is_top()) {
  1.1590 +      // Count instances of (Node *)this
  1.1591 +      cnt = 0;
  1.1592 +      for (idx = 0; idx < n->_outcnt; idx++ ) {
  1.1593 +        if (n->_out[idx] == (Node *)this)  cnt++;
  1.1594 +      }
  1.1595 +      assert( cnt > 0,"Failed to find Def-Use edge." );
  1.1596 +      // Check for duplicate edges
  1.1597 +      // walk the input array downcounting the input edges to n
  1.1598 +      for( j = 0; j < len(); j++ ) {
  1.1599 +        if( in(j) == n ) cnt--;
  1.1600 +      }
  1.1601 +      assert( cnt == 0,"Mismatched edge count.");
  1.1602 +    } else if (n == NULL) {
  1.1603 +      assert(i >= req() || i == 0 || is_Region() || is_Phi(), "only regions or phis have null data edges");
  1.1604 +    } else {
  1.1605 +      assert(n->is_top(), "sanity");
  1.1606 +      // Nothing to check.
  1.1607 +    }
  1.1608 +  }
  1.1609 +  // Recursive walk over all input edges
  1.1610 +  for( i = 0; i < len(); i++ ) {
  1.1611 +    n = in(i);
  1.1612 +    if( n != NULL )
  1.1613 +      in(i)->verify_edges(visited);
  1.1614 +  }
  1.1615 +}
  1.1616 +
  1.1617 +//------------------------------verify_recur-----------------------------------
  1.1618 +static const Node *unique_top = NULL;
  1.1619 +
  1.1620 +void Node::verify_recur(const Node *n, int verify_depth,
  1.1621 +                        VectorSet &old_space, VectorSet &new_space) {
  1.1622 +  if ( verify_depth == 0 )  return;
  1.1623 +  if (verify_depth > 0)  --verify_depth;
  1.1624 +
  1.1625 +  Compile* C = Compile::current();
  1.1626 +
  1.1627 +  // Contained in new_space or old_space?
  1.1628 +  VectorSet *v = C->node_arena()->contains(n) ? &new_space : &old_space;
  1.1629 +  // Check for visited in the proper space.  Numberings are not unique
  1.1630 +  // across spaces so we need a seperate VectorSet for each space.
  1.1631 +  if( v->test_set(n->_idx) ) return;
  1.1632 +
  1.1633 +  if (n->is_Con() && n->bottom_type() == Type::TOP) {
  1.1634 +    if (C->cached_top_node() == NULL)
  1.1635 +      C->set_cached_top_node((Node*)n);
  1.1636 +    assert(C->cached_top_node() == n, "TOP node must be unique");
  1.1637 +  }
  1.1638 +
  1.1639 +  for( uint i = 0; i < n->len(); i++ ) {
  1.1640 +    Node *x = n->in(i);
  1.1641 +    if (!x || x->is_top()) continue;
  1.1642 +
  1.1643 +    // Verify my input has a def-use edge to me
  1.1644 +    if (true /*VerifyDefUse*/) {
  1.1645 +      // Count use-def edges from n to x
  1.1646 +      int cnt = 0;
  1.1647 +      for( uint j = 0; j < n->len(); j++ )
  1.1648 +        if( n->in(j) == x )
  1.1649 +          cnt++;
  1.1650 +      // Count def-use edges from x to n
  1.1651 +      uint max = x->_outcnt;
  1.1652 +      for( uint k = 0; k < max; k++ )
  1.1653 +        if (x->_out[k] == n)
  1.1654 +          cnt--;
  1.1655 +      assert( cnt == 0, "mismatched def-use edge counts" );
  1.1656 +    }
  1.1657 +
  1.1658 +    verify_recur(x, verify_depth, old_space, new_space);
  1.1659 +  }
  1.1660 +
  1.1661 +}
  1.1662 +
  1.1663 +//------------------------------verify-----------------------------------------
  1.1664 +// Check Def-Use info for my subgraph
  1.1665 +void Node::verify() const {
  1.1666 +  Compile* C = Compile::current();
  1.1667 +  Node* old_top = C->cached_top_node();
  1.1668 +  ResourceMark rm;
  1.1669 +  ResourceArea *area = Thread::current()->resource_area();
  1.1670 +  VectorSet old_space(area), new_space(area);
  1.1671 +  verify_recur(this, -1, old_space, new_space);
  1.1672 +  C->set_cached_top_node(old_top);
  1.1673 +}
  1.1674 +#endif
  1.1675 +
  1.1676 +
  1.1677 +//------------------------------walk-------------------------------------------
  1.1678 +// Graph walk, with both pre-order and post-order functions
  1.1679 +void Node::walk(NFunc pre, NFunc post, void *env) {
  1.1680 +  VectorSet visited(Thread::current()->resource_area()); // Setup for local walk
  1.1681 +  walk_(pre, post, env, visited);
  1.1682 +}
  1.1683 +
  1.1684 +void Node::walk_(NFunc pre, NFunc post, void *env, VectorSet &visited) {
  1.1685 +  if( visited.test_set(_idx) ) return;
  1.1686 +  pre(*this,env);               // Call the pre-order walk function
  1.1687 +  for( uint i=0; i<_max; i++ )
  1.1688 +    if( in(i) )                 // Input exists and is not walked?
  1.1689 +      in(i)->walk_(pre,post,env,visited); // Walk it with pre & post functions
  1.1690 +  post(*this,env);              // Call the post-order walk function
  1.1691 +}
  1.1692 +
  1.1693 +void Node::nop(Node &, void*) {}
  1.1694 +
  1.1695 +//------------------------------Registers--------------------------------------
  1.1696 +// Do we Match on this edge index or not?  Generally false for Control
  1.1697 +// and true for everything else.  Weird for calls & returns.
  1.1698 +uint Node::match_edge(uint idx) const {
  1.1699 +  return idx;                   // True for other than index 0 (control)
  1.1700 +}
  1.1701 +
  1.1702 +// Register classes are defined for specific machines
  1.1703 +const RegMask &Node::out_RegMask() const {
  1.1704 +  ShouldNotCallThis();
  1.1705 +  return *(new RegMask());
  1.1706 +}
  1.1707 +
  1.1708 +const RegMask &Node::in_RegMask(uint) const {
  1.1709 +  ShouldNotCallThis();
  1.1710 +  return *(new RegMask());
  1.1711 +}
  1.1712 +
  1.1713 +//=============================================================================
  1.1714 +//-----------------------------------------------------------------------------
  1.1715 +void Node_Array::reset( Arena *new_arena ) {
  1.1716 +  _a->Afree(_nodes,_max*sizeof(Node*));
  1.1717 +  _max   = 0;
  1.1718 +  _nodes = NULL;
  1.1719 +  _a     = new_arena;
  1.1720 +}
  1.1721 +
  1.1722 +//------------------------------clear------------------------------------------
  1.1723 +// Clear all entries in _nodes to NULL but keep storage
  1.1724 +void Node_Array::clear() {
  1.1725 +  Copy::zero_to_bytes( _nodes, _max*sizeof(Node*) );
  1.1726 +}
  1.1727 +
  1.1728 +//-----------------------------------------------------------------------------
  1.1729 +void Node_Array::grow( uint i ) {
  1.1730 +  if( !_max ) {
  1.1731 +    _max = 1;
  1.1732 +    _nodes = (Node**)_a->Amalloc( _max * sizeof(Node*) );
  1.1733 +    _nodes[0] = NULL;
  1.1734 +  }
  1.1735 +  uint old = _max;
  1.1736 +  while( i >= _max ) _max <<= 1;        // Double to fit
  1.1737 +  _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
  1.1738 +  Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
  1.1739 +}
  1.1740 +
  1.1741 +//-----------------------------------------------------------------------------
  1.1742 +void Node_Array::insert( uint i, Node *n ) {
  1.1743 +  if( _nodes[_max-1] ) grow(_max);      // Get more space if full
  1.1744 +  Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i+1], ((_max-i-1)*sizeof(Node*)));
  1.1745 +  _nodes[i] = n;
  1.1746 +}
  1.1747 +
  1.1748 +//-----------------------------------------------------------------------------
  1.1749 +void Node_Array::remove( uint i ) {
  1.1750 +  Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i+1], (HeapWord*)&_nodes[i], ((_max-i-1)*sizeof(Node*)));
  1.1751 +  _nodes[_max-1] = NULL;
  1.1752 +}
  1.1753 +
  1.1754 +//-----------------------------------------------------------------------------
  1.1755 +void Node_Array::sort( C_sort_func_t func) {
  1.1756 +  qsort( _nodes, _max, sizeof( Node* ), func );
  1.1757 +}
  1.1758 +
  1.1759 +//-----------------------------------------------------------------------------
  1.1760 +void Node_Array::dump() const {
  1.1761 +#ifndef PRODUCT
  1.1762 +  for( uint i = 0; i < _max; i++ ) {
  1.1763 +    Node *nn = _nodes[i];
  1.1764 +    if( nn != NULL ) {
  1.1765 +      tty->print("%5d--> ",i); nn->dump();
  1.1766 +    }
  1.1767 +  }
  1.1768 +#endif
  1.1769 +}
  1.1770 +
  1.1771 +//--------------------------is_iteratively_computed------------------------------
  1.1772 +// Operation appears to be iteratively computed (such as an induction variable)
  1.1773 +// It is possible for this operation to return false for a loop-varying
  1.1774 +// value, if it appears (by local graph inspection) to be computed by a simple conditional.
  1.1775 +bool Node::is_iteratively_computed() {
  1.1776 +  if (ideal_reg()) { // does operation have a result register?
  1.1777 +    for (uint i = 1; i < req(); i++) {
  1.1778 +      Node* n = in(i);
  1.1779 +      if (n != NULL && n->is_Phi()) {
  1.1780 +        for (uint j = 1; j < n->req(); j++) {
  1.1781 +          if (n->in(j) == this) {
  1.1782 +            return true;
  1.1783 +          }
  1.1784 +        }
  1.1785 +      }
  1.1786 +    }
  1.1787 +  }
  1.1788 +  return false;
  1.1789 +}
  1.1790 +
  1.1791 +//--------------------------find_similar------------------------------
  1.1792 +// Return a node with opcode "opc" and same inputs as "this" if one can
  1.1793 +// be found; Otherwise return NULL;
  1.1794 +Node* Node::find_similar(int opc) {
  1.1795 +  if (req() >= 2) {
  1.1796 +    Node* def = in(1);
  1.1797 +    if (def && def->outcnt() >= 2) {
  1.1798 +      for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
  1.1799 +        Node* use = def->fast_out(i);
  1.1800 +        if (use->Opcode() == opc &&
  1.1801 +            use->req() == req()) {
  1.1802 +          uint j;
  1.1803 +          for (j = 0; j < use->req(); j++) {
  1.1804 +            if (use->in(j) != in(j)) {
  1.1805 +              break;
  1.1806 +            }
  1.1807 +          }
  1.1808 +          if (j == use->req()) {
  1.1809 +            return use;
  1.1810 +          }
  1.1811 +        }
  1.1812 +      }
  1.1813 +    }
  1.1814 +  }
  1.1815 +  return NULL;
  1.1816 +}
  1.1817 +
  1.1818 +
  1.1819 +//--------------------------unique_ctrl_out------------------------------
  1.1820 +// Return the unique control out if only one. Null if none or more than one.
  1.1821 +Node* Node::unique_ctrl_out() {
  1.1822 +  Node* found = NULL;
  1.1823 +  for (uint i = 0; i < outcnt(); i++) {
  1.1824 +    Node* use = raw_out(i);
  1.1825 +    if (use->is_CFG() && use != this) {
  1.1826 +      if (found != NULL) return NULL;
  1.1827 +      found = use;
  1.1828 +    }
  1.1829 +  }
  1.1830 +  return found;
  1.1831 +}
  1.1832 +
  1.1833 +//=============================================================================
  1.1834 +//------------------------------yank-------------------------------------------
  1.1835 +// Find and remove
  1.1836 +void Node_List::yank( Node *n ) {
  1.1837 +  uint i;
  1.1838 +  for( i = 0; i < _cnt; i++ )
  1.1839 +    if( _nodes[i] == n )
  1.1840 +      break;
  1.1841 +
  1.1842 +  if( i < _cnt )
  1.1843 +    _nodes[i] = _nodes[--_cnt];
  1.1844 +}
  1.1845 +
  1.1846 +//------------------------------dump-------------------------------------------
  1.1847 +void Node_List::dump() const {
  1.1848 +#ifndef PRODUCT
  1.1849 +  for( uint i = 0; i < _cnt; i++ )
  1.1850 +    if( _nodes[i] ) {
  1.1851 +      tty->print("%5d--> ",i);
  1.1852 +      _nodes[i]->dump();
  1.1853 +    }
  1.1854 +#endif
  1.1855 +}
  1.1856 +
  1.1857 +//=============================================================================
  1.1858 +//------------------------------remove-----------------------------------------
  1.1859 +void Unique_Node_List::remove( Node *n ) {
  1.1860 +  if( _in_worklist[n->_idx] ) {
  1.1861 +    for( uint i = 0; i < size(); i++ )
  1.1862 +      if( _nodes[i] == n ) {
  1.1863 +        map(i,Node_List::pop());
  1.1864 +        _in_worklist >>= n->_idx;
  1.1865 +        return;
  1.1866 +      }
  1.1867 +    ShouldNotReachHere();
  1.1868 +  }
  1.1869 +}
  1.1870 +
  1.1871 +//-----------------------remove_useless_nodes----------------------------------
  1.1872 +// Remove useless nodes from worklist
  1.1873 +void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
  1.1874 +
  1.1875 +  for( uint i = 0; i < size(); ++i ) {
  1.1876 +    Node *n = at(i);
  1.1877 +    assert( n != NULL, "Did not expect null entries in worklist");
  1.1878 +    if( ! useful.test(n->_idx) ) {
  1.1879 +      _in_worklist >>= n->_idx;
  1.1880 +      map(i,Node_List::pop());
  1.1881 +      // Node *replacement = Node_List::pop();
  1.1882 +      // if( i != size() ) { // Check if removing last entry
  1.1883 +      //   _nodes[i] = replacement;
  1.1884 +      // }
  1.1885 +      --i;  // Visit popped node
  1.1886 +      // If it was last entry, loop terminates since size() was also reduced
  1.1887 +    }
  1.1888 +  }
  1.1889 +}
  1.1890 +
  1.1891 +//=============================================================================
  1.1892 +void Node_Stack::grow() {
  1.1893 +  size_t old_top = pointer_delta(_inode_top,_inodes,sizeof(INode)); // save _top
  1.1894 +  size_t old_max = pointer_delta(_inode_max,_inodes,sizeof(INode));
  1.1895 +  size_t max = old_max << 1;             // max * 2
  1.1896 +  _inodes = REALLOC_ARENA_ARRAY(_a, INode, _inodes, old_max, max);
  1.1897 +  _inode_max = _inodes + max;
  1.1898 +  _inode_top = _inodes + old_top;        // restore _top
  1.1899 +}
  1.1900 +
  1.1901 +//=============================================================================
  1.1902 +uint TypeNode::size_of() const { return sizeof(*this); }
  1.1903 +#ifndef PRODUCT
  1.1904 +void TypeNode::dump_spec(outputStream *st) const {
  1.1905 +  if( !Verbose && !WizardMode ) {
  1.1906 +    // standard dump does this in Verbose and WizardMode
  1.1907 +    st->print(" #"); _type->dump_on(st);
  1.1908 +  }
  1.1909 +}
  1.1910 +#endif
  1.1911 +uint TypeNode::hash() const {
  1.1912 +  return Node::hash() + _type->hash();
  1.1913 +}
  1.1914 +uint TypeNode::cmp( const Node &n ) const
  1.1915 +{ return !Type::cmp( _type, ((TypeNode&)n)._type ); }
  1.1916 +const Type *TypeNode::bottom_type() const { return _type; }
  1.1917 +const Type *TypeNode::Value( PhaseTransform * ) const { return _type; }
  1.1918 +
  1.1919 +//------------------------------ideal_reg--------------------------------------
  1.1920 +uint TypeNode::ideal_reg() const {
  1.1921 +  return Matcher::base2reg[_type->base()];
  1.1922 +}

mercurial