src/share/vm/opto/node.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "libadt/vectset.hpp"
aoqi@0 27 #include "memory/allocation.inline.hpp"
aoqi@0 28 #include "opto/cfgnode.hpp"
aoqi@0 29 #include "opto/connode.hpp"
aoqi@0 30 #include "opto/loopnode.hpp"
aoqi@0 31 #include "opto/machnode.hpp"
aoqi@0 32 #include "opto/matcher.hpp"
aoqi@0 33 #include "opto/node.hpp"
aoqi@0 34 #include "opto/opcodes.hpp"
aoqi@0 35 #include "opto/regmask.hpp"
aoqi@0 36 #include "opto/type.hpp"
aoqi@0 37 #include "utilities/copy.hpp"
aoqi@0 38
aoqi@0 39 class RegMask;
aoqi@0 40 // #include "phase.hpp"
aoqi@0 41 class PhaseTransform;
aoqi@0 42 class PhaseGVN;
aoqi@0 43
aoqi@0 44 // Arena we are currently building Nodes in
aoqi@0 45 const uint Node::NotAMachineReg = 0xffff0000;
aoqi@0 46
aoqi@0 47 #ifndef PRODUCT
aoqi@0 48 extern int nodes_created;
aoqi@0 49 #endif
aoqi@0 50
aoqi@0 51 #ifdef ASSERT
aoqi@0 52
aoqi@0 53 //-------------------------- construct_node------------------------------------
aoqi@0 54 // Set a breakpoint here to identify where a particular node index is built.
aoqi@0 55 void Node::verify_construction() {
aoqi@0 56 _debug_orig = NULL;
aoqi@0 57 int old_debug_idx = Compile::debug_idx();
aoqi@0 58 int new_debug_idx = old_debug_idx+1;
aoqi@0 59 if (new_debug_idx > 0) {
aoqi@0 60 // Arrange that the lowest five decimal digits of _debug_idx
aoqi@0 61 // will repeat those of _idx. In case this is somehow pathological,
aoqi@0 62 // we continue to assign negative numbers (!) consecutively.
aoqi@0 63 const int mod = 100000;
aoqi@0 64 int bump = (int)(_idx - new_debug_idx) % mod;
aoqi@0 65 if (bump < 0) bump += mod;
aoqi@0 66 assert(bump >= 0 && bump < mod, "");
aoqi@0 67 new_debug_idx += bump;
aoqi@0 68 }
aoqi@0 69 Compile::set_debug_idx(new_debug_idx);
aoqi@0 70 set_debug_idx( new_debug_idx );
aoqi@0 71 assert(Compile::current()->unique() < (INT_MAX - 1), "Node limit exceeded INT_MAX");
aoqi@0 72 assert(Compile::current()->live_nodes() < (uint)MaxNodeLimit, "Live Node limit exceeded limit");
aoqi@0 73 if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
aoqi@0 74 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
aoqi@0 75 BREAKPOINT;
aoqi@0 76 }
aoqi@0 77 #if OPTO_DU_ITERATOR_ASSERT
aoqi@0 78 _last_del = NULL;
aoqi@0 79 _del_tick = 0;
aoqi@0 80 #endif
aoqi@0 81 _hash_lock = 0;
aoqi@0 82 }
aoqi@0 83
aoqi@0 84
aoqi@0 85 // #ifdef ASSERT ...
aoqi@0 86
aoqi@0 87 #if OPTO_DU_ITERATOR_ASSERT
aoqi@0 88 void DUIterator_Common::sample(const Node* node) {
aoqi@0 89 _vdui = VerifyDUIterators;
aoqi@0 90 _node = node;
aoqi@0 91 _outcnt = node->_outcnt;
aoqi@0 92 _del_tick = node->_del_tick;
aoqi@0 93 _last = NULL;
aoqi@0 94 }
aoqi@0 95
aoqi@0 96 void DUIterator_Common::verify(const Node* node, bool at_end_ok) {
aoqi@0 97 assert(_node == node, "consistent iterator source");
aoqi@0 98 assert(_del_tick == node->_del_tick, "no unexpected deletions allowed");
aoqi@0 99 }
aoqi@0 100
aoqi@0 101 void DUIterator_Common::verify_resync() {
aoqi@0 102 // Ensure that the loop body has just deleted the last guy produced.
aoqi@0 103 const Node* node = _node;
aoqi@0 104 // Ensure that at least one copy of the last-seen edge was deleted.
aoqi@0 105 // Note: It is OK to delete multiple copies of the last-seen edge.
aoqi@0 106 // Unfortunately, we have no way to verify that all the deletions delete
aoqi@0 107 // that same edge. On this point we must use the Honor System.
aoqi@0 108 assert(node->_del_tick >= _del_tick+1, "must have deleted an edge");
aoqi@0 109 assert(node->_last_del == _last, "must have deleted the edge just produced");
aoqi@0 110 // We liked this deletion, so accept the resulting outcnt and tick.
aoqi@0 111 _outcnt = node->_outcnt;
aoqi@0 112 _del_tick = node->_del_tick;
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 void DUIterator_Common::reset(const DUIterator_Common& that) {
aoqi@0 116 if (this == &that) return; // ignore assignment to self
aoqi@0 117 if (!_vdui) {
aoqi@0 118 // We need to initialize everything, overwriting garbage values.
aoqi@0 119 _last = that._last;
aoqi@0 120 _vdui = that._vdui;
aoqi@0 121 }
aoqi@0 122 // Note: It is legal (though odd) for an iterator over some node x
aoqi@0 123 // to be reassigned to iterate over another node y. Some doubly-nested
aoqi@0 124 // progress loops depend on being able to do this.
aoqi@0 125 const Node* node = that._node;
aoqi@0 126 // Re-initialize everything, except _last.
aoqi@0 127 _node = node;
aoqi@0 128 _outcnt = node->_outcnt;
aoqi@0 129 _del_tick = node->_del_tick;
aoqi@0 130 }
aoqi@0 131
aoqi@0 132 void DUIterator::sample(const Node* node) {
aoqi@0 133 DUIterator_Common::sample(node); // Initialize the assertion data.
aoqi@0 134 _refresh_tick = 0; // No refreshes have happened, as yet.
aoqi@0 135 }
aoqi@0 136
aoqi@0 137 void DUIterator::verify(const Node* node, bool at_end_ok) {
aoqi@0 138 DUIterator_Common::verify(node, at_end_ok);
aoqi@0 139 assert(_idx < node->_outcnt + (uint)at_end_ok, "idx in range");
aoqi@0 140 }
aoqi@0 141
aoqi@0 142 void DUIterator::verify_increment() {
aoqi@0 143 if (_refresh_tick & 1) {
aoqi@0 144 // We have refreshed the index during this loop.
aoqi@0 145 // Fix up _idx to meet asserts.
aoqi@0 146 if (_idx > _outcnt) _idx = _outcnt;
aoqi@0 147 }
aoqi@0 148 verify(_node, true);
aoqi@0 149 }
aoqi@0 150
aoqi@0 151 void DUIterator::verify_resync() {
aoqi@0 152 // Note: We do not assert on _outcnt, because insertions are OK here.
aoqi@0 153 DUIterator_Common::verify_resync();
aoqi@0 154 // Make sure we are still in sync, possibly with no more out-edges:
aoqi@0 155 verify(_node, true);
aoqi@0 156 }
aoqi@0 157
aoqi@0 158 void DUIterator::reset(const DUIterator& that) {
aoqi@0 159 if (this == &that) return; // self assignment is always a no-op
aoqi@0 160 assert(that._refresh_tick == 0, "assign only the result of Node::outs()");
aoqi@0 161 assert(that._idx == 0, "assign only the result of Node::outs()");
aoqi@0 162 assert(_idx == that._idx, "already assigned _idx");
aoqi@0 163 if (!_vdui) {
aoqi@0 164 // We need to initialize everything, overwriting garbage values.
aoqi@0 165 sample(that._node);
aoqi@0 166 } else {
aoqi@0 167 DUIterator_Common::reset(that);
aoqi@0 168 if (_refresh_tick & 1) {
aoqi@0 169 _refresh_tick++; // Clear the "was refreshed" flag.
aoqi@0 170 }
aoqi@0 171 assert(_refresh_tick < 2*100000, "DU iteration must converge quickly");
aoqi@0 172 }
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 void DUIterator::refresh() {
aoqi@0 176 DUIterator_Common::sample(_node); // Re-fetch assertion data.
aoqi@0 177 _refresh_tick |= 1; // Set the "was refreshed" flag.
aoqi@0 178 }
aoqi@0 179
aoqi@0 180 void DUIterator::verify_finish() {
aoqi@0 181 // If the loop has killed the node, do not require it to re-run.
aoqi@0 182 if (_node->_outcnt == 0) _refresh_tick &= ~1;
aoqi@0 183 // If this assert triggers, it means that a loop used refresh_out_pos
aoqi@0 184 // to re-synch an iteration index, but the loop did not correctly
aoqi@0 185 // re-run itself, using a "while (progress)" construct.
aoqi@0 186 // This iterator enforces the rule that you must keep trying the loop
aoqi@0 187 // until it "runs clean" without any need for refreshing.
aoqi@0 188 assert(!(_refresh_tick & 1), "the loop must run once with no refreshing");
aoqi@0 189 }
aoqi@0 190
aoqi@0 191
aoqi@0 192 void DUIterator_Fast::verify(const Node* node, bool at_end_ok) {
aoqi@0 193 DUIterator_Common::verify(node, at_end_ok);
aoqi@0 194 Node** out = node->_out;
aoqi@0 195 uint cnt = node->_outcnt;
aoqi@0 196 assert(cnt == _outcnt, "no insertions allowed");
aoqi@0 197 assert(_outp >= out && _outp <= out + cnt - !at_end_ok, "outp in range");
aoqi@0 198 // This last check is carefully designed to work for NO_OUT_ARRAY.
aoqi@0 199 }
aoqi@0 200
aoqi@0 201 void DUIterator_Fast::verify_limit() {
aoqi@0 202 const Node* node = _node;
aoqi@0 203 verify(node, true);
aoqi@0 204 assert(_outp == node->_out + node->_outcnt, "limit still correct");
aoqi@0 205 }
aoqi@0 206
aoqi@0 207 void DUIterator_Fast::verify_resync() {
aoqi@0 208 const Node* node = _node;
aoqi@0 209 if (_outp == node->_out + _outcnt) {
aoqi@0 210 // Note that the limit imax, not the pointer i, gets updated with the
aoqi@0 211 // exact count of deletions. (For the pointer it's always "--i".)
aoqi@0 212 assert(node->_outcnt+node->_del_tick == _outcnt+_del_tick, "no insertions allowed with deletion(s)");
aoqi@0 213 // This is a limit pointer, with a name like "imax".
aoqi@0 214 // Fudge the _last field so that the common assert will be happy.
aoqi@0 215 _last = (Node*) node->_last_del;
aoqi@0 216 DUIterator_Common::verify_resync();
aoqi@0 217 } else {
aoqi@0 218 assert(node->_outcnt < _outcnt, "no insertions allowed with deletion(s)");
aoqi@0 219 // A normal internal pointer.
aoqi@0 220 DUIterator_Common::verify_resync();
aoqi@0 221 // Make sure we are still in sync, possibly with no more out-edges:
aoqi@0 222 verify(node, true);
aoqi@0 223 }
aoqi@0 224 }
aoqi@0 225
aoqi@0 226 void DUIterator_Fast::verify_relimit(uint n) {
aoqi@0 227 const Node* node = _node;
aoqi@0 228 assert((int)n > 0, "use imax -= n only with a positive count");
aoqi@0 229 // This must be a limit pointer, with a name like "imax".
aoqi@0 230 assert(_outp == node->_out + node->_outcnt, "apply -= only to a limit (imax)");
aoqi@0 231 // The reported number of deletions must match what the node saw.
aoqi@0 232 assert(node->_del_tick == _del_tick + n, "must have deleted n edges");
aoqi@0 233 // Fudge the _last field so that the common assert will be happy.
aoqi@0 234 _last = (Node*) node->_last_del;
aoqi@0 235 DUIterator_Common::verify_resync();
aoqi@0 236 }
aoqi@0 237
aoqi@0 238 void DUIterator_Fast::reset(const DUIterator_Fast& that) {
aoqi@0 239 assert(_outp == that._outp, "already assigned _outp");
aoqi@0 240 DUIterator_Common::reset(that);
aoqi@0 241 }
aoqi@0 242
aoqi@0 243 void DUIterator_Last::verify(const Node* node, bool at_end_ok) {
aoqi@0 244 // at_end_ok means the _outp is allowed to underflow by 1
aoqi@0 245 _outp += at_end_ok;
aoqi@0 246 DUIterator_Fast::verify(node, at_end_ok); // check _del_tick, etc.
aoqi@0 247 _outp -= at_end_ok;
aoqi@0 248 assert(_outp == (node->_out + node->_outcnt) - 1, "pointer must point to end of nodes");
aoqi@0 249 }
aoqi@0 250
aoqi@0 251 void DUIterator_Last::verify_limit() {
aoqi@0 252 // Do not require the limit address to be resynched.
aoqi@0 253 //verify(node, true);
aoqi@0 254 assert(_outp == _node->_out, "limit still correct");
aoqi@0 255 }
aoqi@0 256
aoqi@0 257 void DUIterator_Last::verify_step(uint num_edges) {
aoqi@0 258 assert((int)num_edges > 0, "need non-zero edge count for loop progress");
aoqi@0 259 _outcnt -= num_edges;
aoqi@0 260 _del_tick += num_edges;
aoqi@0 261 // Make sure we are still in sync, possibly with no more out-edges:
aoqi@0 262 const Node* node = _node;
aoqi@0 263 verify(node, true);
aoqi@0 264 assert(node->_last_del == _last, "must have deleted the edge just produced");
aoqi@0 265 }
aoqi@0 266
aoqi@0 267 #endif //OPTO_DU_ITERATOR_ASSERT
aoqi@0 268
aoqi@0 269
aoqi@0 270 #endif //ASSERT
aoqi@0 271
aoqi@0 272
aoqi@0 273 // This constant used to initialize _out may be any non-null value.
aoqi@0 274 // The value NULL is reserved for the top node only.
aoqi@0 275 #define NO_OUT_ARRAY ((Node**)-1)
aoqi@0 276
aoqi@0 277 // This funny expression handshakes with Node::operator new
aoqi@0 278 // to pull Compile::current out of the new node's _out field,
aoqi@0 279 // and then calls a subroutine which manages most field
aoqi@0 280 // initializations. The only one which is tricky is the
aoqi@0 281 // _idx field, which is const, and so must be initialized
aoqi@0 282 // by a return value, not an assignment.
aoqi@0 283 //
aoqi@0 284 // (Aren't you thankful that Java finals don't require so many tricks?)
aoqi@0 285 #define IDX_INIT(req) this->Init((req), (Compile*) this->_out)
aoqi@0 286 #ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355
aoqi@0 287 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
aoqi@0 288 #endif
aoqi@0 289
aoqi@0 290 // Out-of-line code from node constructors.
aoqi@0 291 // Executed only when extra debug info. is being passed around.
aoqi@0 292 static void init_node_notes(Compile* C, int idx, Node_Notes* nn) {
aoqi@0 293 C->set_node_notes_at(idx, nn);
aoqi@0 294 }
aoqi@0 295
aoqi@0 296 // Shared initialization code.
aoqi@0 297 inline int Node::Init(int req, Compile* C) {
aoqi@0 298 assert(Compile::current() == C, "must use operator new(Compile*)");
aoqi@0 299 int idx = C->next_unique();
aoqi@0 300
aoqi@0 301 // Allocate memory for the necessary number of edges.
aoqi@0 302 if (req > 0) {
aoqi@0 303 // Allocate space for _in array to have double alignment.
aoqi@0 304 _in = (Node **) ((char *) (C->node_arena()->Amalloc_D(req * sizeof(void*))));
aoqi@0 305 #ifdef ASSERT
aoqi@0 306 _in[req-1] = this; // magic cookie for assertion check
aoqi@0 307 #endif
aoqi@0 308 }
aoqi@0 309 // If there are default notes floating around, capture them:
aoqi@0 310 Node_Notes* nn = C->default_node_notes();
aoqi@0 311 if (nn != NULL) init_node_notes(C, idx, nn);
aoqi@0 312
aoqi@0 313 // Note: At this point, C is dead,
aoqi@0 314 // and we begin to initialize the new Node.
aoqi@0 315
aoqi@0 316 _cnt = _max = req;
aoqi@0 317 _outcnt = _outmax = 0;
aoqi@0 318 _class_id = Class_Node;
aoqi@0 319 _flags = 0;
aoqi@0 320 _out = NO_OUT_ARRAY;
aoqi@0 321 return idx;
aoqi@0 322 }
aoqi@0 323
aoqi@0 324 //------------------------------Node-------------------------------------------
aoqi@0 325 // Create a Node, with a given number of required edges.
aoqi@0 326 Node::Node(uint req)
aoqi@0 327 : _idx(IDX_INIT(req))
aoqi@0 328 {
aoqi@0 329 assert( req < (uint)(MaxNodeLimit - NodeLimitFudgeFactor), "Input limit exceeded" );
aoqi@0 330 debug_only( verify_construction() );
aoqi@0 331 NOT_PRODUCT(nodes_created++);
aoqi@0 332 if (req == 0) {
aoqi@0 333 assert( _in == (Node**)this, "Must not pass arg count to 'new'" );
aoqi@0 334 _in = NULL;
aoqi@0 335 } else {
aoqi@0 336 assert( _in[req-1] == this, "Must pass arg count to 'new'" );
aoqi@0 337 Node** to = _in;
aoqi@0 338 for(uint i = 0; i < req; i++) {
aoqi@0 339 to[i] = NULL;
aoqi@0 340 }
aoqi@0 341 }
aoqi@0 342 }
aoqi@0 343
aoqi@0 344 //------------------------------Node-------------------------------------------
aoqi@0 345 Node::Node(Node *n0)
aoqi@0 346 : _idx(IDX_INIT(1))
aoqi@0 347 {
aoqi@0 348 debug_only( verify_construction() );
aoqi@0 349 NOT_PRODUCT(nodes_created++);
aoqi@0 350 // Assert we allocated space for input array already
aoqi@0 351 assert( _in[0] == this, "Must pass arg count to 'new'" );
aoqi@0 352 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 353 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 354 }
aoqi@0 355
aoqi@0 356 //------------------------------Node-------------------------------------------
aoqi@0 357 Node::Node(Node *n0, Node *n1)
aoqi@0 358 : _idx(IDX_INIT(2))
aoqi@0 359 {
aoqi@0 360 debug_only( verify_construction() );
aoqi@0 361 NOT_PRODUCT(nodes_created++);
aoqi@0 362 // Assert we allocated space for input array already
aoqi@0 363 assert( _in[1] == this, "Must pass arg count to 'new'" );
aoqi@0 364 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 365 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 366 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 367 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 368 }
aoqi@0 369
aoqi@0 370 //------------------------------Node-------------------------------------------
aoqi@0 371 Node::Node(Node *n0, Node *n1, Node *n2)
aoqi@0 372 : _idx(IDX_INIT(3))
aoqi@0 373 {
aoqi@0 374 debug_only( verify_construction() );
aoqi@0 375 NOT_PRODUCT(nodes_created++);
aoqi@0 376 // Assert we allocated space for input array already
aoqi@0 377 assert( _in[2] == this, "Must pass arg count to 'new'" );
aoqi@0 378 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 379 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 380 assert( is_not_dead(n2), "can not use dead node");
aoqi@0 381 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 382 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 383 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
aoqi@0 384 }
aoqi@0 385
aoqi@0 386 //------------------------------Node-------------------------------------------
aoqi@0 387 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3)
aoqi@0 388 : _idx(IDX_INIT(4))
aoqi@0 389 {
aoqi@0 390 debug_only( verify_construction() );
aoqi@0 391 NOT_PRODUCT(nodes_created++);
aoqi@0 392 // Assert we allocated space for input array already
aoqi@0 393 assert( _in[3] == this, "Must pass arg count to 'new'" );
aoqi@0 394 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 395 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 396 assert( is_not_dead(n2), "can not use dead node");
aoqi@0 397 assert( is_not_dead(n3), "can not use dead node");
aoqi@0 398 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 399 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 400 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
aoqi@0 401 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
aoqi@0 402 }
aoqi@0 403
aoqi@0 404 //------------------------------Node-------------------------------------------
aoqi@0 405 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4)
aoqi@0 406 : _idx(IDX_INIT(5))
aoqi@0 407 {
aoqi@0 408 debug_only( verify_construction() );
aoqi@0 409 NOT_PRODUCT(nodes_created++);
aoqi@0 410 // Assert we allocated space for input array already
aoqi@0 411 assert( _in[4] == this, "Must pass arg count to 'new'" );
aoqi@0 412 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 413 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 414 assert( is_not_dead(n2), "can not use dead node");
aoqi@0 415 assert( is_not_dead(n3), "can not use dead node");
aoqi@0 416 assert( is_not_dead(n4), "can not use dead node");
aoqi@0 417 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 418 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 419 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
aoqi@0 420 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
aoqi@0 421 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
aoqi@0 422 }
aoqi@0 423
aoqi@0 424 //------------------------------Node-------------------------------------------
aoqi@0 425 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
aoqi@0 426 Node *n4, Node *n5)
aoqi@0 427 : _idx(IDX_INIT(6))
aoqi@0 428 {
aoqi@0 429 debug_only( verify_construction() );
aoqi@0 430 NOT_PRODUCT(nodes_created++);
aoqi@0 431 // Assert we allocated space for input array already
aoqi@0 432 assert( _in[5] == this, "Must pass arg count to 'new'" );
aoqi@0 433 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 434 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 435 assert( is_not_dead(n2), "can not use dead node");
aoqi@0 436 assert( is_not_dead(n3), "can not use dead node");
aoqi@0 437 assert( is_not_dead(n4), "can not use dead node");
aoqi@0 438 assert( is_not_dead(n5), "can not use dead node");
aoqi@0 439 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 440 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 441 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
aoqi@0 442 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
aoqi@0 443 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
aoqi@0 444 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
aoqi@0 445 }
aoqi@0 446
aoqi@0 447 //------------------------------Node-------------------------------------------
aoqi@0 448 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
aoqi@0 449 Node *n4, Node *n5, Node *n6)
aoqi@0 450 : _idx(IDX_INIT(7))
aoqi@0 451 {
aoqi@0 452 debug_only( verify_construction() );
aoqi@0 453 NOT_PRODUCT(nodes_created++);
aoqi@0 454 // Assert we allocated space for input array already
aoqi@0 455 assert( _in[6] == this, "Must pass arg count to 'new'" );
aoqi@0 456 assert( is_not_dead(n0), "can not use dead node");
aoqi@0 457 assert( is_not_dead(n1), "can not use dead node");
aoqi@0 458 assert( is_not_dead(n2), "can not use dead node");
aoqi@0 459 assert( is_not_dead(n3), "can not use dead node");
aoqi@0 460 assert( is_not_dead(n4), "can not use dead node");
aoqi@0 461 assert( is_not_dead(n5), "can not use dead node");
aoqi@0 462 assert( is_not_dead(n6), "can not use dead node");
aoqi@0 463 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this);
aoqi@0 464 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this);
aoqi@0 465 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this);
aoqi@0 466 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this);
aoqi@0 467 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this);
aoqi@0 468 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this);
aoqi@0 469 _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this);
aoqi@0 470 }
aoqi@0 471
aoqi@0 472
aoqi@0 473 //------------------------------clone------------------------------------------
aoqi@0 474 // Clone a Node.
aoqi@0 475 Node *Node::clone() const {
aoqi@0 476 Compile* C = Compile::current();
aoqi@0 477 uint s = size_of(); // Size of inherited Node
aoqi@0 478 Node *n = (Node*)C->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
aoqi@0 479 Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
aoqi@0 480 // Set the new input pointer array
aoqi@0 481 n->_in = (Node**)(((char*)n)+s);
aoqi@0 482 // Cannot share the old output pointer array, so kill it
aoqi@0 483 n->_out = NO_OUT_ARRAY;
aoqi@0 484 // And reset the counters to 0
aoqi@0 485 n->_outcnt = 0;
aoqi@0 486 n->_outmax = 0;
aoqi@0 487 // Unlock this guy, since he is not in any hash table.
aoqi@0 488 debug_only(n->_hash_lock = 0);
aoqi@0 489 // Walk the old node's input list to duplicate its edges
aoqi@0 490 uint i;
aoqi@0 491 for( i = 0; i < len(); i++ ) {
aoqi@0 492 Node *x = in(i);
aoqi@0 493 n->_in[i] = x;
aoqi@0 494 if (x != NULL) x->add_out(n);
aoqi@0 495 }
aoqi@0 496 if (is_macro())
aoqi@0 497 C->add_macro_node(n);
aoqi@0 498 if (is_expensive())
aoqi@0 499 C->add_expensive_node(n);
aoqi@0 500
aoqi@0 501 n->set_idx(C->next_unique()); // Get new unique index as well
aoqi@0 502 debug_only( n->verify_construction() );
aoqi@0 503 NOT_PRODUCT(nodes_created++);
aoqi@0 504 // Do not patch over the debug_idx of a clone, because it makes it
aoqi@0 505 // impossible to break on the clone's moment of creation.
aoqi@0 506 //debug_only( n->set_debug_idx( debug_idx() ) );
aoqi@0 507
aoqi@0 508 C->copy_node_notes_to(n, (Node*) this);
aoqi@0 509
aoqi@0 510 // MachNode clone
aoqi@0 511 uint nopnds;
aoqi@0 512 if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
aoqi@0 513 MachNode *mach = n->as_Mach();
aoqi@0 514 MachNode *mthis = this->as_Mach();
aoqi@0 515 // Get address of _opnd_array.
aoqi@0 516 // It should be the same offset since it is the clone of this node.
aoqi@0 517 MachOper **from = mthis->_opnds;
aoqi@0 518 MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
aoqi@0 519 pointer_delta((const void*)from,
aoqi@0 520 (const void*)(&mthis->_opnds), 1));
aoqi@0 521 mach->_opnds = to;
aoqi@0 522 for ( uint i = 0; i < nopnds; ++i ) {
aoqi@0 523 to[i] = from[i]->clone(C);
aoqi@0 524 }
aoqi@0 525 }
aoqi@0 526 // cloning CallNode may need to clone JVMState
aoqi@0 527 if (n->is_Call()) {
aoqi@0 528 n->as_Call()->clone_jvms(C);
aoqi@0 529 }
aoqi@0 530 return n; // Return the clone
aoqi@0 531 }
aoqi@0 532
aoqi@0 533 //---------------------------setup_is_top--------------------------------------
aoqi@0 534 // Call this when changing the top node, to reassert the invariants
aoqi@0 535 // required by Node::is_top. See Compile::set_cached_top_node.
aoqi@0 536 void Node::setup_is_top() {
aoqi@0 537 if (this == (Node*)Compile::current()->top()) {
aoqi@0 538 // This node has just become top. Kill its out array.
aoqi@0 539 _outcnt = _outmax = 0;
aoqi@0 540 _out = NULL; // marker value for top
aoqi@0 541 assert(is_top(), "must be top");
aoqi@0 542 } else {
aoqi@0 543 if (_out == NULL) _out = NO_OUT_ARRAY;
aoqi@0 544 assert(!is_top(), "must not be top");
aoqi@0 545 }
aoqi@0 546 }
aoqi@0 547
aoqi@0 548
aoqi@0 549 //------------------------------~Node------------------------------------------
aoqi@0 550 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
aoqi@0 551 extern int reclaim_idx ;
aoqi@0 552 extern int reclaim_in ;
aoqi@0 553 extern int reclaim_node;
aoqi@0 554 void Node::destruct() {
aoqi@0 555 // Eagerly reclaim unique Node numberings
aoqi@0 556 Compile* compile = Compile::current();
aoqi@0 557 if ((uint)_idx+1 == compile->unique()) {
aoqi@0 558 compile->set_unique(compile->unique()-1);
aoqi@0 559 #ifdef ASSERT
aoqi@0 560 reclaim_idx++;
aoqi@0 561 #endif
aoqi@0 562 }
aoqi@0 563 // Clear debug info:
aoqi@0 564 Node_Notes* nn = compile->node_notes_at(_idx);
aoqi@0 565 if (nn != NULL) nn->clear();
aoqi@0 566 // Walk the input array, freeing the corresponding output edges
aoqi@0 567 _cnt = _max; // forget req/prec distinction
aoqi@0 568 uint i;
aoqi@0 569 for( i = 0; i < _max; i++ ) {
aoqi@0 570 set_req(i, NULL);
aoqi@0 571 //assert(def->out(def->outcnt()-1) == (Node *)this,"bad def-use hacking in reclaim");
aoqi@0 572 }
aoqi@0 573 assert(outcnt() == 0, "deleting a node must not leave a dangling use");
aoqi@0 574 // See if the input array was allocated just prior to the object
aoqi@0 575 int edge_size = _max*sizeof(void*);
aoqi@0 576 int out_edge_size = _outmax*sizeof(void*);
aoqi@0 577 char *edge_end = ((char*)_in) + edge_size;
aoqi@0 578 char *out_array = (char*)(_out == NO_OUT_ARRAY? NULL: _out);
aoqi@0 579 char *out_edge_end = out_array + out_edge_size;
aoqi@0 580 int node_size = size_of();
aoqi@0 581
aoqi@0 582 // Free the output edge array
aoqi@0 583 if (out_edge_size > 0) {
aoqi@0 584 #ifdef ASSERT
aoqi@0 585 if( out_edge_end == compile->node_arena()->hwm() )
aoqi@0 586 reclaim_in += out_edge_size; // count reclaimed out edges with in edges
aoqi@0 587 #endif
aoqi@0 588 compile->node_arena()->Afree(out_array, out_edge_size);
aoqi@0 589 }
aoqi@0 590
aoqi@0 591 // Free the input edge array and the node itself
aoqi@0 592 if( edge_end == (char*)this ) {
aoqi@0 593 #ifdef ASSERT
aoqi@0 594 if( edge_end+node_size == compile->node_arena()->hwm() ) {
aoqi@0 595 reclaim_in += edge_size;
aoqi@0 596 reclaim_node+= node_size;
aoqi@0 597 }
aoqi@0 598 #else
aoqi@0 599 // It was; free the input array and object all in one hit
aoqi@0 600 compile->node_arena()->Afree(_in,edge_size+node_size);
aoqi@0 601 #endif
aoqi@0 602 } else {
aoqi@0 603
aoqi@0 604 // Free just the input array
aoqi@0 605 #ifdef ASSERT
aoqi@0 606 if( edge_end == compile->node_arena()->hwm() )
aoqi@0 607 reclaim_in += edge_size;
aoqi@0 608 #endif
aoqi@0 609 compile->node_arena()->Afree(_in,edge_size);
aoqi@0 610
aoqi@0 611 // Free just the object
aoqi@0 612 #ifdef ASSERT
aoqi@0 613 if( ((char*)this) + node_size == compile->node_arena()->hwm() )
aoqi@0 614 reclaim_node+= node_size;
aoqi@0 615 #else
aoqi@0 616 compile->node_arena()->Afree(this,node_size);
aoqi@0 617 #endif
aoqi@0 618 }
aoqi@0 619 if (is_macro()) {
aoqi@0 620 compile->remove_macro_node(this);
aoqi@0 621 }
aoqi@0 622 if (is_expensive()) {
aoqi@0 623 compile->remove_expensive_node(this);
aoqi@0 624 }
aoqi@0 625 #ifdef ASSERT
aoqi@0 626 // We will not actually delete the storage, but we'll make the node unusable.
aoqi@0 627 *(address*)this = badAddress; // smash the C++ vtbl, probably
aoqi@0 628 _in = _out = (Node**) badAddress;
aoqi@0 629 _max = _cnt = _outmax = _outcnt = 0;
aoqi@0 630 #endif
aoqi@0 631 }
aoqi@0 632
aoqi@0 633 //------------------------------grow-------------------------------------------
aoqi@0 634 // Grow the input array, making space for more edges
aoqi@0 635 void Node::grow( uint len ) {
aoqi@0 636 Arena* arena = Compile::current()->node_arena();
aoqi@0 637 uint new_max = _max;
aoqi@0 638 if( new_max == 0 ) {
aoqi@0 639 _max = 4;
aoqi@0 640 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
aoqi@0 641 Node** to = _in;
aoqi@0 642 to[0] = NULL;
aoqi@0 643 to[1] = NULL;
aoqi@0 644 to[2] = NULL;
aoqi@0 645 to[3] = NULL;
aoqi@0 646 return;
aoqi@0 647 }
aoqi@0 648 while( new_max <= len ) new_max <<= 1; // Find next power-of-2
aoqi@0 649 // Trimming to limit allows a uint8 to handle up to 255 edges.
aoqi@0 650 // Previously I was using only powers-of-2 which peaked at 128 edges.
aoqi@0 651 //if( new_max >= limit ) new_max = limit-1;
aoqi@0 652 _in = (Node**)arena->Arealloc(_in, _max*sizeof(Node*), new_max*sizeof(Node*));
aoqi@0 653 Copy::zero_to_bytes(&_in[_max], (new_max-_max)*sizeof(Node*)); // NULL all new space
aoqi@0 654 _max = new_max; // Record new max length
aoqi@0 655 // This assertion makes sure that Node::_max is wide enough to
aoqi@0 656 // represent the numerical value of new_max.
aoqi@0 657 assert(_max == new_max && _max > len, "int width of _max is too small");
aoqi@0 658 }
aoqi@0 659
aoqi@0 660 //-----------------------------out_grow----------------------------------------
aoqi@0 661 // Grow the input array, making space for more edges
aoqi@0 662 void Node::out_grow( uint len ) {
aoqi@0 663 assert(!is_top(), "cannot grow a top node's out array");
aoqi@0 664 Arena* arena = Compile::current()->node_arena();
aoqi@0 665 uint new_max = _outmax;
aoqi@0 666 if( new_max == 0 ) {
aoqi@0 667 _outmax = 4;
aoqi@0 668 _out = (Node **)arena->Amalloc(4*sizeof(Node*));
aoqi@0 669 return;
aoqi@0 670 }
aoqi@0 671 while( new_max <= len ) new_max <<= 1; // Find next power-of-2
aoqi@0 672 // Trimming to limit allows a uint8 to handle up to 255 edges.
aoqi@0 673 // Previously I was using only powers-of-2 which peaked at 128 edges.
aoqi@0 674 //if( new_max >= limit ) new_max = limit-1;
aoqi@0 675 assert(_out != NULL && _out != NO_OUT_ARRAY, "out must have sensible value");
aoqi@0 676 _out = (Node**)arena->Arealloc(_out,_outmax*sizeof(Node*),new_max*sizeof(Node*));
aoqi@0 677 //Copy::zero_to_bytes(&_out[_outmax], (new_max-_outmax)*sizeof(Node*)); // NULL all new space
aoqi@0 678 _outmax = new_max; // Record new max length
aoqi@0 679 // This assertion makes sure that Node::_max is wide enough to
aoqi@0 680 // represent the numerical value of new_max.
aoqi@0 681 assert(_outmax == new_max && _outmax > len, "int width of _outmax is too small");
aoqi@0 682 }
aoqi@0 683
aoqi@0 684 #ifdef ASSERT
aoqi@0 685 //------------------------------is_dead----------------------------------------
aoqi@0 686 bool Node::is_dead() const {
aoqi@0 687 // Mach and pinch point nodes may look like dead.
aoqi@0 688 if( is_top() || is_Mach() || (Opcode() == Op_Node && _outcnt > 0) )
aoqi@0 689 return false;
aoqi@0 690 for( uint i = 0; i < _max; i++ )
aoqi@0 691 if( _in[i] != NULL )
aoqi@0 692 return false;
aoqi@0 693 dump();
aoqi@0 694 return true;
aoqi@0 695 }
aoqi@0 696 #endif
aoqi@0 697
aoqi@0 698
aoqi@0 699 //------------------------------is_unreachable---------------------------------
aoqi@0 700 bool Node::is_unreachable(PhaseIterGVN &igvn) const {
aoqi@0 701 assert(!is_Mach(), "doesn't work with MachNodes");
aoqi@0 702 return outcnt() == 0 || igvn.type(this) == Type::TOP || in(0)->is_top();
aoqi@0 703 }
aoqi@0 704
aoqi@0 705 //------------------------------add_req----------------------------------------
aoqi@0 706 // Add a new required input at the end
aoqi@0 707 void Node::add_req( Node *n ) {
aoqi@0 708 assert( is_not_dead(n), "can not use dead node");
aoqi@0 709
aoqi@0 710 // Look to see if I can move precedence down one without reallocating
aoqi@0 711 if( (_cnt >= _max) || (in(_max-1) != NULL) )
aoqi@0 712 grow( _max+1 );
aoqi@0 713
aoqi@0 714 // Find a precedence edge to move
aoqi@0 715 if( in(_cnt) != NULL ) { // Next precedence edge is busy?
aoqi@0 716 uint i;
aoqi@0 717 for( i=_cnt; i<_max; i++ )
aoqi@0 718 if( in(i) == NULL ) // Find the NULL at end of prec edge list
aoqi@0 719 break; // There must be one, since we grew the array
aoqi@0 720 _in[i] = in(_cnt); // Move prec over, making space for req edge
aoqi@0 721 }
aoqi@0 722 _in[_cnt++] = n; // Stuff over old prec edge
aoqi@0 723 if (n != NULL) n->add_out((Node *)this);
aoqi@0 724 }
aoqi@0 725
aoqi@0 726 //---------------------------add_req_batch-------------------------------------
aoqi@0 727 // Add a new required input at the end
aoqi@0 728 void Node::add_req_batch( Node *n, uint m ) {
aoqi@0 729 assert( is_not_dead(n), "can not use dead node");
aoqi@0 730 // check various edge cases
aoqi@0 731 if ((int)m <= 1) {
aoqi@0 732 assert((int)m >= 0, "oob");
aoqi@0 733 if (m != 0) add_req(n);
aoqi@0 734 return;
aoqi@0 735 }
aoqi@0 736
aoqi@0 737 // Look to see if I can move precedence down one without reallocating
aoqi@0 738 if( (_cnt+m) > _max || _in[_max-m] )
aoqi@0 739 grow( _max+m );
aoqi@0 740
aoqi@0 741 // Find a precedence edge to move
aoqi@0 742 if( _in[_cnt] != NULL ) { // Next precedence edge is busy?
aoqi@0 743 uint i;
aoqi@0 744 for( i=_cnt; i<_max; i++ )
aoqi@0 745 if( _in[i] == NULL ) // Find the NULL at end of prec edge list
aoqi@0 746 break; // There must be one, since we grew the array
aoqi@0 747 // Slide all the precs over by m positions (assume #prec << m).
aoqi@0 748 Copy::conjoint_words_to_higher((HeapWord*)&_in[_cnt], (HeapWord*)&_in[_cnt+m], ((i-_cnt)*sizeof(Node*)));
aoqi@0 749 }
aoqi@0 750
aoqi@0 751 // Stuff over the old prec edges
aoqi@0 752 for(uint i=0; i<m; i++ ) {
aoqi@0 753 _in[_cnt++] = n;
aoqi@0 754 }
aoqi@0 755
aoqi@0 756 // Insert multiple out edges on the node.
aoqi@0 757 if (n != NULL && !n->is_top()) {
aoqi@0 758 for(uint i=0; i<m; i++ ) {
aoqi@0 759 n->add_out((Node *)this);
aoqi@0 760 }
aoqi@0 761 }
aoqi@0 762 }
aoqi@0 763
aoqi@0 764 //------------------------------del_req----------------------------------------
aoqi@0 765 // Delete the required edge and compact the edge array
aoqi@0 766 void Node::del_req( uint idx ) {
aoqi@0 767 assert( idx < _cnt, "oob");
aoqi@0 768 assert( !VerifyHashTableKeys || _hash_lock == 0,
aoqi@0 769 "remove node from hash table before modifying it");
aoqi@0 770 // First remove corresponding def-use edge
aoqi@0 771 Node *n = in(idx);
aoqi@0 772 if (n != NULL) n->del_out((Node *)this);
aoqi@0 773 _in[idx] = in(--_cnt); // Compact the array
aoqi@0 774 _in[_cnt] = NULL; // NULL out emptied slot
aoqi@0 775 }
aoqi@0 776
aoqi@0 777 //------------------------------del_req_ordered--------------------------------
aoqi@0 778 // Delete the required edge and compact the edge array with preserved order
aoqi@0 779 void Node::del_req_ordered( uint idx ) {
aoqi@0 780 assert( idx < _cnt, "oob");
aoqi@0 781 assert( !VerifyHashTableKeys || _hash_lock == 0,
aoqi@0 782 "remove node from hash table before modifying it");
aoqi@0 783 // First remove corresponding def-use edge
aoqi@0 784 Node *n = in(idx);
aoqi@0 785 if (n != NULL) n->del_out((Node *)this);
aoqi@0 786 if (idx < _cnt - 1) { // Not last edge ?
aoqi@0 787 Copy::conjoint_words_to_lower((HeapWord*)&_in[idx+1], (HeapWord*)&_in[idx], ((_cnt-idx-1)*sizeof(Node*)));
aoqi@0 788 }
aoqi@0 789 _in[--_cnt] = NULL; // NULL out emptied slot
aoqi@0 790 }
aoqi@0 791
aoqi@0 792 //------------------------------ins_req----------------------------------------
aoqi@0 793 // Insert a new required input at the end
aoqi@0 794 void Node::ins_req( uint idx, Node *n ) {
aoqi@0 795 assert( is_not_dead(n), "can not use dead node");
aoqi@0 796 add_req(NULL); // Make space
aoqi@0 797 assert( idx < _max, "Must have allocated enough space");
aoqi@0 798 // Slide over
aoqi@0 799 if(_cnt-idx-1 > 0) {
aoqi@0 800 Copy::conjoint_words_to_higher((HeapWord*)&_in[idx], (HeapWord*)&_in[idx+1], ((_cnt-idx-1)*sizeof(Node*)));
aoqi@0 801 }
aoqi@0 802 _in[idx] = n; // Stuff over old required edge
aoqi@0 803 if (n != NULL) n->add_out((Node *)this); // Add reciprocal def-use edge
aoqi@0 804 }
aoqi@0 805
aoqi@0 806 //-----------------------------find_edge---------------------------------------
aoqi@0 807 int Node::find_edge(Node* n) {
aoqi@0 808 for (uint i = 0; i < len(); i++) {
aoqi@0 809 if (_in[i] == n) return i;
aoqi@0 810 }
aoqi@0 811 return -1;
aoqi@0 812 }
aoqi@0 813
aoqi@0 814 //----------------------------replace_edge-------------------------------------
aoqi@0 815 int Node::replace_edge(Node* old, Node* neww) {
aoqi@0 816 if (old == neww) return 0; // nothing to do
aoqi@0 817 uint nrep = 0;
aoqi@0 818 for (uint i = 0; i < len(); i++) {
aoqi@0 819 if (in(i) == old) {
aoqi@0 820 if (i < req())
aoqi@0 821 set_req(i, neww);
aoqi@0 822 else
aoqi@0 823 set_prec(i, neww);
aoqi@0 824 nrep++;
aoqi@0 825 }
aoqi@0 826 }
aoqi@0 827 return nrep;
aoqi@0 828 }
aoqi@0 829
aoqi@0 830 /**
aoqi@0 831 * Replace input edges in the range pointing to 'old' node.
aoqi@0 832 */
aoqi@0 833 int Node::replace_edges_in_range(Node* old, Node* neww, int start, int end) {
aoqi@0 834 if (old == neww) return 0; // nothing to do
aoqi@0 835 uint nrep = 0;
aoqi@0 836 for (int i = start; i < end; i++) {
aoqi@0 837 if (in(i) == old) {
aoqi@0 838 set_req(i, neww);
aoqi@0 839 nrep++;
aoqi@0 840 }
aoqi@0 841 }
aoqi@0 842 return nrep;
aoqi@0 843 }
aoqi@0 844
aoqi@0 845 //-------------------------disconnect_inputs-----------------------------------
aoqi@0 846 // NULL out all inputs to eliminate incoming Def-Use edges.
aoqi@0 847 // Return the number of edges between 'n' and 'this'
aoqi@0 848 int Node::disconnect_inputs(Node *n, Compile* C) {
aoqi@0 849 int edges_to_n = 0;
aoqi@0 850
aoqi@0 851 uint cnt = req();
aoqi@0 852 for( uint i = 0; i < cnt; ++i ) {
aoqi@0 853 if( in(i) == 0 ) continue;
aoqi@0 854 if( in(i) == n ) ++edges_to_n;
aoqi@0 855 set_req(i, NULL);
aoqi@0 856 }
aoqi@0 857 // Remove precedence edges if any exist
aoqi@0 858 // Note: Safepoints may have precedence edges, even during parsing
aoqi@0 859 if( (req() != len()) && (in(req()) != NULL) ) {
aoqi@0 860 uint max = len();
aoqi@0 861 for( uint i = 0; i < max; ++i ) {
aoqi@0 862 if( in(i) == 0 ) continue;
aoqi@0 863 if( in(i) == n ) ++edges_to_n;
aoqi@0 864 set_prec(i, NULL);
aoqi@0 865 }
aoqi@0 866 }
aoqi@0 867
aoqi@0 868 // Node::destruct requires all out edges be deleted first
aoqi@0 869 // debug_only(destruct();) // no reuse benefit expected
aoqi@0 870 if (edges_to_n == 0) {
aoqi@0 871 C->record_dead_node(_idx);
aoqi@0 872 }
aoqi@0 873 return edges_to_n;
aoqi@0 874 }
aoqi@0 875
aoqi@0 876 //-----------------------------uncast---------------------------------------
aoqi@0 877 // %%% Temporary, until we sort out CheckCastPP vs. CastPP.
aoqi@0 878 // Strip away casting. (It is depth-limited.)
aoqi@0 879 Node* Node::uncast() const {
aoqi@0 880 // Should be inline:
aoqi@0 881 //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
aoqi@0 882 if (is_ConstraintCast() || is_CheckCastPP())
aoqi@0 883 return uncast_helper(this);
aoqi@0 884 else
aoqi@0 885 return (Node*) this;
aoqi@0 886 }
aoqi@0 887
aoqi@0 888 //---------------------------uncast_helper-------------------------------------
aoqi@0 889 Node* Node::uncast_helper(const Node* p) {
aoqi@0 890 #ifdef ASSERT
aoqi@0 891 uint depth_count = 0;
aoqi@0 892 const Node* orig_p = p;
aoqi@0 893 #endif
aoqi@0 894
aoqi@0 895 while (true) {
aoqi@0 896 #ifdef ASSERT
aoqi@0 897 if (depth_count >= K) {
aoqi@0 898 orig_p->dump(4);
aoqi@0 899 if (p != orig_p)
aoqi@0 900 p->dump(1);
aoqi@0 901 }
aoqi@0 902 assert(depth_count++ < K, "infinite loop in Node::uncast_helper");
aoqi@0 903 #endif
aoqi@0 904 if (p == NULL || p->req() != 2) {
aoqi@0 905 break;
aoqi@0 906 } else if (p->is_ConstraintCast()) {
aoqi@0 907 p = p->in(1);
aoqi@0 908 } else if (p->is_CheckCastPP()) {
aoqi@0 909 p = p->in(1);
aoqi@0 910 } else {
aoqi@0 911 break;
aoqi@0 912 }
aoqi@0 913 }
aoqi@0 914 return (Node*) p;
aoqi@0 915 }
aoqi@0 916
aoqi@0 917 //------------------------------add_prec---------------------------------------
aoqi@0 918 // Add a new precedence input. Precedence inputs are unordered, with
aoqi@0 919 // duplicates removed and NULLs packed down at the end.
aoqi@0 920 void Node::add_prec( Node *n ) {
aoqi@0 921 assert( is_not_dead(n), "can not use dead node");
aoqi@0 922
aoqi@0 923 // Check for NULL at end
aoqi@0 924 if( _cnt >= _max || in(_max-1) )
aoqi@0 925 grow( _max+1 );
aoqi@0 926
aoqi@0 927 // Find a precedence edge to move
aoqi@0 928 uint i = _cnt;
aoqi@0 929 while( in(i) != NULL ) i++;
aoqi@0 930 _in[i] = n; // Stuff prec edge over NULL
aoqi@0 931 if ( n != NULL) n->add_out((Node *)this); // Add mirror edge
aoqi@0 932 }
aoqi@0 933
aoqi@0 934 //------------------------------rm_prec----------------------------------------
aoqi@0 935 // Remove a precedence input. Precedence inputs are unordered, with
aoqi@0 936 // duplicates removed and NULLs packed down at the end.
aoqi@0 937 void Node::rm_prec( uint j ) {
aoqi@0 938
aoqi@0 939 // Find end of precedence list to pack NULLs
aoqi@0 940 uint i;
aoqi@0 941 for( i=j; i<_max; i++ )
aoqi@0 942 if( !_in[i] ) // Find the NULL at end of prec edge list
aoqi@0 943 break;
aoqi@0 944 if (_in[j] != NULL) _in[j]->del_out((Node *)this);
aoqi@0 945 _in[j] = _in[--i]; // Move last element over removed guy
aoqi@0 946 _in[i] = NULL; // NULL out last element
aoqi@0 947 }
aoqi@0 948
aoqi@0 949 //------------------------------size_of----------------------------------------
aoqi@0 950 uint Node::size_of() const { return sizeof(*this); }
aoqi@0 951
aoqi@0 952 //------------------------------ideal_reg--------------------------------------
aoqi@0 953 uint Node::ideal_reg() const { return 0; }
aoqi@0 954
aoqi@0 955 //------------------------------jvms-------------------------------------------
aoqi@0 956 JVMState* Node::jvms() const { return NULL; }
aoqi@0 957
aoqi@0 958 #ifdef ASSERT
aoqi@0 959 //------------------------------jvms-------------------------------------------
aoqi@0 960 bool Node::verify_jvms(const JVMState* using_jvms) const {
aoqi@0 961 for (JVMState* jvms = this->jvms(); jvms != NULL; jvms = jvms->caller()) {
aoqi@0 962 if (jvms == using_jvms) return true;
aoqi@0 963 }
aoqi@0 964 return false;
aoqi@0 965 }
aoqi@0 966
aoqi@0 967 //------------------------------init_NodeProperty------------------------------
aoqi@0 968 void Node::init_NodeProperty() {
aoqi@0 969 assert(_max_classes <= max_jushort, "too many NodeProperty classes");
aoqi@0 970 assert(_max_flags <= max_jushort, "too many NodeProperty flags");
aoqi@0 971 }
aoqi@0 972 #endif
aoqi@0 973
aoqi@0 974 //------------------------------format-----------------------------------------
aoqi@0 975 // Print as assembly
aoqi@0 976 void Node::format( PhaseRegAlloc *, outputStream *st ) const {}
aoqi@0 977 //------------------------------emit-------------------------------------------
aoqi@0 978 // Emit bytes starting at parameter 'ptr'.
aoqi@0 979 void Node::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {}
aoqi@0 980 //------------------------------size-------------------------------------------
aoqi@0 981 // Size of instruction in bytes
aoqi@0 982 uint Node::size(PhaseRegAlloc *ra_) const { return 0; }
aoqi@0 983
aoqi@0 984 //------------------------------CFG Construction-------------------------------
aoqi@0 985 // Nodes that end basic blocks, e.g. IfTrue/IfFalse, JumpProjNode, Root,
aoqi@0 986 // Goto and Return.
aoqi@0 987 const Node *Node::is_block_proj() const { return 0; }
aoqi@0 988
aoqi@0 989 // Minimum guaranteed type
aoqi@0 990 const Type *Node::bottom_type() const { return Type::BOTTOM; }
aoqi@0 991
aoqi@0 992
aoqi@0 993 //------------------------------raise_bottom_type------------------------------
aoqi@0 994 // Get the worst-case Type output for this Node.
aoqi@0 995 void Node::raise_bottom_type(const Type* new_type) {
aoqi@0 996 if (is_Type()) {
aoqi@0 997 TypeNode *n = this->as_Type();
aoqi@0 998 if (VerifyAliases) {
aoqi@0 999 assert(new_type->higher_equal_speculative(n->type()), "new type must refine old type");
aoqi@0 1000 }
aoqi@0 1001 n->set_type(new_type);
aoqi@0 1002 } else if (is_Load()) {
aoqi@0 1003 LoadNode *n = this->as_Load();
aoqi@0 1004 if (VerifyAliases) {
aoqi@0 1005 assert(new_type->higher_equal_speculative(n->type()), "new type must refine old type");
aoqi@0 1006 }
aoqi@0 1007 n->set_type(new_type);
aoqi@0 1008 }
aoqi@0 1009 }
aoqi@0 1010
aoqi@0 1011 //------------------------------Identity---------------------------------------
aoqi@0 1012 // Return a node that the given node is equivalent to.
aoqi@0 1013 Node *Node::Identity( PhaseTransform * ) {
aoqi@0 1014 return this; // Default to no identities
aoqi@0 1015 }
aoqi@0 1016
aoqi@0 1017 //------------------------------Value------------------------------------------
aoqi@0 1018 // Compute a new Type for a node using the Type of the inputs.
aoqi@0 1019 const Type *Node::Value( PhaseTransform * ) const {
aoqi@0 1020 return bottom_type(); // Default to worst-case Type
aoqi@0 1021 }
aoqi@0 1022
aoqi@0 1023 //------------------------------Ideal------------------------------------------
aoqi@0 1024 //
aoqi@0 1025 // 'Idealize' the graph rooted at this Node.
aoqi@0 1026 //
aoqi@0 1027 // In order to be efficient and flexible there are some subtle invariants
aoqi@0 1028 // these Ideal calls need to hold. Running with '+VerifyIterativeGVN' checks
aoqi@0 1029 // these invariants, although its too slow to have on by default. If you are
aoqi@0 1030 // hacking an Ideal call, be sure to test with +VerifyIterativeGVN!
aoqi@0 1031 //
aoqi@0 1032 // The Ideal call almost arbitrarily reshape the graph rooted at the 'this'
aoqi@0 1033 // pointer. If ANY change is made, it must return the root of the reshaped
aoqi@0 1034 // graph - even if the root is the same Node. Example: swapping the inputs
aoqi@0 1035 // to an AddINode gives the same answer and same root, but you still have to
aoqi@0 1036 // return the 'this' pointer instead of NULL.
aoqi@0 1037 //
aoqi@0 1038 // You cannot return an OLD Node, except for the 'this' pointer. Use the
aoqi@0 1039 // Identity call to return an old Node; basically if Identity can find
aoqi@0 1040 // another Node have the Ideal call make no change and return NULL.
aoqi@0 1041 // Example: AddINode::Ideal must check for add of zero; in this case it
aoqi@0 1042 // returns NULL instead of doing any graph reshaping.
aoqi@0 1043 //
aoqi@0 1044 // You cannot modify any old Nodes except for the 'this' pointer. Due to
aoqi@0 1045 // sharing there may be other users of the old Nodes relying on their current
aoqi@0 1046 // semantics. Modifying them will break the other users.
aoqi@0 1047 // Example: when reshape "(X+3)+4" into "X+7" you must leave the Node for
aoqi@0 1048 // "X+3" unchanged in case it is shared.
aoqi@0 1049 //
aoqi@0 1050 // If you modify the 'this' pointer's inputs, you should use
aoqi@0 1051 // 'set_req'. If you are making a new Node (either as the new root or
aoqi@0 1052 // some new internal piece) you may use 'init_req' to set the initial
aoqi@0 1053 // value. You can make a new Node with either 'new' or 'clone'. In
aoqi@0 1054 // either case, def-use info is correctly maintained.
aoqi@0 1055 //
aoqi@0 1056 // Example: reshape "(X+3)+4" into "X+7":
aoqi@0 1057 // set_req(1, in(1)->in(1));
aoqi@0 1058 // set_req(2, phase->intcon(7));
aoqi@0 1059 // return this;
aoqi@0 1060 // Example: reshape "X*4" into "X<<2"
aoqi@0 1061 // return new (C) LShiftINode(in(1), phase->intcon(2));
aoqi@0 1062 //
aoqi@0 1063 // You must call 'phase->transform(X)' on any new Nodes X you make, except
aoqi@0 1064 // for the returned root node. Example: reshape "X*31" with "(X<<5)-X".
aoqi@0 1065 // Node *shift=phase->transform(new(C)LShiftINode(in(1),phase->intcon(5)));
aoqi@0 1066 // return new (C) AddINode(shift, in(1));
aoqi@0 1067 //
aoqi@0 1068 // When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
aoqi@0 1069 // These forms are faster than 'phase->transform(new (C) ConNode())' and Do
aoqi@0 1070 // The Right Thing with def-use info.
aoqi@0 1071 //
aoqi@0 1072 // You cannot bury the 'this' Node inside of a graph reshape. If the reshaped
aoqi@0 1073 // graph uses the 'this' Node it must be the root. If you want a Node with
aoqi@0 1074 // the same Opcode as the 'this' pointer use 'clone'.
aoqi@0 1075 //
aoqi@0 1076 Node *Node::Ideal(PhaseGVN *phase, bool can_reshape) {
aoqi@0 1077 return NULL; // Default to being Ideal already
aoqi@0 1078 }
aoqi@0 1079
aoqi@0 1080 // Some nodes have specific Ideal subgraph transformations only if they are
aoqi@0 1081 // unique users of specific nodes. Such nodes should be put on IGVN worklist
aoqi@0 1082 // for the transformations to happen.
aoqi@0 1083 bool Node::has_special_unique_user() const {
aoqi@0 1084 assert(outcnt() == 1, "match only for unique out");
aoqi@0 1085 Node* n = unique_out();
aoqi@0 1086 int op = Opcode();
aoqi@0 1087 if( this->is_Store() ) {
aoqi@0 1088 // Condition for back-to-back stores folding.
aoqi@0 1089 return n->Opcode() == op && n->in(MemNode::Memory) == this;
aoqi@0 1090 } else if( op == Op_AddL ) {
aoqi@0 1091 // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
aoqi@0 1092 return n->Opcode() == Op_ConvL2I && n->in(1) == this;
aoqi@0 1093 } else if( op == Op_SubI || op == Op_SubL ) {
aoqi@0 1094 // Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
aoqi@0 1095 return n->Opcode() == op && n->in(2) == this;
aoqi@0 1096 }
aoqi@0 1097 return false;
aoqi@0 1098 };
aoqi@0 1099
aoqi@0 1100 //--------------------------find_exact_control---------------------------------
aoqi@0 1101 // Skip Proj and CatchProj nodes chains. Check for Null and Top.
aoqi@0 1102 Node* Node::find_exact_control(Node* ctrl) {
aoqi@0 1103 if (ctrl == NULL && this->is_Region())
aoqi@0 1104 ctrl = this->as_Region()->is_copy();
aoqi@0 1105
aoqi@0 1106 if (ctrl != NULL && ctrl->is_CatchProj()) {
aoqi@0 1107 if (ctrl->as_CatchProj()->_con == CatchProjNode::fall_through_index)
aoqi@0 1108 ctrl = ctrl->in(0);
aoqi@0 1109 if (ctrl != NULL && !ctrl->is_top())
aoqi@0 1110 ctrl = ctrl->in(0);
aoqi@0 1111 }
aoqi@0 1112
aoqi@0 1113 if (ctrl != NULL && ctrl->is_Proj())
aoqi@0 1114 ctrl = ctrl->in(0);
aoqi@0 1115
aoqi@0 1116 return ctrl;
aoqi@0 1117 }
aoqi@0 1118
aoqi@0 1119 //--------------------------dominates------------------------------------------
aoqi@0 1120 // Helper function for MemNode::all_controls_dominate().
aoqi@0 1121 // Check if 'this' control node dominates or equal to 'sub' control node.
aoqi@0 1122 // We already know that if any path back to Root or Start reaches 'this',
aoqi@0 1123 // then all paths so, so this is a simple search for one example,
aoqi@0 1124 // not an exhaustive search for a counterexample.
aoqi@0 1125 bool Node::dominates(Node* sub, Node_List &nlist) {
aoqi@0 1126 assert(this->is_CFG(), "expecting control");
aoqi@0 1127 assert(sub != NULL && sub->is_CFG(), "expecting control");
aoqi@0 1128
aoqi@0 1129 // detect dead cycle without regions
aoqi@0 1130 int iterations_without_region_limit = DominatorSearchLimit;
aoqi@0 1131
aoqi@0 1132 Node* orig_sub = sub;
aoqi@0 1133 Node* dom = this;
aoqi@0 1134 bool met_dom = false;
aoqi@0 1135 nlist.clear();
aoqi@0 1136
aoqi@0 1137 // Walk 'sub' backward up the chain to 'dom', watching for regions.
aoqi@0 1138 // After seeing 'dom', continue up to Root or Start.
aoqi@0 1139 // If we hit a region (backward split point), it may be a loop head.
aoqi@0 1140 // Keep going through one of the region's inputs. If we reach the
aoqi@0 1141 // same region again, go through a different input. Eventually we
aoqi@0 1142 // will either exit through the loop head, or give up.
aoqi@0 1143 // (If we get confused, break out and return a conservative 'false'.)
aoqi@0 1144 while (sub != NULL) {
aoqi@0 1145 if (sub->is_top()) break; // Conservative answer for dead code.
aoqi@0 1146 if (sub == dom) {
aoqi@0 1147 if (nlist.size() == 0) {
aoqi@0 1148 // No Region nodes except loops were visited before and the EntryControl
aoqi@0 1149 // path was taken for loops: it did not walk in a cycle.
aoqi@0 1150 return true;
aoqi@0 1151 } else if (met_dom) {
aoqi@0 1152 break; // already met before: walk in a cycle
aoqi@0 1153 } else {
aoqi@0 1154 // Region nodes were visited. Continue walk up to Start or Root
aoqi@0 1155 // to make sure that it did not walk in a cycle.
aoqi@0 1156 met_dom = true; // first time meet
aoqi@0 1157 iterations_without_region_limit = DominatorSearchLimit; // Reset
aoqi@0 1158 }
aoqi@0 1159 }
aoqi@0 1160 if (sub->is_Start() || sub->is_Root()) {
aoqi@0 1161 // Success if we met 'dom' along a path to Start or Root.
aoqi@0 1162 // We assume there are no alternative paths that avoid 'dom'.
aoqi@0 1163 // (This assumption is up to the caller to ensure!)
aoqi@0 1164 return met_dom;
aoqi@0 1165 }
aoqi@0 1166 Node* up = sub->in(0);
aoqi@0 1167 // Normalize simple pass-through regions and projections:
aoqi@0 1168 up = sub->find_exact_control(up);
aoqi@0 1169 // If sub == up, we found a self-loop. Try to push past it.
aoqi@0 1170 if (sub == up && sub->is_Loop()) {
aoqi@0 1171 // Take loop entry path on the way up to 'dom'.
aoqi@0 1172 up = sub->in(1); // in(LoopNode::EntryControl);
aoqi@0 1173 } else if (sub == up && sub->is_Region() && sub->req() != 3) {
aoqi@0 1174 // Always take in(1) path on the way up to 'dom' for clone regions
aoqi@0 1175 // (with only one input) or regions which merge > 2 paths
aoqi@0 1176 // (usually used to merge fast/slow paths).
aoqi@0 1177 up = sub->in(1);
aoqi@0 1178 } else if (sub == up && sub->is_Region()) {
aoqi@0 1179 // Try both paths for Regions with 2 input paths (it may be a loop head).
aoqi@0 1180 // It could give conservative 'false' answer without information
aoqi@0 1181 // which region's input is the entry path.
aoqi@0 1182 iterations_without_region_limit = DominatorSearchLimit; // Reset
aoqi@0 1183
aoqi@0 1184 bool region_was_visited_before = false;
aoqi@0 1185 // Was this Region node visited before?
aoqi@0 1186 // If so, we have reached it because we accidentally took a
aoqi@0 1187 // loop-back edge from 'sub' back into the body of the loop,
aoqi@0 1188 // and worked our way up again to the loop header 'sub'.
aoqi@0 1189 // So, take the first unexplored path on the way up to 'dom'.
aoqi@0 1190 for (int j = nlist.size() - 1; j >= 0; j--) {
aoqi@0 1191 intptr_t ni = (intptr_t)nlist.at(j);
aoqi@0 1192 Node* visited = (Node*)(ni & ~1);
aoqi@0 1193 bool visited_twice_already = ((ni & 1) != 0);
aoqi@0 1194 if (visited == sub) {
aoqi@0 1195 if (visited_twice_already) {
aoqi@0 1196 // Visited 2 paths, but still stuck in loop body. Give up.
aoqi@0 1197 return false;
aoqi@0 1198 }
aoqi@0 1199 // The Region node was visited before only once.
aoqi@0 1200 // (We will repush with the low bit set, below.)
aoqi@0 1201 nlist.remove(j);
aoqi@0 1202 // We will find a new edge and re-insert.
aoqi@0 1203 region_was_visited_before = true;
aoqi@0 1204 break;
aoqi@0 1205 }
aoqi@0 1206 }
aoqi@0 1207
aoqi@0 1208 // Find an incoming edge which has not been seen yet; walk through it.
aoqi@0 1209 assert(up == sub, "");
aoqi@0 1210 uint skip = region_was_visited_before ? 1 : 0;
aoqi@0 1211 for (uint i = 1; i < sub->req(); i++) {
aoqi@0 1212 Node* in = sub->in(i);
aoqi@0 1213 if (in != NULL && !in->is_top() && in != sub) {
aoqi@0 1214 if (skip == 0) {
aoqi@0 1215 up = in;
aoqi@0 1216 break;
aoqi@0 1217 }
aoqi@0 1218 --skip; // skip this nontrivial input
aoqi@0 1219 }
aoqi@0 1220 }
aoqi@0 1221
aoqi@0 1222 // Set 0 bit to indicate that both paths were taken.
aoqi@0 1223 nlist.push((Node*)((intptr_t)sub + (region_was_visited_before ? 1 : 0)));
aoqi@0 1224 }
aoqi@0 1225
aoqi@0 1226 if (up == sub) {
aoqi@0 1227 break; // some kind of tight cycle
aoqi@0 1228 }
aoqi@0 1229 if (up == orig_sub && met_dom) {
aoqi@0 1230 // returned back after visiting 'dom'
aoqi@0 1231 break; // some kind of cycle
aoqi@0 1232 }
aoqi@0 1233 if (--iterations_without_region_limit < 0) {
aoqi@0 1234 break; // dead cycle
aoqi@0 1235 }
aoqi@0 1236 sub = up;
aoqi@0 1237 }
aoqi@0 1238
aoqi@0 1239 // Did not meet Root or Start node in pred. chain.
aoqi@0 1240 // Conservative answer for dead code.
aoqi@0 1241 return false;
aoqi@0 1242 }
aoqi@0 1243
aoqi@0 1244 //------------------------------remove_dead_region-----------------------------
aoqi@0 1245 // This control node is dead. Follow the subgraph below it making everything
aoqi@0 1246 // using it dead as well. This will happen normally via the usual IterGVN
aoqi@0 1247 // worklist but this call is more efficient. Do not update use-def info
aoqi@0 1248 // inside the dead region, just at the borders.
aoqi@0 1249 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
aoqi@0 1250 // Con's are a popular node to re-hit in the hash table again.
aoqi@0 1251 if( dead->is_Con() ) return;
aoqi@0 1252
aoqi@0 1253 // Can't put ResourceMark here since igvn->_worklist uses the same arena
aoqi@0 1254 // for verify pass with +VerifyOpto and we add/remove elements in it here.
aoqi@0 1255 Node_List nstack(Thread::current()->resource_area());
aoqi@0 1256
aoqi@0 1257 Node *top = igvn->C->top();
aoqi@0 1258 nstack.push(dead);
aoqi@0 1259 bool has_irreducible_loop = igvn->C->has_irreducible_loop();
aoqi@0 1260
aoqi@0 1261 while (nstack.size() > 0) {
aoqi@0 1262 dead = nstack.pop();
aoqi@0 1263 if (dead->outcnt() > 0) {
aoqi@0 1264 // Keep dead node on stack until all uses are processed.
aoqi@0 1265 nstack.push(dead);
aoqi@0 1266 // For all Users of the Dead... ;-)
aoqi@0 1267 for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
aoqi@0 1268 Node* use = dead->last_out(k);
aoqi@0 1269 igvn->hash_delete(use); // Yank from hash table prior to mod
aoqi@0 1270 if (use->in(0) == dead) { // Found another dead node
aoqi@0 1271 assert (!use->is_Con(), "Control for Con node should be Root node.");
aoqi@0 1272 use->set_req(0, top); // Cut dead edge to prevent processing
aoqi@0 1273 nstack.push(use); // the dead node again.
aoqi@0 1274 } else if (!has_irreducible_loop && // Backedge could be alive in irreducible loop
aoqi@0 1275 use->is_Loop() && !use->is_Root() && // Don't kill Root (RootNode extends LoopNode)
aoqi@0 1276 use->in(LoopNode::EntryControl) == dead) { // Dead loop if its entry is dead
aoqi@0 1277 use->set_req(LoopNode::EntryControl, top); // Cut dead edge to prevent processing
aoqi@0 1278 use->set_req(0, top); // Cut self edge
aoqi@0 1279 nstack.push(use);
aoqi@0 1280 } else { // Else found a not-dead user
aoqi@0 1281 // Dead if all inputs are top or null
aoqi@0 1282 bool dead_use = !use->is_Root(); // Keep empty graph alive
aoqi@0 1283 for (uint j = 1; j < use->req(); j++) {
aoqi@0 1284 Node* in = use->in(j);
aoqi@0 1285 if (in == dead) { // Turn all dead inputs into TOP
aoqi@0 1286 use->set_req(j, top);
aoqi@0 1287 } else if (in != NULL && !in->is_top()) {
aoqi@0 1288 dead_use = false;
aoqi@0 1289 }
aoqi@0 1290 }
aoqi@0 1291 if (dead_use) {
aoqi@0 1292 if (use->is_Region()) {
aoqi@0 1293 use->set_req(0, top); // Cut self edge
aoqi@0 1294 }
aoqi@0 1295 nstack.push(use);
aoqi@0 1296 } else {
aoqi@0 1297 igvn->_worklist.push(use);
aoqi@0 1298 }
aoqi@0 1299 }
aoqi@0 1300 // Refresh the iterator, since any number of kills might have happened.
aoqi@0 1301 k = dead->last_outs(kmin);
aoqi@0 1302 }
aoqi@0 1303 } else { // (dead->outcnt() == 0)
aoqi@0 1304 // Done with outputs.
aoqi@0 1305 igvn->hash_delete(dead);
aoqi@0 1306 igvn->_worklist.remove(dead);
aoqi@0 1307 igvn->set_type(dead, Type::TOP);
aoqi@0 1308 if (dead->is_macro()) {
aoqi@0 1309 igvn->C->remove_macro_node(dead);
aoqi@0 1310 }
aoqi@0 1311 if (dead->is_expensive()) {
aoqi@0 1312 igvn->C->remove_expensive_node(dead);
aoqi@0 1313 }
aoqi@0 1314 igvn->C->record_dead_node(dead->_idx);
aoqi@0 1315 // Kill all inputs to the dead guy
aoqi@0 1316 for (uint i=0; i < dead->req(); i++) {
aoqi@0 1317 Node *n = dead->in(i); // Get input to dead guy
aoqi@0 1318 if (n != NULL && !n->is_top()) { // Input is valid?
aoqi@0 1319 dead->set_req(i, top); // Smash input away
aoqi@0 1320 if (n->outcnt() == 0) { // Input also goes dead?
aoqi@0 1321 if (!n->is_Con())
aoqi@0 1322 nstack.push(n); // Clear it out as well
aoqi@0 1323 } else if (n->outcnt() == 1 &&
aoqi@0 1324 n->has_special_unique_user()) {
aoqi@0 1325 igvn->add_users_to_worklist( n );
aoqi@0 1326 } else if (n->outcnt() <= 2 && n->is_Store()) {
aoqi@0 1327 // Push store's uses on worklist to enable folding optimization for
aoqi@0 1328 // store/store and store/load to the same address.
aoqi@0 1329 // The restriction (outcnt() <= 2) is the same as in set_req_X()
aoqi@0 1330 // and remove_globally_dead_node().
aoqi@0 1331 igvn->add_users_to_worklist( n );
aoqi@0 1332 }
aoqi@0 1333 }
aoqi@0 1334 }
aoqi@0 1335 } // (dead->outcnt() == 0)
aoqi@0 1336 } // while (nstack.size() > 0) for outputs
aoqi@0 1337 return;
aoqi@0 1338 }
aoqi@0 1339
aoqi@0 1340 //------------------------------remove_dead_region-----------------------------
aoqi@0 1341 bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
aoqi@0 1342 Node *n = in(0);
aoqi@0 1343 if( !n ) return false;
aoqi@0 1344 // Lost control into this guy? I.e., it became unreachable?
aoqi@0 1345 // Aggressively kill all unreachable code.
aoqi@0 1346 if (can_reshape && n->is_top()) {
aoqi@0 1347 kill_dead_code(this, phase->is_IterGVN());
aoqi@0 1348 return false; // Node is dead.
aoqi@0 1349 }
aoqi@0 1350
aoqi@0 1351 if( n->is_Region() && n->as_Region()->is_copy() ) {
aoqi@0 1352 Node *m = n->nonnull_req();
aoqi@0 1353 set_req(0, m);
aoqi@0 1354 return true;
aoqi@0 1355 }
aoqi@0 1356 return false;
aoqi@0 1357 }
aoqi@0 1358
aoqi@0 1359 //------------------------------Ideal_DU_postCCP-------------------------------
aoqi@0 1360 // Idealize graph, using DU info. Must clone result into new-space
aoqi@0 1361 Node *Node::Ideal_DU_postCCP( PhaseCCP * ) {
aoqi@0 1362 return NULL; // Default to no change
aoqi@0 1363 }
aoqi@0 1364
aoqi@0 1365 //------------------------------hash-------------------------------------------
aoqi@0 1366 // Hash function over Nodes.
aoqi@0 1367 uint Node::hash() const {
aoqi@0 1368 uint sum = 0;
aoqi@0 1369 for( uint i=0; i<_cnt; i++ ) // Add in all inputs
aoqi@0 1370 sum = (sum<<1)-(uintptr_t)in(i); // Ignore embedded NULLs
aoqi@0 1371 return (sum>>2) + _cnt + Opcode();
aoqi@0 1372 }
aoqi@0 1373
aoqi@0 1374 //------------------------------cmp--------------------------------------------
aoqi@0 1375 // Compare special parts of simple Nodes
aoqi@0 1376 uint Node::cmp( const Node &n ) const {
aoqi@0 1377 return 1; // Must be same
aoqi@0 1378 }
aoqi@0 1379
aoqi@0 1380 //------------------------------rematerialize-----------------------------------
aoqi@0 1381 // Should we clone rather than spill this instruction?
aoqi@0 1382 bool Node::rematerialize() const {
aoqi@0 1383 if ( is_Mach() )
aoqi@0 1384 return this->as_Mach()->rematerialize();
aoqi@0 1385 else
aoqi@0 1386 return (_flags & Flag_rematerialize) != 0;
aoqi@0 1387 }
aoqi@0 1388
aoqi@0 1389 //------------------------------needs_anti_dependence_check---------------------
aoqi@0 1390 // Nodes which use memory without consuming it, hence need antidependences.
aoqi@0 1391 bool Node::needs_anti_dependence_check() const {
aoqi@0 1392 if( req() < 2 || (_flags & Flag_needs_anti_dependence_check) == 0 )
aoqi@0 1393 return false;
aoqi@0 1394 else
aoqi@0 1395 return in(1)->bottom_type()->has_memory();
aoqi@0 1396 }
aoqi@0 1397
aoqi@0 1398
aoqi@0 1399 // Get an integer constant from a ConNode (or CastIINode).
aoqi@0 1400 // Return a default value if there is no apparent constant here.
aoqi@0 1401 const TypeInt* Node::find_int_type() const {
aoqi@0 1402 if (this->is_Type()) {
aoqi@0 1403 return this->as_Type()->type()->isa_int();
aoqi@0 1404 } else if (this->is_Con()) {
aoqi@0 1405 assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode");
aoqi@0 1406 return this->bottom_type()->isa_int();
aoqi@0 1407 }
aoqi@0 1408 return NULL;
aoqi@0 1409 }
aoqi@0 1410
aoqi@0 1411 // Get a pointer constant from a ConstNode.
aoqi@0 1412 // Returns the constant if it is a pointer ConstNode
aoqi@0 1413 intptr_t Node::get_ptr() const {
aoqi@0 1414 assert( Opcode() == Op_ConP, "" );
aoqi@0 1415 return ((ConPNode*)this)->type()->is_ptr()->get_con();
aoqi@0 1416 }
aoqi@0 1417
aoqi@0 1418 // Get a narrow oop constant from a ConNNode.
aoqi@0 1419 intptr_t Node::get_narrowcon() const {
aoqi@0 1420 assert( Opcode() == Op_ConN, "" );
aoqi@0 1421 return ((ConNNode*)this)->type()->is_narrowoop()->get_con();
aoqi@0 1422 }
aoqi@0 1423
aoqi@0 1424 // Get a long constant from a ConNode.
aoqi@0 1425 // Return a default value if there is no apparent constant here.
aoqi@0 1426 const TypeLong* Node::find_long_type() const {
aoqi@0 1427 if (this->is_Type()) {
aoqi@0 1428 return this->as_Type()->type()->isa_long();
aoqi@0 1429 } else if (this->is_Con()) {
aoqi@0 1430 assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode");
aoqi@0 1431 return this->bottom_type()->isa_long();
aoqi@0 1432 }
aoqi@0 1433 return NULL;
aoqi@0 1434 }
aoqi@0 1435
aoqi@0 1436
aoqi@0 1437 /**
aoqi@0 1438 * Return a ptr type for nodes which should have it.
aoqi@0 1439 */
aoqi@0 1440 const TypePtr* Node::get_ptr_type() const {
aoqi@0 1441 const TypePtr* tp = this->bottom_type()->make_ptr();
aoqi@0 1442 #ifdef ASSERT
aoqi@0 1443 if (tp == NULL) {
aoqi@0 1444 this->dump(1);
aoqi@0 1445 assert((tp != NULL), "unexpected node type");
aoqi@0 1446 }
aoqi@0 1447 #endif
aoqi@0 1448 return tp;
aoqi@0 1449 }
aoqi@0 1450
aoqi@0 1451 // Get a double constant from a ConstNode.
aoqi@0 1452 // Returns the constant if it is a double ConstNode
aoqi@0 1453 jdouble Node::getd() const {
aoqi@0 1454 assert( Opcode() == Op_ConD, "" );
aoqi@0 1455 return ((ConDNode*)this)->type()->is_double_constant()->getd();
aoqi@0 1456 }
aoqi@0 1457
aoqi@0 1458 // Get a float constant from a ConstNode.
aoqi@0 1459 // Returns the constant if it is a float ConstNode
aoqi@0 1460 jfloat Node::getf() const {
aoqi@0 1461 assert( Opcode() == Op_ConF, "" );
aoqi@0 1462 return ((ConFNode*)this)->type()->is_float_constant()->getf();
aoqi@0 1463 }
aoqi@0 1464
aoqi@0 1465 #ifndef PRODUCT
aoqi@0 1466
aoqi@0 1467 //----------------------------NotANode----------------------------------------
aoqi@0 1468 // Used in debugging code to avoid walking across dead or uninitialized edges.
aoqi@0 1469 static inline bool NotANode(const Node* n) {
aoqi@0 1470 if (n == NULL) return true;
aoqi@0 1471 if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc.
aoqi@0 1472 if (*(address*)n == badAddress) return true; // kill by Node::destruct
aoqi@0 1473 return false;
aoqi@0 1474 }
aoqi@0 1475
aoqi@0 1476
aoqi@0 1477 //------------------------------find------------------------------------------
aoqi@0 1478 // Find a neighbor of this Node with the given _idx
aoqi@0 1479 // If idx is negative, find its absolute value, following both _in and _out.
aoqi@0 1480 static void find_recur(Compile* C, Node* &result, Node *n, int idx, bool only_ctrl,
aoqi@0 1481 VectorSet* old_space, VectorSet* new_space ) {
aoqi@0 1482 int node_idx = (idx >= 0) ? idx : -idx;
aoqi@0 1483 if (NotANode(n)) return; // Gracefully handle NULL, -1, 0xabababab, etc.
aoqi@0 1484 // Contained in new_space or old_space? Check old_arena first since it's mostly empty.
aoqi@0 1485 VectorSet *v = C->old_arena()->contains(n) ? old_space : new_space;
aoqi@0 1486 if( v->test(n->_idx) ) return;
aoqi@0 1487 if( (int)n->_idx == node_idx
aoqi@0 1488 debug_only(|| n->debug_idx() == node_idx) ) {
aoqi@0 1489 if (result != NULL)
aoqi@0 1490 tty->print("find: " INTPTR_FORMAT " and " INTPTR_FORMAT " both have idx==%d\n",
aoqi@0 1491 (uintptr_t)result, (uintptr_t)n, node_idx);
aoqi@0 1492 result = n;
aoqi@0 1493 }
aoqi@0 1494 v->set(n->_idx);
aoqi@0 1495 for( uint i=0; i<n->len(); i++ ) {
aoqi@0 1496 if( only_ctrl && !(n->is_Region()) && (n->Opcode() != Op_Root) && (i != TypeFunc::Control) ) continue;
aoqi@0 1497 find_recur(C, result, n->in(i), idx, only_ctrl, old_space, new_space );
aoqi@0 1498 }
aoqi@0 1499 // Search along forward edges also:
aoqi@0 1500 if (idx < 0 && !only_ctrl) {
aoqi@0 1501 for( uint j=0; j<n->outcnt(); j++ ) {
aoqi@0 1502 find_recur(C, result, n->raw_out(j), idx, only_ctrl, old_space, new_space );
aoqi@0 1503 }
aoqi@0 1504 }
aoqi@0 1505 #ifdef ASSERT
aoqi@0 1506 // Search along debug_orig edges last, checking for cycles
aoqi@0 1507 Node* orig = n->debug_orig();
aoqi@0 1508 if (orig != NULL) {
aoqi@0 1509 do {
aoqi@0 1510 if (NotANode(orig)) break;
aoqi@0 1511 find_recur(C, result, orig, idx, only_ctrl, old_space, new_space );
aoqi@0 1512 orig = orig->debug_orig();
aoqi@0 1513 } while (orig != NULL && orig != n->debug_orig());
aoqi@0 1514 }
aoqi@0 1515 #endif //ASSERT
aoqi@0 1516 }
aoqi@0 1517
aoqi@0 1518 // call this from debugger:
aoqi@0 1519 Node* find_node(Node* n, int idx) {
aoqi@0 1520 return n->find(idx);
aoqi@0 1521 }
aoqi@0 1522
aoqi@0 1523 //------------------------------find-------------------------------------------
aoqi@0 1524 Node* Node::find(int idx) const {
aoqi@0 1525 ResourceArea *area = Thread::current()->resource_area();
aoqi@0 1526 VectorSet old_space(area), new_space(area);
aoqi@0 1527 Node* result = NULL;
aoqi@0 1528 find_recur(Compile::current(), result, (Node*) this, idx, false, &old_space, &new_space );
aoqi@0 1529 return result;
aoqi@0 1530 }
aoqi@0 1531
aoqi@0 1532 //------------------------------find_ctrl--------------------------------------
aoqi@0 1533 // Find an ancestor to this node in the control history with given _idx
aoqi@0 1534 Node* Node::find_ctrl(int idx) const {
aoqi@0 1535 ResourceArea *area = Thread::current()->resource_area();
aoqi@0 1536 VectorSet old_space(area), new_space(area);
aoqi@0 1537 Node* result = NULL;
aoqi@0 1538 find_recur(Compile::current(), result, (Node*) this, idx, true, &old_space, &new_space );
aoqi@0 1539 return result;
aoqi@0 1540 }
aoqi@0 1541 #endif
aoqi@0 1542
aoqi@0 1543
aoqi@0 1544
aoqi@0 1545 #ifndef PRODUCT
aoqi@0 1546
aoqi@0 1547 // -----------------------------Name-------------------------------------------
aoqi@0 1548 extern const char *NodeClassNames[];
aoqi@0 1549 const char *Node::Name() const { return NodeClassNames[Opcode()]; }
aoqi@0 1550
aoqi@0 1551 static bool is_disconnected(const Node* n) {
aoqi@0 1552 for (uint i = 0; i < n->req(); i++) {
aoqi@0 1553 if (n->in(i) != NULL) return false;
aoqi@0 1554 }
aoqi@0 1555 return true;
aoqi@0 1556 }
aoqi@0 1557
aoqi@0 1558 #ifdef ASSERT
aoqi@0 1559 static void dump_orig(Node* orig, outputStream *st) {
aoqi@0 1560 Compile* C = Compile::current();
aoqi@0 1561 if (NotANode(orig)) orig = NULL;
aoqi@0 1562 if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
aoqi@0 1563 if (orig == NULL) return;
aoqi@0 1564 st->print(" !orig=");
aoqi@0 1565 Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops
aoqi@0 1566 if (NotANode(fast)) fast = NULL;
aoqi@0 1567 while (orig != NULL) {
aoqi@0 1568 bool discon = is_disconnected(orig); // if discon, print [123] else 123
aoqi@0 1569 if (discon) st->print("[");
aoqi@0 1570 if (!Compile::current()->node_arena()->contains(orig))
aoqi@0 1571 st->print("o");
aoqi@0 1572 st->print("%d", orig->_idx);
aoqi@0 1573 if (discon) st->print("]");
aoqi@0 1574 orig = orig->debug_orig();
aoqi@0 1575 if (NotANode(orig)) orig = NULL;
aoqi@0 1576 if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
aoqi@0 1577 if (orig != NULL) st->print(",");
aoqi@0 1578 if (fast != NULL) {
aoqi@0 1579 // Step fast twice for each single step of orig:
aoqi@0 1580 fast = fast->debug_orig();
aoqi@0 1581 if (NotANode(fast)) fast = NULL;
aoqi@0 1582 if (fast != NULL && fast != orig) {
aoqi@0 1583 fast = fast->debug_orig();
aoqi@0 1584 if (NotANode(fast)) fast = NULL;
aoqi@0 1585 }
aoqi@0 1586 if (fast == orig) {
aoqi@0 1587 st->print("...");
aoqi@0 1588 break;
aoqi@0 1589 }
aoqi@0 1590 }
aoqi@0 1591 }
aoqi@0 1592 }
aoqi@0 1593
aoqi@0 1594 void Node::set_debug_orig(Node* orig) {
aoqi@0 1595 _debug_orig = orig;
aoqi@0 1596 if (BreakAtNode == 0) return;
aoqi@0 1597 if (NotANode(orig)) orig = NULL;
aoqi@0 1598 int trip = 10;
aoqi@0 1599 while (orig != NULL) {
aoqi@0 1600 if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
aoqi@0 1601 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d orig._idx=%d orig._debug_idx=%d",
aoqi@0 1602 this->_idx, this->debug_idx(), orig->_idx, orig->debug_idx());
aoqi@0 1603 BREAKPOINT;
aoqi@0 1604 }
aoqi@0 1605 orig = orig->debug_orig();
aoqi@0 1606 if (NotANode(orig)) orig = NULL;
aoqi@0 1607 if (trip-- <= 0) break;
aoqi@0 1608 }
aoqi@0 1609 }
aoqi@0 1610 #endif //ASSERT
aoqi@0 1611
aoqi@0 1612 //------------------------------dump------------------------------------------
aoqi@0 1613 // Dump a Node
aoqi@0 1614 void Node::dump(const char* suffix, outputStream *st) const {
aoqi@0 1615 Compile* C = Compile::current();
aoqi@0 1616 bool is_new = C->node_arena()->contains(this);
aoqi@0 1617 C->_in_dump_cnt++;
aoqi@0 1618 st->print("%c%d\t%s\t=== ", is_new ? ' ' : 'o', _idx, Name());
aoqi@0 1619
aoqi@0 1620 // Dump the required and precedence inputs
aoqi@0 1621 dump_req(st);
aoqi@0 1622 dump_prec(st);
aoqi@0 1623 // Dump the outputs
aoqi@0 1624 dump_out(st);
aoqi@0 1625
aoqi@0 1626 if (is_disconnected(this)) {
aoqi@0 1627 #ifdef ASSERT
aoqi@0 1628 st->print(" [%d]",debug_idx());
aoqi@0 1629 dump_orig(debug_orig(), st);
aoqi@0 1630 #endif
aoqi@0 1631 st->cr();
aoqi@0 1632 C->_in_dump_cnt--;
aoqi@0 1633 return; // don't process dead nodes
aoqi@0 1634 }
aoqi@0 1635
aoqi@0 1636 // Dump node-specific info
aoqi@0 1637 dump_spec(st);
aoqi@0 1638 #ifdef ASSERT
aoqi@0 1639 // Dump the non-reset _debug_idx
aoqi@0 1640 if (Verbose && WizardMode) {
aoqi@0 1641 st->print(" [%d]",debug_idx());
aoqi@0 1642 }
aoqi@0 1643 #endif
aoqi@0 1644
aoqi@0 1645 const Type *t = bottom_type();
aoqi@0 1646
aoqi@0 1647 if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
aoqi@0 1648 const TypeInstPtr *toop = t->isa_instptr();
aoqi@0 1649 const TypeKlassPtr *tkls = t->isa_klassptr();
aoqi@0 1650 ciKlass* klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
aoqi@0 1651 if (klass && klass->is_loaded() && klass->is_interface()) {
aoqi@0 1652 st->print(" Interface:");
aoqi@0 1653 } else if (toop) {
aoqi@0 1654 st->print(" Oop:");
aoqi@0 1655 } else if (tkls) {
aoqi@0 1656 st->print(" Klass:");
aoqi@0 1657 }
aoqi@0 1658 t->dump_on(st);
aoqi@0 1659 } else if (t == Type::MEMORY) {
aoqi@0 1660 st->print(" Memory:");
aoqi@0 1661 MemNode::dump_adr_type(this, adr_type(), st);
aoqi@0 1662 } else if (Verbose || WizardMode) {
aoqi@0 1663 st->print(" Type:");
aoqi@0 1664 if (t) {
aoqi@0 1665 t->dump_on(st);
aoqi@0 1666 } else {
aoqi@0 1667 st->print("no type");
aoqi@0 1668 }
aoqi@0 1669 } else if (t->isa_vect() && this->is_MachSpillCopy()) {
aoqi@0 1670 // Dump MachSpillcopy vector type.
aoqi@0 1671 t->dump_on(st);
aoqi@0 1672 }
aoqi@0 1673 if (is_new) {
aoqi@0 1674 debug_only(dump_orig(debug_orig(), st));
aoqi@0 1675 Node_Notes* nn = C->node_notes_at(_idx);
aoqi@0 1676 if (nn != NULL && !nn->is_clear()) {
aoqi@0 1677 if (nn->jvms() != NULL) {
aoqi@0 1678 st->print(" !jvms:");
aoqi@0 1679 nn->jvms()->dump_spec(st);
aoqi@0 1680 }
aoqi@0 1681 }
aoqi@0 1682 }
aoqi@0 1683 if (suffix) st->print("%s", suffix);
aoqi@0 1684 C->_in_dump_cnt--;
aoqi@0 1685 }
aoqi@0 1686
aoqi@0 1687 //------------------------------dump_req--------------------------------------
aoqi@0 1688 void Node::dump_req(outputStream *st) const {
aoqi@0 1689 // Dump the required input edges
aoqi@0 1690 for (uint i = 0; i < req(); i++) { // For all required inputs
aoqi@0 1691 Node* d = in(i);
aoqi@0 1692 if (d == NULL) {
aoqi@0 1693 st->print("_ ");
aoqi@0 1694 } else if (NotANode(d)) {
aoqi@0 1695 st->print("NotANode "); // uninitialized, sentinel, garbage, etc.
aoqi@0 1696 } else {
aoqi@0 1697 st->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
aoqi@0 1698 }
aoqi@0 1699 }
aoqi@0 1700 }
aoqi@0 1701
aoqi@0 1702
aoqi@0 1703 //------------------------------dump_prec-------------------------------------
aoqi@0 1704 void Node::dump_prec(outputStream *st) const {
aoqi@0 1705 // Dump the precedence edges
aoqi@0 1706 int any_prec = 0;
aoqi@0 1707 for (uint i = req(); i < len(); i++) { // For all precedence inputs
aoqi@0 1708 Node* p = in(i);
aoqi@0 1709 if (p != NULL) {
aoqi@0 1710 if (!any_prec++) st->print(" |");
aoqi@0 1711 if (NotANode(p)) { st->print("NotANode "); continue; }
aoqi@0 1712 st->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
aoqi@0 1713 }
aoqi@0 1714 }
aoqi@0 1715 }
aoqi@0 1716
aoqi@0 1717 //------------------------------dump_out--------------------------------------
aoqi@0 1718 void Node::dump_out(outputStream *st) const {
aoqi@0 1719 // Delimit the output edges
aoqi@0 1720 st->print(" [[");
aoqi@0 1721 // Dump the output edges
aoqi@0 1722 for (uint i = 0; i < _outcnt; i++) { // For all outputs
aoqi@0 1723 Node* u = _out[i];
aoqi@0 1724 if (u == NULL) {
aoqi@0 1725 st->print("_ ");
aoqi@0 1726 } else if (NotANode(u)) {
aoqi@0 1727 st->print("NotANode ");
aoqi@0 1728 } else {
aoqi@0 1729 st->print("%c%d ", Compile::current()->node_arena()->contains(u) ? ' ' : 'o', u->_idx);
aoqi@0 1730 }
aoqi@0 1731 }
aoqi@0 1732 st->print("]] ");
aoqi@0 1733 }
aoqi@0 1734
aoqi@0 1735 //------------------------------dump_nodes-------------------------------------
aoqi@0 1736 static void dump_nodes(const Node* start, int d, bool only_ctrl) {
aoqi@0 1737 Node* s = (Node*)start; // remove const
aoqi@0 1738 if (NotANode(s)) return;
aoqi@0 1739
aoqi@0 1740 uint depth = (uint)ABS(d);
aoqi@0 1741 int direction = d;
aoqi@0 1742 Compile* C = Compile::current();
aoqi@0 1743 GrowableArray <Node *> nstack(C->unique());
aoqi@0 1744
aoqi@0 1745 nstack.append(s);
aoqi@0 1746 int begin = 0;
aoqi@0 1747 int end = 0;
aoqi@0 1748 for(uint i = 0; i < depth; i++) {
aoqi@0 1749 end = nstack.length();
aoqi@0 1750 for(int j = begin; j < end; j++) {
aoqi@0 1751 Node* tp = nstack.at(j);
aoqi@0 1752 uint limit = direction > 0 ? tp->len() : tp->outcnt();
aoqi@0 1753 for(uint k = 0; k < limit; k++) {
aoqi@0 1754 Node* n = direction > 0 ? tp->in(k) : tp->raw_out(k);
aoqi@0 1755
aoqi@0 1756 if (NotANode(n)) continue;
aoqi@0 1757 // do not recurse through top or the root (would reach unrelated stuff)
aoqi@0 1758 if (n->is_Root() || n->is_top()) continue;
aoqi@0 1759 if (only_ctrl && !n->is_CFG()) continue;
aoqi@0 1760
aoqi@0 1761 bool on_stack = nstack.contains(n);
aoqi@0 1762 if (!on_stack) {
aoqi@0 1763 nstack.append(n);
aoqi@0 1764 }
aoqi@0 1765 }
aoqi@0 1766 }
aoqi@0 1767 begin = end;
aoqi@0 1768 }
aoqi@0 1769 end = nstack.length();
aoqi@0 1770 if (direction > 0) {
aoqi@0 1771 for(int j = end-1; j >= 0; j--) {
aoqi@0 1772 nstack.at(j)->dump();
aoqi@0 1773 }
aoqi@0 1774 } else {
aoqi@0 1775 for(int j = 0; j < end; j++) {
aoqi@0 1776 nstack.at(j)->dump();
aoqi@0 1777 }
aoqi@0 1778 }
aoqi@0 1779 }
aoqi@0 1780
aoqi@0 1781 //------------------------------dump-------------------------------------------
aoqi@0 1782 void Node::dump(int d) const {
aoqi@0 1783 dump_nodes(this, d, false);
aoqi@0 1784 }
aoqi@0 1785
aoqi@0 1786 //------------------------------dump_ctrl--------------------------------------
aoqi@0 1787 // Dump a Node's control history to depth
aoqi@0 1788 void Node::dump_ctrl(int d) const {
aoqi@0 1789 dump_nodes(this, d, true);
aoqi@0 1790 }
aoqi@0 1791
aoqi@0 1792 // VERIFICATION CODE
aoqi@0 1793 // For each input edge to a node (ie - for each Use-Def edge), verify that
aoqi@0 1794 // there is a corresponding Def-Use edge.
aoqi@0 1795 //------------------------------verify_edges-----------------------------------
aoqi@0 1796 void Node::verify_edges(Unique_Node_List &visited) {
aoqi@0 1797 uint i, j, idx;
aoqi@0 1798 int cnt;
aoqi@0 1799 Node *n;
aoqi@0 1800
aoqi@0 1801 // Recursive termination test
aoqi@0 1802 if (visited.member(this)) return;
aoqi@0 1803 visited.push(this);
aoqi@0 1804
aoqi@0 1805 // Walk over all input edges, checking for correspondence
aoqi@0 1806 for( i = 0; i < len(); i++ ) {
aoqi@0 1807 n = in(i);
aoqi@0 1808 if (n != NULL && !n->is_top()) {
aoqi@0 1809 // Count instances of (Node *)this
aoqi@0 1810 cnt = 0;
aoqi@0 1811 for (idx = 0; idx < n->_outcnt; idx++ ) {
aoqi@0 1812 if (n->_out[idx] == (Node *)this) cnt++;
aoqi@0 1813 }
aoqi@0 1814 assert( cnt > 0,"Failed to find Def-Use edge." );
aoqi@0 1815 // Check for duplicate edges
aoqi@0 1816 // walk the input array downcounting the input edges to n
aoqi@0 1817 for( j = 0; j < len(); j++ ) {
aoqi@0 1818 if( in(j) == n ) cnt--;
aoqi@0 1819 }
aoqi@0 1820 assert( cnt == 0,"Mismatched edge count.");
aoqi@0 1821 } else if (n == NULL) {
aoqi@0 1822 assert(i >= req() || i == 0 || is_Region() || is_Phi(), "only regions or phis have null data edges");
aoqi@0 1823 } else {
aoqi@0 1824 assert(n->is_top(), "sanity");
aoqi@0 1825 // Nothing to check.
aoqi@0 1826 }
aoqi@0 1827 }
aoqi@0 1828 // Recursive walk over all input edges
aoqi@0 1829 for( i = 0; i < len(); i++ ) {
aoqi@0 1830 n = in(i);
aoqi@0 1831 if( n != NULL )
aoqi@0 1832 in(i)->verify_edges(visited);
aoqi@0 1833 }
aoqi@0 1834 }
aoqi@0 1835
aoqi@0 1836 //------------------------------verify_recur-----------------------------------
aoqi@0 1837 static const Node *unique_top = NULL;
aoqi@0 1838
aoqi@0 1839 void Node::verify_recur(const Node *n, int verify_depth,
aoqi@0 1840 VectorSet &old_space, VectorSet &new_space) {
aoqi@0 1841 if ( verify_depth == 0 ) return;
aoqi@0 1842 if (verify_depth > 0) --verify_depth;
aoqi@0 1843
aoqi@0 1844 Compile* C = Compile::current();
aoqi@0 1845
aoqi@0 1846 // Contained in new_space or old_space?
aoqi@0 1847 VectorSet *v = C->node_arena()->contains(n) ? &new_space : &old_space;
aoqi@0 1848 // Check for visited in the proper space. Numberings are not unique
aoqi@0 1849 // across spaces so we need a separate VectorSet for each space.
aoqi@0 1850 if( v->test_set(n->_idx) ) return;
aoqi@0 1851
aoqi@0 1852 if (n->is_Con() && n->bottom_type() == Type::TOP) {
aoqi@0 1853 if (C->cached_top_node() == NULL)
aoqi@0 1854 C->set_cached_top_node((Node*)n);
aoqi@0 1855 assert(C->cached_top_node() == n, "TOP node must be unique");
aoqi@0 1856 }
aoqi@0 1857
aoqi@0 1858 for( uint i = 0; i < n->len(); i++ ) {
aoqi@0 1859 Node *x = n->in(i);
aoqi@0 1860 if (!x || x->is_top()) continue;
aoqi@0 1861
aoqi@0 1862 // Verify my input has a def-use edge to me
aoqi@0 1863 if (true /*VerifyDefUse*/) {
aoqi@0 1864 // Count use-def edges from n to x
aoqi@0 1865 int cnt = 0;
aoqi@0 1866 for( uint j = 0; j < n->len(); j++ )
aoqi@0 1867 if( n->in(j) == x )
aoqi@0 1868 cnt++;
aoqi@0 1869 // Count def-use edges from x to n
aoqi@0 1870 uint max = x->_outcnt;
aoqi@0 1871 for( uint k = 0; k < max; k++ )
aoqi@0 1872 if (x->_out[k] == n)
aoqi@0 1873 cnt--;
aoqi@0 1874 assert( cnt == 0, "mismatched def-use edge counts" );
aoqi@0 1875 }
aoqi@0 1876
aoqi@0 1877 verify_recur(x, verify_depth, old_space, new_space);
aoqi@0 1878 }
aoqi@0 1879
aoqi@0 1880 }
aoqi@0 1881
aoqi@0 1882 //------------------------------verify-----------------------------------------
aoqi@0 1883 // Check Def-Use info for my subgraph
aoqi@0 1884 void Node::verify() const {
aoqi@0 1885 Compile* C = Compile::current();
aoqi@0 1886 Node* old_top = C->cached_top_node();
aoqi@0 1887 ResourceMark rm;
aoqi@0 1888 ResourceArea *area = Thread::current()->resource_area();
aoqi@0 1889 VectorSet old_space(area), new_space(area);
aoqi@0 1890 verify_recur(this, -1, old_space, new_space);
aoqi@0 1891 C->set_cached_top_node(old_top);
aoqi@0 1892 }
aoqi@0 1893 #endif
aoqi@0 1894
aoqi@0 1895
aoqi@0 1896 //------------------------------walk-------------------------------------------
aoqi@0 1897 // Graph walk, with both pre-order and post-order functions
aoqi@0 1898 void Node::walk(NFunc pre, NFunc post, void *env) {
aoqi@0 1899 VectorSet visited(Thread::current()->resource_area()); // Setup for local walk
aoqi@0 1900 walk_(pre, post, env, visited);
aoqi@0 1901 }
aoqi@0 1902
aoqi@0 1903 void Node::walk_(NFunc pre, NFunc post, void *env, VectorSet &visited) {
aoqi@0 1904 if( visited.test_set(_idx) ) return;
aoqi@0 1905 pre(*this,env); // Call the pre-order walk function
aoqi@0 1906 for( uint i=0; i<_max; i++ )
aoqi@0 1907 if( in(i) ) // Input exists and is not walked?
aoqi@0 1908 in(i)->walk_(pre,post,env,visited); // Walk it with pre & post functions
aoqi@0 1909 post(*this,env); // Call the post-order walk function
aoqi@0 1910 }
aoqi@0 1911
aoqi@0 1912 void Node::nop(Node &, void*) {}
aoqi@0 1913
aoqi@0 1914 //------------------------------Registers--------------------------------------
aoqi@0 1915 // Do we Match on this edge index or not? Generally false for Control
aoqi@0 1916 // and true for everything else. Weird for calls & returns.
aoqi@0 1917 uint Node::match_edge(uint idx) const {
aoqi@0 1918 return idx; // True for other than index 0 (control)
aoqi@0 1919 }
aoqi@0 1920
aoqi@0 1921 static RegMask _not_used_at_all;
aoqi@0 1922 // Register classes are defined for specific machines
aoqi@0 1923 const RegMask &Node::out_RegMask() const {
aoqi@0 1924 ShouldNotCallThis();
aoqi@0 1925 return _not_used_at_all;
aoqi@0 1926 }
aoqi@0 1927
aoqi@0 1928 const RegMask &Node::in_RegMask(uint) const {
aoqi@0 1929 ShouldNotCallThis();
aoqi@0 1930 return _not_used_at_all;
aoqi@0 1931 }
aoqi@0 1932
aoqi@0 1933 //=============================================================================
aoqi@0 1934 //-----------------------------------------------------------------------------
aoqi@0 1935 void Node_Array::reset( Arena *new_arena ) {
aoqi@0 1936 _a->Afree(_nodes,_max*sizeof(Node*));
aoqi@0 1937 _max = 0;
aoqi@0 1938 _nodes = NULL;
aoqi@0 1939 _a = new_arena;
aoqi@0 1940 }
aoqi@0 1941
aoqi@0 1942 //------------------------------clear------------------------------------------
aoqi@0 1943 // Clear all entries in _nodes to NULL but keep storage
aoqi@0 1944 void Node_Array::clear() {
aoqi@0 1945 Copy::zero_to_bytes( _nodes, _max*sizeof(Node*) );
aoqi@0 1946 }
aoqi@0 1947
aoqi@0 1948 //-----------------------------------------------------------------------------
aoqi@0 1949 void Node_Array::grow( uint i ) {
aoqi@0 1950 if( !_max ) {
aoqi@0 1951 _max = 1;
aoqi@0 1952 _nodes = (Node**)_a->Amalloc( _max * sizeof(Node*) );
aoqi@0 1953 _nodes[0] = NULL;
aoqi@0 1954 }
aoqi@0 1955 uint old = _max;
aoqi@0 1956 while( i >= _max ) _max <<= 1; // Double to fit
aoqi@0 1957 _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
aoqi@0 1958 Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
aoqi@0 1959 }
aoqi@0 1960
aoqi@0 1961 //-----------------------------------------------------------------------------
aoqi@0 1962 void Node_Array::insert( uint i, Node *n ) {
aoqi@0 1963 if( _nodes[_max-1] ) grow(_max); // Get more space if full
aoqi@0 1964 Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i+1], ((_max-i-1)*sizeof(Node*)));
aoqi@0 1965 _nodes[i] = n;
aoqi@0 1966 }
aoqi@0 1967
aoqi@0 1968 //-----------------------------------------------------------------------------
aoqi@0 1969 void Node_Array::remove( uint i ) {
aoqi@0 1970 Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i+1], (HeapWord*)&_nodes[i], ((_max-i-1)*sizeof(Node*)));
aoqi@0 1971 _nodes[_max-1] = NULL;
aoqi@0 1972 }
aoqi@0 1973
aoqi@0 1974 //-----------------------------------------------------------------------------
aoqi@0 1975 void Node_Array::sort( C_sort_func_t func) {
aoqi@0 1976 qsort( _nodes, _max, sizeof( Node* ), func );
aoqi@0 1977 }
aoqi@0 1978
aoqi@0 1979 //-----------------------------------------------------------------------------
aoqi@0 1980 void Node_Array::dump() const {
aoqi@0 1981 #ifndef PRODUCT
aoqi@0 1982 for( uint i = 0; i < _max; i++ ) {
aoqi@0 1983 Node *nn = _nodes[i];
aoqi@0 1984 if( nn != NULL ) {
aoqi@0 1985 tty->print("%5d--> ",i); nn->dump();
aoqi@0 1986 }
aoqi@0 1987 }
aoqi@0 1988 #endif
aoqi@0 1989 }
aoqi@0 1990
aoqi@0 1991 //--------------------------is_iteratively_computed------------------------------
aoqi@0 1992 // Operation appears to be iteratively computed (such as an induction variable)
aoqi@0 1993 // It is possible for this operation to return false for a loop-varying
aoqi@0 1994 // value, if it appears (by local graph inspection) to be computed by a simple conditional.
aoqi@0 1995 bool Node::is_iteratively_computed() {
aoqi@0 1996 if (ideal_reg()) { // does operation have a result register?
aoqi@0 1997 for (uint i = 1; i < req(); i++) {
aoqi@0 1998 Node* n = in(i);
aoqi@0 1999 if (n != NULL && n->is_Phi()) {
aoqi@0 2000 for (uint j = 1; j < n->req(); j++) {
aoqi@0 2001 if (n->in(j) == this) {
aoqi@0 2002 return true;
aoqi@0 2003 }
aoqi@0 2004 }
aoqi@0 2005 }
aoqi@0 2006 }
aoqi@0 2007 }
aoqi@0 2008 return false;
aoqi@0 2009 }
aoqi@0 2010
aoqi@0 2011 //--------------------------find_similar------------------------------
aoqi@0 2012 // Return a node with opcode "opc" and same inputs as "this" if one can
aoqi@0 2013 // be found; Otherwise return NULL;
aoqi@0 2014 Node* Node::find_similar(int opc) {
aoqi@0 2015 if (req() >= 2) {
aoqi@0 2016 Node* def = in(1);
aoqi@0 2017 if (def && def->outcnt() >= 2) {
aoqi@0 2018 for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
aoqi@0 2019 Node* use = def->fast_out(i);
aoqi@0 2020 if (use->Opcode() == opc &&
aoqi@0 2021 use->req() == req()) {
aoqi@0 2022 uint j;
aoqi@0 2023 for (j = 0; j < use->req(); j++) {
aoqi@0 2024 if (use->in(j) != in(j)) {
aoqi@0 2025 break;
aoqi@0 2026 }
aoqi@0 2027 }
aoqi@0 2028 if (j == use->req()) {
aoqi@0 2029 return use;
aoqi@0 2030 }
aoqi@0 2031 }
aoqi@0 2032 }
aoqi@0 2033 }
aoqi@0 2034 }
aoqi@0 2035 return NULL;
aoqi@0 2036 }
aoqi@0 2037
aoqi@0 2038
aoqi@0 2039 //--------------------------unique_ctrl_out------------------------------
aoqi@0 2040 // Return the unique control out if only one. Null if none or more than one.
aoqi@0 2041 Node* Node::unique_ctrl_out() {
aoqi@0 2042 Node* found = NULL;
aoqi@0 2043 for (uint i = 0; i < outcnt(); i++) {
aoqi@0 2044 Node* use = raw_out(i);
aoqi@0 2045 if (use->is_CFG() && use != this) {
aoqi@0 2046 if (found != NULL) return NULL;
aoqi@0 2047 found = use;
aoqi@0 2048 }
aoqi@0 2049 }
aoqi@0 2050 return found;
aoqi@0 2051 }
aoqi@0 2052
aoqi@0 2053 //=============================================================================
aoqi@0 2054 //------------------------------yank-------------------------------------------
aoqi@0 2055 // Find and remove
aoqi@0 2056 void Node_List::yank( Node *n ) {
aoqi@0 2057 uint i;
aoqi@0 2058 for( i = 0; i < _cnt; i++ )
aoqi@0 2059 if( _nodes[i] == n )
aoqi@0 2060 break;
aoqi@0 2061
aoqi@0 2062 if( i < _cnt )
aoqi@0 2063 _nodes[i] = _nodes[--_cnt];
aoqi@0 2064 }
aoqi@0 2065
aoqi@0 2066 //------------------------------dump-------------------------------------------
aoqi@0 2067 void Node_List::dump() const {
aoqi@0 2068 #ifndef PRODUCT
aoqi@0 2069 for( uint i = 0; i < _cnt; i++ )
aoqi@0 2070 if( _nodes[i] ) {
aoqi@0 2071 tty->print("%5d--> ",i);
aoqi@0 2072 _nodes[i]->dump();
aoqi@0 2073 }
aoqi@0 2074 #endif
aoqi@0 2075 }
aoqi@0 2076
aoqi@0 2077 //=============================================================================
aoqi@0 2078 //------------------------------remove-----------------------------------------
aoqi@0 2079 void Unique_Node_List::remove( Node *n ) {
aoqi@0 2080 if( _in_worklist[n->_idx] ) {
aoqi@0 2081 for( uint i = 0; i < size(); i++ )
aoqi@0 2082 if( _nodes[i] == n ) {
aoqi@0 2083 map(i,Node_List::pop());
aoqi@0 2084 _in_worklist >>= n->_idx;
aoqi@0 2085 return;
aoqi@0 2086 }
aoqi@0 2087 ShouldNotReachHere();
aoqi@0 2088 }
aoqi@0 2089 }
aoqi@0 2090
aoqi@0 2091 //-----------------------remove_useless_nodes----------------------------------
aoqi@0 2092 // Remove useless nodes from worklist
aoqi@0 2093 void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
aoqi@0 2094
aoqi@0 2095 for( uint i = 0; i < size(); ++i ) {
aoqi@0 2096 Node *n = at(i);
aoqi@0 2097 assert( n != NULL, "Did not expect null entries in worklist");
aoqi@0 2098 if( ! useful.test(n->_idx) ) {
aoqi@0 2099 _in_worklist >>= n->_idx;
aoqi@0 2100 map(i,Node_List::pop());
aoqi@0 2101 // Node *replacement = Node_List::pop();
aoqi@0 2102 // if( i != size() ) { // Check if removing last entry
aoqi@0 2103 // _nodes[i] = replacement;
aoqi@0 2104 // }
aoqi@0 2105 --i; // Visit popped node
aoqi@0 2106 // If it was last entry, loop terminates since size() was also reduced
aoqi@0 2107 }
aoqi@0 2108 }
aoqi@0 2109 }
aoqi@0 2110
aoqi@0 2111 //=============================================================================
aoqi@0 2112 void Node_Stack::grow() {
aoqi@0 2113 size_t old_top = pointer_delta(_inode_top,_inodes,sizeof(INode)); // save _top
aoqi@0 2114 size_t old_max = pointer_delta(_inode_max,_inodes,sizeof(INode));
aoqi@0 2115 size_t max = old_max << 1; // max * 2
aoqi@0 2116 _inodes = REALLOC_ARENA_ARRAY(_a, INode, _inodes, old_max, max);
aoqi@0 2117 _inode_max = _inodes + max;
aoqi@0 2118 _inode_top = _inodes + old_top; // restore _top
aoqi@0 2119 }
aoqi@0 2120
aoqi@0 2121 // Node_Stack is used to map nodes.
aoqi@0 2122 Node* Node_Stack::find(uint idx) const {
aoqi@0 2123 uint sz = size();
aoqi@0 2124 for (uint i=0; i < sz; i++) {
aoqi@0 2125 if (idx == index_at(i) )
aoqi@0 2126 return node_at(i);
aoqi@0 2127 }
aoqi@0 2128 return NULL;
aoqi@0 2129 }
aoqi@0 2130
aoqi@0 2131 //=============================================================================
aoqi@0 2132 uint TypeNode::size_of() const { return sizeof(*this); }
aoqi@0 2133 #ifndef PRODUCT
aoqi@0 2134 void TypeNode::dump_spec(outputStream *st) const {
aoqi@0 2135 if( !Verbose && !WizardMode ) {
aoqi@0 2136 // standard dump does this in Verbose and WizardMode
aoqi@0 2137 st->print(" #"); _type->dump_on(st);
aoqi@0 2138 }
aoqi@0 2139 }
aoqi@0 2140 #endif
aoqi@0 2141 uint TypeNode::hash() const {
aoqi@0 2142 return Node::hash() + _type->hash();
aoqi@0 2143 }
aoqi@0 2144 uint TypeNode::cmp( const Node &n ) const
aoqi@0 2145 { return !Type::cmp( _type, ((TypeNode&)n)._type ); }
aoqi@0 2146 const Type *TypeNode::bottom_type() const { return _type; }
aoqi@0 2147 const Type *TypeNode::Value( PhaseTransform * ) const { return _type; }
aoqi@0 2148
aoqi@0 2149 //------------------------------ideal_reg--------------------------------------
aoqi@0 2150 uint TypeNode::ideal_reg() const {
aoqi@0 2151 return _type->ideal_reg();
aoqi@0 2152 }

mercurial