< prev index next >

src/hotspot/share/opto/compile.hpp

Print this page

  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 ConnectionGraph;
  57 class IdealGraphPrinter;
  58 class InlineTree;
  59 class Matcher;
  60 class MachConstantNode;
  61 class MachConstantBaseNode;
  62 class MachNode;
  63 class MachOper;
  64 class MachSafePointNode;
  65 class Node;
  66 class Node_Array;
  67 class Node_List;
  68 class Node_Notes;
  69 class NodeCloneInfo;
  70 class OptoReg;
  71 class PhaseCFG;
  72 class PhaseGVN;
  73 class PhaseIterGVN;
  74 class PhaseRegAlloc;
  75 class PhaseCCP;
  76 class PhaseOutput;
  77 class RootNode;
  78 class relocInfo;
  79 class StartNode;
  80 class SafePointNode;
  81 class JVMState;
  82 class Type;
  83 class TypeInt;
  84 class TypeInteger;
  85 class TypeKlassPtr;
  86 class TypePtr;
  87 class TypeOopPtr;
  88 class TypeFunc;
  89 class TypeVect;
  90 class Unique_Node_List;
  91 class UnstableIfTrap;

  92 class nmethod;
  93 class Node_Stack;
  94 struct Final_Reshape_Counts;
  95 
  96 enum LoopOptsMode {
  97   LoopOptsDefault,
  98   LoopOptsNone,
  99   LoopOptsMaxUnroll,
 100   LoopOptsShenandoahExpand,
 101   LoopOptsShenandoahPostExpand,
 102   LoopOptsSkipSplitIf,
 103   LoopOptsVerify
 104 };
 105 
 106 // The type of all node counts and indexes.
 107 // It must hold at least 16 bits, but must also be fast to load and store.
 108 // This type, if less than 32 bits, could limit the number of possible nodes.
 109 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
 110 typedef unsigned int node_idx_t;
 111 

 322   bool                  _do_scheduling;         // True if we intend to do scheduling
 323   bool                  _do_freq_based_layout;  // True if we intend to do frequency based block layout
 324   bool                  _do_vector_loop;        // True if allowed to execute loop in parallel iterations
 325   bool                  _use_cmove;             // True if CMove should be used without profitability analysis
 326   bool                  _do_aliasing;           // True if we intend to do aliasing
 327   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 328   bool                  _print_inlining;        // True if we should print inlining for this compilation
 329   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 330 #ifndef PRODUCT
 331   uint                  _igv_idx;               // Counter for IGV node identifiers
 332   bool                  _trace_opto_output;
 333   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 334 #endif
 335   bool                  _has_irreducible_loop;  // Found irreducible loops
 336   // JSR 292
 337   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 338   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 339   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 340   int                   _loop_opts_cnt;         // loop opts round
 341   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry



 342   uint                  _stress_seed;           // Seed for stress testing
 343 
 344   // Compilation environment.
 345   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 346   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 347   ciEnv*                _env;                   // CI interface
 348   DirectiveSet*         _directive;             // Compiler directive
 349   CompileLog*           _log;                   // from CompilerThread
 350   const char*           _failure_reason;        // for record_failure/failing pattern
 351   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 352   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 353   GrowableArray<Node*>  _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 354   GrowableArray<Node*>  _skeleton_predicate_opaqs; // List of Opaque4 nodes for the loop skeleton predicates.
 355   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 356   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over

 357   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 358   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes
 359   ConnectionGraph*      _congraph;
 360 #ifndef PRODUCT
 361   IdealGraphPrinter*    _igv_printer;
 362   static IdealGraphPrinter* _debug_file_printer;
 363   static IdealGraphPrinter* _debug_network_printer;
 364 #endif
 365 
 366 
 367   // Node management
 368   uint                  _unique;                // Counter for unique Node indices
 369   VectorSet             _dead_node_list;        // Set of dead nodes
 370   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 371                                                 // So use this to keep count and make the call O(1).
 372   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 373   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 374 
 375   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 376   Arena                 _node_arena;            // Arena for new-space Nodes

 610   void          set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
 611   bool              do_vector_loop() const      { return _do_vector_loop; }
 612   void          set_do_vector_loop(bool z)      { _do_vector_loop = z; }
 613   bool              use_cmove() const           { return _use_cmove; }
 614   void          set_use_cmove(bool z)           { _use_cmove = z; }
 615   bool              do_aliasing() const          { return _do_aliasing; }
 616   bool              print_assembly() const       { return _print_assembly; }
 617   void          set_print_assembly(bool z)       { _print_assembly = z; }
 618   bool              print_inlining() const       { return _print_inlining; }
 619   void          set_print_inlining(bool z)       { _print_inlining = z; }
 620   bool              print_intrinsics() const     { return _print_intrinsics; }
 621   void          set_print_intrinsics(bool z)     { _print_intrinsics = z; }
 622   RTMState          rtm_state()  const           { return _rtm_state; }
 623   void          set_rtm_state(RTMState s)        { _rtm_state = s; }
 624   bool              use_rtm() const              { return (_rtm_state & NoRTM) == 0; }
 625   bool          profile_rtm() const              { return _rtm_state == ProfileRTM; }
 626   uint              max_node_limit() const       { return (uint)_max_node_limit; }
 627   void          set_max_node_limit(uint n)       { _max_node_limit = n; }
 628   bool              clinit_barrier_on_entry()       { return _clinit_barrier_on_entry; }
 629   void          set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }










 630   bool              has_monitors() const         { return _has_monitors; }
 631   void          set_has_monitors(bool v)         { _has_monitors = v; }
 632 
 633   // check the CompilerOracle for special behaviours for this compile
 634   bool          method_has_option(enum CompileCommand option) {
 635     return method() != NULL && method()->has_option(option);
 636   }
 637 
 638 #ifndef PRODUCT
 639   uint          next_igv_idx()                  { return _igv_idx++; }
 640   bool          trace_opto_output() const       { return _trace_opto_output; }
 641   void          print_ideal_ir(const char* phase_name);
 642   bool          should_print_ideal() const      { return _directive->PrintIdealOption; }
 643   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 644   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 645   int _in_dump_cnt;  // Required for dumping ir nodes.
 646 #endif
 647   bool              has_irreducible_loop() const { return _has_irreducible_loop; }
 648   void          set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
 649 

 711     assert(!_skeleton_predicate_opaqs.contains(n), "duplicate entry in skeleton predicate opaque4 list");
 712     _skeleton_predicate_opaqs.append(n);
 713   }
 714   void remove_skeleton_predicate_opaq(Node* n) {
 715     if (skeleton_predicate_count() > 0) {
 716       _skeleton_predicate_opaqs.remove_if_existing(n);
 717     }
 718   }
 719   void add_coarsened_locks(GrowableArray<AbstractLockNode*>& locks);
 720   void remove_coarsened_lock(Node* n);
 721   bool coarsened_locks_consistent();
 722 
 723   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 724   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 725   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 726 
 727   void record_for_post_loop_opts_igvn(Node* n);
 728   void remove_from_post_loop_opts_igvn(Node* n);
 729   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 730 







 731   void record_unstable_if_trap(UnstableIfTrap* trap);
 732   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 733   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 734   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 735 
 736   void sort_macro_nodes();
 737 
 738   // remove the opaque nodes that protect the predicates so that the unused checks and
 739   // uncommon traps will be eliminated from the graph.
 740   void cleanup_loop_predicates(PhaseIterGVN &igvn);
 741   bool is_predicate_opaq(Node* n) {
 742     return _predicate_opaqs.contains(n);
 743   }
 744 
 745   // Are there candidate expensive nodes for optimization?
 746   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 747   // Check whether n1 and n2 are similar
 748   static int cmp_expensive_nodes(Node* n1, Node* n2);
 749   // Sort expensive nodes to locate similar expensive nodes
 750   void sort_expensive_nodes();

 855   Arena*            type_arena()                { return _type_arena; }
 856   Dict*             type_dict()                 { return _type_dict; }
 857   size_t            type_last_size()            { return _type_last_size; }
 858   int               num_alias_types()           { return _num_alias_types; }
 859 
 860   void          init_type_arena()                       { _type_arena = &_Compile_types; }
 861   void          set_type_arena(Arena* a)                { _type_arena = a; }
 862   void          set_type_dict(Dict* d)                  { _type_dict = d; }
 863   void          set_type_last_size(size_t sz)           { _type_last_size = sz; }
 864 
 865   const TypeFunc* last_tf(ciMethod* m) {
 866     return (m == _last_tf_m) ? _last_tf : NULL;
 867   }
 868   void set_last_tf(ciMethod* m, const TypeFunc* tf) {
 869     assert(m != NULL || tf == NULL, "");
 870     _last_tf_m = m;
 871     _last_tf = tf;
 872   }
 873 
 874   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
 875   AliasType*        alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
 876   bool         have_alias_type(const TypePtr* adr_type);
 877   AliasType*        alias_type(ciField*         field);
 878 
 879   int               get_alias_index(const TypePtr* at)  { return alias_type(at)->index(); }
 880   const TypePtr*    get_adr_type(uint aidx)             { return alias_type(aidx)->adr_type(); }
 881   int               get_general_index(uint aidx)        { return alias_type(aidx)->general_index(); }
 882 
 883   // Building nodes
 884   void              rethrow_exceptions(JVMState* jvms);
 885   void              return_values(JVMState* jvms);
 886   JVMState*         build_start_state(StartNode* start, const TypeFunc* tf);
 887 
 888   // Decide how to build a call.
 889   // The profile factor is a discount to apply to this site's interp. profile.
 890   CallGenerator*    call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
 891                                    JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,
 892                                    bool allow_intrinsics = true);
 893   bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
 894     return should_delay_string_inlining(call_method, jvms) ||
 895            should_delay_boxing_inlining(call_method, jvms) ||
 896            should_delay_vector_inlining(call_method, jvms);
 897   }
 898   bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
 899   bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);

1090   // Number of outgoing stack slots killed above the out_preserve_stack_slots
1091   // for calls to C.  Supports the var-args backing area for register parms.
1092   uint varargs_C_out_slots_killed() const;
1093 
1094   // Number of Stack Slots consumed by a synchronization entry
1095   int sync_stack_slots() const;
1096 
1097   // Compute the name of old_SP.  See <arch>.ad for frame layout.
1098   OptoReg::Name compute_old_SP();
1099 
1100  private:
1101   // Phase control:
1102   void Init(bool aliasing);                      // Prepare for a single compilation
1103   void Optimize();                               // Given a graph, optimize it
1104   void Code_Gen();                               // Generate code from a graph
1105 
1106   // Management of the AliasType table.
1107   void grow_alias_types();
1108   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1109   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1110   AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
1111 
1112   void verify_top(Node*) const PRODUCT_RETURN;
1113 
1114   // Intrinsic setup.
1115   CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual);          // constructor
1116   int            intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found);  // helper
1117   CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual);             // query fn
1118   void           register_intrinsic(CallGenerator* cg);                    // update fn
1119 
1120 #ifndef PRODUCT
1121   static juint  _intrinsic_hist_count[];
1122   static jubyte _intrinsic_hist_flags[];
1123 #endif
1124   // Function calls made by the public function final_graph_reshaping.
1125   // No need to be made public as they are not called elsewhere.
1126   void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1127   void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1128   void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1129   void eliminate_redundant_card_marks(Node* n);
1130 

1166   // End-of-run dumps.
1167   static void print_statistics() PRODUCT_RETURN;
1168 
1169   // Verify ADLC assumptions during startup
1170   static void adlc_verification() PRODUCT_RETURN;
1171 
1172   // Definitions of pd methods
1173   static void pd_compiler2_init();
1174 
1175   // Static parse-time type checking logic for gen_subtype_check:
1176   enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1177   SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1178 
1179   static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1180                               // Optional control dependency (for example, on range check)
1181                               Node* ctrl = NULL);
1182 
1183   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1184   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1185 
1186   // Auxiliary methods for randomized fuzzing/stressing


1187   int random();
1188   bool randomized_select(int count);
1189 
1190   // supporting clone_map
1191   CloneMap&     clone_map();
1192   void          set_clone_map(Dict* d);
1193 
1194   bool needs_clinit_barrier(ciField* ik,         ciMethod* accessing_method);
1195   bool needs_clinit_barrier(ciMethod* ik,        ciMethod* accessing_method);
1196   bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1197 
1198 #ifdef IA32
1199  private:
1200   bool _select_24_bit_instr;   // We selected an instruction with a 24-bit result
1201   bool _in_24_bit_fp_mode;     // We are emitting instructions with 24-bit results
1202 
1203   // Remember if this compilation changes hardware mode to 24-bit precision.
1204   void set_24_bit_selection_and_mode(bool selection, bool mode) {
1205     _select_24_bit_instr = selection;
1206     _in_24_bit_fp_mode   = mode;

  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 CallNode;
  55 class CallStaticJavaNode;
  56 class CloneMap;
  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 NodeCloneInfo;
  71 class OptoReg;
  72 class PhaseCFG;
  73 class PhaseGVN;
  74 class PhaseIterGVN;
  75 class PhaseRegAlloc;
  76 class PhaseCCP;
  77 class PhaseOutput;
  78 class RootNode;
  79 class relocInfo;
  80 class StartNode;
  81 class SafePointNode;
  82 class JVMState;
  83 class Type;
  84 class TypeInt;
  85 class TypeInteger;
  86 class TypeKlassPtr;
  87 class TypePtr;
  88 class TypeOopPtr;
  89 class TypeFunc;
  90 class TypeVect;
  91 class Unique_Node_List;
  92 class UnstableIfTrap;
  93 class InlineTypeNode;
  94 class nmethod;
  95 class Node_Stack;
  96 struct Final_Reshape_Counts;
  97 
  98 enum LoopOptsMode {
  99   LoopOptsDefault,
 100   LoopOptsNone,
 101   LoopOptsMaxUnroll,
 102   LoopOptsShenandoahExpand,
 103   LoopOptsShenandoahPostExpand,
 104   LoopOptsSkipSplitIf,
 105   LoopOptsVerify
 106 };
 107 
 108 // The type of all node counts and indexes.
 109 // It must hold at least 16 bits, but must also be fast to load and store.
 110 // This type, if less than 32 bits, could limit the number of possible nodes.
 111 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
 112 typedef unsigned int node_idx_t;
 113 

 324   bool                  _do_scheduling;         // True if we intend to do scheduling
 325   bool                  _do_freq_based_layout;  // True if we intend to do frequency based block layout
 326   bool                  _do_vector_loop;        // True if allowed to execute loop in parallel iterations
 327   bool                  _use_cmove;             // True if CMove should be used without profitability analysis
 328   bool                  _do_aliasing;           // True if we intend to do aliasing
 329   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 330   bool                  _print_inlining;        // True if we should print inlining for this compilation
 331   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 332 #ifndef PRODUCT
 333   uint                  _igv_idx;               // Counter for IGV node identifiers
 334   bool                  _trace_opto_output;
 335   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 336 #endif
 337   bool                  _has_irreducible_loop;  // Found irreducible loops
 338   // JSR 292
 339   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 340   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 341   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 342   int                   _loop_opts_cnt;         // loop opts round
 343   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
 344   bool                  _has_flattened_accesses; // Any known flattened array accesses?
 345   bool                  _flattened_accesses_share_alias; // Initially all flattened array share a single slice
 346   bool                  _scalarize_in_safepoints; // Scalarize inline types in safepoint debug info
 347   uint                  _stress_seed;           // Seed for stress testing
 348 
 349   // Compilation environment.
 350   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 351   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 352   ciEnv*                _env;                   // CI interface
 353   DirectiveSet*         _directive;             // Compiler directive
 354   CompileLog*           _log;                   // from CompilerThread
 355   const char*           _failure_reason;        // for record_failure/failing pattern
 356   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 357   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 358   GrowableArray<Node*>  _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
 359   GrowableArray<Node*>  _skeleton_predicate_opaqs; // List of Opaque4 nodes for the loop skeleton predicates.
 360   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 361   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over
 362   GrowableArray<Node*>  _inline_type_nodes;     // List of InlineType nodes
 363   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 364   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes
 365   ConnectionGraph*      _congraph;
 366 #ifndef PRODUCT
 367   IdealGraphPrinter*    _igv_printer;
 368   static IdealGraphPrinter* _debug_file_printer;
 369   static IdealGraphPrinter* _debug_network_printer;
 370 #endif
 371 
 372 
 373   // Node management
 374   uint                  _unique;                // Counter for unique Node indices
 375   VectorSet             _dead_node_list;        // Set of dead nodes
 376   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 377                                                 // So use this to keep count and make the call O(1).
 378   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 379   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 380 
 381   debug_only(static int _debug_idx;)            // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
 382   Arena                 _node_arena;            // Arena for new-space Nodes

 616   void          set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
 617   bool              do_vector_loop() const      { return _do_vector_loop; }
 618   void          set_do_vector_loop(bool z)      { _do_vector_loop = z; }
 619   bool              use_cmove() const           { return _use_cmove; }
 620   void          set_use_cmove(bool z)           { _use_cmove = z; }
 621   bool              do_aliasing() const          { return _do_aliasing; }
 622   bool              print_assembly() const       { return _print_assembly; }
 623   void          set_print_assembly(bool z)       { _print_assembly = z; }
 624   bool              print_inlining() const       { return _print_inlining; }
 625   void          set_print_inlining(bool z)       { _print_inlining = z; }
 626   bool              print_intrinsics() const     { return _print_intrinsics; }
 627   void          set_print_intrinsics(bool z)     { _print_intrinsics = z; }
 628   RTMState          rtm_state()  const           { return _rtm_state; }
 629   void          set_rtm_state(RTMState s)        { _rtm_state = s; }
 630   bool              use_rtm() const              { return (_rtm_state & NoRTM) == 0; }
 631   bool          profile_rtm() const              { return _rtm_state == ProfileRTM; }
 632   uint              max_node_limit() const       { return (uint)_max_node_limit; }
 633   void          set_max_node_limit(uint n)       { _max_node_limit = n; }
 634   bool              clinit_barrier_on_entry()       { return _clinit_barrier_on_entry; }
 635   void          set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
 636   void          set_flattened_accesses()         { _has_flattened_accesses = true; }
 637   bool          flattened_accesses_share_alias() const { return _flattened_accesses_share_alias; }
 638   void          set_flattened_accesses_share_alias(bool z) { _flattened_accesses_share_alias = z; }
 639   bool          scalarize_in_safepoints() const { return _scalarize_in_safepoints; }
 640   void          set_scalarize_in_safepoints(bool z) { _scalarize_in_safepoints = z; }
 641 
 642   // Support for scalarized inline type calling convention
 643   bool              has_scalarized_args() const  { return _method != NULL && _method->has_scalarized_args(); }
 644   bool              needs_stack_repair()  const  { return _method != NULL && _method->get_Method()->c2_needs_stack_repair(); }
 645 
 646   bool              has_monitors() const         { return _has_monitors; }
 647   void          set_has_monitors(bool v)         { _has_monitors = v; }
 648 
 649   // check the CompilerOracle for special behaviours for this compile
 650   bool          method_has_option(enum CompileCommand option) {
 651     return method() != NULL && method()->has_option(option);
 652   }
 653 
 654 #ifndef PRODUCT
 655   uint          next_igv_idx()                  { return _igv_idx++; }
 656   bool          trace_opto_output() const       { return _trace_opto_output; }
 657   void          print_ideal_ir(const char* phase_name);
 658   bool          should_print_ideal() const      { return _directive->PrintIdealOption; }
 659   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 660   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 661   int _in_dump_cnt;  // Required for dumping ir nodes.
 662 #endif
 663   bool              has_irreducible_loop() const { return _has_irreducible_loop; }
 664   void          set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
 665 

 727     assert(!_skeleton_predicate_opaqs.contains(n), "duplicate entry in skeleton predicate opaque4 list");
 728     _skeleton_predicate_opaqs.append(n);
 729   }
 730   void remove_skeleton_predicate_opaq(Node* n) {
 731     if (skeleton_predicate_count() > 0) {
 732       _skeleton_predicate_opaqs.remove_if_existing(n);
 733     }
 734   }
 735   void add_coarsened_locks(GrowableArray<AbstractLockNode*>& locks);
 736   void remove_coarsened_lock(Node* n);
 737   bool coarsened_locks_consistent();
 738 
 739   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 740   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 741   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 742 
 743   void record_for_post_loop_opts_igvn(Node* n);
 744   void remove_from_post_loop_opts_igvn(Node* n);
 745   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 746 
 747   // Keep track of inline type nodes for later processing
 748   void add_inline_type(Node* n);
 749   void remove_inline_type(Node* n);
 750   void process_inline_types(PhaseIterGVN &igvn, bool remove = false);
 751 
 752   void adjust_flattened_array_access_aliases(PhaseIterGVN& igvn);
 753 
 754   void record_unstable_if_trap(UnstableIfTrap* trap);
 755   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 756   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 757   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 758 
 759   void sort_macro_nodes();
 760 
 761   // remove the opaque nodes that protect the predicates so that the unused checks and
 762   // uncommon traps will be eliminated from the graph.
 763   void cleanup_loop_predicates(PhaseIterGVN &igvn);
 764   bool is_predicate_opaq(Node* n) {
 765     return _predicate_opaqs.contains(n);
 766   }
 767 
 768   // Are there candidate expensive nodes for optimization?
 769   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 770   // Check whether n1 and n2 are similar
 771   static int cmp_expensive_nodes(Node* n1, Node* n2);
 772   // Sort expensive nodes to locate similar expensive nodes
 773   void sort_expensive_nodes();

 878   Arena*            type_arena()                { return _type_arena; }
 879   Dict*             type_dict()                 { return _type_dict; }
 880   size_t            type_last_size()            { return _type_last_size; }
 881   int               num_alias_types()           { return _num_alias_types; }
 882 
 883   void          init_type_arena()                       { _type_arena = &_Compile_types; }
 884   void          set_type_arena(Arena* a)                { _type_arena = a; }
 885   void          set_type_dict(Dict* d)                  { _type_dict = d; }
 886   void          set_type_last_size(size_t sz)           { _type_last_size = sz; }
 887 
 888   const TypeFunc* last_tf(ciMethod* m) {
 889     return (m == _last_tf_m) ? _last_tf : NULL;
 890   }
 891   void set_last_tf(ciMethod* m, const TypeFunc* tf) {
 892     assert(m != NULL || tf == NULL, "");
 893     _last_tf_m = m;
 894     _last_tf = tf;
 895   }
 896 
 897   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
 898   AliasType*        alias_type(const TypePtr* adr_type, ciField* field = NULL, bool uncached = false) { return find_alias_type(adr_type, false, field, uncached); }
 899   bool         have_alias_type(const TypePtr* adr_type);
 900   AliasType*        alias_type(ciField*         field);
 901 
 902   int               get_alias_index(const TypePtr* at, bool uncached = false) { return alias_type(at, NULL, uncached)->index(); }
 903   const TypePtr*    get_adr_type(uint aidx)             { return alias_type(aidx)->adr_type(); }
 904   int               get_general_index(uint aidx)        { return alias_type(aidx)->general_index(); }
 905 
 906   // Building nodes
 907   void              rethrow_exceptions(JVMState* jvms);
 908   void              return_values(JVMState* jvms);
 909   JVMState*         build_start_state(StartNode* start, const TypeFunc* tf);
 910 
 911   // Decide how to build a call.
 912   // The profile factor is a discount to apply to this site's interp. profile.
 913   CallGenerator*    call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
 914                                    JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,
 915                                    bool allow_intrinsics = true);
 916   bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
 917     return should_delay_string_inlining(call_method, jvms) ||
 918            should_delay_boxing_inlining(call_method, jvms) ||
 919            should_delay_vector_inlining(call_method, jvms);
 920   }
 921   bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
 922   bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);

1113   // Number of outgoing stack slots killed above the out_preserve_stack_slots
1114   // for calls to C.  Supports the var-args backing area for register parms.
1115   uint varargs_C_out_slots_killed() const;
1116 
1117   // Number of Stack Slots consumed by a synchronization entry
1118   int sync_stack_slots() const;
1119 
1120   // Compute the name of old_SP.  See <arch>.ad for frame layout.
1121   OptoReg::Name compute_old_SP();
1122 
1123  private:
1124   // Phase control:
1125   void Init(bool aliasing);                      // Prepare for a single compilation
1126   void Optimize();                               // Given a graph, optimize it
1127   void Code_Gen();                               // Generate code from a graph
1128 
1129   // Management of the AliasType table.
1130   void grow_alias_types();
1131   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1132   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1133   AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field, bool uncached = false);
1134 
1135   void verify_top(Node*) const PRODUCT_RETURN;
1136 
1137   // Intrinsic setup.
1138   CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual);          // constructor
1139   int            intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found);  // helper
1140   CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual);             // query fn
1141   void           register_intrinsic(CallGenerator* cg);                    // update fn
1142 
1143 #ifndef PRODUCT
1144   static juint  _intrinsic_hist_count[];
1145   static jubyte _intrinsic_hist_flags[];
1146 #endif
1147   // Function calls made by the public function final_graph_reshaping.
1148   // No need to be made public as they are not called elsewhere.
1149   void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1150   void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1151   void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1152   void eliminate_redundant_card_marks(Node* n);
1153 

1189   // End-of-run dumps.
1190   static void print_statistics() PRODUCT_RETURN;
1191 
1192   // Verify ADLC assumptions during startup
1193   static void adlc_verification() PRODUCT_RETURN;
1194 
1195   // Definitions of pd methods
1196   static void pd_compiler2_init();
1197 
1198   // Static parse-time type checking logic for gen_subtype_check:
1199   enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1200   SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1201 
1202   static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1203                               // Optional control dependency (for example, on range check)
1204                               Node* ctrl = NULL);
1205 
1206   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1207   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1208 
1209   Node* optimize_acmp(PhaseGVN* phase, Node* a, Node* b);
1210 
1211   // Auxiliary method for randomized fuzzing/stressing
1212   int random();
1213   bool randomized_select(int count);
1214 
1215   // supporting clone_map
1216   CloneMap&     clone_map();
1217   void          set_clone_map(Dict* d);
1218 
1219   bool needs_clinit_barrier(ciField* ik,         ciMethod* accessing_method);
1220   bool needs_clinit_barrier(ciMethod* ik,        ciMethod* accessing_method);
1221   bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1222 
1223 #ifdef IA32
1224  private:
1225   bool _select_24_bit_instr;   // We selected an instruction with a 24-bit result
1226   bool _in_24_bit_fp_mode;     // We are emitting instructions with 24-bit results
1227 
1228   // Remember if this compilation changes hardware mode to 24-bit precision.
1229   void set_24_bit_selection_and_mode(bool selection, bool mode) {
1230     _select_24_bit_instr = selection;
1231     _in_24_bit_fp_mode   = mode;
< prev index next >