< prev index next >

src/share/vm/opto/compile.hpp

Print this page




  52 class InlineTree;
  53 class Int_Array;
  54 class Matcher;
  55 class MachConstantNode;
  56 class MachConstantBaseNode;
  57 class MachNode;
  58 class MachOper;
  59 class MachSafePointNode;
  60 class Node;
  61 class Node_Array;
  62 class Node_Notes;
  63 class OptoReg;
  64 class PhaseCFG;
  65 class PhaseGVN;
  66 class PhaseIterGVN;
  67 class PhaseRegAlloc;
  68 class PhaseCCP;
  69 class PhaseCCP_DCE;
  70 class RootNode;
  71 class relocInfo;

  72 class Scope;
  73 class StartNode;
  74 class SafePointNode;
  75 class JVMState;
  76 class Type;
  77 class TypeData;
  78 class TypeInt;
  79 class TypePtr;
  80 class TypeOopPtr;
  81 class TypeFunc;
  82 class Unique_Node_List;
  83 class nmethod;
  84 class WarmCallInfo;
  85 class Node_Stack;
  86 struct Final_Reshape_Counts;
  87 
  88 //------------------------------Compile----------------------------------------
  89 // This class defines a top-level Compiler invocation.
  90 
  91 class Compile : public Phase {


 321   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 322 #ifndef PRODUCT
 323   bool                  _trace_opto_output;
 324   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 325 #endif
 326   bool                  _has_irreducible_loop;  // Found irreducible loops
 327   // JSR 292
 328   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 329   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 330 
 331   // Compilation environment.
 332   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 333   ciEnv*                _env;                   // CI interface
 334   CompileLog*           _log;                   // from CompilerThread
 335   const char*           _failure_reason;        // for record_failure/failing pattern
 336   GrowableArray<CallGenerator*>* _intrinsics;   // List of intrinsics.
 337   GrowableArray<Node*>* _macro_nodes;           // List of nodes which need to be expanded before matching.
 338   GrowableArray<Node*>* _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 339   GrowableArray<Node*>* _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 340   GrowableArray<Node*>* _range_check_casts;     // List of CastII nodes with a range check dependency

 341   ConnectionGraph*      _congraph;
 342 #ifndef PRODUCT
 343   IdealGraphPrinter*    _printer;
 344 #endif
 345 
 346 

 347   // Node management
 348   uint                  _unique;                // Counter for unique Node indices
 349   VectorSet             _dead_node_list;        // Set of dead nodes
 350   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 351                                                 // So use this to keep count and make the call O(1).
 352   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 353   Arena                 _node_arena;            // Arena for new-space Nodes
 354   Arena                 _old_arena;             // Arena for old-space Nodes, lifetime during xform
 355   RootNode*             _root;                  // Unique root of compilation, or NULL after bail-out.
 356   Node*                 _top;                   // Unique top node.  (Reset by various phases.)
 357 
 358   Node*                 _immutable_memory;      // Initial memory state
 359 
 360   Node*                 _recent_alloc_obj;
 361   Node*                 _recent_alloc_ctl;
 362 
 363   // Constant table
 364   ConstantTable         _constant_table;        // The constant table for this compile.
 365   MachConstantBaseNode* _mach_constant_base_node;  // Constant table base node singleton.
 366 


 649     C->_latest_stage_start_counter.stamp();
 650   }
 651 
 652   void end_method(int level = 1) {
 653     EventCompilerPhase event;
 654     if (event.should_commit()) {
 655       event.set_starttime(C->_latest_stage_start_counter);
 656       event.set_phase((u1) PHASE_END);
 657       event.set_compileId(C->_compile_id);
 658       event.set_phaseLevel(level);
 659       event.commit();
 660     }
 661 #ifndef PRODUCT
 662     if (_printer) _printer->end_method();
 663 #endif
 664   }
 665 
 666   int           macro_count()             const { return _macro_nodes->length(); }
 667   int           predicate_count()         const { return _predicate_opaqs->length();}
 668   int           expensive_count()         const { return _expensive_nodes->length(); }

 669   Node*         macro_node(int idx)       const { return _macro_nodes->at(idx); }
 670   Node*         predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
 671   Node*         expensive_node(int idx)   const { return _expensive_nodes->at(idx); }

 672   ConnectionGraph* congraph()                   { return _congraph;}
 673   void set_congraph(ConnectionGraph* congraph)  { _congraph = congraph;}
 674   void add_macro_node(Node * n) {
 675     //assert(n->is_macro(), "must be a macro node");
 676     assert(!_macro_nodes->contains(n), "duplicate entry in expand list");
 677     _macro_nodes->append(n);
 678   }
 679   void remove_macro_node(Node * n) {
 680     // this function may be called twice for a node so check
 681     // that the node is in the array before attempting to remove it
 682     if (_macro_nodes->contains(n))
 683       _macro_nodes->remove(n);
 684     // remove from _predicate_opaqs list also if it is there
 685     if (predicate_count() > 0 && _predicate_opaqs->contains(n)){
 686       _predicate_opaqs->remove(n);
 687     }
 688   }
 689   void add_expensive_node(Node * n);
 690   void remove_expensive_node(Node * n) {
 691     if (_expensive_nodes->contains(n)) {
 692       _expensive_nodes->remove(n);
 693     }
 694   }









 695   void add_predicate_opaq(Node * n) {
 696     assert(!_predicate_opaqs->contains(n), "duplicate entry in predicate opaque1");
 697     assert(_macro_nodes->contains(n), "should have already been in macro list");
 698     _predicate_opaqs->append(n);
 699   }
 700 
 701   // Range check dependent CastII nodes that can be removed after loop optimizations
 702   void add_range_check_cast(Node* n);
 703   void remove_range_check_cast(Node* n) {
 704     if (_range_check_casts->contains(n)) {
 705       _range_check_casts->remove(n);
 706     }
 707   }
 708   Node* range_check_cast_node(int idx) const { return _range_check_casts->at(idx);  }
 709   int   range_check_cast_count()       const { return _range_check_casts->length(); }
 710   // Remove all range check dependent CastIINodes.
 711   void  remove_range_check_casts(PhaseIterGVN &igvn);
 712 
 713   // remove the opaque nodes that protect the predicates so that the unused checks and
 714   // uncommon traps will be eliminated from the graph.
 715   void cleanup_loop_predicates(PhaseIterGVN &igvn);
 716   bool is_predicate_opaq(Node * n) {
 717     return _predicate_opaqs->contains(n);
 718   }
 719 
 720   // Are there candidate expensive nodes for optimization?
 721   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 722   // Check whether n1 and n2 are similar
 723   static int cmp_expensive_nodes(Node* n1, Node* n2);
 724   // Sort expensive nodes to locate similar expensive nodes
 725   void sort_expensive_nodes();
 726 


 727   // Compilation environment.
 728   Arena*            comp_arena()                { return &_comp_arena; }
 729   ciEnv*            env() const                 { return _env; }
 730   CompileLog*       log() const                 { return _log; }
 731   bool              failing() const             { return _env->failing() || _failure_reason != NULL; }
 732   const char*       failure_reason() { return _failure_reason; }
 733   bool              failure_reason_is(const char* r) { return (r==_failure_reason) || (r!=NULL && _failure_reason!=NULL && strcmp(r, _failure_reason)==0); }
 734 
 735   void record_failure(const char* reason);
 736   void record_method_not_compilable(const char* reason, bool all_tiers = false) {
 737     // All bailouts cover "all_tiers" when TieredCompilation is off.
 738     if (!TieredCompilation) all_tiers = true;
 739     env()->record_method_not_compilable(reason, all_tiers);
 740     // Record failure reason.
 741     record_failure(reason);
 742   }
 743   void record_method_not_compilable_all_tiers(const char* reason) {
 744     record_method_not_compilable(reason, true);
 745   }
 746   bool check_node_count(uint margin, const char* reason) {


1210   static void print_statistics() PRODUCT_RETURN;
1211 
1212   // Dump formatted assembly
1213   void dump_asm(int *pcs = NULL, uint pc_limit = 0) PRODUCT_RETURN;
1214   void dump_pc(int *pcs, int pc_limit, Node *n);
1215 
1216   // Verify ADLC assumptions during startup
1217   static void adlc_verification() PRODUCT_RETURN;
1218 
1219   // Definitions of pd methods
1220   static void pd_compiler2_init();
1221 
1222   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1223   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl);
1224 
1225   // Auxiliary method for randomized fuzzing/stressing
1226   static bool randomized_select(int count);
1227 #ifdef ASSERT
1228   bool _type_verify_symmetry;
1229 #endif


1230 };
1231 
1232 #endif // SHARE_VM_OPTO_COMPILE_HPP


  52 class InlineTree;
  53 class Int_Array;
  54 class Matcher;
  55 class MachConstantNode;
  56 class MachConstantBaseNode;
  57 class MachNode;
  58 class MachOper;
  59 class MachSafePointNode;
  60 class Node;
  61 class Node_Array;
  62 class Node_Notes;
  63 class OptoReg;
  64 class PhaseCFG;
  65 class PhaseGVN;
  66 class PhaseIterGVN;
  67 class PhaseRegAlloc;
  68 class PhaseCCP;
  69 class PhaseCCP_DCE;
  70 class RootNode;
  71 class relocInfo;
  72 class ShenandoahLoadReferenceBarrierNode;
  73 class Scope;
  74 class StartNode;
  75 class SafePointNode;
  76 class JVMState;
  77 class Type;
  78 class TypeData;
  79 class TypeInt;
  80 class TypePtr;
  81 class TypeOopPtr;
  82 class TypeFunc;
  83 class Unique_Node_List;
  84 class nmethod;
  85 class WarmCallInfo;
  86 class Node_Stack;
  87 struct Final_Reshape_Counts;
  88 
  89 //------------------------------Compile----------------------------------------
  90 // This class defines a top-level Compiler invocation.
  91 
  92 class Compile : public Phase {


 322   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 323 #ifndef PRODUCT
 324   bool                  _trace_opto_output;
 325   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 326 #endif
 327   bool                  _has_irreducible_loop;  // Found irreducible loops
 328   // JSR 292
 329   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 330   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 331 
 332   // Compilation environment.
 333   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 334   ciEnv*                _env;                   // CI interface
 335   CompileLog*           _log;                   // from CompilerThread
 336   const char*           _failure_reason;        // for record_failure/failing pattern
 337   GrowableArray<CallGenerator*>* _intrinsics;   // List of intrinsics.
 338   GrowableArray<Node*>* _macro_nodes;           // List of nodes which need to be expanded before matching.
 339   GrowableArray<Node*>* _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 340   GrowableArray<Node*>* _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 341   GrowableArray<Node*>* _range_check_casts;     // List of CastII nodes with a range check dependency
 342   GrowableArray<ShenandoahLoadReferenceBarrierNode*>* _shenandoah_barriers;
 343   ConnectionGraph*      _congraph;
 344 #ifndef PRODUCT
 345   IdealGraphPrinter*    _printer;
 346 #endif
 347 
 348 
 349 
 350   // Node management
 351   uint                  _unique;                // Counter for unique Node indices
 352   VectorSet             _dead_node_list;        // Set of dead nodes
 353   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 354                                                 // So use this to keep count and make the call O(1).
 355   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 356   Arena                 _node_arena;            // Arena for new-space Nodes
 357   Arena                 _old_arena;             // Arena for old-space Nodes, lifetime during xform
 358   RootNode*             _root;                  // Unique root of compilation, or NULL after bail-out.
 359   Node*                 _top;                   // Unique top node.  (Reset by various phases.)
 360 
 361   Node*                 _immutable_memory;      // Initial memory state
 362 
 363   Node*                 _recent_alloc_obj;
 364   Node*                 _recent_alloc_ctl;
 365 
 366   // Constant table
 367   ConstantTable         _constant_table;        // The constant table for this compile.
 368   MachConstantBaseNode* _mach_constant_base_node;  // Constant table base node singleton.
 369 


 652     C->_latest_stage_start_counter.stamp();
 653   }
 654 
 655   void end_method(int level = 1) {
 656     EventCompilerPhase event;
 657     if (event.should_commit()) {
 658       event.set_starttime(C->_latest_stage_start_counter);
 659       event.set_phase((u1) PHASE_END);
 660       event.set_compileId(C->_compile_id);
 661       event.set_phaseLevel(level);
 662       event.commit();
 663     }
 664 #ifndef PRODUCT
 665     if (_printer) _printer->end_method();
 666 #endif
 667   }
 668 
 669   int           macro_count()             const { return _macro_nodes->length(); }
 670   int           predicate_count()         const { return _predicate_opaqs->length();}
 671   int           expensive_count()         const { return _expensive_nodes->length(); }
 672   int           shenandoah_barriers_count()         const { return _shenandoah_barriers->length(); }
 673   Node*         macro_node(int idx)       const { return _macro_nodes->at(idx); }
 674   Node*         predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
 675   Node*         expensive_node(int idx)   const { return _expensive_nodes->at(idx); }
 676   ShenandoahLoadReferenceBarrierNode* shenandoah_barrier(int idx)   const { return _shenandoah_barriers->at(idx); }
 677   ConnectionGraph* congraph()                   { return _congraph;}
 678   void set_congraph(ConnectionGraph* congraph)  { _congraph = congraph;}
 679   void add_macro_node(Node * n) {
 680     //assert(n->is_macro(), "must be a macro node");
 681     assert(!_macro_nodes->contains(n), "duplicate entry in expand list");
 682     _macro_nodes->append(n);
 683   }
 684   void remove_macro_node(Node * n) {
 685     // this function may be called twice for a node so check
 686     // that the node is in the array before attempting to remove it
 687     if (_macro_nodes->contains(n))
 688       _macro_nodes->remove(n);
 689     // remove from _predicate_opaqs list also if it is there
 690     if (predicate_count() > 0 && _predicate_opaqs->contains(n)){
 691       _predicate_opaqs->remove(n);
 692     }
 693   }
 694   void add_expensive_node(Node * n);
 695   void remove_expensive_node(Node * n) {
 696     if (_expensive_nodes->contains(n)) {
 697       _expensive_nodes->remove(n);
 698     }
 699   }
 700   void add_shenandoah_barrier(ShenandoahLoadReferenceBarrierNode * n) {
 701     assert(!_shenandoah_barriers->contains(n), "duplicate entry in barrier list");
 702     _shenandoah_barriers->append(n);
 703   }
 704   void remove_shenandoah_barrier(ShenandoahLoadReferenceBarrierNode * n) {
 705     if (_shenandoah_barriers->contains(n)) {
 706       _shenandoah_barriers->remove(n);
 707     }
 708   }
 709   void add_predicate_opaq(Node * n) {
 710     assert(!_predicate_opaqs->contains(n), "duplicate entry in predicate opaque1");
 711     assert(_macro_nodes->contains(n), "should have already been in macro list");
 712     _predicate_opaqs->append(n);
 713   }
 714 
 715   // Range check dependent CastII nodes that can be removed after loop optimizations
 716   void add_range_check_cast(Node* n);
 717   void remove_range_check_cast(Node* n) {
 718     if (_range_check_casts->contains(n)) {
 719       _range_check_casts->remove(n);
 720     }
 721   }
 722   Node* range_check_cast_node(int idx) const { return _range_check_casts->at(idx);  }
 723   int   range_check_cast_count()       const { return _range_check_casts->length(); }
 724   // Remove all range check dependent CastIINodes.
 725   void  remove_range_check_casts(PhaseIterGVN &igvn);
 726 
 727   // remove the opaque nodes that protect the predicates so that the unused checks and
 728   // uncommon traps will be eliminated from the graph.
 729   void cleanup_loop_predicates(PhaseIterGVN &igvn);
 730   bool is_predicate_opaq(Node * n) {
 731     return _predicate_opaqs->contains(n);
 732   }
 733 
 734   // Are there candidate expensive nodes for optimization?
 735   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 736   // Check whether n1 and n2 are similar
 737   static int cmp_expensive_nodes(Node* n1, Node* n2);
 738   // Sort expensive nodes to locate similar expensive nodes
 739   void sort_expensive_nodes();
 740 
 741   GrowableArray<ShenandoahLoadReferenceBarrierNode*>* shenandoah_barriers() { return _shenandoah_barriers; }
 742 
 743   // Compilation environment.
 744   Arena*            comp_arena()                { return &_comp_arena; }
 745   ciEnv*            env() const                 { return _env; }
 746   CompileLog*       log() const                 { return _log; }
 747   bool              failing() const             { return _env->failing() || _failure_reason != NULL; }
 748   const char*       failure_reason() { return _failure_reason; }
 749   bool              failure_reason_is(const char* r) { return (r==_failure_reason) || (r!=NULL && _failure_reason!=NULL && strcmp(r, _failure_reason)==0); }
 750 
 751   void record_failure(const char* reason);
 752   void record_method_not_compilable(const char* reason, bool all_tiers = false) {
 753     // All bailouts cover "all_tiers" when TieredCompilation is off.
 754     if (!TieredCompilation) all_tiers = true;
 755     env()->record_method_not_compilable(reason, all_tiers);
 756     // Record failure reason.
 757     record_failure(reason);
 758   }
 759   void record_method_not_compilable_all_tiers(const char* reason) {
 760     record_method_not_compilable(reason, true);
 761   }
 762   bool check_node_count(uint margin, const char* reason) {


1226   static void print_statistics() PRODUCT_RETURN;
1227 
1228   // Dump formatted assembly
1229   void dump_asm(int *pcs = NULL, uint pc_limit = 0) PRODUCT_RETURN;
1230   void dump_pc(int *pcs, int pc_limit, Node *n);
1231 
1232   // Verify ADLC assumptions during startup
1233   static void adlc_verification() PRODUCT_RETURN;
1234 
1235   // Definitions of pd methods
1236   static void pd_compiler2_init();
1237 
1238   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1239   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl);
1240 
1241   // Auxiliary method for randomized fuzzing/stressing
1242   static bool randomized_select(int count);
1243 #ifdef ASSERT
1244   bool _type_verify_symmetry;
1245 #endif
1246 
1247   void shenandoah_eliminate_g1_wb_pre(Node* call, PhaseIterGVN* igvn);
1248 };
1249 
1250 #endif // SHARE_VM_OPTO_COMPILE_HPP
< prev index next >