Mercurial > hg > truffle
annotate src/share/vm/opto/idealKit.cpp @ 8071:bbc7936779f9
8006398: Add regression tests for deprectated GCs
Reviewed-by: ehelin, jwilhelm, jmasa
author | brutisso |
---|---|
date | Thu, 14 Feb 2013 09:11:43 +0100 |
parents | b9a9ed0f8eeb |
children | 30f42e691e70 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6804
diff
changeset
|
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1000
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1000
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1000
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "opto/addnode.hpp" | |
27 #include "opto/callnode.hpp" | |
28 #include "opto/cfgnode.hpp" | |
29 #include "opto/idealKit.hpp" | |
30 #include "opto/runtime.hpp" | |
0 | 31 |
32 // Static initialization | |
33 | |
34 // This declares the position where vars are kept in the cvstate | |
35 // For some degree of consistency we use the TypeFunc enum to | |
36 // soak up spots in the inputs even though we only use early Control | |
37 // and Memory slots. (So far.) | |
38 const uint IdealKit::first_var = TypeFunc::Parms + 1; | |
39 | |
40 //----------------------------IdealKit----------------------------------------- | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
41 IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) : |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
42 _gvn(gkit->gvn()), C(gkit->C) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
43 _initial_ctrl = gkit->control(); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
44 _initial_memory = gkit->merged_memory(); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
45 _initial_i_o = gkit->i_o(); |
0 | 46 _delay_all_transforms = delay_all_transforms; |
47 _var_ct = 0; | |
48 _cvstate = NULL; | |
49 // We can go memory state free or else we need the entire memory state | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
50 assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split"); |
0 | 51 int init_size = 5; |
52 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0); | |
53 _delay_transform = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0); | |
54 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0)); | |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
55 if (!has_declarations) { |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
56 declarations_done(); |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
57 } |
0 | 58 } |
59 | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
60 //----------------------------sync_kit----------------------------------------- |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
61 void IdealKit::sync_kit(GraphKit* gkit) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
62 set_all_memory(gkit->merged_memory()); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
63 set_i_o(gkit->i_o()); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
64 set_ctrl(gkit->control()); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
65 } |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
66 |
0 | 67 //-------------------------------if_then------------------------------------- |
68 // Create: if(left relop right) | |
69 // / \ | |
70 // iffalse iftrue | |
71 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate. | |
72 void IdealKit::if_then(Node* left, BoolTest::mask relop, | |
73 Node* right, float prob, float cnt, bool push_new_state) { | |
74 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If"); | |
75 Node* bol; | |
76 if (left->bottom_type()->isa_ptr() == NULL) { | |
77 if (left->bottom_type()->isa_int() != NULL) { | |
78 bol = Bool(CmpI(left, right), relop); | |
79 } else { | |
80 assert(left->bottom_type()->isa_long() != NULL, "what else?"); | |
81 bol = Bool(CmpL(left, right), relop); | |
82 } | |
83 | |
84 } else { | |
85 bol = Bool(CmpP(left, right), relop); | |
86 } | |
87 // Delay gvn.tranform on if-nodes until construction is finished | |
88 // to prevent a constant bool input from discarding a control output. | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
89 IfNode* iff = delay_transform(new (C) IfNode(ctrl(), bol, prob, cnt))->as_If(); |
0 | 90 Node* then = IfTrue(iff); |
91 Node* elsen = IfFalse(iff); | |
92 Node* else_cvstate = copy_cvstate(); | |
93 else_cvstate->set_req(TypeFunc::Control, elsen); | |
94 _pending_cvstates->push(else_cvstate); | |
95 DEBUG_ONLY(if (push_new_state) _state->push(IfThenS)); | |
96 set_ctrl(then); | |
97 } | |
98 | |
99 //-------------------------------else_------------------------------------- | |
100 // Pop the else cvstate off the stack, and push the (current) then cvstate. | |
101 // The else cvstate becomes the current cvstate. | |
102 void IdealKit::else_() { | |
103 assert(state() == IfThenS, "bad state for new Else"); | |
104 Node* else_cvstate = _pending_cvstates->pop(); | |
105 DEBUG_ONLY(_state->pop()); | |
106 // save current (then) cvstate for later use at endif | |
107 _pending_cvstates->push(_cvstate); | |
108 DEBUG_ONLY(_state->push(ElseS)); | |
109 _cvstate = else_cvstate; | |
110 } | |
111 | |
112 //-------------------------------end_if------------------------------------- | |
113 // Merge the "then" and "else" cvstates. | |
114 // | |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
115 // The if_then() pushed a copy of the current state for later use |
0 | 116 // as the initial state for a future "else" clause. The |
117 // current state then became the initial state for the | |
118 // then clause. If an "else" clause was encountered, it will | |
119 // pop the top state and use it for it's initial state. | |
120 // It will also push the current state (the state at the end of | |
121 // the "then" clause) for latter use at the end_if. | |
122 // | |
123 // At the endif, the states are: | |
124 // 1) else exists a) current state is end of "else" clause | |
125 // b) top stack state is end of "then" clause | |
126 // | |
127 // 2) no else: a) current state is end of "then" clause | |
128 // b) top stack state is from the "if_then" which | |
129 // would have been the initial state of the else. | |
130 // | |
131 // Merging the states is accomplished by: | |
132 // 1) make a label for the merge | |
133 // 2) terminate the current state with a goto to the label | |
134 // 3) pop the top state from the stack and make it the | |
135 // current state | |
136 // 4) bind the label at the current state. Binding a label | |
137 // terminates the current state with a goto to the | |
138 // label and makes the label's state the current state. | |
139 // | |
140 void IdealKit::end_if() { | |
141 assert(state() & (IfThenS|ElseS), "bad state for new Endif"); | |
142 Node* lab = make_label(1); | |
143 | |
144 // Node* join_state = _pending_cvstates->pop(); | |
145 /* merging, join */ | |
146 goto_(lab); | |
147 _cvstate = _pending_cvstates->pop(); | |
148 | |
149 bind(lab); | |
150 DEBUG_ONLY(_state->pop()); | |
151 } | |
152 | |
153 //-------------------------------loop------------------------------------- | |
154 // Create the loop head portion (*) of: | |
155 // * iv = init | |
156 // * top: (region node) | |
157 // * if (iv relop limit) { | |
158 // loop body | |
159 // i = i + 1 | |
160 // goto top | |
161 // * } else // exits loop | |
162 // | |
163 // Pushes the loop top cvstate first, then the else (loop exit) cvstate | |
164 // onto the stack. | |
2383
9dc311b8473e
7008866: Missing loop predicate for loop with multiple entries
kvn
parents:
1972
diff
changeset
|
165 void IdealKit::loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) { |
0 | 166 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop"); |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
167 if (UseLoopPredicate) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
168 // Sync IdealKit and graphKit. |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
169 gkit->sync_kit(*this); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
170 // Add loop predicate. |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
171 gkit->add_predicate(nargs); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
172 // Update IdealKit memory. |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
173 sync_kit(gkit); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
174 } |
0 | 175 set(iv, init); |
176 Node* head = make_label(1); | |
177 bind(head); | |
178 _pending_cvstates->push(head); // push for use at end_loop | |
179 _cvstate = copy_cvstate(); | |
180 if_then(value(iv), relop, limit, prob, cnt, false /* no new state */); | |
181 DEBUG_ONLY(_state->push(LoopS)); | |
182 assert(ctrl()->is_IfTrue(), "true branch stays in loop"); | |
183 assert(_pending_cvstates->top()->in(TypeFunc::Control)->is_IfFalse(), "false branch exits loop"); | |
184 } | |
185 | |
186 //-------------------------------end_loop------------------------------------- | |
187 // Creates the goto top label. | |
188 // Expects the else (loop exit) cvstate to be on top of the | |
189 // stack, and the loop top cvstate to be 2nd. | |
190 void IdealKit::end_loop() { | |
191 assert((state() == LoopS), "bad state for new end_loop"); | |
192 Node* exit = _pending_cvstates->pop(); | |
193 Node* head = _pending_cvstates->pop(); | |
194 goto_(head); | |
195 clear(head); | |
196 DEBUG_ONLY(_state->pop()); | |
197 _cvstate = exit; | |
198 } | |
199 | |
200 //-------------------------------make_label------------------------------------- | |
201 // Creates a label. The number of goto's | |
202 // must be specified (which should be 1 less than | |
203 // the number of precedessors.) | |
204 Node* IdealKit::make_label(int goto_ct) { | |
205 assert(_cvstate != NULL, "must declare variables before labels"); | |
206 Node* lab = new_cvstate(); | |
207 int sz = 1 + goto_ct + 1 /* fall thru */; | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
208 Node* reg = delay_transform(new (C) RegionNode(sz)); |
0 | 209 lab->init_req(TypeFunc::Control, reg); |
210 return lab; | |
211 } | |
212 | |
213 //-------------------------------bind------------------------------------- | |
214 // Bind a label at the current cvstate by simulating | |
215 // a goto to the label. | |
216 void IdealKit::bind(Node* lab) { | |
217 goto_(lab, true /* bind */); | |
218 _cvstate = lab; | |
219 } | |
220 | |
221 //-------------------------------goto_------------------------------------- | |
222 // Make the current cvstate a predecessor of the label, | |
223 // creating phi's to merge values. If bind is true and | |
224 // this is not the last control edge, then ensure that | |
225 // all live values have phis created. Used to create phis | |
226 // at loop-top regions. | |
227 void IdealKit::goto_(Node* lab, bool bind) { | |
228 Node* reg = lab->in(TypeFunc::Control); | |
229 // find next empty slot in region | |
230 uint slot = 1; | |
231 while (slot < reg->req() && reg->in(slot) != NULL) slot++; | |
232 assert(slot < reg->req(), "too many gotos"); | |
233 // If this is last predecessor, then don't force phi creation | |
234 if (slot == reg->req() - 1) bind = false; | |
235 reg->init_req(slot, ctrl()); | |
236 assert(first_var + _var_ct == _cvstate->req(), "bad _cvstate size"); | |
237 for (uint i = first_var; i < _cvstate->req(); i++) { | |
238 | |
239 // l is the value of var reaching the label. Could be a single value | |
240 // reaching the label, or a phi that merges multiples values reaching | |
241 // the label. The latter is true if the label's input: in(..) is | |
242 // a phi whose control input is the region node for the label. | |
243 | |
244 Node* l = lab->in(i); | |
245 // Get the current value of the var | |
246 Node* m = _cvstate->in(i); | |
247 // If the var went unused no need for a phi | |
248 if (m == NULL) { | |
249 continue; | |
250 } else if (l == NULL || m == l) { | |
251 // Only one unique value "m" is known to reach this label so a phi | |
252 // is not yet necessary unless: | |
253 // the label is being bound and all predecessors have not been seen, | |
254 // in which case "bind" will be true. | |
255 if (bind) { | |
256 m = promote_to_phi(m, reg); | |
257 } | |
258 // Record the phi/value used for this var in the label's cvstate | |
259 lab->set_req(i, m); | |
260 } else { | |
261 // More than one value for the variable reaches this label so | |
262 // a create a phi if one does not already exist. | |
263 if (!was_promoted_to_phi(l, reg)) { | |
264 l = promote_to_phi(l, reg); | |
265 lab->set_req(i, l); | |
266 } | |
267 // Record in the phi, the var's value from the current state | |
268 l->set_req(slot, m); | |
269 } | |
270 } | |
271 do_memory_merge(_cvstate, lab); | |
272 stop(); | |
273 } | |
274 | |
275 //-----------------------------promote_to_phi----------------------------------- | |
276 Node* IdealKit::promote_to_phi(Node* n, Node* reg) { | |
277 assert(!was_promoted_to_phi(n, reg), "n already promoted to phi on this region"); | |
278 // Get a conservative type for the phi | |
279 const BasicType bt = n->bottom_type()->basic_type(); | |
280 const Type* ct = Type::get_const_basic_type(bt); | |
281 return delay_transform(PhiNode::make(reg, n, ct)); | |
282 } | |
283 | |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
284 //-----------------------------declarations_done------------------------------- |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
285 void IdealKit::declarations_done() { |
0 | 286 _cvstate = new_cvstate(); // initialize current cvstate |
287 set_ctrl(_initial_ctrl); // initialize control in current cvstate | |
288 set_all_memory(_initial_memory);// initialize memory in current cvstate | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
289 set_i_o(_initial_i_o); // initialize i_o in current cvstate |
0 | 290 DEBUG_ONLY(_state->push(BlockS)); |
291 } | |
292 | |
293 //-----------------------------transform----------------------------------- | |
294 Node* IdealKit::transform(Node* n) { | |
295 if (_delay_all_transforms) { | |
296 return delay_transform(n); | |
297 } else { | |
6615
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
2468
diff
changeset
|
298 n = gvn().transform(n); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
2468
diff
changeset
|
299 if (!gvn().is_IterGVN()) { |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
2468
diff
changeset
|
300 C->record_for_igvn(n); |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
2468
diff
changeset
|
301 } |
09aad8452938
7190310: Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
kvn
parents:
2468
diff
changeset
|
302 return n; |
0 | 303 } |
304 } | |
305 | |
306 //-----------------------------delay_transform----------------------------------- | |
307 Node* IdealKit::delay_transform(Node* n) { | |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
308 if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
309 gvn().set_type(n, n->bottom_type()); |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
310 } |
0 | 311 _delay_transform->push(n); |
312 return n; | |
313 } | |
314 | |
315 //-----------------------------new_cvstate----------------------------------- | |
316 Node* IdealKit::new_cvstate() { | |
317 uint sz = _var_ct + first_var; | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
318 return new (C) Node(sz); |
0 | 319 } |
320 | |
321 //-----------------------------copy_cvstate----------------------------------- | |
322 Node* IdealKit::copy_cvstate() { | |
323 Node* ns = new_cvstate(); | |
324 for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i)); | |
325 // We must clone memory since it will be updated as we do stores. | |
326 ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory))); | |
327 return ns; | |
328 } | |
329 | |
330 //-----------------------------clear----------------------------------- | |
331 void IdealKit::clear(Node* m) { | |
332 for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL); | |
333 } | |
334 | |
335 //-----------------------------drain_delay_transform---------------------------- | |
336 void IdealKit::drain_delay_transform() { | |
337 while (_delay_transform->length() > 0) { | |
338 Node* n = _delay_transform->pop(); | |
339 gvn().transform(n); | |
340 if (!gvn().is_IterGVN()) { | |
341 C->record_for_igvn(n); | |
342 } | |
343 } | |
344 } | |
345 | |
346 //-----------------------------IdealVariable---------------------------- | |
347 IdealVariable::IdealVariable(IdealKit &k) { | |
348 k.declare(this); | |
349 } | |
350 | |
351 Node* IdealKit::memory(uint alias_idx) { | |
352 MergeMemNode* mem = merged_memory(); | |
353 Node* p = mem->memory_at(alias_idx); | |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
354 if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
355 _gvn.set_type(p, Type::MEMORY); // must be mapped |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
356 } |
0 | 357 return p; |
358 } | |
359 | |
360 void IdealKit::set_memory(Node* mem, uint alias_idx) { | |
361 merged_memory()->set_memory_at(alias_idx, mem); | |
362 } | |
363 | |
364 //----------------------------- make_load ---------------------------- | |
365 Node* IdealKit::load(Node* ctl, | |
366 Node* adr, | |
367 const Type* t, | |
368 BasicType bt, | |
369 int adr_idx, | |
370 bool require_atomic_access) { | |
371 | |
372 assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); | |
373 const TypePtr* adr_type = NULL; // debug-mode-only argument | |
374 debug_only(adr_type = C->get_adr_type(adr_idx)); | |
375 Node* mem = memory(adr_idx); | |
376 Node* ld; | |
377 if (require_atomic_access && bt == T_LONG) { | |
378 ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t); | |
379 } else { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
380 ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt); |
0 | 381 } |
382 return transform(ld); | |
383 } | |
384 | |
385 Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt, | |
386 int adr_idx, | |
387 bool require_atomic_access) { | |
388 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); | |
389 const TypePtr* adr_type = NULL; | |
390 debug_only(adr_type = C->get_adr_type(adr_idx)); | |
391 Node *mem = memory(adr_idx); | |
392 Node* st; | |
393 if (require_atomic_access && bt == T_LONG) { | |
394 st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val); | |
395 } else { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
396 st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt); |
0 | 397 } |
398 st = transform(st); | |
399 set_memory(st, adr_idx); | |
400 | |
401 return st; | |
402 } | |
403 | |
404 // Card mark store. Must be ordered so that it will come after the store of | |
405 // the oop. | |
985
685e959d09ea
6877254: Server vm crashes with no branches off of store slice" when run with CMS and UseSuperWord(default)
cfang
parents:
851
diff
changeset
|
406 Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx, |
0 | 407 BasicType bt, |
408 int adr_idx) { | |
409 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); | |
410 const TypePtr* adr_type = NULL; | |
411 debug_only(adr_type = C->get_adr_type(adr_idx)); | |
412 Node *mem = memory(adr_idx); | |
413 | |
414 // Add required edge to oop_store, optimizer does not support precedence edges. | |
415 // Convert required edge to precedence edge before allocation. | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
416 Node* st = new (C) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx); |
0 | 417 |
418 st = transform(st); | |
419 set_memory(st, adr_idx); | |
420 | |
421 return st; | |
422 } | |
423 | |
424 //---------------------------- do_memory_merge -------------------------------- | |
425 // The memory from one merging cvstate needs to be merged with the memory for another | |
426 // join cvstate. If the join cvstate doesn't have a merged memory yet then we | |
427 // can just copy the state from the merging cvstate | |
428 | |
429 // Merge one slow path into the rest of memory. | |
430 void IdealKit::do_memory_merge(Node* merging, Node* join) { | |
431 | |
432 // Get the region for the join state | |
433 Node* join_region = join->in(TypeFunc::Control); | |
434 assert(join_region != NULL, "join region must exist"); | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
435 if (join->in(TypeFunc::I_O) == NULL ) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
436 join->set_req(TypeFunc::I_O, merging->in(TypeFunc::I_O)); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
437 } |
0 | 438 if (join->in(TypeFunc::Memory) == NULL ) { |
439 join->set_req(TypeFunc::Memory, merging->in(TypeFunc::Memory)); | |
440 return; | |
441 } | |
442 | |
443 // The control flow for merging must have already been attached to the join region | |
444 // we need its index for the phis. | |
445 uint slot; | |
446 for (slot = 1; slot < join_region->req() ; slot ++ ) { | |
447 if (join_region->in(slot) == merging->in(TypeFunc::Control)) break; | |
448 } | |
449 assert(slot != join_region->req(), "edge must already exist"); | |
450 | |
451 MergeMemNode* join_m = join->in(TypeFunc::Memory)->as_MergeMem(); | |
452 MergeMemNode* merging_m = merging->in(TypeFunc::Memory)->as_MergeMem(); | |
453 | |
454 // join_m should be an ancestor mergemem of merging | |
455 // Slow path memory comes from the current map (which is from a slow call) | |
456 // Fast path/null path memory comes from the call's input | |
457 | |
458 // Merge the other fast-memory inputs with the new slow-default memory. | |
459 // for (MergeMemStream mms(merged_memory(), fast_mem->as_MergeMem()); mms.next_non_empty2(); ) { | |
460 for (MergeMemStream mms(join_m, merging_m); mms.next_non_empty2(); ) { | |
461 Node* join_slice = mms.force_memory(); | |
462 Node* merging_slice = mms.memory2(); | |
463 if (join_slice != merging_slice) { | |
464 PhiNode* phi; | |
465 // bool new_phi = false; | |
466 // Is the phi for this slice one that we created for this join region or simply | |
467 // one we copied? If it is ours then add | |
468 if (join_slice->is_Phi() && join_slice->as_Phi()->region() == join_region) { | |
469 phi = join_slice->as_Phi(); | |
470 } else { | |
471 // create the phi with join_slice filling supplying memory for all of the | |
472 // control edges to the join region | |
473 phi = PhiNode::make(join_region, join_slice, Type::MEMORY, mms.adr_type(C)); | |
474 phi = (PhiNode*) delay_transform(phi); | |
475 // gvn().set_type(phi, Type::MEMORY); | |
476 // new_phi = true; | |
477 } | |
478 // Now update the phi with the slice for the merging slice | |
479 phi->set_req(slot, merging_slice/* slow_path, slow_slice */); | |
480 // this updates join_m with the phi | |
481 mms.set_memory(phi); | |
482 } | |
483 } | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
484 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
485 Node* join_io = join->in(TypeFunc::I_O); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
486 Node* merging_io = merging->in(TypeFunc::I_O); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
487 if (join_io != merging_io) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
488 PhiNode* phi; |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
489 if (join_io->is_Phi() && join_io->as_Phi()->region() == join_region) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
490 phi = join_io->as_Phi(); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
491 } else { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
492 phi = PhiNode::make(join_region, join_io, Type::ABIO); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
493 phi = (PhiNode*) delay_transform(phi); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
494 join->set_req(TypeFunc::I_O, phi); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
495 } |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
496 phi->set_req(slot, merging_io); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
497 } |
0 | 498 } |
499 | |
500 | |
501 //----------------------------- make_call ---------------------------- | |
502 // Trivial runtime call | |
503 void IdealKit::make_leaf_call(const TypeFunc *slow_call_type, | |
504 address slow_call, | |
505 const char *leaf_name, | |
506 Node* parm0, | |
507 Node* parm1, | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
508 Node* parm2, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
509 Node* parm3) { |
0 | 510 |
511 // We only handle taking in RawMem and modifying RawMem | |
512 const TypePtr* adr_type = TypeRawPtr::BOTTOM; | |
513 uint adr_idx = C->get_alias_index(adr_type); | |
514 | |
515 // Slow-path leaf call | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
516 CallNode *call = (CallNode*)new (C) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type); |
0 | 517 |
518 // Set fixed predefined input arguments | |
519 call->init_req( TypeFunc::Control, ctrl() ); | |
520 call->init_req( TypeFunc::I_O , top() ) ; // does no i/o | |
521 // Narrow memory as only memory input | |
522 call->init_req( TypeFunc::Memory , memory(adr_idx)); | |
523 call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ ); | |
524 call->init_req( TypeFunc::ReturnAdr, top() ); | |
525 | |
526 if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); | |
527 if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); | |
528 if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
529 if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); |
0 | 530 |
531 // Node *c = _gvn.transform(call); | |
532 call = (CallNode *) _gvn.transform(call); | |
533 Node *c = call; // dbx gets confused with call call->dump() | |
534 | |
535 // Slow leaf call has no side-effects, sets few values | |
536 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
537 set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); |
0 | 538 |
539 // Make memory for the call | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
540 Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); |
0 | 541 |
542 // Set the RawPtr memory state only. | |
543 set_memory(mem, adr_idx); | |
544 | |
545 assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), | |
546 "call node must be constructed correctly"); | |
547 } | |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
548 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
549 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
550 void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
551 address slow_call, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
552 const char *leaf_name, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
553 const TypePtr* adr_type, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
554 Node* parm0, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
555 Node* parm1, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
556 Node* parm2, |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
557 Node* parm3) { |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
558 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
559 // We only handle taking in RawMem and modifying RawMem |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
560 uint adr_idx = C->get_alias_index(adr_type); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
561 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
562 // Slow-path leaf call |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
563 CallNode *call = (CallNode*)new (C) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type); |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
564 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
565 // Set fixed predefined input arguments |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
566 call->init_req( TypeFunc::Control, ctrl() ); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
567 call->init_req( TypeFunc::I_O , top() ) ; // does no i/o |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
568 // Narrow memory as only memory input |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
569 call->init_req( TypeFunc::Memory , memory(adr_idx)); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
570 call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ ); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
571 call->init_req( TypeFunc::ReturnAdr, top() ); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
572 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
573 if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
574 if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
575 if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
576 if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
577 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
578 // Node *c = _gvn.transform(call); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
579 call = (CallNode *) _gvn.transform(call); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
580 Node *c = call; // dbx gets confused with call call->dump() |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
581 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
582 // Slow leaf call has no side-effects, sets few values |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
583 |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
584 set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
585 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
586 // Make memory for the call |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6615
diff
changeset
|
587 Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); |
2444
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
588 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
589 // Set the RawPtr memory state only. |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
590 set_memory(mem, adr_idx); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
591 |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
592 assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
593 "call node must be constructed correctly"); |
07acc51c1d2a
7032314: Allow to generate CallLeafNoFPNode in IdealKit
kvn
parents:
2383
diff
changeset
|
594 } |