< 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 CloneMap;
  55 class ConnectionGraph;
  56 class IdealGraphPrinter;
  57 class InlineTree;
  58 class Int_Array;
  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 Scope;
  80 class StartNode;
  81 class SafePointNode;
  82 class JVMState;
  83 class Type;
  84 class TypeData;
  85 class TypeInt;
  86 class TypeInteger;
  87 class TypePtr;
  88 class TypeOopPtr;
  89 class TypeFunc;
  90 class TypeVect;
  91 class Unique_Node_List;

  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 typedef unsigned int node_idx_t;
 107 class NodeCloneInfo {
 108  private:
 109   uint64_t _idx_clone_orig;
 110  public:
 111 

 318   bool                  _do_scheduling;         // True if we intend to do scheduling
 319   bool                  _do_freq_based_layout;  // True if we intend to do frequency based block layout
 320   bool                  _do_vector_loop;        // True if allowed to execute loop in parallel iterations
 321   bool                  _use_cmove;             // True if CMove should be used without profitability analysis
 322   bool                  _age_code;              // True if we need to profile code age (decrement the aging counter)
 323   int                   _AliasLevel;            // Locally-adjusted version of AliasLevel flag.
 324   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 325   bool                  _print_inlining;        // True if we should print inlining for this compilation
 326   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 327 #ifndef PRODUCT
 328   uint                  _igv_idx;               // Counter for IGV node identifiers
 329   bool                  _trace_opto_output;
 330   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 331 #endif
 332   bool                  _has_irreducible_loop;  // Found irreducible loops
 333   // JSR 292
 334   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
 335   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 336   int                   _loop_opts_cnt;         // loop opts round
 337   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry



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

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

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









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

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







 728   void sort_macro_nodes();
 729 
 730   // remove the opaque nodes that protect the predicates so that the unused checks and
 731   // uncommon traps will be eliminated from the graph.
 732   void cleanup_loop_predicates(PhaseIterGVN &igvn);
 733   bool is_predicate_opaq(Node* n) {
 734     return _predicate_opaqs.contains(n);
 735   }
 736 
 737   // Are there candidate expensive nodes for optimization?
 738   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 739   // Check whether n1 and n2 are similar
 740   static int cmp_expensive_nodes(Node* n1, Node* n2);
 741   // Sort expensive nodes to locate similar expensive nodes
 742   void sort_expensive_nodes();
 743 
 744   // Compilation environment.
 745   Arena*      comp_arena()           { return &_comp_arena; }
 746   ciEnv*      env() const            { return _env; }
 747   CompileLog* log() const            { return _log; }

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

 921   // Return a bitset with the reasons where deoptimization is allowed,
 922   // i.e., where there were not too many uncommon traps.
 923   int _allowed_reasons;
 924   int      allowed_deopt_reasons() { return _allowed_reasons; }
 925   void set_allowed_deopt_reasons();
 926 
 927   // Parsing, optimization
 928   PhaseGVN*         initial_gvn()               { return _initial_gvn; }
 929   Unique_Node_List* for_igvn()                  { return _for_igvn; }
 930   inline void       record_for_igvn(Node* n);   // Body is after class Unique_Node_List.
 931   void          set_initial_gvn(PhaseGVN *gvn)           { _initial_gvn = gvn; }
 932   void          set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }
 933 
 934   // Replace n by nn using initial_gvn, calling hash_delete and
 935   // record_for_igvn as needed.
 936   void gvn_replace_by(Node* n, Node* nn);
 937 
 938 
 939   void              identify_useful_nodes(Unique_Node_List &useful);
 940   void              update_dead_node_list(Unique_Node_List &useful);
 941   void              remove_useless_nodes (Unique_Node_List &useful);
 942 
 943   void              remove_useless_node(Node* dead);
 944 
 945   // Record this CallGenerator for inlining at the end of parsing.
 946   void              add_late_inline(CallGenerator* cg)        {
 947     _late_inlines.insert_before(_late_inlines_pos, cg);
 948     _late_inlines_pos++;
 949   }
 950 
 951   void              prepend_late_inline(CallGenerator* cg)    {
 952     _late_inlines.insert_before(0, cg);
 953   }
 954 
 955   void              add_string_late_inline(CallGenerator* cg) {
 956     _string_late_inlines.push(cg);
 957   }
 958 
 959   void              add_boxing_late_inline(CallGenerator* cg) {
 960     _boxing_late_inlines.push(cg);
 961   }

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

1157   // End-of-run dumps.
1158   static void print_statistics() PRODUCT_RETURN;
1159 
1160   // Verify ADLC assumptions during startup
1161   static void adlc_verification() PRODUCT_RETURN;
1162 
1163   // Definitions of pd methods
1164   static void pd_compiler2_init();
1165 
1166   // Static parse-time type checking logic for gen_subtype_check:
1167   enum { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1168   int static_subtype_check(ciKlass* superk, ciKlass* subk);
1169 
1170   static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1171                               // Optional control dependency (for example, on range check)
1172                               Node* ctrl = NULL);
1173 
1174   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1175   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1176 
1177   // Auxiliary methods for randomized fuzzing/stressing


1178   int random();
1179   bool randomized_select(int count);
1180 
1181   // supporting clone_map
1182   CloneMap&     clone_map();
1183   void          set_clone_map(Dict* d);
1184 
1185   bool needs_clinit_barrier(ciField* ik,         ciMethod* accessing_method);
1186   bool needs_clinit_barrier(ciMethod* ik,        ciMethod* accessing_method);
1187   bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1188 
1189 #ifdef IA32
1190  private:
1191   bool _select_24_bit_instr;   // We selected an instruction with a 24-bit result
1192   bool _in_24_bit_fp_mode;     // We are emitting instructions with 24-bit results
1193 
1194   // Remember if this compilation changes hardware mode to 24-bit precision.
1195   void set_24_bit_selection_and_mode(bool selection, bool mode) {
1196     _select_24_bit_instr = selection;
1197     _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 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;
  74 class PhaseIterGVN;
  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 TypePtr;
  89 class TypeOopPtr;
  90 class TypeFunc;
  91 class TypeVect;
  92 class Unique_Node_List;
  93 class InlineTypeBaseNode;
  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 typedef unsigned int node_idx_t;
 109 class NodeCloneInfo {
 110  private:
 111   uint64_t _idx_clone_orig;
 112  public:
 113 

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

 615   void          set_do_vector_loop(bool z)      { _do_vector_loop = z; }
 616   bool              use_cmove() const           { return _use_cmove; }
 617   void          set_use_cmove(bool z)           { _use_cmove = z; }
 618   bool              age_code() const             { return _age_code; }
 619   void          set_age_code(bool z)             { _age_code = 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   void          set_flattened_accesses()         { _has_flattened_accesses = true; }
 636   bool          flattened_accesses_share_alias() const { return _flattened_accesses_share_alias; }
 637   void          set_flattened_accesses_share_alias(bool z) { _flattened_accesses_share_alias = z; }
 638   bool          scalarize_in_safepoints() const { return _scalarize_in_safepoints; }
 639   void          set_scalarize_in_safepoints(bool z) { _scalarize_in_safepoints = z; }
 640 
 641   // Support for scalarized inline type calling convention
 642   bool              has_scalarized_args() const  { return _method != NULL && _method->has_scalarized_args(); }
 643   bool              needs_stack_repair()  const  { return _method != NULL && _method->get_Method()->c2_needs_stack_repair(); }
 644 
 645   // check the CompilerOracle for special behaviours for this compile
 646   bool          method_has_option(enum CompileCommand option) {
 647     return method() != NULL && method()->has_option(option);
 648   }
 649 
 650 #ifndef PRODUCT
 651   uint          next_igv_idx()                  { return _igv_idx++; }
 652   bool          trace_opto_output() const       { return _trace_opto_output; }
 653   void          print_ideal_ir(const char* phase_name);
 654   bool          should_print_ideal() const      { return _directive->PrintIdealOption; }
 655   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 656   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 657   int _in_dump_cnt;  // Required for dumping ir nodes.
 658 #endif
 659   bool              has_irreducible_loop() const { return _has_irreducible_loop; }
 660   void          set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
 661 
 662   // JSR 292
 663   bool              has_method_handle_invokes() const { return _has_method_handle_invokes;     }

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

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

 943   // Return a bitset with the reasons where deoptimization is allowed,
 944   // i.e., where there were not too many uncommon traps.
 945   int _allowed_reasons;
 946   int      allowed_deopt_reasons() { return _allowed_reasons; }
 947   void set_allowed_deopt_reasons();
 948 
 949   // Parsing, optimization
 950   PhaseGVN*         initial_gvn()               { return _initial_gvn; }
 951   Unique_Node_List* for_igvn()                  { return _for_igvn; }
 952   inline void       record_for_igvn(Node* n);   // Body is after class Unique_Node_List.
 953   void          set_initial_gvn(PhaseGVN *gvn)           { _initial_gvn = gvn; }
 954   void          set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }
 955 
 956   // Replace n by nn using initial_gvn, calling hash_delete and
 957   // record_for_igvn as needed.
 958   void gvn_replace_by(Node* n, Node* nn);
 959 
 960 
 961   void              identify_useful_nodes(Unique_Node_List &useful);
 962   void              update_dead_node_list(Unique_Node_List &useful);
 963   void              disconnect_useless_nodes(Unique_Node_List &useful, Unique_Node_List* worklist);
 964 
 965   void              remove_useless_node(Node* dead);
 966 
 967   // Record this CallGenerator for inlining at the end of parsing.
 968   void              add_late_inline(CallGenerator* cg)        {
 969     _late_inlines.insert_before(_late_inlines_pos, cg);
 970     _late_inlines_pos++;
 971   }
 972 
 973   void              prepend_late_inline(CallGenerator* cg)    {
 974     _late_inlines.insert_before(0, cg);
 975   }
 976 
 977   void              add_string_late_inline(CallGenerator* cg) {
 978     _string_late_inlines.push(cg);
 979   }
 980 
 981   void              add_boxing_late_inline(CallGenerator* cg) {
 982     _boxing_late_inlines.push(cg);
 983   }

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

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