annotate src/share/vm/opto/escape.hpp @ 39:76256d272075

6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation Summary: Cloning an allocation will not allow scalar replacement since memory operations could not be associated with one allocation. Reviewed-by: rasbold
author kvn
date Thu, 06 Mar 2008 10:53:33 -0800
parents a61af66fc99e
children 99269dbf4ba8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 //
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // Adaptation for C2 of the escape analysis algorithm described in:
a61af66fc99e Initial load
duke
parents:
diff changeset
27 //
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // [Choi99] Jong-Deok Shoi, Manish Gupta, Mauricio Seffano, Vugranam C. Sreedhar,
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Sam Midkiff, "Escape Analysis for Java", Procedings of ACM SIGPLAN
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // OOPSLA Conference, November 1, 1999
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // The flow-insensitive analysis described in the paper has been implemented.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // The analysis requires construction of a "connection graph" (CG) for the method being
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // analyzed. The nodes of the connection graph are:
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // - Java objects (JO)
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // - Local variables (LV)
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // - Fields of an object (OF), these also include array elements
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // The CG contains 3 types of edges:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // - PointsTo (-P>) {LV,OF} to JO
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // - Deferred (-D>) from {LV, OF} to {LV, OF}
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // - Field (-F>) from JO to OF
a61af66fc99e Initial load
duke
parents:
diff changeset
46 //
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // The following utility functions is used by the algorithm:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // PointsTo(n) - n is any CG node, it returns the set of JO that n could
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // point to.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 //
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // The algorithm describes how to construct the connection graph in the following 4 cases:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 //
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Case Edges Created
a61af66fc99e Initial load
duke
parents:
diff changeset
55 //
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // (1) p = new T() LV -P> JO
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // (2) p = q LV -D> LV
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // (3) p.f = q JO -F> OF, OF -D> LV
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // (4) p = q.f JO -F> OF, LV -D> OF
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // In all these cases, p and q are local variables. For static field references, we can
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // construct a local variable containing a reference to the static memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 //
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // C2 does not have local variables. However for the purposes of constructing
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // the connection graph, the following IR nodes are treated as local variables:
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Phi (pointer values)
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // LoadP
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Proj (value returned from callnodes including allocations)
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // CheckCastPP
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // The LoadP, Proj and CheckCastPP behave like variables assigned to only once. Only
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // a Phi can have multiple assignments. Each input to a Phi is treated
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // as an assignment to it.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 //
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // The following note types are JavaObject:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // top()
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Allocate
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // AllocateArray
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Parm (for incoming arguments)
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // CreateEx
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // ConP
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // LoadKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // AddP nodes are fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // After building the graph, a pass is made over the nodes, deleting deferred
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // nodes and copying the edges from the target of the deferred edge to the
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // source. This results in a graph with no deferred edges, only:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 //
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // LV -P> JO
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // OF -P> JO
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // JO -F> OF
a61af66fc99e Initial load
duke
parents:
diff changeset
94 //
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Then, for each node which is GlobalEscape, anything it could point to
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // is marked GlobalEscape. Finally, for any node marked ArgEscape, anything
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // it could point to is marked ArgEscape.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 //
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 class Compile;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 class Node;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 class CallNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 class PhiNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 class PhaseTransform;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 class Type;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 class TypePtr;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 class VectorSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 class PointsToNode {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 friend class ConnectionGraph;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 typedef enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 UnknownType = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 JavaObject = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
115 LocalVar = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
116 Field = 3
a61af66fc99e Initial load
duke
parents:
diff changeset
117 } NodeType;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 typedef enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 UnknownEscape = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
121 NoEscape = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
122 ArgEscape = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 GlobalEscape = 3
a61af66fc99e Initial load
duke
parents:
diff changeset
124 } EscapeState;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 typedef enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 UnknownEdge = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 PointsToEdge = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 DeferredEdge = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 FieldEdge = 3
a61af66fc99e Initial load
duke
parents:
diff changeset
131 } EdgeType;
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
134 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 EdgeMask = 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 EdgeShift = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 INITIAL_EDGE_COUNT = 4
a61af66fc99e Initial load
duke
parents:
diff changeset
139 };
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 NodeType _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 EscapeState _escape;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 GrowableArray<uint>* _edges; // outgoing edges
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int _offset; // for fields
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 bool _unique_type; // For allocated objects, this node may be a unique type
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
148 Node* _node; // Ideal node corresponding to this PointsTo node
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int _inputs_processed; // the number of Phi inputs that have been processed so far
a61af66fc99e Initial load
duke
parents:
diff changeset
150 bool _hidden_alias; // this node is an argument to a function which may return it
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // creating a hidden alias
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 PointsToNode(): _offset(-1), _type(UnknownType), _escape(UnknownEscape), _edges(NULL), _node(NULL), _inputs_processed(0), _hidden_alias(false), _unique_type(true) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 EscapeState escape_state() const { return _escape; }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 NodeType node_type() const { return _type;}
a61af66fc99e Initial load
duke
parents:
diff changeset
158 int offset() { return _offset;}
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void set_offset(int offs) { _offset = offs;}
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void set_escape_state(EscapeState state) { _escape = state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void set_node_type(NodeType ntype) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 assert(_type == UnknownType || _type == ntype, "Can't change node type");
a61af66fc99e Initial load
duke
parents:
diff changeset
164 _type = ntype;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // count of outgoing edges
a61af66fc99e Initial load
duke
parents:
diff changeset
168 uint edge_count() const { return (_edges == NULL) ? 0 : _edges->length(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // node index of target of outgoing edge "e"
a61af66fc99e Initial load
duke
parents:
diff changeset
170 uint edge_target(uint e) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // type of outgoing edge "e"
a61af66fc99e Initial load
duke
parents:
diff changeset
172 EdgeType edge_type(uint e) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // add a edge of the specified type pointing to the specified target
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void add_edge(uint targIdx, EdgeType et);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // remove an edge of the specified type pointing to the specified target
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void remove_edge(uint targIdx, EdgeType et);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void dump() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 };
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 class ConnectionGraph: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
185 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 INITIAL_NODE_COUNT = 100 // initial size of _nodes array
a61af66fc99e Initial load
duke
parents:
diff changeset
187 };
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 GrowableArray<PointsToNode>* _nodes; // connection graph nodes Indexed by ideal
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // node index
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Unique_Node_List _deferred; // Phi's to be processed after parsing
a61af66fc99e Initial load
duke
parents:
diff changeset
193 VectorSet _processed; // records which nodes have been processed
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bool _collecting; // indicates whether escape information is
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // still being collected. If false, no new
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // nodes will be processed
a61af66fc99e Initial load
duke
parents:
diff changeset
197 uint _phantom_object; // index of globally escaping object that
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // pointer values loaded from a field which
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // has not been set are assumed to point to
a61af66fc99e Initial load
duke
parents:
diff changeset
200 Compile * _compile; // Compile object for current compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // address of an element in _nodes. Used when the element is to be modified
a61af66fc99e Initial load
duke
parents:
diff changeset
203 PointsToNode *ptnode_adr(uint idx) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if ((uint)_nodes->length() <= idx) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // expand _nodes array
a61af66fc99e Initial load
duke
parents:
diff changeset
206 PointsToNode dummy = _nodes->at_grow(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return _nodes->adr_at(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // offset of a field reference
a61af66fc99e Initial load
duke
parents:
diff changeset
212 int type_to_offset(const Type *t);
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // compute the escape state for arguments to a call
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void process_call_arguments(CallNode *call, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // compute the escape state for the return value of a call
a61af66fc99e Initial load
duke
parents:
diff changeset
218 void process_call_result(ProjNode *resproj, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // compute the escape state of a Phi. This may be called multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // times as new inputs are added to the Phi.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 void process_phi_escape(PhiNode *phi, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // compute the escape state of an ideal node.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void record_escape_work(Node *n, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // walk the connection graph starting at the node corresponding to "n" and
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // add the index of everything it could point to, to "ptset". This may cause
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Phi's encountered to get (re)processed (which requires "phase".)
a61af66fc99e Initial load
duke
parents:
diff changeset
230 void PointsTo(VectorSet &ptset, Node * n, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Edge manipulation. The "from_i" and "to_i" arguments are the
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // node indices of the source and destination of the edge
a61af66fc99e Initial load
duke
parents:
diff changeset
234 void add_pointsto_edge(uint from_i, uint to_i);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 void add_deferred_edge(uint from_i, uint to_i);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void add_field_edge(uint from_i, uint to_i, int offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // Add an edge to node given by "to_i" from any field of adr_i whose offset
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // matches "offset" A deferred edge is added if to_i is a LocalVar, and
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // a pointsto edge is added if it is a JavaObject
a61af66fc99e Initial load
duke
parents:
diff changeset
242 void add_edge_from_fields(uint adr, uint to_i, int offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Add a deferred edge from node given by "from_i" to any field of adr_i whose offset
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // matches "offset"
a61af66fc99e Initial load
duke
parents:
diff changeset
246 void add_deferred_edge_to_fields(uint from_i, uint adr, int offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // Remove outgoing deferred edges from the node referenced by "ni".
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // Any outgoing edges from the target of the deferred edge are copied
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // to "ni".
a61af66fc99e Initial load
duke
parents:
diff changeset
252 void remove_deferred(uint ni);
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 Node_Array _node_map; // used for bookeeping during type splitting
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Used for the following purposes:
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Memory Phi - most recent unique Phi split out
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // from this Phi
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // MemNode - new memory input for this node
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // ChecCastPP - allocation that this is a cast of
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // allocation - CheckCastPP of the allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
261 void split_AddP(Node *addp, Node *base, PhaseGVN *igvn);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 PhiNode *create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn, bool &new_created);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 PhiNode *split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 Node *find_mem(Node *mem, int alias_idx, PhaseGVN *igvn);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // Propagate unique types created for unescaped allocated objects
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // through the graph
a61af66fc99e Initial load
duke
parents:
diff changeset
267 void split_unique_types(GrowableArray<Node *> &alloc_worklist);
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // manage entries in _node_map
a61af66fc99e Initial load
duke
parents:
diff changeset
270 void set_map(int idx, Node *n) { _node_map.map(idx, n); }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 void set_map_phi(int idx, PhiNode *p) { _node_map.map(idx, (Node *) p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 Node *get_map(int idx) { return _node_map[idx]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 PhiNode *get_map_phi(int idx) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Node *phi = _node_map[idx];
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return (phi == NULL) ? NULL : phi->as_Phi();
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Notify optimizer that a node has been modified
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // Node: This assumes that escape analysis is run before
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // PhaseIterGVN creation
a61af66fc99e Initial load
duke
parents:
diff changeset
281 void record_for_optimizer(Node *n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _compile->record_for_igvn(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // Set the escape state of a node
a61af66fc99e Initial load
duke
parents:
diff changeset
286 void set_escape_state(uint ni, PointsToNode::EscapeState es);
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // bypass any casts and return the node they refer to
a61af66fc99e Initial load
duke
parents:
diff changeset
289 Node * skip_casts(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Get Compile object for current compilation.
a61af66fc99e Initial load
duke
parents:
diff changeset
292 Compile *C() const { return _compile; }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
295 ConnectionGraph(Compile *C);
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // record a Phi for later processing.
a61af66fc99e Initial load
duke
parents:
diff changeset
298 void record_for_escape_analysis(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // process a node and fill in its connection graph node
a61af66fc99e Initial load
duke
parents:
diff changeset
301 void record_escape(Node *n, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // All nodes have been recorded, compute the escape information
a61af66fc99e Initial load
duke
parents:
diff changeset
304 void compute_escape();
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // escape state of a node
a61af66fc99e Initial load
duke
parents:
diff changeset
307 PointsToNode::EscapeState escape_state(Node *n, PhaseTransform *phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 bool hidden_alias(Node *n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (_collecting)
a61af66fc99e Initial load
duke
parents:
diff changeset
311 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 PointsToNode ptn = _nodes->at_grow(n->_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 return (ptn.escape_state() != PointsToNode::NoEscape) || ptn._hidden_alias;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
317 void dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
318 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
319 };