< prev index next >

src/hotspot/share/opto/compile.hpp

Print this page

  28 #include "asm/codeBuffer.hpp"
  29 #include "ci/compilerInterface.hpp"
  30 #include "code/debugInfoRec.hpp"
  31 #include "compiler/cHeapStringHolder.hpp"
  32 #include "compiler/compileBroker.hpp"
  33 #include "compiler/compiler_globals.hpp"
  34 #include "compiler/compilerEvent.hpp"
  35 #include "libadt/dict.hpp"
  36 #include "libadt/vectset.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "opto/idealGraphPrinter.hpp"
  40 #include "opto/phase.hpp"
  41 #include "opto/phasetype.hpp"
  42 #include "opto/printinlining.hpp"
  43 #include "opto/regmask.hpp"
  44 #include "runtime/deoptimization.hpp"
  45 #include "runtime/sharedRuntime.hpp"
  46 #include "runtime/timerTrace.hpp"
  47 #include "runtime/vmThread.hpp"

  48 #include "utilities/ticks.hpp"
  49 #include "utilities/vmEnums.hpp"
  50 
  51 class AbstractLockNode;
  52 class AddPNode;
  53 class Block;
  54 class Bundle;
  55 class CallGenerator;

  56 class CallStaticJavaNode;
  57 class CloneMap;
  58 class CompilationFailureInfo;
  59 class ConnectionGraph;
  60 class IdealGraphPrinter;
  61 class InlineTree;
  62 class Matcher;
  63 class MachConstantNode;
  64 class MachConstantBaseNode;
  65 class MachNode;
  66 class MachOper;
  67 class MachSafePointNode;
  68 class Node;
  69 class Node_Array;
  70 class Node_List;
  71 class Node_Notes;
  72 class NodeHash;
  73 class NodeCloneInfo;
  74 class OpaqueTemplateAssertionPredicateNode;
  75 class OptoReg;

  80 class PhaseRegAlloc;
  81 class PhaseCCP;
  82 class PhaseOutput;
  83 class ReachabilityFenceNode;
  84 class RootNode;
  85 class relocInfo;
  86 class StartNode;
  87 class SafePointNode;
  88 class JVMState;
  89 class Type;
  90 class TypeInt;
  91 class TypeInteger;
  92 class TypeKlassPtr;
  93 class TypePtr;
  94 class TypeOopPtr;
  95 class TypeFunc;
  96 class TypeVect;
  97 class Type_Array;
  98 class Unique_Node_List;
  99 class UnstableIfTrap;

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

 319   int                   _fixed_slots;           // count of frame slots not allocated by the register
 320                                                 // allocator i.e. locks, original deopt pc, etc.
 321   uintx                 _max_node_limit;        // Max unique node count during a single compilation.
 322 
 323   bool                  _post_loop_opts_phase;  // Loop opts are finished.
 324   bool                  _merge_stores_phase;    // Phase for merging stores, after post loop opts phase.
 325   bool                  _allow_macro_nodes;     // True if we allow creation of macro nodes.
 326 
 327   /* If major progress is set:
 328    *   Marks that the loop tree information (get_ctrl, idom, get_loop, etc.) could be invalid, and we need to rebuild the loop tree.
 329    *   It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimization.
 330    * If major progress is not set:
 331    *   Loop tree information is valid.
 332    *   If major progress is not set at the end of a loop opts phase, then we can stop loop opts, because we do not expect any further progress if we did more loop opts phases.
 333    *
 334    * This is not 100% accurate, the semantics of major progress has become less clear over time, but this is the general idea.
 335    */
 336   bool                  _major_progress;
 337   bool                  _inlining_progress;     // progress doing incremental inlining?
 338   bool                  _inlining_incrementally;// Are we doing incremental inlining (post parse)

 339   bool                  _do_cleanup;            // Cleanup is needed before proceeding with incremental inlining
 340   bool                  _has_loops;             // True if the method _may_ have some loops
 341   bool                  _has_split_ifs;         // True if the method _may_ have some split-if
 342   bool                  _has_unsafe_access;     // True if the method _may_ produce faults in unsafe loads or stores.
 343   bool                  _has_stringbuilder;     // True StringBuffers or StringBuilders are allocated
 344   bool                  _has_boxed_value;       // True if a boxed object is allocated
 345   bool                  _has_reserved_stack_access; // True if the method or an inlined method is annotated with ReservedStackAccess


 346   uint                  _max_vector_size;       // Maximum size of generated vectors
 347   bool                  _clear_upper_avx;       // Clear upper bits of ymm registers using vzeroupper
 348   uint                  _trap_hist[trapHistLength];  // Cumulative traps
 349   bool                  _trap_can_recompile;    // Have we emitted a recompiling trap?
 350   uint                  _decompile_count;       // Cumulative decompilation counts.
 351   bool                  _do_inlining;           // True if we intend to do inlining
 352   bool                  _do_scheduling;         // True if we intend to do scheduling
 353   bool                  _do_freq_based_layout;  // True if we intend to do frequency based block layout
 354   bool                  _do_vector_loop;        // True if allowed to execute loop in parallel iterations
 355   bool                  _use_cmove;             // True if CMove should be used without profitability analysis
 356   bool                  _do_aliasing;           // True if we intend to do aliasing
 357   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 358   bool                  _print_inlining;        // True if we should print inlining for this compilation
 359   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 360   bool                  _print_phase_loop_opts; // True if we should print before and after loop opts phase
 361 #ifndef PRODUCT
 362   uint                  _phase_counter;         // Counter for the number of already printed phases
 363   uint                  _igv_idx;               // Counter for IGV node identifiers
 364   uint                  _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
 365   bool                  _trace_opto_output;
 366   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 367 #endif
 368   bool                  _has_irreducible_loop;  // Found irreducible loops
 369   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 370   bool                  _has_scoped_access;     // For shared scope closure
 371   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
 372   int                   _loop_opts_cnt;         // loop opts round



 373   uint                  _stress_seed;           // Seed for stress testing
 374 
 375   // Compilation environment.
 376   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 377   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 378   ciEnv*                _env;                   // CI interface
 379   DirectiveSet*         _directive;             // Compiler directive
 380   CompileLog*           _log;                   // from CompilerThread
 381   CHeapStringHolder     _failure_reason;        // for record_failure/failing pattern
 382   CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
 383   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 384   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 385   GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
 386   // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
 387   // of Template Assertion Predicates themselves.
 388   GrowableArray<OpaqueTemplateAssertionPredicateNode*>  _template_assertion_predicate_opaques;
 389   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 390   GrowableArray<ReachabilityFenceNode*> _reachability_fences; // List of reachability fences
 391   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over


 392   GrowableArray<Node*>  _for_merge_stores_igvn; // List of nodes for IGVN merge stores
 393   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 394   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes
 395   ConnectionGraph*      _congraph;
 396 #ifndef PRODUCT
 397   IdealGraphPrinter*    _igv_printer;
 398   static IdealGraphPrinter* _debug_file_printer;
 399   static IdealGraphPrinter* _debug_network_printer;
 400 #endif
 401 
 402 
 403   // Node management
 404   uint                  _unique;                // Counter for unique Node indices
 405   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 406                                                 // So use this to keep count and make the call O(1).
 407   VectorSet             _dead_node_list;        // Set of dead nodes
 408   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 409   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 410 
 411   DEBUG_ONLY(bool       _phase_verify_ideal_loop;) // Are we in PhaseIdealLoop verification?

 585   ciMethod*         method() const              { return _method; }
 586   int               entry_bci() const           { return _entry_bci; }
 587   bool              is_osr_compilation() const  { return _entry_bci != InvocationEntryBci; }
 588   bool              is_method_compilation() const { return (_method != nullptr && !_method->flags().is_native()); }
 589   const TypeFunc*   tf() const                  { assert(_tf!=nullptr, ""); return _tf; }
 590   void         init_tf(const TypeFunc* tf)      { assert(_tf==nullptr, ""); _tf = tf; }
 591   InlineTree*       ilt() const                 { return _ilt; }
 592   address           stub_function() const       { return _stub_function; }
 593   const char*       stub_name() const           { return _stub_name; }
 594   StubId            stub_id() const             { return _stub_id; }
 595   address           stub_entry_point() const    { return _stub_entry_point; }
 596   void          set_stub_entry_point(address z) { _stub_entry_point = z; }
 597 
 598   // Control of this compilation.
 599   int               fixed_slots() const         { assert(_fixed_slots >= 0, "");         return _fixed_slots; }
 600   void          set_fixed_slots(int n)          { _fixed_slots = n; }
 601   void          set_inlining_progress(bool z)   { _inlining_progress = z; }
 602   int               inlining_progress() const   { return _inlining_progress; }
 603   void          set_inlining_incrementally(bool z) { _inlining_incrementally = z; }
 604   int               inlining_incrementally() const { return _inlining_incrementally; }


 605   void          set_do_cleanup(bool z)          { _do_cleanup = z; }
 606   int               do_cleanup() const          { return _do_cleanup; }
 607   bool              major_progress() const      { return _major_progress; }
 608   void          set_major_progress()            { _major_progress = true; }
 609   void          restore_major_progress(bool progress) { _major_progress = _major_progress || progress; }
 610   void        clear_major_progress()            { _major_progress = false; }
 611   int               max_inline_size() const     { return _max_inline_size; }
 612   void          set_freq_inline_size(int n)     { _freq_inline_size = n; }
 613   int               freq_inline_size() const    { return _freq_inline_size; }
 614   void          set_max_inline_size(int n)      { _max_inline_size = n; }
 615   bool              has_loops() const           { return _has_loops; }
 616   void          set_has_loops(bool z)           { _has_loops = z; }
 617   bool              has_split_ifs() const       { return _has_split_ifs; }
 618   void          set_has_split_ifs(bool z)       { _has_split_ifs = z; }
 619   bool              has_unsafe_access() const   { return _has_unsafe_access; }
 620   void          set_has_unsafe_access(bool z)   { _has_unsafe_access = z; }
 621   bool              has_stringbuilder() const   { return _has_stringbuilder; }
 622   void          set_has_stringbuilder(bool z)   { _has_stringbuilder = z; }
 623   bool              has_boxed_value() const     { return _has_boxed_value; }
 624   void          set_has_boxed_value(bool z)     { _has_boxed_value = z; }
 625   bool              has_reserved_stack_access() const { return _has_reserved_stack_access; }
 626   void          set_has_reserved_stack_access(bool z) { _has_reserved_stack_access = z; }


 627   uint              max_vector_size() const     { return _max_vector_size; }
 628   void          set_max_vector_size(uint s)     { _max_vector_size = s; }
 629   bool              clear_upper_avx() const     { return _clear_upper_avx; }
 630   void          set_clear_upper_avx(bool s)     { _clear_upper_avx = s; }
 631   void          set_trap_count(uint r, uint c)  { assert(r < trapHistLength, "oob");        _trap_hist[r] = c; }
 632   uint              trap_count(uint r) const    { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
 633   bool              trap_can_recompile() const  { return _trap_can_recompile; }
 634   void          set_trap_can_recompile(bool z)  { _trap_can_recompile = z; }
 635   uint              decompile_count() const     { return _decompile_count; }
 636   void          set_decompile_count(uint c)     { _decompile_count = c; }
 637   bool              allow_range_check_smearing() const;
 638   bool              do_inlining() const         { return _do_inlining; }
 639   void          set_do_inlining(bool z)         { _do_inlining = z; }
 640   bool              do_scheduling() const       { return _do_scheduling; }
 641   void          set_do_scheduling(bool z)       { _do_scheduling = z; }
 642   bool              do_freq_based_layout() const{ return _do_freq_based_layout; }
 643   void          set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
 644   bool              do_vector_loop() const      { return _do_vector_loop; }
 645   void          set_do_vector_loop(bool z)      { _do_vector_loop = z; }
 646   bool              use_cmove() const           { return _use_cmove; }
 647   void          set_use_cmove(bool z)           { _use_cmove = z; }
 648   bool              do_aliasing() const          { return _do_aliasing; }
 649   bool              print_assembly() const       { return _print_assembly; }
 650   void          set_print_assembly(bool z)       { _print_assembly = z; }
 651   bool              print_inlining() const       { return _print_inlining; }
 652   void          set_print_inlining(bool z)       { _print_inlining = z; }
 653   bool              print_intrinsics() const     { return _print_intrinsics; }
 654   void          set_print_intrinsics(bool z)     { _print_intrinsics = z; }
 655   uint              max_node_limit() const       { return (uint)_max_node_limit; }
 656   void          set_max_node_limit(uint n)       { _max_node_limit = n; }
 657   bool              clinit_barrier_on_entry()       { return _clinit_barrier_on_entry; }
 658   void          set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }












 659   bool              has_monitors() const         { return _has_monitors; }
 660   void          set_has_monitors(bool v)         { _has_monitors = v; }
 661   bool              has_scoped_access() const    { return _has_scoped_access; }
 662   void          set_has_scoped_access(bool v)    { _has_scoped_access = v; }
 663 
 664   // check the CompilerOracle for special behaviours for this compile
 665   bool          method_has_option(CompileCommandEnum option) const {
 666     return method() != nullptr && method()->has_option(option);
 667   }
 668 
 669 #ifndef PRODUCT
 670   uint          next_igv_idx()                  { return _igv_idx++; }
 671   bool          trace_opto_output() const       { return _trace_opto_output; }
 672   void          print_phase(const char* phase_name);
 673   void          print_ideal_ir(const char* compile_phase_name) const;
 674   bool          should_print_ideal() const      { return _directive->PrintIdealOption; }
 675   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 676   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 677   int _in_dump_cnt;  // Required for dumping ir nodes.
 678 #endif

 780   bool coarsened_locks_consistent();
 781   void mark_unbalanced_boxes() const;
 782 
 783   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 784   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 785   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 786 
 787 #ifdef ASSERT
 788   bool       phase_verify_ideal_loop() const { return _phase_verify_ideal_loop; }
 789   void   set_phase_verify_ideal_loop() { _phase_verify_ideal_loop = true; }
 790   void reset_phase_verify_ideal_loop() { _phase_verify_ideal_loop = false; }
 791 #endif
 792 
 793   bool       allow_macro_nodes() { return _allow_macro_nodes;  }
 794   void reset_allow_macro_nodes() { _allow_macro_nodes = false;  }
 795 
 796   void record_for_post_loop_opts_igvn(Node* n);
 797   void remove_from_post_loop_opts_igvn(Node* n);
 798   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 799 





















 800   void record_unstable_if_trap(UnstableIfTrap* trap);
 801   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 802   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 803   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 804 
 805   bool     merge_stores_phase() { return _merge_stores_phase;  }
 806   void set_merge_stores_phase() { _merge_stores_phase = true;  }
 807   void record_for_merge_stores_igvn(Node* n);
 808   void remove_from_merge_stores_igvn(Node* n);
 809   void process_for_merge_stores_igvn(PhaseIterGVN& igvn);
 810 
 811   void shuffle_late_inlines();
 812   void shuffle_macro_nodes();
 813   void sort_macro_nodes();
 814 
 815   void mark_parse_predicate_nodes_useless(PhaseIterGVN& igvn);
 816 
 817   // Are there candidate expensive nodes for optimization?
 818   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 819   // Check whether n1 and n2 are similar

 963   Arena*            type_arena()                { return _type_arena; }
 964   Dict*             type_dict()                 { return _type_dict; }
 965   size_t            type_last_size()            { return _type_last_size; }
 966   int               num_alias_types()           { return _num_alias_types; }
 967 
 968   void          init_type_arena()                       { _type_arena = &_Compile_types; }
 969   void          set_type_arena(Arena* a)                { _type_arena = a; }
 970   void          set_type_dict(Dict* d)                  { _type_dict = d; }
 971   void          set_type_last_size(size_t sz)           { _type_last_size = sz; }
 972 
 973   const TypeFunc* last_tf(ciMethod* m) {
 974     return (m == _last_tf_m) ? _last_tf : nullptr;
 975   }
 976   void set_last_tf(ciMethod* m, const TypeFunc* tf) {
 977     assert(m != nullptr || tf == nullptr, "");
 978     _last_tf_m = m;
 979     _last_tf = tf;
 980   }
 981 
 982   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
 983   AliasType*        alias_type(const TypePtr* adr_type, ciField* field = nullptr) { return find_alias_type(adr_type, false, field); }
 984   bool         have_alias_type(const TypePtr* adr_type);
 985   AliasType*        alias_type(ciField*         field);
 986 
 987   int               get_alias_index(const TypePtr* at)  { return alias_type(at)->index(); }
 988   const TypePtr*    get_adr_type(uint aidx)             { return alias_type(aidx)->adr_type(); }
 989   int               get_general_index(uint aidx)        { return alias_type(aidx)->general_index(); }
 990 
 991   // Building nodes
 992   void              rethrow_exceptions(JVMState* jvms);
 993   void              return_values(JVMState* jvms);
 994   JVMState*         build_start_state(StartNode* start, const TypeFunc* tf);
 995 
 996   // Decide how to build a call.
 997   // The profile factor is a discount to apply to this site's interp. profile.
 998   CallGenerator*    call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
 999                                    JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = nullptr,
1000                                    bool allow_intrinsics = true);
1001   bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
1002     return C->directive()->should_delay_inline(call_method) ||
1003            should_delay_string_inlining(call_method, jvms) ||
1004            should_delay_boxing_inlining(call_method, jvms) ||
1005            should_delay_vector_inlining(call_method, jvms);
1006   }
1007   bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);

1217   // Number of outgoing stack slots killed above the out_preserve_stack_slots
1218   // for calls to C.  Supports the var-args backing area for register parms.
1219   uint varargs_C_out_slots_killed() const;
1220 
1221   // Number of Stack Slots consumed by a synchronization entry
1222   int sync_stack_slots() const;
1223 
1224   // Compute the name of old_SP.  See <arch>.ad for frame layout.
1225   OptoReg::Name compute_old_SP();
1226 
1227  private:
1228   // Phase control:
1229   void Init(bool aliasing);                      // Prepare for a single compilation
1230   void Optimize();                               // Given a graph, optimize it
1231   void Code_Gen();                               // Generate code from a graph
1232 
1233   // Management of the AliasType table.
1234   void grow_alias_types();
1235   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1236   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1237   AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
1238 
1239   void verify_top(Node*) const PRODUCT_RETURN;
1240 
1241   // Intrinsic setup.
1242   CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual);          // constructor
1243   int            intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found);  // helper
1244   CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual);             // query fn
1245   void           register_intrinsic(CallGenerator* cg);                    // update fn
1246 
1247 #ifndef PRODUCT
1248   static juint  _intrinsic_hist_count[];
1249   static jubyte _intrinsic_hist_flags[];
1250 #endif
1251   // Function calls made by the public function final_graph_reshaping.
1252   // No need to be made public as they are not called elsewhere.
1253   void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1254   void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1255   void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1256   void handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned);
1257 

1310   // Verify ADLC assumptions during startup
1311   static void adlc_verification() PRODUCT_RETURN;
1312 
1313   // Definitions of pd methods
1314   static void pd_compiler2_init();
1315 
1316   // Materialize reachability fences from reachability edges on safepoints.
1317   void expand_reachability_edges(Unique_Node_List& safepoints);
1318 
1319   // Static parse-time type checking logic for gen_subtype_check:
1320   enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1321   SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1322 
1323   static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1324                               // Optional control dependency (for example, on range check)
1325                               Node* ctrl = nullptr);
1326 
1327   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1328   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1329 
1330   // Auxiliary methods for randomized fuzzing/stressing
1331   int random();
1332   bool randomized_select(int count);
1333 
1334   // seed random number generation and log the seed for repeatability.
1335   void initialize_stress_seed(const DirectiveSet* directive);
1336 
1337   // supporting clone_map
1338   CloneMap&     clone_map();
1339   void          set_clone_map(Dict* d);
1340 
1341   bool needs_clinit_barrier(ciField* ik,         ciMethod* accessing_method);
1342   bool needs_clinit_barrier(ciMethod* ik,        ciMethod* accessing_method);
1343   bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1344 
1345 #ifdef ASSERT
1346   VerifyMeetResult* _type_verify;
1347   void set_exception_backedge() { _exception_backedge = true; }
1348   bool has_exception_backedge() const { return _exception_backedge; }
1349 #endif
1350 

  28 #include "asm/codeBuffer.hpp"
  29 #include "ci/compilerInterface.hpp"
  30 #include "code/debugInfoRec.hpp"
  31 #include "compiler/cHeapStringHolder.hpp"
  32 #include "compiler/compileBroker.hpp"
  33 #include "compiler/compiler_globals.hpp"
  34 #include "compiler/compilerEvent.hpp"
  35 #include "libadt/dict.hpp"
  36 #include "libadt/vectset.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "oops/methodData.hpp"
  39 #include "opto/idealGraphPrinter.hpp"
  40 #include "opto/phase.hpp"
  41 #include "opto/phasetype.hpp"
  42 #include "opto/printinlining.hpp"
  43 #include "opto/regmask.hpp"
  44 #include "runtime/deoptimization.hpp"
  45 #include "runtime/sharedRuntime.hpp"
  46 #include "runtime/timerTrace.hpp"
  47 #include "runtime/vmThread.hpp"
  48 #include "utilities/growableArray.hpp"
  49 #include "utilities/ticks.hpp"
  50 #include "utilities/vmEnums.hpp"
  51 
  52 class AbstractLockNode;
  53 class AddPNode;
  54 class Block;
  55 class Bundle;
  56 class CallGenerator;
  57 class CallNode;
  58 class CallStaticJavaNode;
  59 class CloneMap;
  60 class CompilationFailureInfo;
  61 class ConnectionGraph;
  62 class IdealGraphPrinter;
  63 class InlineTree;
  64 class Matcher;
  65 class MachConstantNode;
  66 class MachConstantBaseNode;
  67 class MachNode;
  68 class MachOper;
  69 class MachSafePointNode;
  70 class Node;
  71 class Node_Array;
  72 class Node_List;
  73 class Node_Notes;
  74 class NodeHash;
  75 class NodeCloneInfo;
  76 class OpaqueTemplateAssertionPredicateNode;
  77 class OptoReg;

  82 class PhaseRegAlloc;
  83 class PhaseCCP;
  84 class PhaseOutput;
  85 class ReachabilityFenceNode;
  86 class RootNode;
  87 class relocInfo;
  88 class StartNode;
  89 class SafePointNode;
  90 class JVMState;
  91 class Type;
  92 class TypeInt;
  93 class TypeInteger;
  94 class TypeKlassPtr;
  95 class TypePtr;
  96 class TypeOopPtr;
  97 class TypeFunc;
  98 class TypeVect;
  99 class Type_Array;
 100 class Unique_Node_List;
 101 class UnstableIfTrap;
 102 class InlineTypeNode;
 103 class nmethod;
 104 class Node_Stack;
 105 struct Final_Reshape_Counts;
 106 class VerifyMeetResult;
 107 
 108 enum LoopOptsMode {
 109   LoopOptsDefault,
 110   LoopOptsNone,
 111   LoopOptsMaxUnroll,
 112   LoopOptsShenandoahExpand,
 113   LoopOptsSkipSplitIf,
 114   LoopOptsVerify,
 115   PostLoopOptsExpandReachabilityFences
 116 };
 117 
 118 // The type of all node counts and indexes.
 119 // It must hold at least 16 bits, but must also be fast to load and store.
 120 // This type, if less than 32 bits, could limit the number of possible nodes.
 121 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
 122 typedef unsigned int node_idx_t;

 322   int                   _fixed_slots;           // count of frame slots not allocated by the register
 323                                                 // allocator i.e. locks, original deopt pc, etc.
 324   uintx                 _max_node_limit;        // Max unique node count during a single compilation.
 325 
 326   bool                  _post_loop_opts_phase;  // Loop opts are finished.
 327   bool                  _merge_stores_phase;    // Phase for merging stores, after post loop opts phase.
 328   bool                  _allow_macro_nodes;     // True if we allow creation of macro nodes.
 329 
 330   /* If major progress is set:
 331    *   Marks that the loop tree information (get_ctrl, idom, get_loop, etc.) could be invalid, and we need to rebuild the loop tree.
 332    *   It also indicates that the graph was changed in a way that is promising to be able to apply more loop optimization.
 333    * If major progress is not set:
 334    *   Loop tree information is valid.
 335    *   If major progress is not set at the end of a loop opts phase, then we can stop loop opts, because we do not expect any further progress if we did more loop opts phases.
 336    *
 337    * This is not 100% accurate, the semantics of major progress has become less clear over time, but this is the general idea.
 338    */
 339   bool                  _major_progress;
 340   bool                  _inlining_progress;     // progress doing incremental inlining?
 341   bool                  _inlining_incrementally;// Are we doing incremental inlining (post parse)
 342   bool                  _strength_reduction;    // Are we doing strength reduction to direct call
 343   bool                  _do_cleanup;            // Cleanup is needed before proceeding with incremental inlining
 344   bool                  _has_loops;             // True if the method _may_ have some loops
 345   bool                  _has_split_ifs;         // True if the method _may_ have some split-if
 346   bool                  _has_unsafe_access;     // True if the method _may_ produce faults in unsafe loads or stores.
 347   bool                  _has_stringbuilder;     // True StringBuffers or StringBuilders are allocated
 348   bool                  _has_boxed_value;       // True if a boxed object is allocated
 349   bool                  _has_reserved_stack_access; // True if the method or an inlined method is annotated with ReservedStackAccess
 350   bool                  _has_circular_inline_type; // True if method loads an inline type with a circular, non-flat field
 351   bool                  _needs_nm_slot;         // True if an extra stack slot is needed to hold the null marker at scalarized returns
 352   uint                  _max_vector_size;       // Maximum size of generated vectors
 353   bool                  _clear_upper_avx;       // Clear upper bits of ymm registers using vzeroupper
 354   uint                  _trap_hist[trapHistLength];  // Cumulative traps
 355   bool                  _trap_can_recompile;    // Have we emitted a recompiling trap?
 356   uint                  _decompile_count;       // Cumulative decompilation counts.
 357   bool                  _do_inlining;           // True if we intend to do inlining
 358   bool                  _do_scheduling;         // True if we intend to do scheduling
 359   bool                  _do_freq_based_layout;  // True if we intend to do frequency based block layout
 360   bool                  _do_vector_loop;        // True if allowed to execute loop in parallel iterations
 361   bool                  _use_cmove;             // True if CMove should be used without profitability analysis
 362   bool                  _do_aliasing;           // True if we intend to do aliasing
 363   bool                  _print_assembly;        // True if we should dump assembly code for this compilation
 364   bool                  _print_inlining;        // True if we should print inlining for this compilation
 365   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 366   bool                  _print_phase_loop_opts; // True if we should print before and after loop opts phase
 367 #ifndef PRODUCT
 368   uint                  _phase_counter;         // Counter for the number of already printed phases
 369   uint                  _igv_idx;               // Counter for IGV node identifiers
 370   uint                  _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
 371   bool                  _trace_opto_output;
 372   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 373 #endif
 374   bool                  _has_irreducible_loop;  // Found irreducible loops
 375   bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
 376   bool                  _has_scoped_access;     // For shared scope closure
 377   bool                  _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
 378   int                   _loop_opts_cnt;         // loop opts round
 379   bool                  _has_flat_accesses;     // Any known flat array accesses?
 380   bool                  _flat_accesses_share_alias; // Initially all flat array share a single slice
 381   bool                  _scalarize_in_safepoints; // Scalarize inline types in safepoint debug info
 382   uint                  _stress_seed;           // Seed for stress testing
 383 
 384   // Compilation environment.
 385   Arena                 _comp_arena;            // Arena with lifetime equivalent to Compile
 386   void*                 _barrier_set_state;     // Potential GC barrier state for Compile
 387   ciEnv*                _env;                   // CI interface
 388   DirectiveSet*         _directive;             // Compiler directive
 389   CompileLog*           _log;                   // from CompilerThread
 390   CHeapStringHolder     _failure_reason;        // for record_failure/failing pattern
 391   CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
 392   GrowableArray<CallGenerator*> _intrinsics;    // List of intrinsics.
 393   GrowableArray<Node*>  _macro_nodes;           // List of nodes which need to be expanded before matching.
 394   GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
 395   // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
 396   // of Template Assertion Predicates themselves.
 397   GrowableArray<OpaqueTemplateAssertionPredicateNode*>  _template_assertion_predicate_opaques;
 398   GrowableArray<Node*>  _expensive_nodes;       // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
 399   GrowableArray<ReachabilityFenceNode*> _reachability_fences; // List of reachability fences
 400   GrowableArray<Node*>  _for_post_loop_igvn;    // List of nodes for IGVN after loop opts are over
 401   GrowableArray<Node*>  _inline_type_nodes;     // List of InlineType nodes
 402   GrowableArray<Node*>  _flat_access_nodes;     // List of LoadFlat and StoreFlat nodes
 403   GrowableArray<Node*>  _for_merge_stores_igvn; // List of nodes for IGVN merge stores
 404   GrowableArray<UnstableIfTrap*> _unstable_if_traps;        // List of ifnodes after IGVN
 405   GrowableArray<Node_List*> _coarsened_locks;   // List of coarsened Lock and Unlock nodes
 406   ConnectionGraph*      _congraph;
 407 #ifndef PRODUCT
 408   IdealGraphPrinter*    _igv_printer;
 409   static IdealGraphPrinter* _debug_file_printer;
 410   static IdealGraphPrinter* _debug_network_printer;
 411 #endif
 412 
 413 
 414   // Node management
 415   uint                  _unique;                // Counter for unique Node indices
 416   uint                  _dead_node_count;       // Number of dead nodes; VectorSet::Size() is O(N).
 417                                                 // So use this to keep count and make the call O(1).
 418   VectorSet             _dead_node_list;        // Set of dead nodes
 419   DEBUG_ONLY(Unique_Node_List* _modified_nodes;)   // List of nodes which inputs were modified
 420   DEBUG_ONLY(bool       _phase_optimize_finished;) // Used for live node verification while creating new nodes
 421 
 422   DEBUG_ONLY(bool       _phase_verify_ideal_loop;) // Are we in PhaseIdealLoop verification?

 596   ciMethod*         method() const              { return _method; }
 597   int               entry_bci() const           { return _entry_bci; }
 598   bool              is_osr_compilation() const  { return _entry_bci != InvocationEntryBci; }
 599   bool              is_method_compilation() const { return (_method != nullptr && !_method->flags().is_native()); }
 600   const TypeFunc*   tf() const                  { assert(_tf!=nullptr, ""); return _tf; }
 601   void         init_tf(const TypeFunc* tf)      { assert(_tf==nullptr, ""); _tf = tf; }
 602   InlineTree*       ilt() const                 { return _ilt; }
 603   address           stub_function() const       { return _stub_function; }
 604   const char*       stub_name() const           { return _stub_name; }
 605   StubId            stub_id() const             { return _stub_id; }
 606   address           stub_entry_point() const    { return _stub_entry_point; }
 607   void          set_stub_entry_point(address z) { _stub_entry_point = z; }
 608 
 609   // Control of this compilation.
 610   int               fixed_slots() const         { assert(_fixed_slots >= 0, "");         return _fixed_slots; }
 611   void          set_fixed_slots(int n)          { _fixed_slots = n; }
 612   void          set_inlining_progress(bool z)   { _inlining_progress = z; }
 613   int               inlining_progress() const   { return _inlining_progress; }
 614   void          set_inlining_incrementally(bool z) { _inlining_incrementally = z; }
 615   int               inlining_incrementally() const { return _inlining_incrementally; }
 616   void          set_strength_reduction(bool z)  { _strength_reduction = z; }
 617   bool              strength_reduction() const  { return _strength_reduction; }
 618   void          set_do_cleanup(bool z)          { _do_cleanup = z; }
 619   int               do_cleanup() const          { return _do_cleanup; }
 620   bool              major_progress() const      { return _major_progress; }
 621   void          set_major_progress()            { _major_progress = true; }
 622   void          restore_major_progress(bool progress) { _major_progress = _major_progress || progress; }
 623   void        clear_major_progress()            { _major_progress = false; }
 624   int               max_inline_size() const     { return _max_inline_size; }
 625   void          set_freq_inline_size(int n)     { _freq_inline_size = n; }
 626   int               freq_inline_size() const    { return _freq_inline_size; }
 627   void          set_max_inline_size(int n)      { _max_inline_size = n; }
 628   bool              has_loops() const           { return _has_loops; }
 629   void          set_has_loops(bool z)           { _has_loops = z; }
 630   bool              has_split_ifs() const       { return _has_split_ifs; }
 631   void          set_has_split_ifs(bool z)       { _has_split_ifs = z; }
 632   bool              has_unsafe_access() const   { return _has_unsafe_access; }
 633   void          set_has_unsafe_access(bool z)   { _has_unsafe_access = z; }
 634   bool              has_stringbuilder() const   { return _has_stringbuilder; }
 635   void          set_has_stringbuilder(bool z)   { _has_stringbuilder = z; }
 636   bool              has_boxed_value() const     { return _has_boxed_value; }
 637   void          set_has_boxed_value(bool z)     { _has_boxed_value = z; }
 638   bool              has_reserved_stack_access() const { return _has_reserved_stack_access; }
 639   void          set_has_reserved_stack_access(bool z) { _has_reserved_stack_access = z; }
 640   bool              has_circular_inline_type() const { return _has_circular_inline_type; }
 641   void          set_has_circular_inline_type(bool z) { _has_circular_inline_type = z; }
 642   uint              max_vector_size() const     { return _max_vector_size; }
 643   void          set_max_vector_size(uint s)     { _max_vector_size = s; }
 644   bool              clear_upper_avx() const     { return _clear_upper_avx; }
 645   void          set_clear_upper_avx(bool s)     { _clear_upper_avx = s; }
 646   void          set_trap_count(uint r, uint c)  { assert(r < trapHistLength, "oob");        _trap_hist[r] = c; }
 647   uint              trap_count(uint r) const    { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
 648   bool              trap_can_recompile() const  { return _trap_can_recompile; }
 649   void          set_trap_can_recompile(bool z)  { _trap_can_recompile = z; }
 650   uint              decompile_count() const     { return _decompile_count; }
 651   void          set_decompile_count(uint c)     { _decompile_count = c; }
 652   bool              allow_range_check_smearing() const;
 653   bool              do_inlining() const         { return _do_inlining; }
 654   void          set_do_inlining(bool z)         { _do_inlining = z; }
 655   bool              do_scheduling() const       { return _do_scheduling; }
 656   void          set_do_scheduling(bool z)       { _do_scheduling = z; }
 657   bool              do_freq_based_layout() const{ return _do_freq_based_layout; }
 658   void          set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
 659   bool              do_vector_loop() const      { return _do_vector_loop; }
 660   void          set_do_vector_loop(bool z)      { _do_vector_loop = z; }
 661   bool              use_cmove() const           { return _use_cmove; }
 662   void          set_use_cmove(bool z)           { _use_cmove = z; }
 663   bool              do_aliasing() const          { return _do_aliasing; }
 664   bool              print_assembly() const       { return _print_assembly; }
 665   void          set_print_assembly(bool z)       { _print_assembly = z; }
 666   bool              print_inlining() const       { return _print_inlining; }
 667   void          set_print_inlining(bool z)       { _print_inlining = z; }
 668   bool              print_intrinsics() const     { return _print_intrinsics; }
 669   void          set_print_intrinsics(bool z)     { _print_intrinsics = z; }
 670   uint              max_node_limit() const       { return (uint)_max_node_limit; }
 671   void          set_max_node_limit(uint n)       { _max_node_limit = n; }
 672   bool              clinit_barrier_on_entry()       { return _clinit_barrier_on_entry; }
 673   void          set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
 674   void          set_flat_accesses()              { _has_flat_accesses = true; }
 675   bool          flat_accesses_share_alias() const { return _flat_accesses_share_alias; }
 676   void          set_flat_accesses_share_alias(bool z) { _flat_accesses_share_alias = z; }
 677   bool          scalarize_in_safepoints() const { return _scalarize_in_safepoints; }
 678   void          set_scalarize_in_safepoints(bool z) { _scalarize_in_safepoints = z; }
 679 
 680   // Support for scalarized inline type calling convention
 681   bool              has_scalarized_args() const  { return _method != nullptr && _method->has_scalarized_args(); }
 682   bool              needs_stack_repair()  const  { return _method != nullptr && _method->c2_needs_stack_repair(); }
 683   bool              needs_nm_slot()       const  { return _needs_nm_slot; }
 684   void          set_needs_nm_slot(bool v)        { _needs_nm_slot = v; }
 685 
 686   bool              has_monitors() const         { return _has_monitors; }
 687   void          set_has_monitors(bool v)         { _has_monitors = v; }
 688   bool              has_scoped_access() const    { return _has_scoped_access; }
 689   void          set_has_scoped_access(bool v)    { _has_scoped_access = v; }
 690 
 691   // check the CompilerOracle for special behaviours for this compile
 692   bool          method_has_option(CompileCommandEnum option) const {
 693     return method() != nullptr && method()->has_option(option);
 694   }
 695 
 696 #ifndef PRODUCT
 697   uint          next_igv_idx()                  { return _igv_idx++; }
 698   bool          trace_opto_output() const       { return _trace_opto_output; }
 699   void          print_phase(const char* phase_name);
 700   void          print_ideal_ir(const char* compile_phase_name) const;
 701   bool          should_print_ideal() const      { return _directive->PrintIdealOption; }
 702   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
 703   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
 704   int _in_dump_cnt;  // Required for dumping ir nodes.
 705 #endif

 807   bool coarsened_locks_consistent();
 808   void mark_unbalanced_boxes() const;
 809 
 810   bool       post_loop_opts_phase() { return _post_loop_opts_phase;  }
 811   void   set_post_loop_opts_phase() { _post_loop_opts_phase = true;  }
 812   void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
 813 
 814 #ifdef ASSERT
 815   bool       phase_verify_ideal_loop() const { return _phase_verify_ideal_loop; }
 816   void   set_phase_verify_ideal_loop() { _phase_verify_ideal_loop = true; }
 817   void reset_phase_verify_ideal_loop() { _phase_verify_ideal_loop = false; }
 818 #endif
 819 
 820   bool       allow_macro_nodes() { return _allow_macro_nodes;  }
 821   void reset_allow_macro_nodes() { _allow_macro_nodes = false;  }
 822 
 823   void record_for_post_loop_opts_igvn(Node* n);
 824   void remove_from_post_loop_opts_igvn(Node* n);
 825   void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
 826 
 827   // Keep track of inline type nodes for later processing
 828   void add_inline_type(Node* n);
 829   void remove_inline_type(Node* n);
 830 
 831   bool clear_argument_if_only_used_as_buffer_at_calls(Node* result_cast, PhaseIterGVN& igvn);
 832 
 833   void process_inline_types(PhaseIterGVN &igvn, bool remove = false);
 834 
 835   void add_flat_access(Node* n);
 836   void remove_flat_access(Node* n);
 837   void process_flat_accesses(PhaseIterGVN& igvn);
 838 
 839   template <class F>
 840   void for_each_flat_access(F consumer) {
 841     for (int i = _flat_access_nodes.length() - 1; i >= 0; i--) {
 842       consumer(_flat_access_nodes.at(i));
 843     }
 844   }
 845 
 846   void adjust_flat_array_access_aliases(PhaseIterGVN& igvn);
 847 
 848   void record_unstable_if_trap(UnstableIfTrap* trap);
 849   bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
 850   void remove_useless_unstable_if_traps(Unique_Node_List &useful);
 851   void process_for_unstable_if_traps(PhaseIterGVN& igvn);
 852 
 853   bool     merge_stores_phase() { return _merge_stores_phase;  }
 854   void set_merge_stores_phase() { _merge_stores_phase = true;  }
 855   void record_for_merge_stores_igvn(Node* n);
 856   void remove_from_merge_stores_igvn(Node* n);
 857   void process_for_merge_stores_igvn(PhaseIterGVN& igvn);
 858 
 859   void shuffle_late_inlines();
 860   void shuffle_macro_nodes();
 861   void sort_macro_nodes();
 862 
 863   void mark_parse_predicate_nodes_useless(PhaseIterGVN& igvn);
 864 
 865   // Are there candidate expensive nodes for optimization?
 866   bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
 867   // Check whether n1 and n2 are similar

1011   Arena*            type_arena()                { return _type_arena; }
1012   Dict*             type_dict()                 { return _type_dict; }
1013   size_t            type_last_size()            { return _type_last_size; }
1014   int               num_alias_types()           { return _num_alias_types; }
1015 
1016   void          init_type_arena()                       { _type_arena = &_Compile_types; }
1017   void          set_type_arena(Arena* a)                { _type_arena = a; }
1018   void          set_type_dict(Dict* d)                  { _type_dict = d; }
1019   void          set_type_last_size(size_t sz)           { _type_last_size = sz; }
1020 
1021   const TypeFunc* last_tf(ciMethod* m) {
1022     return (m == _last_tf_m) ? _last_tf : nullptr;
1023   }
1024   void set_last_tf(ciMethod* m, const TypeFunc* tf) {
1025     assert(m != nullptr || tf == nullptr, "");
1026     _last_tf_m = m;
1027     _last_tf = tf;
1028   }
1029 
1030   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
1031   AliasType*        alias_type(const TypePtr* adr_type, ciField* field = nullptr, bool uncached = false) { return find_alias_type(adr_type, false, field, uncached); }
1032   bool         have_alias_type(const TypePtr* adr_type);
1033   AliasType*        alias_type(ciField*         field);
1034 
1035   int               get_alias_index(const TypePtr* at, bool uncached = false) { return alias_type(at, nullptr, uncached)->index(); }
1036   const TypePtr*    get_adr_type(uint aidx)             { return alias_type(aidx)->adr_type(); }
1037   int               get_general_index(uint aidx)        { return alias_type(aidx)->general_index(); }
1038 
1039   // Building nodes
1040   void              rethrow_exceptions(JVMState* jvms);
1041   void              return_values(JVMState* jvms);
1042   JVMState*         build_start_state(StartNode* start, const TypeFunc* tf);
1043 
1044   // Decide how to build a call.
1045   // The profile factor is a discount to apply to this site's interp. profile.
1046   CallGenerator*    call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
1047                                    JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = nullptr,
1048                                    bool allow_intrinsics = true);
1049   bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
1050     return C->directive()->should_delay_inline(call_method) ||
1051            should_delay_string_inlining(call_method, jvms) ||
1052            should_delay_boxing_inlining(call_method, jvms) ||
1053            should_delay_vector_inlining(call_method, jvms);
1054   }
1055   bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);

1265   // Number of outgoing stack slots killed above the out_preserve_stack_slots
1266   // for calls to C.  Supports the var-args backing area for register parms.
1267   uint varargs_C_out_slots_killed() const;
1268 
1269   // Number of Stack Slots consumed by a synchronization entry
1270   int sync_stack_slots() const;
1271 
1272   // Compute the name of old_SP.  See <arch>.ad for frame layout.
1273   OptoReg::Name compute_old_SP();
1274 
1275  private:
1276   // Phase control:
1277   void Init(bool aliasing);                      // Prepare for a single compilation
1278   void Optimize();                               // Given a graph, optimize it
1279   void Code_Gen();                               // Generate code from a graph
1280 
1281   // Management of the AliasType table.
1282   void grow_alias_types();
1283   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1284   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1285   AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field, bool uncached = false);
1286 
1287   void verify_top(Node*) const PRODUCT_RETURN;
1288 
1289   // Intrinsic setup.
1290   CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual);          // constructor
1291   int            intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found);  // helper
1292   CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual);             // query fn
1293   void           register_intrinsic(CallGenerator* cg);                    // update fn
1294 
1295 #ifndef PRODUCT
1296   static juint  _intrinsic_hist_count[];
1297   static jubyte _intrinsic_hist_flags[];
1298 #endif
1299   // Function calls made by the public function final_graph_reshaping.
1300   // No need to be made public as they are not called elsewhere.
1301   void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1302   void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1303   void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1304   void handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned);
1305 

1358   // Verify ADLC assumptions during startup
1359   static void adlc_verification() PRODUCT_RETURN;
1360 
1361   // Definitions of pd methods
1362   static void pd_compiler2_init();
1363 
1364   // Materialize reachability fences from reachability edges on safepoints.
1365   void expand_reachability_edges(Unique_Node_List& safepoints);
1366 
1367   // Static parse-time type checking logic for gen_subtype_check:
1368   enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1369   SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1370 
1371   static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1372                               // Optional control dependency (for example, on range check)
1373                               Node* ctrl = nullptr);
1374 
1375   // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1376   static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1377 
1378   // Auxiliary method for randomized fuzzing/stressing
1379   int random();
1380   bool randomized_select(int count);
1381 
1382   // seed random number generation and log the seed for repeatability.
1383   void initialize_stress_seed(const DirectiveSet* directive);
1384 
1385   // supporting clone_map
1386   CloneMap&     clone_map();
1387   void          set_clone_map(Dict* d);
1388 
1389   bool needs_clinit_barrier(ciField* ik,         ciMethod* accessing_method);
1390   bool needs_clinit_barrier(ciMethod* ik,        ciMethod* accessing_method);
1391   bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1392 
1393 #ifdef ASSERT
1394   VerifyMeetResult* _type_verify;
1395   void set_exception_backedge() { _exception_backedge = true; }
1396   bool has_exception_backedge() const { return _exception_backedge; }
1397 #endif
1398 
< prev index next >