< prev index next >

src/share/vm/opto/node.hpp

Print this page




 268   Node **_out;                  // Array of def-use references to Nodes
 269 
 270   // Input edges are split into two categories.  Required edges are required
 271   // for semantic correctness; order is important and NULLs are allowed.
 272   // Precedence edges are used to help determine execution order and are
 273   // added, e.g., for scheduling purposes.  They are unordered and not
 274   // duplicated; they have no embedded NULLs.  Edges from 0 to _cnt-1
 275   // are required, from _cnt to _max-1 are precedence edges.
 276   node_idx_t _cnt;              // Total number of required Node inputs.
 277 
 278   node_idx_t _max;              // Actual length of input array.
 279 
 280   // Output edges are an unordered list of def-use edges which exactly
 281   // correspond to required input edges which point from other nodes
 282   // to this one.  Thus the count of the output edges is the number of
 283   // users of this node.
 284   node_idx_t _outcnt;           // Total number of Node outputs.
 285 
 286   node_idx_t _outmax;           // Actual length of output array.
 287 


 288   // Grow the actual input array to the next larger power-of-2 bigger than len.
 289   void grow( uint len );
 290   // Grow the output array to the next larger power-of-2 bigger than len.
 291   void out_grow( uint len );
 292 
 293  public:
 294   // Each Node is assigned a unique small/dense number.  This number is used
 295   // to index into auxiliary arrays of data and bitvectors.
 296   // It is declared const to defend against inadvertant assignment,
 297   // since it is used by clients as a naked field.
 298   const node_idx_t _idx;
 299 
 300   // Get the (read-only) number of input edges
 301   uint req() const { return _cnt; }
 302   uint len() const { return _max; }

 303   // Get the (read-only) number of output edges
 304   uint outcnt() const { return _outcnt; }
 305 
 306 #if OPTO_DU_ITERATOR_ASSERT
 307   // Iterate over the out-edges of this node.  Deletions are illegal.
 308   inline DUIterator outs() const;
 309   // Use this when the out array might have changed to suppress asserts.
 310   inline DUIterator& refresh_out_pos(DUIterator& i) const;
 311   // Does the node have an out at this position?  (Used for iteration.)
 312   inline bool has_out(DUIterator& i) const;
 313   inline Node*    out(DUIterator& i) const;
 314   // Iterate over the out-edges of this node.  All changes are illegal.
 315   inline DUIterator_Fast fast_outs(DUIterator_Fast& max) const;
 316   inline Node*    fast_out(DUIterator_Fast& i) const;
 317   // Iterate over the out-edges of this node, deleting one at a time.
 318   inline DUIterator_Last last_outs(DUIterator_Last& min) const;
 319   inline Node*    last_out(DUIterator_Last& i) const;
 320   // The inline bodies of all these methods are after the iterator definitions.
 321 #else
 322   // Iterate over the out-edges of this node.  Deletions are illegal.


 385   void add_req( Node *n ); // Append a NEW required input
 386   void add_req( Node *n0, Node *n1 ) {
 387     add_req(n0); add_req(n1); }
 388   void add_req( Node *n0, Node *n1, Node *n2 ) {
 389     add_req(n0); add_req(n1); add_req(n2); }
 390   void add_req_batch( Node* n, uint m ); // Append m NEW required inputs (all n).
 391   void del_req( uint idx ); // Delete required edge & compact
 392   void del_req_ordered( uint idx ); // Delete required edge & compact with preserved order
 393   void ins_req( uint i, Node *n ); // Insert a NEW required input
 394   void set_req( uint i, Node *n ) {
 395     assert( is_not_dead(n), "can not use dead node");
 396     assert( i < _cnt, err_msg_res("oob: i=%d, _cnt=%d", i, _cnt));
 397     assert( !VerifyHashTableKeys || _hash_lock == 0,
 398             "remove node from hash table before modifying it");
 399     Node** p = &_in[i];    // cache this._in, across the del_out call
 400     if (*p != NULL)  (*p)->del_out((Node *)this);
 401     (*p) = n;
 402     if (n != NULL)      n->add_out((Node *)this);
 403     Compile::current()->record_modified_node(this);
 404   }

 405   // Light version of set_req() to init inputs after node creation.
 406   void init_req( uint i, Node *n ) {
 407     assert( i == 0 && this == n ||
 408             is_not_dead(n), "can not use dead node");
 409     assert( i < _cnt, "oob");
 410     assert( !VerifyHashTableKeys || _hash_lock == 0,
 411             "remove node from hash table before modifying it");
 412     assert( _in[i] == NULL, "sanity");
 413     _in[i] = n;
 414     if (n != NULL)      n->add_out((Node *)this);
 415     Compile::current()->record_modified_node(this);
 416   }
 417   // Find first occurrence of n among my edges:
 418   int find_edge(Node* n);
 419   int replace_edge(Node* old, Node* neww);
 420   int replace_edges_in_range(Node* old, Node* neww, int start, int end);
 421   // NULL out all inputs to eliminate incoming Def-Use edges.
 422   // Return the number of edges between 'n' and 'this'
 423   int  disconnect_inputs(Node *n, Compile *c);
 424 


 656     DEFINE_CLASS_ID(Vector,   Node, 13)
 657     DEFINE_CLASS_ID(ClearArray, Node, 14)
 658 
 659     _max_classes  = ClassMask_ClearArray
 660   };
 661   #undef DEFINE_CLASS_ID
 662 
 663   // Flags are sorted by usage frequency.
 664   enum NodeFlags {
 665     Flag_is_Copy                     = 0x01, // should be first bit to avoid shift
 666     Flag_rematerialize               = Flag_is_Copy << 1,
 667     Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
 668     Flag_is_macro                    = Flag_needs_anti_dependence_check << 1,
 669     Flag_is_Con                      = Flag_is_macro << 1,
 670     Flag_is_cisc_alternate           = Flag_is_Con << 1,
 671     Flag_is_dead_loop_safe           = Flag_is_cisc_alternate << 1,
 672     Flag_may_be_short_branch         = Flag_is_dead_loop_safe << 1,
 673     Flag_avoid_back_to_back_before   = Flag_may_be_short_branch << 1,
 674     Flag_avoid_back_to_back_after    = Flag_avoid_back_to_back_before << 1,
 675     Flag_has_call                    = Flag_avoid_back_to_back_after << 1,
 676     Flag_is_expensive                = Flag_has_call << 1,


 677     _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
 678   };
 679 
 680 private:
 681   jushort _class_id;
 682   jushort _flags;
 683 
 684 protected:
 685   // These methods should be called from constructors only.
 686   void init_class_id(jushort c) {
 687     assert(c <= _max_classes, "invalid node class");
 688     _class_id = c; // cast out const
 689   }
 690   void init_flags(jushort fl) {
 691     assert(fl <= _max_flags, "invalid node flag");
 692     _flags |= fl;
 693   }
 694   void clear_flag(jushort fl) {
 695     assert(fl <= _max_flags, "invalid node flag");
 696     _flags &= ~fl;
 697   }
 698 
 699 public:
 700   const jushort class_id() const { return _class_id; }
 701 
 702   const jushort flags() const { return _flags; }




 703 
 704   // Return a dense integer opcode number
 705   virtual int Opcode() const;
 706 
 707   // Virtual inherited Node size
 708   virtual uint size_of() const;
 709 
 710   // Other interesting Node properties
 711   #define DEFINE_CLASS_QUERY(type)                           \
 712   bool is_##type() const {                                   \
 713     return ((_class_id & ClassMask_##type) == Class_##type); \
 714   }                                                          \
 715   type##Node *as_##type() const {                            \
 716     assert(is_##type(), "invalid node class");               \
 717     return (type##Node*)this;                                \
 718   }                                                          \
 719   type##Node* isa_##type() const {                           \
 720     return (is_##type()) ? as_##type() : NULL;               \
 721   }
 722 




 268   Node **_out;                  // Array of def-use references to Nodes
 269 
 270   // Input edges are split into two categories.  Required edges are required
 271   // for semantic correctness; order is important and NULLs are allowed.
 272   // Precedence edges are used to help determine execution order and are
 273   // added, e.g., for scheduling purposes.  They are unordered and not
 274   // duplicated; they have no embedded NULLs.  Edges from 0 to _cnt-1
 275   // are required, from _cnt to _max-1 are precedence edges.
 276   node_idx_t _cnt;              // Total number of required Node inputs.
 277 
 278   node_idx_t _max;              // Actual length of input array.
 279 
 280   // Output edges are an unordered list of def-use edges which exactly
 281   // correspond to required input edges which point from other nodes
 282   // to this one.  Thus the count of the output edges is the number of
 283   // users of this node.
 284   node_idx_t _outcnt;           // Total number of Node outputs.
 285 
 286   node_idx_t _outmax;           // Actual length of output array.
 287 
 288   node_idx_t _attr;             // Programmable phase attribute used for scratch info
 289 
 290   // Grow the actual input array to the next larger power-of-2 bigger than len.
 291   void grow( uint len );
 292   // Grow the output array to the next larger power-of-2 bigger than len.
 293   void out_grow( uint len );
 294 
 295  public:
 296   // Each Node is assigned a unique small/dense number.  This number is used
 297   // to index into auxiliary arrays of data and bitvectors.
 298   // It is declared const to defend against inadvertant assignment,
 299   // since it is used by clients as a naked field.
 300   const node_idx_t _idx;
 301 
 302   // Get the (read-only) number of input edges
 303   uint req() const { return _cnt; }
 304   uint len() const { return _max; }
 305   uint attr() const { return _attr; }
 306   // Get the (read-only) number of output edges
 307   uint outcnt() const { return _outcnt; }
 308 
 309 #if OPTO_DU_ITERATOR_ASSERT
 310   // Iterate over the out-edges of this node.  Deletions are illegal.
 311   inline DUIterator outs() const;
 312   // Use this when the out array might have changed to suppress asserts.
 313   inline DUIterator& refresh_out_pos(DUIterator& i) const;
 314   // Does the node have an out at this position?  (Used for iteration.)
 315   inline bool has_out(DUIterator& i) const;
 316   inline Node*    out(DUIterator& i) const;
 317   // Iterate over the out-edges of this node.  All changes are illegal.
 318   inline DUIterator_Fast fast_outs(DUIterator_Fast& max) const;
 319   inline Node*    fast_out(DUIterator_Fast& i) const;
 320   // Iterate over the out-edges of this node, deleting one at a time.
 321   inline DUIterator_Last last_outs(DUIterator_Last& min) const;
 322   inline Node*    last_out(DUIterator_Last& i) const;
 323   // The inline bodies of all these methods are after the iterator definitions.
 324 #else
 325   // Iterate over the out-edges of this node.  Deletions are illegal.


 388   void add_req( Node *n ); // Append a NEW required input
 389   void add_req( Node *n0, Node *n1 ) {
 390     add_req(n0); add_req(n1); }
 391   void add_req( Node *n0, Node *n1, Node *n2 ) {
 392     add_req(n0); add_req(n1); add_req(n2); }
 393   void add_req_batch( Node* n, uint m ); // Append m NEW required inputs (all n).
 394   void del_req( uint idx ); // Delete required edge & compact
 395   void del_req_ordered( uint idx ); // Delete required edge & compact with preserved order
 396   void ins_req( uint i, Node *n ); // Insert a NEW required input
 397   void set_req( uint i, Node *n ) {
 398     assert( is_not_dead(n), "can not use dead node");
 399     assert( i < _cnt, err_msg_res("oob: i=%d, _cnt=%d", i, _cnt));
 400     assert( !VerifyHashTableKeys || _hash_lock == 0,
 401             "remove node from hash table before modifying it");
 402     Node** p = &_in[i];    // cache this._in, across the del_out call
 403     if (*p != NULL)  (*p)->del_out((Node *)this);
 404     (*p) = n;
 405     if (n != NULL)      n->add_out((Node *)this);
 406     Compile::current()->record_modified_node(this);
 407   }
 408   void set_attr(uint i) { _attr = i; }
 409   // Light version of set_req() to init inputs after node creation.
 410   void init_req( uint i, Node *n ) {
 411     assert( i == 0 && this == n ||
 412             is_not_dead(n), "can not use dead node");
 413     assert( i < _cnt, "oob");
 414     assert( !VerifyHashTableKeys || _hash_lock == 0,
 415             "remove node from hash table before modifying it");
 416     assert( _in[i] == NULL, "sanity");
 417     _in[i] = n;
 418     if (n != NULL)      n->add_out((Node *)this);
 419     Compile::current()->record_modified_node(this);
 420   }
 421   // Find first occurrence of n among my edges:
 422   int find_edge(Node* n);
 423   int replace_edge(Node* old, Node* neww);
 424   int replace_edges_in_range(Node* old, Node* neww, int start, int end);
 425   // NULL out all inputs to eliminate incoming Def-Use edges.
 426   // Return the number of edges between 'n' and 'this'
 427   int  disconnect_inputs(Node *n, Compile *c);
 428 


 660     DEFINE_CLASS_ID(Vector,   Node, 13)
 661     DEFINE_CLASS_ID(ClearArray, Node, 14)
 662 
 663     _max_classes  = ClassMask_ClearArray
 664   };
 665   #undef DEFINE_CLASS_ID
 666 
 667   // Flags are sorted by usage frequency.
 668   enum NodeFlags {
 669     Flag_is_Copy                     = 0x01, // should be first bit to avoid shift
 670     Flag_rematerialize               = Flag_is_Copy << 1,
 671     Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
 672     Flag_is_macro                    = Flag_needs_anti_dependence_check << 1,
 673     Flag_is_Con                      = Flag_is_macro << 1,
 674     Flag_is_cisc_alternate           = Flag_is_Con << 1,
 675     Flag_is_dead_loop_safe           = Flag_is_cisc_alternate << 1,
 676     Flag_may_be_short_branch         = Flag_is_dead_loop_safe << 1,
 677     Flag_avoid_back_to_back_before   = Flag_may_be_short_branch << 1,
 678     Flag_avoid_back_to_back_after    = Flag_avoid_back_to_back_before << 1,
 679     Flag_has_call                    = Flag_avoid_back_to_back_after << 1,
 680     Flag_is_loop_carried_dep         = Flag_has_call << 1,
 681     Flag_has_reduction               = Flag_is_loop_carried_dep << 1,
 682     Flag_is_expensive                = Flag_has_reduction << 1,
 683     _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
 684   };
 685 
 686 private:
 687   jushort _class_id;
 688   jushort _flags;
 689 
 690 protected:
 691   // These methods should be called from constructors only.
 692   void init_class_id(jushort c) {
 693     assert(c <= _max_classes, "invalid node class");
 694     _class_id = c; // cast out const
 695   }
 696   void init_flags(jushort fl) {
 697     assert(fl <= _max_flags, "invalid node flag");
 698     _flags |= fl;
 699   }
 700   void clear_flag(jushort fl) {
 701     assert(fl <= _max_flags, "invalid node flag");
 702     _flags &= ~fl;
 703   }
 704 
 705 public:
 706   const jushort class_id() const { return _class_id; }
 707 
 708   const jushort flags() const { return _flags; }
 709 
 710   void add_flag(jushort fl) { init_flags(fl); }
 711 
 712   void remove_flag(jushort fl) { clear_flag(fl); }
 713 
 714   // Return a dense integer opcode number
 715   virtual int Opcode() const;
 716 
 717   // Virtual inherited Node size
 718   virtual uint size_of() const;
 719 
 720   // Other interesting Node properties
 721   #define DEFINE_CLASS_QUERY(type)                           \
 722   bool is_##type() const {                                   \
 723     return ((_class_id & ClassMask_##type) == Class_##type); \
 724   }                                                          \
 725   type##Node *as_##type() const {                            \
 726     assert(is_##type(), "invalid node class");               \
 727     return (type##Node*)this;                                \
 728   }                                                          \
 729   type##Node* isa_##type() const {                           \
 730     return (is_##type()) ? as_##type() : NULL;               \
 731   }
 732 


< prev index next >