< 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 Int_Array;
  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;

  75 class PhaseRegAlloc;
  76 class PhaseCCP;
  77 class PhaseOutput;
  78 class RootNode;
  79 class relocInfo;
  80 class Scope;
  81 class StartNode;
  82 class SafePointNode;
  83 class JVMState;
  84 class Type;
  85 class TypeData;
  86 class TypeInt;
  87 class TypeInteger;
  88 class TypeKlassPtr;
  89 class TypePtr;
  90 class TypeOopPtr;
  91 class TypeFunc;
  92 class TypeVect;
  93 class Unique_Node_List;
  94 class UnstableIfTrap;

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

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



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

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

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










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

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







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

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

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

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);
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 Int_Array;
  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 NodeCloneInfo;
  72 class OptoReg;
  73 class PhaseCFG;
  74 class PhaseGVN;

  76 class PhaseRegAlloc;
  77 class PhaseCCP;
  78 class PhaseOutput;
  79 class RootNode;
  80 class relocInfo;
  81 class Scope;
  82 class StartNode;
  83 class SafePointNode;
  84 class JVMState;
  85 class Type;
  86 class TypeData;
  87 class TypeInt;
  88 class TypeInteger;
  89 class TypeKlassPtr;
  90 class TypePtr;
  91 class TypeOopPtr;
  92 class TypeFunc;
  93 class TypeVect;
  94 class Unique_Node_List;
  95 class UnstableIfTrap;
  96 class InlineTypeBaseNode;
  97 class nmethod;
  98 class Node_Stack;
  99 struct Final_Reshape_Counts;
 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 

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

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

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

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

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

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);
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 >