annotate src/share/vm/opto/idealKit.cpp @ 17795:a9becfeecd1b

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