50
51 static bool verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used);
52 static void report_verify_failure(const char* msg, Node* n1 = nullptr, Node* n2 = nullptr);
53 #endif
54 static Node* dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase);
55 static Node* no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase);
56 static bool is_gc_state_test(Node* iff, int mask);
57 static bool has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase);
58 static Node* find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase);
59 static void follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase);
60 static void test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase);
61 static void test_gc_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl,
62 PhaseIdealLoop* phase, int flags);
63 static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr,
64 DecoratorSet decorators, PhaseIdealLoop* phase);
65
66 static void collect_nodes_above_barrier(Unique_Node_List &nodes_above_barrier, PhaseIdealLoop* phase, Node* ctrl,
67 Node* init_raw_mem);
68
69 static void test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase);
70 static void move_gc_state_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase);
71 static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase);
72 static bool merge_point_safe(Node* region);
73 static bool identical_backtoback_ifs(Node *n, PhaseIdealLoop* phase);
74 static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& nodes_above_barrier, uint last, PhaseIdealLoop* phase);
75 static IfNode* find_unswitching_candidate(const IdealLoopTree *loop, PhaseIdealLoop* phase);
76
77 static Node* get_load_addr(PhaseIdealLoop* phase, VectorSet& visited, Node* lrb);
78 public:
79 static bool is_dominator(Node* d_c, Node* n_c, Node* d, Node* n, PhaseIdealLoop* phase);
80 static bool is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase);
81
82 static bool is_gc_state_load(Node* n);
83 static bool is_heap_stable_test(Node* iff);
84
85 static bool expand(Compile* C, PhaseIterGVN& igvn);
86 static void pin_and_expand(PhaseIdealLoop* phase);
87 static void optimize_after_expansion(VectorSet& visited, Node_Stack& nstack, Node_List& old_new, PhaseIdealLoop* phase);
88
89 static void push_data_inputs_at_control(PhaseIdealLoop* phase, Node* n, Node* ctrl,
90 Unique_Node_List &wq);
91 static bool is_anti_dependent_load_at_control(PhaseIdealLoop* phase, Node* maybe_load, Node* store, Node* control);
92
93 static void maybe_push_anti_dependent_loads(PhaseIdealLoop* phase, Node* maybe_store, Node* control, Unique_Node_List &wq);
94 #ifdef ASSERT
95 static void verify(RootNode* root);
96 #endif
97 };
98
99 class ShenandoahIUBarrierNode : public Node {
100 public:
101 ShenandoahIUBarrierNode(Node* val);
102
103 const Type *bottom_type() const;
104 const Type* Value(PhaseGVN* phase) const;
105 Node* Identity(PhaseGVN* phase);
106
107 int Opcode() const;
108
109 private:
110 enum { Needed, NotNeeded, MaybeNeeded };
111
112 static int needed(Node* n);
113 static Node* next(Node* n);
114 };
115
116 class MemoryGraphFixer : public ResourceObj {
117 private:
118 Node_List _memory_nodes;
119 int _alias;
120 PhaseIdealLoop* _phase;
121 bool _include_lsm;
122
123 void collect_memory_nodes();
124 Node* get_ctrl(Node* n) const;
125 Node* ctrl_or_self(Node* n) const;
126 bool mem_is_valid(Node* m, Node* c) const;
127 MergeMemNode* allocate_merge_mem(Node* mem, Node* rep_proj, Node* rep_ctrl) const;
128 MergeMemNode* clone_merge_mem(Node* u, Node* mem, Node* rep_proj, Node* rep_ctrl, DUIterator& i) const;
129 void fix_memory_uses(Node* mem, Node* replacement, Node* rep_proj, Node* rep_ctrl) const;
130 bool should_process_phi(Node* phi) const;
131 bool has_mem_phi(Node* region) const;
132
133 public:
134 MemoryGraphFixer(int alias, bool include_lsm, PhaseIdealLoop* phase) :
135 _alias(alias), _phase(phase), _include_lsm(include_lsm) {
|
50
51 static bool verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used);
52 static void report_verify_failure(const char* msg, Node* n1 = nullptr, Node* n2 = nullptr);
53 #endif
54 static Node* dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase);
55 static Node* no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase);
56 static bool is_gc_state_test(Node* iff, int mask);
57 static bool has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase);
58 static Node* find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase);
59 static void follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase);
60 static void test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase);
61 static void test_gc_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl,
62 PhaseIdealLoop* phase, int flags);
63 static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr,
64 DecoratorSet decorators, PhaseIdealLoop* phase);
65
66 static void collect_nodes_above_barrier(Unique_Node_List &nodes_above_barrier, PhaseIdealLoop* phase, Node* ctrl,
67 Node* init_raw_mem);
68
69 static void test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase);
70 static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& nodes_above_barrier, uint last, PhaseIdealLoop* phase);
71
72 static Node* get_load_addr(PhaseIdealLoop* phase, VectorSet& visited, Node* lrb);
73 public:
74 static bool is_dominator(Node* d_c, Node* n_c, Node* d, Node* n, PhaseIdealLoop* phase);
75 static bool is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase);
76
77 static bool is_gc_state_load(Node* n);
78 static bool is_heap_stable_test(Node* iff);
79
80 static bool expand(Compile* C, PhaseIterGVN& igvn);
81 static void pin_and_expand(PhaseIdealLoop* phase);
82
83 static void push_data_inputs_at_control(PhaseIdealLoop* phase, Node* n, Node* ctrl,
84 Unique_Node_List &wq);
85 static bool is_anti_dependent_load_at_control(PhaseIdealLoop* phase, Node* maybe_load, Node* store, Node* control);
86
87 static void maybe_push_anti_dependent_loads(PhaseIdealLoop* phase, Node* maybe_store, Node* control, Unique_Node_List &wq);
88 #ifdef ASSERT
89 static void verify(RootNode* root);
90 #endif
91 };
92
93 class MemoryGraphFixer : public ResourceObj {
94 private:
95 Node_List _memory_nodes;
96 int _alias;
97 PhaseIdealLoop* _phase;
98 bool _include_lsm;
99
100 void collect_memory_nodes();
101 Node* get_ctrl(Node* n) const;
102 Node* ctrl_or_self(Node* n) const;
103 bool mem_is_valid(Node* m, Node* c) const;
104 MergeMemNode* allocate_merge_mem(Node* mem, Node* rep_proj, Node* rep_ctrl) const;
105 MergeMemNode* clone_merge_mem(Node* u, Node* mem, Node* rep_proj, Node* rep_ctrl, DUIterator& i) const;
106 void fix_memory_uses(Node* mem, Node* replacement, Node* rep_proj, Node* rep_ctrl) const;
107 bool should_process_phi(Node* phi) const;
108 bool has_mem_phi(Node* region) const;
109
110 public:
111 MemoryGraphFixer(int alias, bool include_lsm, PhaseIdealLoop* phase) :
112 _alias(alias), _phase(phase), _include_lsm(include_lsm) {
|