src/share/vm/opto/node.hpp

changeset 9912
97d09139b360
parent 8504
a96cf90239c6
child 9931
fd44df5e3bc3
child 9952
19056c781208
equal deleted inserted replaced
9911:6f33e450999c 9912:97d09139b360
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
421 _in[i] = n; 421 _in[i] = n;
422 if (n != NULL) n->add_out((Node *)this); 422 if (n != NULL) n->add_out((Node *)this);
423 } 423 }
424 // Find first occurrence of n among my edges: 424 // Find first occurrence of n among my edges:
425 int find_edge(Node* n); 425 int find_edge(Node* n);
426 int find_prec_edge(Node* n) {
427 for (uint i = req(); i < len(); i++) {
428 if (_in[i] == n) return i;
429 if (_in[i] == NULL) {
430 DEBUG_ONLY( while ((++i) < len()) assert(_in[i] == NULL, "Gap in prec edges!"); )
431 break;
432 }
433 }
434 return -1;
435 }
426 int replace_edge(Node* old, Node* neww); 436 int replace_edge(Node* old, Node* neww);
427 int replace_edges_in_range(Node* old, Node* neww, int start, int end); 437 int replace_edges_in_range(Node* old, Node* neww, int start, int end);
428 // NULL out all inputs to eliminate incoming Def-Use edges. 438 // NULL out all inputs to eliminate incoming Def-Use edges.
429 // Return the number of edges between 'n' and 'this' 439 // Return the number of edges between 'n' and 'this'
430 int disconnect_inputs(Node *n, Compile *c); 440 int disconnect_inputs(Node *n, Compile *c);
467 // Record that a change happened here. 477 // Record that a change happened here.
468 #if OPTO_DU_ITERATOR_ASSERT 478 #if OPTO_DU_ITERATOR_ASSERT
469 debug_only(_last_del = n; ++_del_tick); 479 debug_only(_last_del = n; ++_del_tick);
470 #endif 480 #endif
471 } 481 }
482 // Close gap after removing edge.
483 void close_prec_gap_at(uint gap) {
484 assert(_cnt <= gap && gap < _max, "no valid prec edge");
485 uint i = gap;
486 Node *last = NULL;
487 for (; i < _max-1; ++i) {
488 Node *next = _in[i+1];
489 if (next == NULL) break;
490 last = next;
491 }
492 _in[gap] = last; // Move last slot to empty one.
493 _in[i] = NULL; // NULL out last slot.
494 }
472 495
473 public: 496 public:
474 // Globally replace this node by a given new node, updating all uses. 497 // Globally replace this node by a given new node, updating all uses.
475 void replace_by(Node* new_node); 498 void replace_by(Node* new_node);
476 // Globally replace this node by a given new node, updating all uses 499 // Globally replace this node by a given new node, updating all uses
483 // Find the one non-null required input. RegionNode only 506 // Find the one non-null required input. RegionNode only
484 Node *nonnull_req() const; 507 Node *nonnull_req() const;
485 // Add or remove precedence edges 508 // Add or remove precedence edges
486 void add_prec( Node *n ); 509 void add_prec( Node *n );
487 void rm_prec( uint i ); 510 void rm_prec( uint i );
511
512 // Note: prec(i) will not necessarily point to n if edge already exists.
488 void set_prec( uint i, Node *n ) { 513 void set_prec( uint i, Node *n ) {
489 assert( is_not_dead(n), "can not use dead node"); 514 assert(i < _max, err_msg("oob: i=%d, _max=%d", i, _max));
490 assert( i >= _cnt, "not a precedence edge"); 515 assert(is_not_dead(n), "can not use dead node");
516 assert(i >= _cnt, "not a precedence edge");
517 // Avoid spec violation: duplicated prec edge.
518 if (_in[i] == n) return;
519 if (n == NULL || find_prec_edge(n) != -1) {
520 rm_prec(i);
521 return;
522 }
491 if (_in[i] != NULL) _in[i]->del_out((Node *)this); 523 if (_in[i] != NULL) _in[i]->del_out((Node *)this);
492 _in[i] = n; 524 _in[i] = n;
493 if (n != NULL) n->add_out((Node *)this); 525 if (n != NULL) n->add_out((Node *)this);
494 } 526 }
527
495 // Set this node's index, used by cisc_version to replace current node 528 // Set this node's index, used by cisc_version to replace current node
496 void set_idx(uint new_idx) { 529 void set_idx(uint new_idx) {
497 const node_idx_t* ref = &_idx; 530 const node_idx_t* ref = &_idx;
498 *(node_idx_t*)ref = new_idx; 531 *(node_idx_t*)ref = new_idx;
499 } 532 }

mercurial