31 #include "compiler/compilerOracle.hpp"
32 #include "compiler/compileBroker.hpp"
33 #include "compiler/compilerEvent.hpp"
34 #include "libadt/dict.hpp"
35 #include "libadt/vectset.hpp"
36 #include "memory/resourceArea.hpp"
37 #include "oops/methodData.hpp"
38 #include "opto/idealGraphPrinter.hpp"
39 #include "opto/phasetype.hpp"
40 #include "opto/phase.hpp"
41 #include "opto/regmask.hpp"
42 #include "runtime/deoptimization.hpp"
43 #include "runtime/timerTrace.hpp"
44 #include "runtime/vmThread.hpp"
45 #include "utilities/ticks.hpp"
46
47 class AddPNode;
48 class Block;
49 class Bundle;
50 class CallGenerator;
51 class CloneMap;
52 class ConnectionGraph;
53 class IdealGraphPrinter;
54 class InlineTree;
55 class Int_Array;
56 class Matcher;
57 class MachConstantNode;
58 class MachConstantBaseNode;
59 class MachNode;
60 class MachOper;
61 class MachSafePointNode;
62 class Node;
63 class Node_Array;
64 class Node_Notes;
65 class NodeCloneInfo;
66 class OptoReg;
67 class PhaseCFG;
68 class PhaseGVN;
69 class PhaseIterGVN;
70 class PhaseRegAlloc;
71 class PhaseCCP;
72 class PhaseCCP_DCE;
73 class PhaseOutput;
74 class RootNode;
75 class relocInfo;
76 class Scope;
77 class StartNode;
78 class SafePointNode;
79 class JVMState;
80 class Type;
81 class TypeData;
82 class TypeInt;
83 class TypePtr;
84 class TypeOopPtr;
85 class TypeFunc;
86 class TypeVect;
87 class Unique_Node_List;
88 class nmethod;
89 class WarmCallInfo;
90 class Node_Stack;
91 struct Final_Reshape_Counts;
92
93 enum LoopOptsMode {
94 LoopOptsDefault,
95 LoopOptsNone,
96 LoopOptsMaxUnroll,
97 LoopOptsShenandoahExpand,
98 LoopOptsShenandoahPostExpand,
99 LoopOptsSkipSplitIf,
100 LoopOptsVerify
101 };
102
103 typedef unsigned int node_idx_t;
104 class NodeCloneInfo {
105 private:
106 uint64_t _idx_clone_orig;
107 public:
284 bool _do_count_invocations; // True if we generate code to count invocations
285 bool _do_method_data_update; // True if we generate code to update MethodData*s
286 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
287 bool _use_cmove; // True if CMove should be used without profitability analysis
288 bool _age_code; // True if we need to profile code age (decrement the aging counter)
289 int _AliasLevel; // Locally-adjusted version of AliasLevel flag.
290 bool _print_assembly; // True if we should dump assembly code for this compilation
291 bool _print_inlining; // True if we should print inlining for this compilation
292 bool _print_intrinsics; // True if we should print intrinsics for this compilation
293 #ifndef PRODUCT
294 bool _trace_opto_output;
295 bool _print_ideal;
296 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
297 #endif
298 bool _has_irreducible_loop; // Found irreducible loops
299 // JSR 292
300 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
301 RTMState _rtm_state; // State of Restricted Transactional Memory usage
302 int _loop_opts_cnt; // loop opts round
303 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
304
305 // Compilation environment.
306 Arena _comp_arena; // Arena with lifetime equivalent to Compile
307 void* _barrier_set_state; // Potential GC barrier state for Compile
308 ciEnv* _env; // CI interface
309 DirectiveSet* _directive; // Compiler directive
310 CompileLog* _log; // from CompilerThread
311 const char* _failure_reason; // for record_failure/failing pattern
312 GrowableArray<CallGenerator*>* _intrinsics; // List of intrinsics.
313 GrowableArray<Node*>* _macro_nodes; // List of nodes which need to be expanded before matching.
314 GrowableArray<Node*>* _predicate_opaqs; // List of Opaque1 nodes for the loop predicates.
315 GrowableArray<Node*>* _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
316 GrowableArray<Node*>* _range_check_casts; // List of CastII nodes with a range check dependency
317 GrowableArray<Node*>* _opaque4_nodes; // List of Opaque4 nodes that have a default value
318 ConnectionGraph* _congraph;
319 #ifndef PRODUCT
320 IdealGraphPrinter* _printer;
321 static IdealGraphPrinter* _debug_file_printer;
322 static IdealGraphPrinter* _debug_network_printer;
323 #endif
324
325
326 // Node management
327 uint _unique; // Counter for unique Node indices
328 VectorSet _dead_node_list; // Set of dead nodes
329 uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).
330 // So use this to keep count and make the call O(1).
331 DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified
332 DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes
333
334 debug_only(static int _debug_idx;) // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
335 Arena _node_arena; // Arena for new-space Nodes
336 Arena _old_arena; // Arena for old-space Nodes, lifetime during xform
337 RootNode* _root; // Unique root of compilation, or NULL after bail-out.
577 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
578 bool use_cmove() const { return _use_cmove; }
579 void set_use_cmove(bool z) { _use_cmove = z; }
580 bool age_code() const { return _age_code; }
581 void set_age_code(bool z) { _age_code = z; }
582 int AliasLevel() const { return _AliasLevel; }
583 bool print_assembly() const { return _print_assembly; }
584 void set_print_assembly(bool z) { _print_assembly = z; }
585 bool print_inlining() const { return _print_inlining; }
586 void set_print_inlining(bool z) { _print_inlining = z; }
587 bool print_intrinsics() const { return _print_intrinsics; }
588 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
589 RTMState rtm_state() const { return _rtm_state; }
590 void set_rtm_state(RTMState s) { _rtm_state = s; }
591 bool use_rtm() const { return (_rtm_state & NoRTM) == 0; }
592 bool profile_rtm() const { return _rtm_state == ProfileRTM; }
593 uint max_node_limit() const { return (uint)_max_node_limit; }
594 void set_max_node_limit(uint n) { _max_node_limit = n; }
595 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
596 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
597
598 // check the CompilerOracle for special behaviours for this compile
599 bool method_has_option(const char * option) {
600 return method() != NULL && method()->has_option(option);
601 }
602
603 #ifndef PRODUCT
604 bool trace_opto_output() const { return _trace_opto_output; }
605 bool print_ideal() const { return _print_ideal; }
606 bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
607 void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
608 int _in_dump_cnt; // Required for dumping ir nodes.
609 #endif
610 bool has_irreducible_loop() const { return _has_irreducible_loop; }
611 void set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
612
613 // JSR 292
614 bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
615 void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }
616
687 }
688
689 // Range check dependent CastII nodes that can be removed after loop optimizations
690 void add_range_check_cast(Node* n);
691 void remove_range_check_cast(Node* n) {
692 _range_check_casts->remove_if_existing(n);
693 }
694 Node* range_check_cast_node(int idx) const { return _range_check_casts->at(idx); }
695 int range_check_cast_count() const { return _range_check_casts->length(); }
696 // Remove all range check dependent CastIINodes.
697 void remove_range_check_casts(PhaseIterGVN &igvn);
698
699 void add_opaque4_node(Node* n);
700 void remove_opaque4_node(Node* n) {
701 _opaque4_nodes->remove_if_existing(n);
702 }
703 Node* opaque4_node(int idx) const { return _opaque4_nodes->at(idx); }
704 int opaque4_count() const { return _opaque4_nodes->length(); }
705 void remove_opaque4_nodes(PhaseIterGVN &igvn);
706
707 void sort_macro_nodes();
708
709 // remove the opaque nodes that protect the predicates so that the unused checks and
710 // uncommon traps will be eliminated from the graph.
711 void cleanup_loop_predicates(PhaseIterGVN &igvn);
712 bool is_predicate_opaq(Node * n) {
713 return _predicate_opaqs->contains(n);
714 }
715
716 // Are there candidate expensive nodes for optimization?
717 bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
718 // Check whether n1 and n2 are similar
719 static int cmp_expensive_nodes(Node* n1, Node* n2);
720 // Sort expensive nodes to locate similar expensive nodes
721 void sort_expensive_nodes();
722
723 // Compilation environment.
724 Arena* comp_arena() { return &_comp_arena; }
725 ciEnv* env() const { return _env; }
726 CompileLog* log() const { return _log; }
827 Arena* type_arena() { return _type_arena; }
828 Dict* type_dict() { return _type_dict; }
829 size_t type_last_size() { return _type_last_size; }
830 int num_alias_types() { return _num_alias_types; }
831
832 void init_type_arena() { _type_arena = &_Compile_types; }
833 void set_type_arena(Arena* a) { _type_arena = a; }
834 void set_type_dict(Dict* d) { _type_dict = d; }
835 void set_type_last_size(size_t sz) { _type_last_size = sz; }
836
837 const TypeFunc* last_tf(ciMethod* m) {
838 return (m == _last_tf_m) ? _last_tf : NULL;
839 }
840 void set_last_tf(ciMethod* m, const TypeFunc* tf) {
841 assert(m != NULL || tf == NULL, "");
842 _last_tf_m = m;
843 _last_tf = tf;
844 }
845
846 AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
847 AliasType* alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
848 bool have_alias_type(const TypePtr* adr_type);
849 AliasType* alias_type(ciField* field);
850
851 int get_alias_index(const TypePtr* at) { return alias_type(at)->index(); }
852 const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }
853 int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }
854
855 // Building nodes
856 void rethrow_exceptions(JVMState* jvms);
857 void return_values(JVMState* jvms);
858 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
859
860 // Decide how to build a call.
861 // The profile factor is a discount to apply to this site's interp. profile.
862 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
863 JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,
864 bool allow_intrinsics = true);
865 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
866 return should_delay_string_inlining(call_method, jvms) ||
867 should_delay_boxing_inlining(call_method, jvms);
868 }
869 bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
870 bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
871
1055 uint varargs_C_out_slots_killed() const;
1056
1057 // Number of Stack Slots consumed by a synchronization entry
1058 int sync_stack_slots() const;
1059
1060 // Compute the name of old_SP. See <arch>.ad for frame layout.
1061 OptoReg::Name compute_old_SP();
1062
1063 private:
1064 // Phase control:
1065 void Init(int aliaslevel); // Prepare for a single compilation
1066 int Inline_Warm(); // Find more inlining work.
1067 void Finish_Warm(); // Give up on further inlines.
1068 void Optimize(); // Given a graph, optimize it
1069 void Code_Gen(); // Generate code from a graph
1070
1071 // Management of the AliasType table.
1072 void grow_alias_types();
1073 AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1074 const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1075 AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
1076
1077 void verify_top(Node*) const PRODUCT_RETURN;
1078
1079 // Intrinsic setup.
1080 void register_library_intrinsics(); // initializer
1081 CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual); // constructor
1082 int intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found); // helper
1083 CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual); // query fn
1084 void register_intrinsic(CallGenerator* cg); // update fn
1085
1086 #ifndef PRODUCT
1087 static juint _intrinsic_hist_count[vmIntrinsics::ID_LIMIT];
1088 static jubyte _intrinsic_hist_flags[vmIntrinsics::ID_LIMIT];
1089 #endif
1090 // Function calls made by the public function final_graph_reshaping.
1091 // No need to be made public as they are not called elsewhere.
1092 void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc);
1093 void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop);
1094 void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc );
1095 void eliminate_redundant_card_marks(Node* n);
1128 // End-of-run dumps.
1129 static void print_statistics() PRODUCT_RETURN;
1130
1131 // Verify ADLC assumptions during startup
1132 static void adlc_verification() PRODUCT_RETURN;
1133
1134 // Definitions of pd methods
1135 static void pd_compiler2_init();
1136
1137 // Static parse-time type checking logic for gen_subtype_check:
1138 enum { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1139 int static_subtype_check(ciKlass* superk, ciKlass* subk);
1140
1141 static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1142 // Optional control dependency (for example, on range check)
1143 Node* ctrl = NULL);
1144
1145 // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1146 static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl);
1147
1148 // Auxiliary method for randomized fuzzing/stressing
1149 static bool randomized_select(int count);
1150
1151 // supporting clone_map
1152 CloneMap& clone_map();
1153 void set_clone_map(Dict* d);
1154
1155 bool needs_clinit_barrier(ciField* ik, ciMethod* accessing_method);
1156 bool needs_clinit_barrier(ciMethod* ik, ciMethod* accessing_method);
1157 bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1158
1159 #ifdef IA32
1160 private:
1161 bool _select_24_bit_instr; // We selected an instruction with a 24-bit result
1162 bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results
1163
1164 // Remember if this compilation changes hardware mode to 24-bit precision.
1165 void set_24_bit_selection_and_mode(bool selection, bool mode) {
1166 _select_24_bit_instr = selection;
1167 _in_24_bit_fp_mode = mode;
|
31 #include "compiler/compilerOracle.hpp"
32 #include "compiler/compileBroker.hpp"
33 #include "compiler/compilerEvent.hpp"
34 #include "libadt/dict.hpp"
35 #include "libadt/vectset.hpp"
36 #include "memory/resourceArea.hpp"
37 #include "oops/methodData.hpp"
38 #include "opto/idealGraphPrinter.hpp"
39 #include "opto/phasetype.hpp"
40 #include "opto/phase.hpp"
41 #include "opto/regmask.hpp"
42 #include "runtime/deoptimization.hpp"
43 #include "runtime/timerTrace.hpp"
44 #include "runtime/vmThread.hpp"
45 #include "utilities/ticks.hpp"
46
47 class AddPNode;
48 class Block;
49 class Bundle;
50 class CallGenerator;
51 class CallNode;
52 class CloneMap;
53 class ConnectionGraph;
54 class IdealGraphPrinter;
55 class InlineTree;
56 class Int_Array;
57 class Matcher;
58 class MachConstantNode;
59 class MachConstantBaseNode;
60 class MachNode;
61 class MachOper;
62 class MachSafePointNode;
63 class Node;
64 class Node_Array;
65 class Node_Notes;
66 class NodeCloneInfo;
67 class OptoReg;
68 class PhaseCFG;
69 class PhaseGVN;
70 class PhaseIterGVN;
71 class PhaseRegAlloc;
72 class PhaseCCP;
73 class PhaseCCP_DCE;
74 class PhaseOutput;
75 class RootNode;
76 class relocInfo;
77 class Scope;
78 class StartNode;
79 class SafePointNode;
80 class JVMState;
81 class Type;
82 class TypeData;
83 class TypeInt;
84 class TypePtr;
85 class TypeOopPtr;
86 class TypeFunc;
87 class TypeVect;
88 class Unique_Node_List;
89 class InlineTypeBaseNode;
90 class nmethod;
91 class WarmCallInfo;
92 class Node_Stack;
93 struct Final_Reshape_Counts;
94
95 enum LoopOptsMode {
96 LoopOptsDefault,
97 LoopOptsNone,
98 LoopOptsMaxUnroll,
99 LoopOptsShenandoahExpand,
100 LoopOptsShenandoahPostExpand,
101 LoopOptsSkipSplitIf,
102 LoopOptsVerify
103 };
104
105 typedef unsigned int node_idx_t;
106 class NodeCloneInfo {
107 private:
108 uint64_t _idx_clone_orig;
109 public:
286 bool _do_count_invocations; // True if we generate code to count invocations
287 bool _do_method_data_update; // True if we generate code to update MethodData*s
288 bool _do_vector_loop; // True if allowed to execute loop in parallel iterations
289 bool _use_cmove; // True if CMove should be used without profitability analysis
290 bool _age_code; // True if we need to profile code age (decrement the aging counter)
291 int _AliasLevel; // Locally-adjusted version of AliasLevel flag.
292 bool _print_assembly; // True if we should dump assembly code for this compilation
293 bool _print_inlining; // True if we should print inlining for this compilation
294 bool _print_intrinsics; // True if we should print intrinsics for this compilation
295 #ifndef PRODUCT
296 bool _trace_opto_output;
297 bool _print_ideal;
298 bool _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
299 #endif
300 bool _has_irreducible_loop; // Found irreducible loops
301 // JSR 292
302 bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
303 RTMState _rtm_state; // State of Restricted Transactional Memory usage
304 int _loop_opts_cnt; // loop opts round
305 bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
306 bool _has_flattened_accesses; // Any known flattened array accesses?
307 bool _flattened_accesses_share_alias; // Initially all flattened array share a single slice
308
309 // Compilation environment.
310 Arena _comp_arena; // Arena with lifetime equivalent to Compile
311 void* _barrier_set_state; // Potential GC barrier state for Compile
312 ciEnv* _env; // CI interface
313 DirectiveSet* _directive; // Compiler directive
314 CompileLog* _log; // from CompilerThread
315 const char* _failure_reason; // for record_failure/failing pattern
316 GrowableArray<CallGenerator*>* _intrinsics; // List of intrinsics.
317 GrowableArray<Node*>* _macro_nodes; // List of nodes which need to be expanded before matching.
318 GrowableArray<Node*>* _predicate_opaqs; // List of Opaque1 nodes for the loop predicates.
319 GrowableArray<Node*>* _expensive_nodes; // List of nodes that are expensive to compute and that we'd better not let the GVN freely common
320 GrowableArray<Node*>* _range_check_casts; // List of CastII nodes with a range check dependency
321 GrowableArray<Node*>* _opaque4_nodes; // List of Opaque4 nodes that have a default value
322 GrowableArray<Node*>* _inline_type_nodes; // List of InlineType nodes
323 ConnectionGraph* _congraph;
324 #ifndef PRODUCT
325 IdealGraphPrinter* _printer;
326 static IdealGraphPrinter* _debug_file_printer;
327 static IdealGraphPrinter* _debug_network_printer;
328 #endif
329
330
331 // Node management
332 uint _unique; // Counter for unique Node indices
333 VectorSet _dead_node_list; // Set of dead nodes
334 uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).
335 // So use this to keep count and make the call O(1).
336 DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified
337 DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes
338
339 debug_only(static int _debug_idx;) // Monotonic counter (not reset), use -XX:BreakAtNode=<idx>
340 Arena _node_arena; // Arena for new-space Nodes
341 Arena _old_arena; // Arena for old-space Nodes, lifetime during xform
342 RootNode* _root; // Unique root of compilation, or NULL after bail-out.
582 void set_do_vector_loop(bool z) { _do_vector_loop = z; }
583 bool use_cmove() const { return _use_cmove; }
584 void set_use_cmove(bool z) { _use_cmove = z; }
585 bool age_code() const { return _age_code; }
586 void set_age_code(bool z) { _age_code = z; }
587 int AliasLevel() const { return _AliasLevel; }
588 bool print_assembly() const { return _print_assembly; }
589 void set_print_assembly(bool z) { _print_assembly = z; }
590 bool print_inlining() const { return _print_inlining; }
591 void set_print_inlining(bool z) { _print_inlining = z; }
592 bool print_intrinsics() const { return _print_intrinsics; }
593 void set_print_intrinsics(bool z) { _print_intrinsics = z; }
594 RTMState rtm_state() const { return _rtm_state; }
595 void set_rtm_state(RTMState s) { _rtm_state = s; }
596 bool use_rtm() const { return (_rtm_state & NoRTM) == 0; }
597 bool profile_rtm() const { return _rtm_state == ProfileRTM; }
598 uint max_node_limit() const { return (uint)_max_node_limit; }
599 void set_max_node_limit(uint n) { _max_node_limit = n; }
600 bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
601 void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
602 void set_flattened_accesses() { _has_flattened_accesses = true; }
603 bool flattened_accesses_share_alias() const { return _flattened_accesses_share_alias; }
604 void set_flattened_accesses_share_alias(bool z) { _flattened_accesses_share_alias = z; }
605
606 // Support for scalarized inline type calling convention
607 bool has_scalarized_args() const { return _method != NULL && _method->has_scalarized_args(); }
608 bool needs_stack_repair() const { return _method != NULL && _method->get_Method()->c2_needs_stack_repair(); }
609
610 // check the CompilerOracle for special behaviours for this compile
611 bool method_has_option(const char * option) {
612 return method() != NULL && method()->has_option(option);
613 }
614
615 #ifndef PRODUCT
616 bool trace_opto_output() const { return _trace_opto_output; }
617 bool print_ideal() const { return _print_ideal; }
618 bool parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
619 void set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
620 int _in_dump_cnt; // Required for dumping ir nodes.
621 #endif
622 bool has_irreducible_loop() const { return _has_irreducible_loop; }
623 void set_has_irreducible_loop(bool z) { _has_irreducible_loop = z; }
624
625 // JSR 292
626 bool has_method_handle_invokes() const { return _has_method_handle_invokes; }
627 void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; }
628
699 }
700
701 // Range check dependent CastII nodes that can be removed after loop optimizations
702 void add_range_check_cast(Node* n);
703 void remove_range_check_cast(Node* n) {
704 _range_check_casts->remove_if_existing(n);
705 }
706 Node* range_check_cast_node(int idx) const { return _range_check_casts->at(idx); }
707 int range_check_cast_count() const { return _range_check_casts->length(); }
708 // Remove all range check dependent CastIINodes.
709 void remove_range_check_casts(PhaseIterGVN &igvn);
710
711 void add_opaque4_node(Node* n);
712 void remove_opaque4_node(Node* n) {
713 _opaque4_nodes->remove_if_existing(n);
714 }
715 Node* opaque4_node(int idx) const { return _opaque4_nodes->at(idx); }
716 int opaque4_count() const { return _opaque4_nodes->length(); }
717 void remove_opaque4_nodes(PhaseIterGVN &igvn);
718
719 // Keep track of inline type nodes for later processing
720 void add_inline_type(Node* n);
721 void remove_inline_type(Node* n);
722 void process_inline_types(PhaseIterGVN &igvn, bool post_ea = false);
723
724 void adjust_flattened_array_access_aliases(PhaseIterGVN& igvn);
725
726 void sort_macro_nodes();
727
728 // remove the opaque nodes that protect the predicates so that the unused checks and
729 // uncommon traps will be eliminated from the graph.
730 void cleanup_loop_predicates(PhaseIterGVN &igvn);
731 bool is_predicate_opaq(Node * n) {
732 return _predicate_opaqs->contains(n);
733 }
734
735 // Are there candidate expensive nodes for optimization?
736 bool should_optimize_expensive_nodes(PhaseIterGVN &igvn);
737 // Check whether n1 and n2 are similar
738 static int cmp_expensive_nodes(Node* n1, Node* n2);
739 // Sort expensive nodes to locate similar expensive nodes
740 void sort_expensive_nodes();
741
742 // Compilation environment.
743 Arena* comp_arena() { return &_comp_arena; }
744 ciEnv* env() const { return _env; }
745 CompileLog* log() const { return _log; }
846 Arena* type_arena() { return _type_arena; }
847 Dict* type_dict() { return _type_dict; }
848 size_t type_last_size() { return _type_last_size; }
849 int num_alias_types() { return _num_alias_types; }
850
851 void init_type_arena() { _type_arena = &_Compile_types; }
852 void set_type_arena(Arena* a) { _type_arena = a; }
853 void set_type_dict(Dict* d) { _type_dict = d; }
854 void set_type_last_size(size_t sz) { _type_last_size = sz; }
855
856 const TypeFunc* last_tf(ciMethod* m) {
857 return (m == _last_tf_m) ? _last_tf : NULL;
858 }
859 void set_last_tf(ciMethod* m, const TypeFunc* tf) {
860 assert(m != NULL || tf == NULL, "");
861 _last_tf_m = m;
862 _last_tf = tf;
863 }
864
865 AliasType* alias_type(int idx) { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
866 AliasType* alias_type(const TypePtr* adr_type, ciField* field = NULL, bool uncached = false) { return find_alias_type(adr_type, false, field, uncached); }
867 bool have_alias_type(const TypePtr* adr_type);
868 AliasType* alias_type(ciField* field);
869
870 int get_alias_index(const TypePtr* at, bool uncached = false) { return alias_type(at, NULL, uncached)->index(); }
871 const TypePtr* get_adr_type(uint aidx) { return alias_type(aidx)->adr_type(); }
872 int get_general_index(uint aidx) { return alias_type(aidx)->general_index(); }
873
874 // Building nodes
875 void rethrow_exceptions(JVMState* jvms);
876 void return_values(JVMState* jvms);
877 JVMState* build_start_state(StartNode* start, const TypeFunc* tf);
878
879 // Decide how to build a call.
880 // The profile factor is a discount to apply to this site's interp. profile.
881 CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch,
882 JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL,
883 bool allow_intrinsics = true);
884 bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
885 return should_delay_string_inlining(call_method, jvms) ||
886 should_delay_boxing_inlining(call_method, jvms);
887 }
888 bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
889 bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
890
1074 uint varargs_C_out_slots_killed() const;
1075
1076 // Number of Stack Slots consumed by a synchronization entry
1077 int sync_stack_slots() const;
1078
1079 // Compute the name of old_SP. See <arch>.ad for frame layout.
1080 OptoReg::Name compute_old_SP();
1081
1082 private:
1083 // Phase control:
1084 void Init(int aliaslevel); // Prepare for a single compilation
1085 int Inline_Warm(); // Find more inlining work.
1086 void Finish_Warm(); // Give up on further inlines.
1087 void Optimize(); // Given a graph, optimize it
1088 void Code_Gen(); // Generate code from a graph
1089
1090 // Management of the AliasType table.
1091 void grow_alias_types();
1092 AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
1093 const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
1094 AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field, bool uncached = false);
1095
1096 void verify_top(Node*) const PRODUCT_RETURN;
1097
1098 // Intrinsic setup.
1099 void register_library_intrinsics(); // initializer
1100 CallGenerator* make_vm_intrinsic(ciMethod* m, bool is_virtual); // constructor
1101 int intrinsic_insertion_index(ciMethod* m, bool is_virtual, bool& found); // helper
1102 CallGenerator* find_intrinsic(ciMethod* m, bool is_virtual); // query fn
1103 void register_intrinsic(CallGenerator* cg); // update fn
1104
1105 #ifndef PRODUCT
1106 static juint _intrinsic_hist_count[vmIntrinsics::ID_LIMIT];
1107 static jubyte _intrinsic_hist_flags[vmIntrinsics::ID_LIMIT];
1108 #endif
1109 // Function calls made by the public function final_graph_reshaping.
1110 // No need to be made public as they are not called elsewhere.
1111 void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc);
1112 void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop);
1113 void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc );
1114 void eliminate_redundant_card_marks(Node* n);
1147 // End-of-run dumps.
1148 static void print_statistics() PRODUCT_RETURN;
1149
1150 // Verify ADLC assumptions during startup
1151 static void adlc_verification() PRODUCT_RETURN;
1152
1153 // Definitions of pd methods
1154 static void pd_compiler2_init();
1155
1156 // Static parse-time type checking logic for gen_subtype_check:
1157 enum { SSC_always_false, SSC_always_true, SSC_easy_test, SSC_full_test };
1158 int static_subtype_check(ciKlass* superk, ciKlass* subk);
1159
1160 static Node* conv_I2X_index(PhaseGVN* phase, Node* offset, const TypeInt* sizetype,
1161 // Optional control dependency (for example, on range check)
1162 Node* ctrl = NULL);
1163
1164 // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check)
1165 static Node* constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl);
1166
1167 Node* optimize_acmp(PhaseGVN* phase, Node* a, Node* b);
1168
1169 // Auxiliary method for randomized fuzzing/stressing
1170 static bool randomized_select(int count);
1171
1172 // supporting clone_map
1173 CloneMap& clone_map();
1174 void set_clone_map(Dict* d);
1175
1176 bool needs_clinit_barrier(ciField* ik, ciMethod* accessing_method);
1177 bool needs_clinit_barrier(ciMethod* ik, ciMethod* accessing_method);
1178 bool needs_clinit_barrier(ciInstanceKlass* ik, ciMethod* accessing_method);
1179
1180 #ifdef IA32
1181 private:
1182 bool _select_24_bit_instr; // We selected an instruction with a 24-bit result
1183 bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results
1184
1185 // Remember if this compilation changes hardware mode to 24-bit precision.
1186 void set_24_bit_selection_and_mode(bool selection, bool mode) {
1187 _select_24_bit_instr = selection;
1188 _in_24_bit_fp_mode = mode;
|