< prev index next >

src/hotspot/share/opto/phaseX.hpp

Print this page

507   PhaseIterGVN();
508 
509   // Reset IGVN: call deconstructor, and placement new.
510   void reset() {
511     this->~PhaseIterGVN();
512     ::new (static_cast<void*>(this)) PhaseIterGVN();
513   }
514 
515   // Reset IGVN with another: call deconstructor, and placement new.
516   // Achieves the same as the following (but without move constructors):
517   // igvn = PhaseIterGVN(other);
518   void reset_from_igvn(PhaseIterGVN* other) {
519     if (this != other) {
520       this->~PhaseIterGVN();
521       ::new (static_cast<void*>(this)) PhaseIterGVN(other);
522     }
523   }
524 
525   // Idealize new Node 'n' with respect to its inputs and its value
526   virtual Node *transform( Node *a_node );
527   virtual void record_for_igvn(Node *n) { }
528 
529   // Iterative worklist. Reference to "C->igvn_worklist()".
530   Unique_Node_List &_worklist;
531 
532   // Given def-use info and an initial worklist, apply Node::Ideal,
533   // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU
534   // and dominator info to a fixed point.
535   // When deep is true, after the main worklist drains, re-process
536   // nodes that inspect the graph deeply (Load, CmpP, If, RangeCheck,
537   // CountedLoopEnd, LongCountedLoopEnd) to catch optimization opportunities
538   // from changes far away that the normal notification mechanism misses.
539   void optimize(bool deep = false);
540 
541 #ifdef ASSERT
542   void verify_optimize(bool deep_revisit_converged);
543   void verify_Value_for(const Node* n, bool strict = false);
544   void verify_Ideal_for(Node* n, bool can_reshape, bool deep_revisit_converged);
545   void verify_Identity_for(Node* n);
546   void verify_node_invariants_for(const Node* n);
547   void verify_empty_worklist(Node* n);

594   // direct inputs, so it is necessary to ensure the appropriate
595   // notifications are made here.
596   static void add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_List& worklist);
597 
598   // Add users of 'n', and any other nodes that could be directly
599   // affected by changes to 'n', to the worklist.
600   // Node 'n' may be a node that is about to get replaced. In this
601   // case, 'n' should not be considered part of the new graph.
602   // Passing the old node (as 'n'), rather than the new node,
603   // prevents unnecessary notifications when the new node already
604   // has other users.
605   void add_users_to_worklist(Node* n);
606 
607   // Replace old node with new one.
608   void replace_node( Node *old, Node *nn ) {
609     add_users_to_worklist(old);
610     hash_delete(old); // Yank from hash before hacking edges
611     subsume_node(old, nn);
612   }
613 


614   // Delayed node rehash: remove a node from the hash table and rehash it during
615   // next optimizing pass
616   void rehash_node_delayed(Node* n) {
617     hash_delete(n);
618     _worklist.push(n);
619   }
620 
621   // Replace ith edge of "n" with "in"
622   void replace_input_of(Node* n, uint i, Node* in) {
623     rehash_node_delayed(n);
624     n->set_req_X(i, in, this);
625   }
626 
627   // Add "in" as input (req) of "n"
628   void add_input_to(Node* n, Node* in) {
629     rehash_node_delayed(n);
630     n->add_req(in);
631   }
632 
633   // Delete ith edge of "n"

693 //------------------------------PhaseCCP---------------------------------------
694 // Phase for performing global Conditional Constant Propagation.
695 // Should be replaced with combined CCP & GVN someday.
696 class PhaseCCP : public PhaseIterGVN {
697   Unique_Node_List _root_and_safepoints;
698   Unique_Node_List _maybe_top_type_nodes;
699   // Non-recursive.  Use analysis to transform single Node.
700   virtual Node* transform_once(Node* n);
701 
702   Node* fetch_next_node(Unique_Node_List& worklist);
703   static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN;
704 
705   bool not_bottom_type(Node* n) const;
706   void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const;
707   void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const;
708   void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const;
709   void push_phis(Unique_Node_List& worklist, const Node* use) const;
710   static void push_catch(Unique_Node_List& worklist, const Node* use);
711   void push_cmpu(Unique_Node_List& worklist, const Node* use) const;
712   static void push_counted_loop_phi(Unique_Node_List& worklist, Node* parent, const Node* use);

713   void push_loadp(Unique_Node_List& worklist, const Node* use) const;
714   static void push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use);
715   void push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
716   void push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
717   void push_opaque_zero_trip_guard(Unique_Node_List& worklist, const Node* use) const;
718   void push_bool_with_cmpu_and_mask(Unique_Node_List& worklist, const Node* use) const;
719   void push_bool_matching_case1b(Unique_Node_List& worklist, const Node* cmpu) const;
720 
721  public:
722   PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
723   NOT_PRODUCT( ~PhaseCCP(); )
724 
725   // Worklist algorithm identifies constants
726   void analyze();
727   void analyze_step(Unique_Node_List& worklist, Node* n);
728   bool needs_revisit(Node* n) const;
729 #ifdef ASSERT
730   void verify_type(Node* n, const Type* tnew, const Type* told);
731   // For every node n on verify list, check if type(n) == n->Value()
732   void verify_analyze(Unique_Node_List& worklist_verify);

507   PhaseIterGVN();
508 
509   // Reset IGVN: call deconstructor, and placement new.
510   void reset() {
511     this->~PhaseIterGVN();
512     ::new (static_cast<void*>(this)) PhaseIterGVN();
513   }
514 
515   // Reset IGVN with another: call deconstructor, and placement new.
516   // Achieves the same as the following (but without move constructors):
517   // igvn = PhaseIterGVN(other);
518   void reset_from_igvn(PhaseIterGVN* other) {
519     if (this != other) {
520       this->~PhaseIterGVN();
521       ::new (static_cast<void*>(this)) PhaseIterGVN(other);
522     }
523   }
524 
525   // Idealize new Node 'n' with respect to its inputs and its value
526   virtual Node *transform( Node *a_node );
527   virtual void record_for_igvn(Node *n) { _worklist.push(n); }
528 
529   // Iterative worklist. Reference to "C->igvn_worklist()".
530   Unique_Node_List &_worklist;
531 
532   // Given def-use info and an initial worklist, apply Node::Ideal,
533   // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU
534   // and dominator info to a fixed point.
535   // When deep is true, after the main worklist drains, re-process
536   // nodes that inspect the graph deeply (Load, CmpP, If, RangeCheck,
537   // CountedLoopEnd, LongCountedLoopEnd) to catch optimization opportunities
538   // from changes far away that the normal notification mechanism misses.
539   void optimize(bool deep = false);
540 
541 #ifdef ASSERT
542   void verify_optimize(bool deep_revisit_converged);
543   void verify_Value_for(const Node* n, bool strict = false);
544   void verify_Ideal_for(Node* n, bool can_reshape, bool deep_revisit_converged);
545   void verify_Identity_for(Node* n);
546   void verify_node_invariants_for(const Node* n);
547   void verify_empty_worklist(Node* n);

594   // direct inputs, so it is necessary to ensure the appropriate
595   // notifications are made here.
596   static void add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_List& worklist);
597 
598   // Add users of 'n', and any other nodes that could be directly
599   // affected by changes to 'n', to the worklist.
600   // Node 'n' may be a node that is about to get replaced. In this
601   // case, 'n' should not be considered part of the new graph.
602   // Passing the old node (as 'n'), rather than the new node,
603   // prevents unnecessary notifications when the new node already
604   // has other users.
605   void add_users_to_worklist(Node* n);
606 
607   // Replace old node with new one.
608   void replace_node( Node *old, Node *nn ) {
609     add_users_to_worklist(old);
610     hash_delete(old); // Yank from hash before hacking edges
611     subsume_node(old, nn);
612   }
613 
614   void replace_in_uses(Node* n, Node* m);
615 
616   // Delayed node rehash: remove a node from the hash table and rehash it during
617   // next optimizing pass
618   void rehash_node_delayed(Node* n) {
619     hash_delete(n);
620     _worklist.push(n);
621   }
622 
623   // Replace ith edge of "n" with "in"
624   void replace_input_of(Node* n, uint i, Node* in) {
625     rehash_node_delayed(n);
626     n->set_req_X(i, in, this);
627   }
628 
629   // Add "in" as input (req) of "n"
630   void add_input_to(Node* n, Node* in) {
631     rehash_node_delayed(n);
632     n->add_req(in);
633   }
634 
635   // Delete ith edge of "n"

695 //------------------------------PhaseCCP---------------------------------------
696 // Phase for performing global Conditional Constant Propagation.
697 // Should be replaced with combined CCP & GVN someday.
698 class PhaseCCP : public PhaseIterGVN {
699   Unique_Node_List _root_and_safepoints;
700   Unique_Node_List _maybe_top_type_nodes;
701   // Non-recursive.  Use analysis to transform single Node.
702   virtual Node* transform_once(Node* n);
703 
704   Node* fetch_next_node(Unique_Node_List& worklist);
705   static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN;
706 
707   bool not_bottom_type(Node* n) const;
708   void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const;
709   void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const;
710   void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const;
711   void push_phis(Unique_Node_List& worklist, const Node* use) const;
712   static void push_catch(Unique_Node_List& worklist, const Node* use);
713   void push_cmpu(Unique_Node_List& worklist, const Node* use) const;
714   static void push_counted_loop_phi(Unique_Node_List& worklist, Node* parent, const Node* use);
715   static void push_cast(Unique_Node_List& worklist, const Node* use);
716   void push_loadp(Unique_Node_List& worklist, const Node* use) const;
717   static void push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use);
718   void push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
719   void push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
720   void push_opaque_zero_trip_guard(Unique_Node_List& worklist, const Node* use) const;
721   void push_bool_with_cmpu_and_mask(Unique_Node_List& worklist, const Node* use) const;
722   void push_bool_matching_case1b(Unique_Node_List& worklist, const Node* cmpu) const;
723 
724  public:
725   PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
726   NOT_PRODUCT( ~PhaseCCP(); )
727 
728   // Worklist algorithm identifies constants
729   void analyze();
730   void analyze_step(Unique_Node_List& worklist, Node* n);
731   bool needs_revisit(Node* n) const;
732 #ifdef ASSERT
733   void verify_type(Node* n, const Type* tnew, const Type* told);
734   // For every node n on verify list, check if type(n) == n->Value()
735   void verify_analyze(Unique_Node_List& worklist_verify);
< prev index next >