< prev index next >

src/hotspot/share/opto/compile.hpp

Print this page

  31 #include "compiler/compiler_globals.hpp"
  32 #include "compiler/compilerOracle.hpp"
  33 #include "compiler/compileBroker.hpp"
  34 #include "compiler/compilerEvent.hpp"
  35 #include "libadt/dict.hpp"
  36 #include "libadt/vectset.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "opto/idealGraphPrinter.hpp"
  40 #include "opto/phasetype.hpp"
  41 #include "opto/phase.hpp"
  42 #include "opto/regmask.hpp"
  43 #include "runtime/deoptimization.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/timerTrace.hpp"
  46 #include "runtime/vmThread.hpp"
  47 #include "utilities/ticks.hpp"
  48 
  49 class AbstractLockNode;
  50 class AddPNode;

  51 class Block;
  52 class Bundle;
  53 class CallGenerator;
  54 class CallStaticJavaNode;
  55 class CloneMap;
  56 class CompilationFailureInfo;
  57 class ConnectionGraph;
  58 class IdealGraphPrinter;
  59 class InlineTree;
  60 class Matcher;
  61 class MachConstantNode;
  62 class MachConstantBaseNode;
  63 class MachNode;
  64 class MachOper;
  65 class MachSafePointNode;
  66 class Node;
  67 class Node_Array;
  68 class Node_List;
  69 class Node_Notes;
  70 class NodeHash;
  71 class NodeCloneInfo;
  72 class OptoReg;
  73 class ParsePredicateNode;

  74 class PhaseCFG;
  75 class PhaseGVN;
  76 class PhaseIterGVN;
  77 class PhaseRegAlloc;
  78 class PhaseCCP;
  79 class PhaseOutput;
  80 class RootNode;
  81 class relocInfo;
  82 class StartNode;
  83 class SafePointNode;
  84 class JVMState;
  85 class Type;
  86 class TypeInt;
  87 class TypeInteger;
  88 class TypeKlassPtr;
  89 class TypePtr;
  90 class TypeOopPtr;
  91 class TypeFunc;
  92 class TypeVect;
  93 class Type_Array;
  94 class Unique_Node_List;
  95 class UnstableIfTrap;
  96 class nmethod;
  97 class Node_Stack;
  98 struct Final_Reshape_Counts;
  99 class VerifyMeetResult;
 100 


 101 enum LoopOptsMode {
 102   LoopOptsDefault,
 103   LoopOptsNone,
 104   LoopOptsMaxUnroll,
 105   LoopOptsShenandoahExpand,
 106   LoopOptsShenandoahPostExpand,
 107   LoopOptsSkipSplitIf,
 108   LoopOptsVerify
 109 };
 110 
 111 // The type of all node counts and indexes.
 112 // It must hold at least 16 bits, but must also be fast to load and store.
 113 // This type, if less than 32 bits, could limit the number of possible nodes.
 114 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
 115 typedef unsigned int node_idx_t;
 116 
 117 class NodeCloneInfo {
 118  private:
 119   uint64_t _idx_clone_orig;
 120  public:

 342   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 343   bool                  _print_inlining;        // True if we should print inlining for this compilation
 344   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 345 #ifndef PRODUCT
 346   uint                  _igv_idx;               // Counter for IGV node identifiers
 347   uint                  _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
 348   bool                  _trace_opto_output;
 349   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 350 #endif
 351   bool                  _has_irreducible_loop;  // Found irreducible loops
 352   // JSR 292
 353   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 354   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 355   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
 356   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 357   int                   _loop_opts_cnt;         // loop opts round
 358   uint                  _stress_seed;           // Seed for stress testing
 359 
 360   // Compilation environment.
 361   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile

 362   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 363   ciEnv*                _env;                   // CI interface
 364   DirectiveSet*         _directive;             // Compiler directive
 365   CompileLog*           _log;                   // from CompilerThread
 366   const char*           _failure_reason;        // for record_failure/failing pattern
 367   CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
 368   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 369   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 370   GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
 371   GrowableArray<Node*>  _template_assertion_predicate_opaqs; // List of Opaque4 nodes for Template Assertion Predicates.
 372   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 373   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over
 374   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 375   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes

 376   ConnectionGraph*      _congraph;
 377 #ifndef PRODUCT
 378   IdealGraphPrinter*    _igv_printer;
 379   static IdealGraphPrinter* _debug_file_printer;
 380   static IdealGraphPrinter* _debug_network_printer;
 381 #endif
 382 
 383 
 384   // Node management
 385   uint                  _unique;                // Counter for unique Node indices
 386   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 387                                                 // So use this to keep count and make the call O(1).
 388   VectorSet             _dead_node_list;        // Set of dead nodes
 389   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 390   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 391 
 392   // Arenas for new-space and old-space nodes.
 393   // Swapped between using _node_arena.
 394   // The lifetime of the old-space nodes is during xform.
 395   Arena                 _node_arena_one;

 764     if (parse_predicate_count() > 0) {
 765       _parse_predicates.remove_if_existing(n);
 766     }
 767   }
 768 
 769   void add_template_assertion_predicate_opaq(Node* n) {
 770     assert(!_template_assertion_predicate_opaqs.contains(n),
 771            "duplicate entry in template assertion predicate opaque4 list");
 772     _template_assertion_predicate_opaqs.append(n);
 773   }
 774 
 775   void remove_template_assertion_predicate_opaq(Node* n) {
 776     if (template_assertion_predicate_count() > 0) {
 777       _template_assertion_predicate_opaqs.remove_if_existing(n);
 778     }
 779   }
 780   void add_coarsened_locks(GrowableArray<AbstractLockNode*>& locks);
 781   void remove_coarsened_lock(Node* n);
 782   bool coarsened_locks_consistent();
 783 





 784   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 785   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 786   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 787 
 788   void record_for_post_loop_opts_igvn(Node* n);
 789   void remove_from_post_loop_opts_igvn(Node* n);
 790   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 791 
 792   void record_unstable_if_trap(UnstableIfTrap* trap);
 793   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 794   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 795   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 796 
 797   void sort_macro_nodes();
 798 
 799   void mark_parse_predicate_nodes_useless(PhaseIterGVN& igvn);
 800 
 801   // Are there candidate expensive nodes for optimization?
 802   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 803   // Check whether n1 and n2 are similar
 804   static int cmp_expensive_nodes(Node* n1, Node* n2);
 805   // Sort expensive nodes to locate similar expensive nodes
 806   void sort_expensive_nodes();
 807 
 808   // Compilation environment.
 809   Arena*      comp_arena()           { return &_comp_arena; }

 810   ciEnv*      env() const            { return _env; }
 811   CompileLog* log() const            { return _log; }
 812   bool        failing() const        { return _env->failing() || _failure_reason != nullptr; }
 813   const char* failure_reason() const { return (_env->failing()) ? _env->failure_reason() : _failure_reason; }
 814   const CompilationFailureInfo* first_failure_details() const { return _first_failure_details; }
 815 
 816   bool failure_reason_is(const char* r) const {
 817     return (r == _failure_reason) || (r != nullptr && _failure_reason != nullptr && strcmp(r, _failure_reason) == 0);
 818   }
 819 
 820   void record_failure(const char* reason);
 821   void record_method_not_compilable(const char* reason) {
 822     env()->record_method_not_compilable(reason);
 823     // Record failure reason.
 824     record_failure(reason);
 825   }
 826   bool check_node_count(uint margin, const char* reason) {
 827     if (oom()) {
 828       record_method_not_compilable_oom();
 829       return true;

  31 #include "compiler/compiler_globals.hpp"
  32 #include "compiler/compilerOracle.hpp"
  33 #include "compiler/compileBroker.hpp"
  34 #include "compiler/compilerEvent.hpp"
  35 #include "libadt/dict.hpp"
  36 #include "libadt/vectset.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "opto/idealGraphPrinter.hpp"
  40 #include "opto/phasetype.hpp"
  41 #include "opto/phase.hpp"
  42 #include "opto/regmask.hpp"
  43 #include "runtime/deoptimization.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/timerTrace.hpp"
  46 #include "runtime/vmThread.hpp"
  47 #include "utilities/ticks.hpp"
  48 
  49 class AbstractLockNode;
  50 class AddPNode;
  51 class AllocateNode;
  52 class Block;
  53 class Bundle;
  54 class CallGenerator;
  55 class CallStaticJavaNode;
  56 class CloneMap;
  57 class CompilationFailureInfo;
  58 class ConnectionGraph;
  59 class IdealGraphPrinter;
  60 class InlineTree;
  61 class Matcher;
  62 class MachConstantNode;
  63 class MachConstantBaseNode;
  64 class MachNode;
  65 class MachOper;
  66 class MachSafePointNode;
  67 class Node;
  68 class Node_Array;
  69 class Node_List;
  70 class Node_Notes;
  71 class NodeHash;
  72 class NodeCloneInfo;
  73 class OptoReg;
  74 class ParsePredicateNode;
  75 class PartialEscapeAnalysis;
  76 class PhaseCFG;
  77 class PhaseGVN;
  78 class PhaseIterGVN;
  79 class PhaseRegAlloc;
  80 class PhaseCCP;
  81 class PhaseOutput;
  82 class RootNode;
  83 class relocInfo;
  84 class StartNode;
  85 class SafePointNode;
  86 class JVMState;
  87 class Type;
  88 class TypeInt;
  89 class TypeInteger;
  90 class TypeKlassPtr;
  91 class TypePtr;
  92 class TypeOopPtr;
  93 class TypeFunc;
  94 class TypeVect;
  95 class Type_Array;
  96 class Unique_Node_List;
  97 class UnstableIfTrap;
  98 class nmethod;
  99 class Node_Stack;
 100 struct Final_Reshape_Counts;
 101 class VerifyMeetResult;
 102 
 103 typedef AllocateNode* ObjID;
 104 
 105 enum LoopOptsMode {
 106   LoopOptsDefault,
 107   LoopOptsNone,
 108   LoopOptsMaxUnroll,
 109   LoopOptsShenandoahExpand,
 110   LoopOptsShenandoahPostExpand,
 111   LoopOptsSkipSplitIf,
 112   LoopOptsVerify
 113 };
 114 
 115 // The type of all node counts and indexes.
 116 // It must hold at least 16 bits, but must also be fast to load and store.
 117 // This type, if less than 32 bits, could limit the number of possible nodes.
 118 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
 119 typedef unsigned int node_idx_t;
 120 
 121 class NodeCloneInfo {
 122  private:
 123   uint64_t _idx_clone_orig;
 124  public:

 346   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 347   bool                  _print_inlining;        // True if we should print inlining for this compilation
 348   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 349 #ifndef PRODUCT
 350   uint                  _igv_idx;               // Counter for IGV node identifiers
 351   uint                  _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
 352   bool                  _trace_opto_output;
 353   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 354 #endif
 355   bool                  _has_irreducible_loop;  // Found irreducible loops
 356   // JSR 292
 357   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 358   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 359   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
 360   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 361   int                   _loop_opts_cnt;         // loop opts round
 362   uint                  _stress_seed;           // Seed for stress testing
 363 
 364   // Compilation environment.
 365   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 366   Arena*                _parser_arena;          // Arena with lifttime equivalent to the top-level parser.
 367   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 368   ciEnv*                _env;                   // CI interface
 369   DirectiveSet*         _directive;             // Compiler directive
 370   CompileLog*           _log;                   // from CompilerThread
 371   const char*           _failure_reason;        // for record_failure/failing pattern
 372   CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
 373   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 374   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 375   GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
 376   GrowableArray<Node*>  _template_assertion_predicate_opaqs; // List of Opaque4 nodes for Template Assertion Predicates.
 377   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 378   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over
 379   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 380   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes
 381   PartialEscapeAnalysis* _pea;
 382   ConnectionGraph*      _congraph;
 383 #ifndef PRODUCT
 384   IdealGraphPrinter*    _igv_printer;
 385   static IdealGraphPrinter* _debug_file_printer;
 386   static IdealGraphPrinter* _debug_network_printer;
 387 #endif
 388 
 389 
 390   // Node management
 391   uint                  _unique;                // Counter for unique Node indices
 392   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 393                                                 // So use this to keep count and make the call O(1).
 394   VectorSet             _dead_node_list;        // Set of dead nodes
 395   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 396   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 397 
 398   // Arenas for new-space and old-space nodes.
 399   // Swapped between using _node_arena.
 400   // The lifetime of the old-space nodes is during xform.
 401   Arena                 _node_arena_one;

 770     if (parse_predicate_count() > 0) {
 771       _parse_predicates.remove_if_existing(n);
 772     }
 773   }
 774 
 775   void add_template_assertion_predicate_opaq(Node* n) {
 776     assert(!_template_assertion_predicate_opaqs.contains(n),
 777            "duplicate entry in template assertion predicate opaque4 list");
 778     _template_assertion_predicate_opaqs.append(n);
 779   }
 780 
 781   void remove_template_assertion_predicate_opaq(Node* n) {
 782     if (template_assertion_predicate_count() > 0) {
 783       _template_assertion_predicate_opaqs.remove_if_existing(n);
 784     }
 785   }
 786   void add_coarsened_locks(GrowableArray<AbstractLockNode*>& locks);
 787   void remove_coarsened_lock(Node* n);
 788   bool coarsened_locks_consistent();
 789 
 790   PartialEscapeAnalysis* PEA() const {
 791     assert(!DoPartialEscapeAnalysis || _pea != nullptr, "sanity check");
 792     return _pea;
 793   }
 794 
 795   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 796   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 797   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 798 
 799   void record_for_post_loop_opts_igvn(Node* n);
 800   void remove_from_post_loop_opts_igvn(Node* n);
 801   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 802 
 803   void record_unstable_if_trap(UnstableIfTrap* trap);
 804   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 805   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 806   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 807 
 808   void sort_macro_nodes();
 809 
 810   void mark_parse_predicate_nodes_useless(PhaseIterGVN& igvn);
 811 
 812   // Are there candidate expensive nodes for optimization?
 813   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 814   // Check whether n1 and n2 are similar
 815   static int cmp_expensive_nodes(Node* n1, Node* n2);
 816   // Sort expensive nodes to locate similar expensive nodes
 817   void sort_expensive_nodes();
 818 
 819   // Compilation environment.
 820   Arena*      comp_arena()           { return &_comp_arena; }
 821   Arena*      parser_arena()         { return comp_arena(); } // for the time being, just return comp_arena.
 822   ciEnv*      env() const            { return _env; }
 823   CompileLog* log() const            { return _log; }
 824   bool        failing() const        { return _env->failing() || _failure_reason != nullptr; }
 825   const char* failure_reason() const { return (_env->failing()) ? _env->failure_reason() : _failure_reason; }
 826   const CompilationFailureInfo* first_failure_details() const { return _first_failure_details; }
 827 
 828   bool failure_reason_is(const char* r) const {
 829     return (r == _failure_reason) || (r != nullptr && _failure_reason != nullptr && strcmp(r, _failure_reason) == 0);
 830   }
 831 
 832   void record_failure(const char* reason);
 833   void record_method_not_compilable(const char* reason) {
 834     env()->record_method_not_compilable(reason);
 835     // Record failure reason.
 836     record_failure(reason);
 837   }
 838   bool check_node_count(uint margin, const char* reason) {
 839     if (oom()) {
 840       record_method_not_compilable_oom();
 841       return true;
< prev index next >