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;
79 class PhaseIterGVN;
80 class PhaseRegAlloc;
81 class PhaseCCP;
82 class PhaseOutput;
83 class RootNode;
84 class relocInfo;
85 class StartNode;
86 class SafePointNode;
87 class JVMState;
88 class Type;
89 class TypeInt;
90 class TypeInteger;
91 class TypeKlassPtr;
92 class TypePtr;
93 class TypeOopPtr;
94 class TypeFunc;
95 class TypeVect;
96 class Type_Array;
97 class Unique_Node_List;
98 class UnstableIfTrap;
99 class nmethod;
100 class Node_Stack;
101 struct Final_Reshape_Counts;
102 class VerifyMeetResult;
103
104 enum LoopOptsMode {
105 LoopOptsDefault,
106 LoopOptsNone,
107 LoopOptsMaxUnroll,
108 LoopOptsShenandoahExpand,
109 LoopOptsSkipSplitIf,
110 LoopOptsVerify
111 };
112
113 // The type of all node counts and indexes.
114 // It must hold at least 16 bits, but must also be fast to load and store.
115 // This type, if less than 32 bits, could limit the number of possible nodes.
116 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
117 typedef unsigned int node_idx_t;
118
315 int _max_inline_size; // Max inline size for this compilation
316 int _freq_inline_size; // Max hot method inline size for this compilation
317 int _fixed_slots; // count of frame slots not allocated by the register
318 // allocator i.e. locks, original deopt pc, etc.
319 uintx _max_node_limit; // Max unique node count during a single compilation.
320
321 bool _post_loop_opts_phase; // Loop opts are finished.
322 bool _merge_stores_phase; // Phase for merging stores, after post loop opts phase.
323 bool _allow_macro_nodes; // True if we allow creation of macro nodes.
324
325 int _major_progress; // Count of something big happening
326 bool _inlining_progress; // progress doing incremental inlining?
327 bool _inlining_incrementally;// Are we doing incremental inlining (post parse)
328 bool _do_cleanup; // Cleanup is needed before proceeding with incremental inlining
329 bool _has_loops; // True if the method _may_ have some loops
330 bool _has_split_ifs; // True if the method _may_ have some split-if
331 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.
332 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated
333 bool _has_boxed_value; // True if a boxed object is allocated
334 bool _has_reserved_stack_access; // True if the method or an inlined method is annotated with ReservedStackAccess
335 uint _max_vector_size; // Maximum size of generated vectors
336 bool _clear_upper_avx; // Clear upper bits of ymm registers using vzeroupper
337 uint _trap_hist[trapHistLength]; // Cumulative traps
338 bool _trap_can_recompile; // Have we emitted a recompiling trap?
339 uint _decompile_count; // Cumulative decompilation counts.
340 bool _do_inlining; // True if we intend to do inlining
341 bool _do_scheduling; // True if we intend to do scheduling
342 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
343 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
344 bool _use_cmove; // True if CMove should be used without profitability analysis
345 bool _do_aliasing; // True if we intend to do aliasing
346 bool _print_assembly; // True if we should dump assembly code for this compilation
347 bool _print_inlining; // True if we should print inlining for this compilation
348 bool _print_intrinsics; // True if we should print intrinsics for this compilation
349 #ifndef PRODUCT
350 uint _phase_counter; // Counter for the number of already printed phases
351 uint _igv_idx; // Counter for IGV node identifiers
352 uint _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
353 bool _trace_opto_output;
354 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
355 #endif
356 bool _has_irreducible_loop; // Found irreducible loops
357 // JSR 292
358 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
359 bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
360 bool _has_scoped_access; // For shared scope closure
361 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
362 int _loop_opts_cnt; // loop opts round
363 uint _stress_seed; // Seed for stress testing
364
365 // Compilation environment.
366 Arena _comp_arena; // Arena with lifetime equivalent to Compile
367 void* _barrier_set_state; // Potential GC barrier state for Compile
368 ciEnv* _env; // CI interface
369 DirectiveSet* _directive; // Compiler directive
370 CompileLog* _log; // from CompilerThread
371 CHeapStringHolder _failure_reason; // for record_failure/failing pattern
372 CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
373 GrowableArray<CallGenerator*> _intrinsics; // List of intrinsics.
374 GrowableArray<Node*> _macro_nodes; // List of nodes which need to be expanded before matching.
375 GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
376 // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
377 // of Template Assertion Predicates themselves.
378 GrowableArray<OpaqueTemplateAssertionPredicateNode*> _template_assertion_predicate_opaques;
379 GrowableArray<Node*> _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
380 GrowableArray<Node*> _for_post_loop_igvn; // List of nodes for IGVN after loop opts are over
381 GrowableArray<Node*> _for_merge_stores_igvn; // List of nodes for IGVN merge stores
382 GrowableArray<UnstableIfTrap*> _unstable_if_traps; // List of ifnodes after IGVN
383 GrowableArray<Node_List*> _coarsened_locks; // List of coarsened Lock and Unlock nodes
384 ConnectionGraph* _congraph;
385 #ifndef PRODUCT
386 IdealGraphPrinter* _igv_printer;
387 static IdealGraphPrinter* _debug_file_printer;
388 static IdealGraphPrinter* _debug_network_printer;
389 #endif
390
391
392 // Node management
393 uint _unique; // Counter for unique Node indices
394 uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).
395 // So use this to keep count and make the call O(1).
396 VectorSet _dead_node_list; // Set of dead nodes
397 DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified
398 DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes
399
400 DEBUG_ONLY(bool _phase_verify_ideal_loop;) // Are we in PhaseIdealLoop verification?
588 int do_cleanup() const { return _do_cleanup; }
589 void set_major_progress() { _major_progress++; }
590 void restore_major_progress(int progress) { _major_progress += progress; }
591 void clear_major_progress() { _major_progress = 0; }
592 int max_inline_size() const { return _max_inline_size; }
593 void set_freq_inline_size(int n) { _freq_inline_size = n; }
594 int freq_inline_size() const { return _freq_inline_size; }
595 void set_max_inline_size(int n) { _max_inline_size = n; }
596 bool has_loops() const { return _has_loops; }
597 void set_has_loops(bool z) { _has_loops = z; }
598 bool has_split_ifs() const { return _has_split_ifs; }
599 void set_has_split_ifs(bool z) { _has_split_ifs = z; }
600 bool has_unsafe_access() const { return _has_unsafe_access; }
601 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
602 bool has_stringbuilder() const { return _has_stringbuilder; }
603 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }
604 bool has_boxed_value() const { return _has_boxed_value; }
605 void set_has_boxed_value(bool z) { _has_boxed_value = z; }
606 bool has_reserved_stack_access() const { return _has_reserved_stack_access; }
607 void set_has_reserved_stack_access(bool z) { _has_reserved_stack_access = z; }
608 uint max_vector_size() const { return _max_vector_size; }
609 void set_max_vector_size(uint s) { _max_vector_size = s; }
610 bool clear_upper_avx() const { return _clear_upper_avx; }
611 void set_clear_upper_avx(bool s) { _clear_upper_avx = s; }
612 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }
613 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
614 bool trap_can_recompile() const { return _trap_can_recompile; }
615 void set_trap_can_recompile(bool z) { _trap_can_recompile = z; }
616 uint decompile_count() const { return _decompile_count; }
617 void set_decompile_count(uint c) { _decompile_count = c; }
618 bool allow_range_check_smearing() const;
619 bool do_inlining() const { return _do_inlining; }
620 void set_do_inlining(bool z) { _do_inlining = z; }
621 bool do_scheduling() const { return _do_scheduling; }
622 void set_do_scheduling(bool z) { _do_scheduling = z; }
623 bool do_freq_based_layout() const{ return _do_freq_based_layout; }
624 void set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
625 bool do_vector_loop() const { return _do_vector_loop; }
626 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
627 bool use_cmove() const { return _use_cmove; }
628 void set_use_cmove(bool z) { _use_cmove = z; }
629 bool do_aliasing() const { return _do_aliasing; }
630 bool print_assembly() const { return _print_assembly; }
631 void set_print_assembly(bool z) { _print_assembly = z; }
632 bool print_inlining() const { return _print_inlining; }
633 void set_print_inlining(bool z) { _print_inlining = z; }
634 bool print_intrinsics() const { return _print_intrinsics; }
635 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
636 uint max_node_limit() const { return (uint)_max_node_limit; }
637 void set_max_node_limit(uint n) { _max_node_limit = n; }
638 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
639 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
640 bool has_monitors() const { return _has_monitors; }
641 void set_has_monitors(bool v) { _has_monitors = v; }
642 bool has_scoped_access() const { return _has_scoped_access; }
643 void set_has_scoped_access(bool v) { _has_scoped_access = v; }
644
645 // check the CompilerOracle for special behaviours for this compile
646 bool method_has_option(CompileCommandEnum option) const {
647 return method() != nullptr && 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_phase(const char* phase_name);
654 void print_ideal_ir(const char* phase_name);
655 bool should_print_ideal() const { return _directive->PrintIdealOption; }
656 bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
657 void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
658 int _in_dump_cnt; // Required for dumping ir nodes.
659 #endif
755 bool coarsened_locks_consistent();
756 void mark_unbalanced_boxes() const;
757
758 bool post_loop_opts_phase() { return _post_loop_opts_phase; }
759 void set_post_loop_opts_phase() { _post_loop_opts_phase = true; }
760 void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
761
762 #ifdef ASSERT
763 bool phase_verify_ideal_loop() const { return _phase_verify_ideal_loop; }
764 void set_phase_verify_ideal_loop() { _phase_verify_ideal_loop = true; }
765 void reset_phase_verify_ideal_loop() { _phase_verify_ideal_loop = false; }
766 #endif
767
768 bool allow_macro_nodes() { return _allow_macro_nodes; }
769 void reset_allow_macro_nodes() { _allow_macro_nodes = false; }
770
771 void record_for_post_loop_opts_igvn(Node* n);
772 void remove_from_post_loop_opts_igvn(Node* n);
773 void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
774
775 void record_unstable_if_trap(UnstableIfTrap* trap);
776 bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
777 void remove_useless_unstable_if_traps(Unique_Node_List &useful);
778 void process_for_unstable_if_traps(PhaseIterGVN& igvn);
779
780 bool merge_stores_phase() { return _merge_stores_phase; }
781 void set_merge_stores_phase() { _merge_stores_phase = true; }
782 void record_for_merge_stores_igvn(Node* n);
783 void remove_from_merge_stores_igvn(Node* n);
784 void process_for_merge_stores_igvn(PhaseIterGVN& igvn);
785
786 void shuffle_macro_nodes();
787 void sort_macro_nodes();
788
789 void mark_parse_predicate_nodes_useless(PhaseIterGVN& igvn);
790
791 // Are there candidate expensive nodes for optimization?
792 bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
793 // Check whether n1 and n2 are similar
794 static int cmp_expensive_nodes(Node* n1, Node* n2);
937 Arena* type_arena() { return _type_arena; }
938 Dict* type_dict() { return _type_dict; }
939 size_t type_last_size() { return _type_last_size; }
940 int num_alias_types() { return _num_alias_types; }
941
942 void init_type_arena() { _type_arena = &_Compile_types; }
943 void set_type_arena(Arena* a) { _type_arena = a; }
944 void set_type_dict(Dict* d) { _type_dict = d; }
945 void set_type_last_size(size_t sz) { _type_last_size = sz; }
946
947 const TypeFunc* last_tf(ciMethod* m) {
948 return (m == _last_tf_m) ? _last_tf : nullptr;
949 }
950 void set_last_tf(ciMethod* m, const TypeFunc* tf) {
951 assert(m != nullptr || tf == nullptr, "");
952 _last_tf_m = m;
953 _last_tf = tf;
954 }
955
956 AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
957 AliasType* alias_type(const TypePtr* adr_type, ciField* field = nullptr) { return find_alias_type(adr_type, false, field); }
958 bool have_alias_type(const TypePtr* adr_type);
959 AliasType* alias_type(ciField* field);
960
961 int get_alias_index(const TypePtr* at) { return alias_type(at)->index(); }
962 const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }
963 int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }
964
965 // Building nodes
966 void rethrow_exceptions(JVMState* jvms);
967 void return_values(JVMState* jvms);
968 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
969
970 // Decide how to build a call.
971 // The profile factor is a discount to apply to this site's interp. profile.
972 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
973 JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = nullptr,
974 bool allow_intrinsics = true);
975 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
976 return should_delay_string_inlining(call_method, jvms) ||
977 should_delay_boxing_inlining(call_method, jvms) ||
978 should_delay_vector_inlining(call_method, jvms);
979 }
980 bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
981 bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
1182 // Number of outgoing stack slots killed above the out_preserve_stack_slots
1183 // for calls to C. Supports the var-args backing area for register parms.
1184 uint varargs_C_out_slots_killed() const;
1185
1186 // Number of Stack Slots consumed by a synchronization entry
1187 int sync_stack_slots() const;
1188
1189 // Compute the name of old_SP. See <arch>.ad for frame layout.
1190 OptoReg::Name compute_old_SP();
1191
1192 private:
1193 // Phase control:
1194 void Init(bool aliasing); // Prepare for a single compilation
1195 void Optimize(); // Given a graph, optimize it
1196 void Code_Gen(); // Generate code from a graph
1197
1198 // Management of the AliasType table.
1199 void grow_alias_types();
1200 AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1201 const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1202 AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
1203
1204 void verify_top(Node*) const PRODUCT_RETURN;
1205
1206 // Intrinsic setup.
1207 CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual); // constructor
1208 int intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found); // helper
1209 CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual); // query fn
1210 void register_intrinsic(CallGenerator* cg); // update fn
1211
1212 #ifndef PRODUCT
1213 static juint _intrinsic_hist_count[];
1214 static jubyte _intrinsic_hist_flags[];
1215 #endif
1216 // Function calls made by the public function final_graph_reshaping.
1217 // No need to be made public as they are not called elsewhere.
1218 void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1219 void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1220 void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1221 void handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned);
1222
1272 // End-of-run dumps.
1273 static void print_statistics() PRODUCT_RETURN;
1274
1275 // Verify ADLC assumptions during startup
1276 static void adlc_verification() PRODUCT_RETURN;
1277
1278 // Definitions of pd methods
1279 static void pd_compiler2_init();
1280
1281 // Static parse-time type checking logic for gen_subtype_check:
1282 enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1283 SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1284
1285 static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1286 // Optional control dependency (for example, on range check)
1287 Node* ctrl = nullptr);
1288
1289 // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1290 static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1291
1292 // Auxiliary methods for randomized fuzzing/stressing
1293 int random();
1294 bool randomized_select(int count);
1295
1296 // seed random number generation and log the seed for repeatability.
1297 void initialize_stress_seed(const DirectiveSet* directive);
1298
1299 // supporting clone_map
1300 CloneMap& clone_map();
1301 void set_clone_map(Dict* d);
1302
1303 bool needs_clinit_barrier(ciField* ik, ciMethod* accessing_method);
1304 bool needs_clinit_barrier(ciMethod* ik, ciMethod* accessing_method);
1305 bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1306
1307 #ifdef ASSERT
1308 VerifyMeetResult* _type_verify;
1309 void set_exception_backedge() { _exception_backedge = true; }
1310 bool has_exception_backedge() const { return _exception_backedge; }
1311 #endif
1312
|
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 CallNode;
57 class CallStaticJavaNode;
58 class CloneMap;
59 class CompilationFailureInfo;
60 class ConnectionGraph;
61 class IdealGraphPrinter;
62 class InlineTree;
63 class Matcher;
64 class MachConstantNode;
65 class MachConstantBaseNode;
66 class MachNode;
67 class MachOper;
68 class MachSafePointNode;
69 class Node;
70 class Node_Array;
71 class Node_List;
72 class Node_Notes;
73 class NodeHash;
74 class NodeCloneInfo;
75 class OpaqueTemplateAssertionPredicateNode;
76 class OptoReg;
80 class PhaseIterGVN;
81 class PhaseRegAlloc;
82 class PhaseCCP;
83 class PhaseOutput;
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 InlineTypeNode;
101 class nmethod;
102 class Node_Stack;
103 struct Final_Reshape_Counts;
104 class VerifyMeetResult;
105
106 enum LoopOptsMode {
107 LoopOptsDefault,
108 LoopOptsNone,
109 LoopOptsMaxUnroll,
110 LoopOptsShenandoahExpand,
111 LoopOptsSkipSplitIf,
112 LoopOptsVerify
113 };
114
115 // The type of all node counts and indexes.
116 // It must hold at least 16 bits, but must also be fast to load and store.
117 // This type, if less than 32 bits, could limit the number of possible nodes.
118 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
119 typedef unsigned int node_idx_t;
120
317 int _max_inline_size; // Max inline size for this compilation
318 int _freq_inline_size; // Max hot method inline size for this compilation
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 int _major_progress; // Count of something big happening
328 bool _inlining_progress; // progress doing incremental inlining?
329 bool _inlining_incrementally;// Are we doing incremental inlining (post parse)
330 bool _do_cleanup; // Cleanup is needed before proceeding with incremental inlining
331 bool _has_loops; // True if the method _may_ have some loops
332 bool _has_split_ifs; // True if the method _may_ have some split-if
333 bool _has_unsafe_access; // True if the method _may_ produce faults in unsafe loads or stores.
334 bool _has_stringbuilder; // True StringBuffers or StringBuilders are allocated
335 bool _has_boxed_value; // True if a boxed object is allocated
336 bool _has_reserved_stack_access; // True if the method or an inlined method is annotated with ReservedStackAccess
337 bool _has_circular_inline_type; // True if method loads an inline type with a circular, non-flat field
338 uint _max_vector_size; // Maximum size of generated vectors
339 bool _clear_upper_avx; // Clear upper bits of ymm registers using vzeroupper
340 uint _trap_hist[trapHistLength]; // Cumulative traps
341 bool _trap_can_recompile; // Have we emitted a recompiling trap?
342 uint _decompile_count; // Cumulative decompilation counts.
343 bool _do_inlining; // True if we intend to do inlining
344 bool _do_scheduling; // True if we intend to do scheduling
345 bool _do_freq_based_layout; // True if we intend to do frequency based block layout
346 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
347 bool _use_cmove; // True if CMove should be used without profitability analysis
348 bool _do_aliasing; // True if we intend to do aliasing
349 bool _print_assembly; // True if we should dump assembly code for this compilation
350 bool _print_inlining; // True if we should print inlining for this compilation
351 bool _print_intrinsics; // True if we should print intrinsics for this compilation
352 #ifndef PRODUCT
353 uint _phase_counter; // Counter for the number of already printed phases
354 uint _igv_idx; // Counter for IGV node identifiers
355 uint _igv_phase_iter[PHASE_NUM_TYPES]; // Counters for IGV phase iterations
356 bool _trace_opto_output;
357 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
358 #endif
359 bool _has_irreducible_loop; // Found irreducible loops
360 // JSR 292
361 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
362 bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
363 bool _has_scoped_access; // For shared scope closure
364 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
365 int _loop_opts_cnt; // loop opts round
366 bool _has_flat_accesses; // Any known flat array accesses?
367 bool _flat_accesses_share_alias; // Initially all flat array share a single slice
368 bool _scalarize_in_safepoints; // Scalarize inline types in safepoint debug info
369 uint _stress_seed; // Seed for stress testing
370
371 // Compilation environment.
372 Arena _comp_arena; // Arena with lifetime equivalent to Compile
373 void* _barrier_set_state; // Potential GC barrier state for Compile
374 ciEnv* _env; // CI interface
375 DirectiveSet* _directive; // Compiler directive
376 CompileLog* _log; // from CompilerThread
377 CHeapStringHolder _failure_reason; // for record_failure/failing pattern
378 CompilationFailureInfo* _first_failure_details; // Details for the first failure happening during compilation
379 GrowableArray<CallGenerator*> _intrinsics; // List of intrinsics.
380 GrowableArray<Node*> _macro_nodes; // List of nodes which need to be expanded before matching.
381 GrowableArray<ParsePredicateNode*> _parse_predicates; // List of Parse Predicates.
382 // List of OpaqueTemplateAssertionPredicateNode nodes for Template Assertion Predicates which can be seen as list
383 // of Template Assertion Predicates themselves.
384 GrowableArray<OpaqueTemplateAssertionPredicateNode*> _template_assertion_predicate_opaques;
385 GrowableArray<Node*> _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
386 GrowableArray<Node*> _for_post_loop_igvn; // List of nodes for IGVN after loop opts are over
387 GrowableArray<Node*> _inline_type_nodes; // List of InlineType nodes
388 GrowableArray<Node*> _for_merge_stores_igvn; // List of nodes for IGVN merge stores
389 GrowableArray<UnstableIfTrap*> _unstable_if_traps; // List of ifnodes after IGVN
390 GrowableArray<Node_List*> _coarsened_locks; // List of coarsened Lock and Unlock nodes
391 ConnectionGraph* _congraph;
392 #ifndef PRODUCT
393 IdealGraphPrinter* _igv_printer;
394 static IdealGraphPrinter* _debug_file_printer;
395 static IdealGraphPrinter* _debug_network_printer;
396 #endif
397
398
399 // Node management
400 uint _unique; // Counter for unique Node indices
401 uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).
402 // So use this to keep count and make the call O(1).
403 VectorSet _dead_node_list; // Set of dead nodes
404 DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified
405 DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes
406
407 DEBUG_ONLY(bool _phase_verify_ideal_loop;) // Are we in PhaseIdealLoop verification?
595 int do_cleanup() const { return _do_cleanup; }
596 void set_major_progress() { _major_progress++; }
597 void restore_major_progress(int progress) { _major_progress += progress; }
598 void clear_major_progress() { _major_progress = 0; }
599 int max_inline_size() const { return _max_inline_size; }
600 void set_freq_inline_size(int n) { _freq_inline_size = n; }
601 int freq_inline_size() const { return _freq_inline_size; }
602 void set_max_inline_size(int n) { _max_inline_size = n; }
603 bool has_loops() const { return _has_loops; }
604 void set_has_loops(bool z) { _has_loops = z; }
605 bool has_split_ifs() const { return _has_split_ifs; }
606 void set_has_split_ifs(bool z) { _has_split_ifs = z; }
607 bool has_unsafe_access() const { return _has_unsafe_access; }
608 void set_has_unsafe_access(bool z) { _has_unsafe_access = z; }
609 bool has_stringbuilder() const { return _has_stringbuilder; }
610 void set_has_stringbuilder(bool z) { _has_stringbuilder = z; }
611 bool has_boxed_value() const { return _has_boxed_value; }
612 void set_has_boxed_value(bool z) { _has_boxed_value = z; }
613 bool has_reserved_stack_access() const { return _has_reserved_stack_access; }
614 void set_has_reserved_stack_access(bool z) { _has_reserved_stack_access = z; }
615 bool has_circular_inline_type() const { return _has_circular_inline_type; }
616 void set_has_circular_inline_type(bool z) { _has_circular_inline_type = z; }
617 uint max_vector_size() const { return _max_vector_size; }
618 void set_max_vector_size(uint s) { _max_vector_size = s; }
619 bool clear_upper_avx() const { return _clear_upper_avx; }
620 void set_clear_upper_avx(bool s) { _clear_upper_avx = s; }
621 void set_trap_count(uint r, uint c) { assert(r < trapHistLength, "oob"); _trap_hist[r] = c; }
622 uint trap_count(uint r) const { assert(r < trapHistLength, "oob"); return _trap_hist[r]; }
623 bool trap_can_recompile() const { return _trap_can_recompile; }
624 void set_trap_can_recompile(bool z) { _trap_can_recompile = z; }
625 uint decompile_count() const { return _decompile_count; }
626 void set_decompile_count(uint c) { _decompile_count = c; }
627 bool allow_range_check_smearing() const;
628 bool do_inlining() const { return _do_inlining; }
629 void set_do_inlining(bool z) { _do_inlining = z; }
630 bool do_scheduling() const { return _do_scheduling; }
631 void set_do_scheduling(bool z) { _do_scheduling = z; }
632 bool do_freq_based_layout() const{ return _do_freq_based_layout; }
633 void set_do_freq_based_layout(bool z){ _do_freq_based_layout = z; }
634 bool do_vector_loop() const { return _do_vector_loop; }
635 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
636 bool use_cmove() const { return _use_cmove; }
637 void set_use_cmove(bool z) { _use_cmove = z; }
638 bool do_aliasing() const { return _do_aliasing; }
639 bool print_assembly() const { return _print_assembly; }
640 void set_print_assembly(bool z) { _print_assembly = z; }
641 bool print_inlining() const { return _print_inlining; }
642 void set_print_inlining(bool z) { _print_inlining = z; }
643 bool print_intrinsics() const { return _print_intrinsics; }
644 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
645 uint max_node_limit() const { return (uint)_max_node_limit; }
646 void set_max_node_limit(uint n) { _max_node_limit = n; }
647 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
648 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
649 void set_flat_accesses() { _has_flat_accesses = true; }
650 bool flat_accesses_share_alias() const { return _flat_accesses_share_alias; }
651 void set_flat_accesses_share_alias(bool z) { _flat_accesses_share_alias = z; }
652 bool scalarize_in_safepoints() const { return _scalarize_in_safepoints; }
653 void set_scalarize_in_safepoints(bool z) { _scalarize_in_safepoints = z; }
654
655 // Support for scalarized inline type calling convention
656 bool has_scalarized_args() const { return _method != nullptr && _method->has_scalarized_args(); }
657 bool needs_stack_repair() const { return _method != nullptr && _method->get_Method()->c2_needs_stack_repair(); }
658
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* phase_name);
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
774 bool coarsened_locks_consistent();
775 void mark_unbalanced_boxes() const;
776
777 bool post_loop_opts_phase() { return _post_loop_opts_phase; }
778 void set_post_loop_opts_phase() { _post_loop_opts_phase = true; }
779 void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
780
781 #ifdef ASSERT
782 bool phase_verify_ideal_loop() const { return _phase_verify_ideal_loop; }
783 void set_phase_verify_ideal_loop() { _phase_verify_ideal_loop = true; }
784 void reset_phase_verify_ideal_loop() { _phase_verify_ideal_loop = false; }
785 #endif
786
787 bool allow_macro_nodes() { return _allow_macro_nodes; }
788 void reset_allow_macro_nodes() { _allow_macro_nodes = false; }
789
790 void record_for_post_loop_opts_igvn(Node* n);
791 void remove_from_post_loop_opts_igvn(Node* n);
792 void process_for_post_loop_opts_igvn(PhaseIterGVN& igvn);
793
794 // Keep track of inline type nodes for later processing
795 void add_inline_type(Node* n);
796 void remove_inline_type(Node* n);
797 void process_inline_types(PhaseIterGVN &igvn, bool remove = false);
798
799 void adjust_flat_array_access_aliases(PhaseIterGVN& igvn);
800
801 void record_unstable_if_trap(UnstableIfTrap* trap);
802 bool remove_unstable_if_trap(CallStaticJavaNode* unc, bool yield);
803 void remove_useless_unstable_if_traps(Unique_Node_List &useful);
804 void process_for_unstable_if_traps(PhaseIterGVN& igvn);
805
806 bool merge_stores_phase() { return _merge_stores_phase; }
807 void set_merge_stores_phase() { _merge_stores_phase = true; }
808 void record_for_merge_stores_igvn(Node* n);
809 void remove_from_merge_stores_igvn(Node* n);
810 void process_for_merge_stores_igvn(PhaseIterGVN& igvn);
811
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
820 static int cmp_expensive_nodes(Node* n1, Node* n2);
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, bool uncached = false) { return find_alias_type(adr_type, false, field, uncached); }
984 bool have_alias_type(const TypePtr* adr_type);
985 AliasType* alias_type(ciField* field);
986
987 int get_alias_index(const TypePtr* at, bool uncached = false) { return alias_type(at, nullptr, uncached)->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 should_delay_string_inlining(call_method, jvms) ||
1003 should_delay_boxing_inlining(call_method, jvms) ||
1004 should_delay_vector_inlining(call_method, jvms);
1005 }
1006 bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
1007 bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
1208 // Number of outgoing stack slots killed above the out_preserve_stack_slots
1209 // for calls to C. Supports the var-args backing area for register parms.
1210 uint varargs_C_out_slots_killed() const;
1211
1212 // Number of Stack Slots consumed by a synchronization entry
1213 int sync_stack_slots() const;
1214
1215 // Compute the name of old_SP. See <arch>.ad for frame layout.
1216 OptoReg::Name compute_old_SP();
1217
1218 private:
1219 // Phase control:
1220 void Init(bool aliasing); // Prepare for a single compilation
1221 void Optimize(); // Given a graph, optimize it
1222 void Code_Gen(); // Generate code from a graph
1223
1224 // Management of the AliasType table.
1225 void grow_alias_types();
1226 AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1227 const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1228 AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field, bool uncached = false);
1229
1230 void verify_top(Node*) const PRODUCT_RETURN;
1231
1232 // Intrinsic setup.
1233 CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual); // constructor
1234 int intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found); // helper
1235 CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual); // query fn
1236 void register_intrinsic(CallGenerator* cg); // update fn
1237
1238 #ifndef PRODUCT
1239 static juint _intrinsic_hist_count[];
1240 static jubyte _intrinsic_hist_flags[];
1241 #endif
1242 // Function calls made by the public function final_graph_reshaping.
1243 // No need to be made public as they are not called elsewhere.
1244 void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1245 void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes);
1246 void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes);
1247 void handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned);
1248
1298 // End-of-run dumps.
1299 static void print_statistics() PRODUCT_RETURN;
1300
1301 // Verify ADLC assumptions during startup
1302 static void adlc_verification() PRODUCT_RETURN;
1303
1304 // Definitions of pd methods
1305 static void pd_compiler2_init();
1306
1307 // Static parse-time type checking logic for gen_subtype_check:
1308 enum SubTypeCheckResult { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1309 SubTypeCheckResult static_subtype_check(const TypeKlassPtr* superk, const TypeKlassPtr* subk, bool skip = StressReflectiveCode);
1310
1311 static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1312 // Optional control dependency (for example, on range check)
1313 Node* ctrl = nullptr);
1314
1315 // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1316 static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl, bool carry_dependency = false);
1317
1318 Node* optimize_acmp(PhaseGVN* phase, Node* a, Node* b);
1319
1320 // Auxiliary method for randomized fuzzing/stressing
1321 int random();
1322 bool randomized_select(int count);
1323
1324 // seed random number generation and log the seed for repeatability.
1325 void initialize_stress_seed(const DirectiveSet* directive);
1326
1327 // supporting clone_map
1328 CloneMap& clone_map();
1329 void set_clone_map(Dict* d);
1330
1331 bool needs_clinit_barrier(ciField* ik, ciMethod* accessing_method);
1332 bool needs_clinit_barrier(ciMethod* ik, ciMethod* accessing_method);
1333 bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1334
1335 #ifdef ASSERT
1336 VerifyMeetResult* _type_verify;
1337 void set_exception_backedge() { _exception_backedge = true; }
1338 bool has_exception_backedge() const { return _exception_backedge; }
1339 #endif
1340
|