duke@1
|
1 /*
|
dcubed@30244
|
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
duke@1
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
duke@1
|
4 *
|
duke@1
|
5 * This code is free software; you can redistribute it and/or modify it
|
duke@1
|
6 * under the terms of the GNU General Public License version 2 only, as
|
duke@1
|
7 * published by the Free Software Foundation.
|
duke@1
|
8 *
|
duke@1
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
duke@1
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
duke@1
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
duke@1
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
duke@1
|
13 * accompanied this code).
|
duke@1
|
14 *
|
duke@1
|
15 * You should have received a copy of the GNU General Public License version
|
duke@1
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
duke@1
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
duke@1
|
18 *
|
trims@5547
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
trims@5547
|
20 * or visit www.oracle.com if you need additional information or have any
|
trims@5547
|
21 * questions.
|
duke@1
|
22 *
|
duke@1
|
23 */
|
duke@1
|
24
|
stefank@7397
|
25 #ifndef SHARE_VM_OPTO_MACRO_HPP
|
stefank@7397
|
26 #define SHARE_VM_OPTO_MACRO_HPP
|
stefank@7397
|
27
|
stefank@7397
|
28 #include "opto/phase.hpp"
|
stefank@7397
|
29
|
duke@1
|
30 class AllocateNode;
|
duke@1
|
31 class AllocateArrayNode;
|
duke@1
|
32 class CallNode;
|
duke@1
|
33 class Node;
|
duke@1
|
34 class PhaseIterGVN;
|
duke@1
|
35
|
duke@1
|
36 class PhaseMacroExpand : public Phase {
|
duke@1
|
37 private:
|
duke@1
|
38 PhaseIterGVN &_igvn;
|
duke@1
|
39
|
eosterlund@50764
|
40 public:
|
roland@26166
|
41 // Helper methods roughly modeled after GraphKit:
|
duke@1
|
42 Node* basic_plus_adr(Node* base, int offset) {
|
duke@1
|
43 return (offset == 0)? base: basic_plus_adr(base, MakeConX(offset));
|
duke@1
|
44 }
|
duke@1
|
45 Node* basic_plus_adr(Node* base, Node* ptr, int offset) {
|
duke@1
|
46 return (offset == 0)? ptr: basic_plus_adr(base, ptr, MakeConX(offset));
|
duke@1
|
47 }
|
duke@1
|
48 Node* basic_plus_adr(Node* base, Node* offset) {
|
duke@1
|
49 return basic_plus_adr(base, base, offset);
|
duke@1
|
50 }
|
duke@1
|
51 Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) {
|
thartmann@24923
|
52 Node* adr = new AddPNode(base, ptr, offset);
|
duke@1
|
53 return transform_later(adr);
|
duke@1
|
54 }
|
duke@1
|
55 Node* transform_later(Node* n) {
|
duke@1
|
56 // equivalent to _gvn.transform in GraphKit, Ideal, etc.
|
duke@1
|
57 _igvn.register_new_node_with_optimizer(n);
|
duke@1
|
58 return n;
|
duke@1
|
59 }
|
duke@1
|
60 void set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr);
|
duke@1
|
61 Node* make_load( Node* ctl, Node* mem, Node* base, int offset,
|
duke@1
|
62 const Type* value_type, BasicType bt);
|
duke@1
|
63 Node* make_store(Node* ctl, Node* mem, Node* base, int offset,
|
duke@1
|
64 Node* value, BasicType bt);
|
duke@1
|
65
|
eosterlund@50764
|
66 private:
|
duke@1
|
67 // projections extracted from a call node
|
duke@1
|
68 ProjNode *_fallthroughproj;
|
duke@1
|
69 ProjNode *_fallthroughcatchproj;
|
duke@1
|
70 ProjNode *_ioproj_fallthrough;
|
duke@1
|
71 ProjNode *_ioproj_catchall;
|
duke@1
|
72 ProjNode *_catchallcatchproj;
|
duke@1
|
73 ProjNode *_memproj_fallthrough;
|
duke@1
|
74 ProjNode *_memproj_catchall;
|
duke@1
|
75 ProjNode *_resproj;
|
duke@1
|
76
|
kvn@23491
|
77 // Additional data collected during macro expansion
|
kvn@23491
|
78 bool _has_locks;
|
duke@1
|
79
|
duke@1
|
80 void expand_allocate(AllocateNode *alloc);
|
duke@1
|
81 void expand_allocate_array(AllocateArrayNode *alloc);
|
duke@1
|
82 void expand_allocate_common(AllocateNode* alloc,
|
duke@1
|
83 Node* length,
|
duke@1
|
84 const TypeFunc* slow_call_type,
|
duke@1
|
85 address slow_call_address);
|
roland@32370
|
86 Node *value_from_mem(Node *mem, Node *ctl, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc);
|
roland@32370
|
87 Node *value_from_mem_phi(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc, Node_Stack *value_phis, int level);
|
kvn@246
|
88
|
kvn@17383
|
89 bool eliminate_boxing_node(CallStaticJavaNode *boxing);
|
kvn@246
|
90 bool eliminate_allocate_node(AllocateNode *alloc);
|
kvn@246
|
91 bool can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints);
|
kvn@246
|
92 bool scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints_done);
|
kvn@17383
|
93 void process_users_of_allocation(CallNode *alloc);
|
kvn@246
|
94
|
eosterlund@50764
|
95 void eliminate_gc_barrier(Node *p2x);
|
kvn@11445
|
96 void mark_eliminated_box(Node* box, Node* obj);
|
kvn@9977
|
97 void mark_eliminated_locking_nodes(AbstractLockNode *alock);
|
kvn@239
|
98 bool eliminate_locking_node(AbstractLockNode *alock);
|
duke@1
|
99 void expand_lock_node(LockNode *lock);
|
duke@1
|
100 void expand_unlock_node(UnlockNode *unlock);
|
duke@1
|
101
|
roland@26166
|
102 // More helper methods modeled after GraphKit for array copy
|
roland@26166
|
103 void insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent = NULL);
|
roland@26166
|
104 Node* array_element_address(Node* ary, Node* idx, BasicType elembt);
|
roland@26166
|
105 Node* ConvI2L(Node* offset);
|
roland@26166
|
106 Node* make_leaf_call(Node* ctrl, Node* mem,
|
roland@26166
|
107 const TypeFunc* call_type, address call_addr,
|
roland@26166
|
108 const char* call_name,
|
roland@26166
|
109 const TypePtr* adr_type,
|
roland@26166
|
110 Node* parm0 = NULL, Node* parm1 = NULL,
|
roland@26166
|
111 Node* parm2 = NULL, Node* parm3 = NULL,
|
roland@26166
|
112 Node* parm4 = NULL, Node* parm5 = NULL,
|
roland@26166
|
113 Node* parm6 = NULL, Node* parm7 = NULL);
|
roland@26166
|
114
|
roland@26166
|
115 // helper methods modeled after LibraryCallKit for array copy
|
roland@26166
|
116 Node* generate_guard(Node** ctrl, Node* test, RegionNode* region, float true_prob);
|
roland@26166
|
117 Node* generate_slow_guard(Node** ctrl, Node* test, RegionNode* region);
|
roland@26166
|
118 void generate_negative_guard(Node** ctrl, Node* index, RegionNode* region);
|
roland@26166
|
119 void generate_limit_guard(Node** ctrl, Node* offset, Node* subseq_length, Node* array_length, RegionNode* region);
|
roland@26166
|
120
|
roland@26166
|
121 // More helper methods for array copy
|
roland@26166
|
122 Node* generate_nonpositive_guard(Node** ctrl, Node* index, bool never_negative);
|
roland@26166
|
123 void finish_arraycopy_call(Node* call, Node** ctrl, MergeMemNode** mem, const TypePtr* adr_type);
|
roland@26166
|
124 address basictype2arraycopy(BasicType t,
|
roland@26166
|
125 Node* src_offset,
|
roland@26166
|
126 Node* dest_offset,
|
roland@26166
|
127 bool disjoint_bases,
|
roland@26166
|
128 const char* &name,
|
roland@26166
|
129 bool dest_uninitialized);
|
roland@26166
|
130 Node* generate_arraycopy(ArrayCopyNode *ac,
|
roland@26166
|
131 AllocateArrayNode* alloc,
|
roland@26166
|
132 Node** ctrl, MergeMemNode* mem, Node** io,
|
roland@26166
|
133 const TypePtr* adr_type,
|
roland@26166
|
134 BasicType basic_elem_type,
|
roland@26166
|
135 Node* src, Node* src_offset,
|
roland@26166
|
136 Node* dest, Node* dest_offset,
|
roland@26166
|
137 Node* copy_length,
|
roland@26166
|
138 bool disjoint_bases = false,
|
roland@26166
|
139 bool length_never_negative = false,
|
roland@26166
|
140 RegionNode* slow_region = NULL);
|
roland@26166
|
141 void generate_clear_array(Node* ctrl, MergeMemNode* merge_mem,
|
roland@26166
|
142 const TypePtr* adr_type,
|
roland@26166
|
143 Node* dest,
|
roland@26166
|
144 BasicType basic_elem_type,
|
roland@26166
|
145 Node* slice_idx,
|
roland@26166
|
146 Node* slice_len,
|
roland@26166
|
147 Node* dest_size);
|
roland@26166
|
148 bool generate_block_arraycopy(Node** ctrl, MergeMemNode** mem, Node* io,
|
roland@26166
|
149 const TypePtr* adr_type,
|
roland@26166
|
150 BasicType basic_elem_type,
|
roland@26166
|
151 AllocateNode* alloc,
|
roland@26166
|
152 Node* src, Node* src_offset,
|
roland@26166
|
153 Node* dest, Node* dest_offset,
|
roland@26166
|
154 Node* dest_size, bool dest_uninitialized);
|
roland@26166
|
155 MergeMemNode* generate_slow_arraycopy(ArrayCopyNode *ac,
|
roland@26166
|
156 Node** ctrl, Node* mem, Node** io,
|
roland@26166
|
157 const TypePtr* adr_type,
|
roland@26166
|
158 Node* src, Node* src_offset,
|
roland@26166
|
159 Node* dest, Node* dest_offset,
|
roland@26166
|
160 Node* copy_length, bool dest_uninitialized);
|
roland@26166
|
161 Node* generate_checkcast_arraycopy(Node** ctrl, MergeMemNode** mem,
|
roland@26166
|
162 const TypePtr* adr_type,
|
roland@26166
|
163 Node* dest_elem_klass,
|
roland@26166
|
164 Node* src, Node* src_offset,
|
roland@26166
|
165 Node* dest, Node* dest_offset,
|
roland@26166
|
166 Node* copy_length, bool dest_uninitialized);
|
roland@26166
|
167 Node* generate_generic_arraycopy(Node** ctrl, MergeMemNode** mem,
|
roland@26166
|
168 const TypePtr* adr_type,
|
roland@26166
|
169 Node* src, Node* src_offset,
|
roland@26166
|
170 Node* dest, Node* dest_offset,
|
roland@26166
|
171 Node* copy_length, bool dest_uninitialized);
|
roland@26166
|
172 void generate_unchecked_arraycopy(Node** ctrl, MergeMemNode** mem,
|
roland@26166
|
173 const TypePtr* adr_type,
|
roland@26166
|
174 BasicType basic_elem_type,
|
roland@26166
|
175 bool disjoint_bases,
|
roland@26166
|
176 Node* src, Node* src_offset,
|
roland@26166
|
177 Node* dest, Node* dest_offset,
|
roland@26166
|
178 Node* copy_length, bool dest_uninitialized);
|
roland@26166
|
179
|
roland@26166
|
180 void expand_arraycopy_node(ArrayCopyNode *ac);
|
roland@26166
|
181
|
duke@1
|
182 int replace_input(Node *use, Node *oldref, Node *newref);
|
duke@1
|
183 void copy_call_debug_info(CallNode *oldcall, CallNode * newcall);
|
kvn@1500
|
184 Node* opt_bits_test(Node* ctrl, Node* region, int edge, Node* word, int mask, int bits, bool return_fast_path = false);
|
duke@1
|
185 void copy_predefined_input_for_runtime_call(Node * ctrl, CallNode* oldcall, CallNode* call);
|
duke@1
|
186 CallNode* make_slow_call(CallNode *oldcall, const TypeFunc* slow_call_type, address slow_call,
|
dcubed@30244
|
187 const char* leaf_name, Node* slow_path, Node* parm0, Node* parm1,
|
dcubed@30244
|
188 Node* parm2);
|
duke@1
|
189 void extract_call_projections(CallNode *call);
|
duke@1
|
190
|
duke@1
|
191 Node* initialize_object(AllocateNode* alloc,
|
duke@1
|
192 Node* control, Node* rawmem, Node* object,
|
duke@1
|
193 Node* klass_node, Node* length,
|
duke@1
|
194 Node* size_in_bytes);
|
duke@1
|
195
|
roland@43483
|
196 Node* make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, Node* ctl, Node* mem, BasicType ft, const Type *ftype, AllocateNode *alloc);
|
roland@32370
|
197
|
duke@1
|
198 public:
|
kvn@23491
|
199 PhaseMacroExpand(PhaseIterGVN &igvn) : Phase(Macro_Expand), _igvn(igvn), _has_locks(false) {
|
coleenp@360
|
200 _igvn.set_delay_transform(true);
|
coleenp@360
|
201 }
|
kvn@11191
|
202 void eliminate_macro_nodes();
|
duke@1
|
203 bool expand_macro_nodes();
|
duke@1
|
204
|
eosterlund@50764
|
205 PhaseIterGVN &igvn() const { return _igvn; }
|
eosterlund@50764
|
206
|
eosterlund@50764
|
207 // Members accessed from BarrierSetC2
|
eosterlund@50764
|
208 void replace_node(Node* source, Node* target) { _igvn.replace_node(source, target); }
|
eosterlund@50764
|
209 Node* intcon(jint con) const { return _igvn.intcon(con); }
|
eosterlund@50764
|
210 Node* longcon(jlong con) const { return _igvn.longcon(con); }
|
eosterlund@50764
|
211 Node* makecon(const Type *t) const { return _igvn.makecon(t); }
|
eosterlund@50764
|
212 Node* top() const { return C->top(); }
|
rkennke@52592
|
213
|
rkennke@52592
|
214 Node* prefetch_allocation(Node* i_o,
|
rkennke@52592
|
215 Node*& needgc_false, Node*& contended_phi_rawmem,
|
rkennke@52592
|
216 Node* old_eden_top, Node* new_eden_top,
|
rkennke@52592
|
217 intx lines);
|
duke@1
|
218 };
|
stefank@7397
|
219
|
stefank@7397
|
220 #endif // SHARE_VM_OPTO_MACRO_HPP
|