Mercurial > hg > truffle
comparison src/share/vm/opto/escape.hpp @ 276:aa8f54688692
Merge
author | trims |
---|---|
date | Sun, 10 Aug 2008 21:31:42 -0700 |
parents | b0fe4deeb9fb |
children | c3e045194476 |
comparison
equal
deleted
inserted
replaced
240:585535ec8a14 | 276:aa8f54688692 |
---|---|
176 _type = ntype; | 176 _type = ntype; |
177 } | 177 } |
178 | 178 |
179 // count of outgoing edges | 179 // count of outgoing edges |
180 uint edge_count() const { return (_edges == NULL) ? 0 : _edges->length(); } | 180 uint edge_count() const { return (_edges == NULL) ? 0 : _edges->length(); } |
181 | |
181 // node index of target of outgoing edge "e" | 182 // node index of target of outgoing edge "e" |
182 uint edge_target(uint e) const; | 183 uint edge_target(uint e) const { |
184 assert(_edges != NULL, "valid edge index"); | |
185 return (_edges->at(e) >> EdgeShift); | |
186 } | |
183 // type of outgoing edge "e" | 187 // type of outgoing edge "e" |
184 EdgeType edge_type(uint e) const; | 188 EdgeType edge_type(uint e) const { |
189 assert(_edges != NULL, "valid edge index"); | |
190 return (EdgeType) (_edges->at(e) & EdgeMask); | |
191 } | |
192 | |
185 // add a edge of the specified type pointing to the specified target | 193 // add a edge of the specified type pointing to the specified target |
186 void add_edge(uint targIdx, EdgeType et); | 194 void add_edge(uint targIdx, EdgeType et); |
195 | |
187 // remove an edge of the specified type pointing to the specified target | 196 // remove an edge of the specified type pointing to the specified target |
188 void remove_edge(uint targIdx, EdgeType et); | 197 void remove_edge(uint targIdx, EdgeType et); |
198 | |
189 #ifndef PRODUCT | 199 #ifndef PRODUCT |
190 void dump() const; | 200 void dump(bool print_state=true) const; |
191 #endif | 201 #endif |
192 | 202 |
193 }; | 203 }; |
194 | 204 |
195 class ConnectionGraph: public ResourceObj { | 205 class ConnectionGraph: public ResourceObj { |
196 private: | 206 private: |
197 GrowableArray<PointsToNode>* _nodes; // Connection graph nodes indexed | 207 GrowableArray<PointsToNode> _nodes; // Connection graph nodes indexed |
198 // by ideal node index. | 208 // by ideal node index. |
199 | 209 |
200 Unique_Node_List _delayed_worklist; // Nodes to be processed before | 210 Unique_Node_List _delayed_worklist; // Nodes to be processed before |
201 // the call build_connection_graph(). | 211 // the call build_connection_graph(). |
202 | 212 |
204 // processed. | 214 // processed. |
205 | 215 |
206 bool _collecting; // Indicates whether escape information | 216 bool _collecting; // Indicates whether escape information |
207 // is still being collected. If false, | 217 // is still being collected. If false, |
208 // no new nodes will be processed. | 218 // no new nodes will be processed. |
209 | |
210 bool _has_allocations; // Indicates whether method has any | |
211 // non-escaping allocations. | |
212 | 219 |
213 uint _phantom_object; // Index of globally escaping object | 220 uint _phantom_object; // Index of globally escaping object |
214 // that pointer values loaded from | 221 // that pointer values loaded from |
215 // a field which has not been set | 222 // a field which has not been set |
216 // are assumed to point to. | 223 // are assumed to point to. |
224 uint _oop_null; // ConP(#NULL) | |
225 uint _noop_null; // ConN(#NULL) | |
217 | 226 |
218 Compile * _compile; // Compile object for current compilation | 227 Compile * _compile; // Compile object for current compilation |
219 | 228 |
220 // address of an element in _nodes. Used when the element is to be modified | 229 // Address of an element in _nodes. Used when the element is to be modified |
221 PointsToNode *ptnode_adr(uint idx) { | 230 PointsToNode *ptnode_adr(uint idx) const { |
222 if ((uint)_nodes->length() <= idx) { | 231 // There should be no new ideal nodes during ConnectionGraph build, |
223 // expand _nodes array | 232 // growableArray::adr_at() will throw assert otherwise. |
224 PointsToNode dummy = _nodes->at_grow(idx); | 233 return _nodes.adr_at(idx); |
225 } | 234 } |
226 return _nodes->adr_at(idx); | 235 uint nodes_size() const { return _nodes.length(); } |
227 } | |
228 | 236 |
229 // Add node to ConnectionGraph. | 237 // Add node to ConnectionGraph. |
230 void add_node(Node *n, PointsToNode::NodeType nt, PointsToNode::EscapeState es, bool done); | 238 void add_node(Node *n, PointsToNode::NodeType nt, PointsToNode::EscapeState es, bool done); |
231 | 239 |
232 // offset of a field reference | 240 // offset of a field reference |
305 } | 313 } |
306 | 314 |
307 // Set the escape state of a node | 315 // Set the escape state of a node |
308 void set_escape_state(uint ni, PointsToNode::EscapeState es); | 316 void set_escape_state(uint ni, PointsToNode::EscapeState es); |
309 | 317 |
310 // Get Compile object for current compilation. | |
311 Compile *C() const { return _compile; } | |
312 | |
313 public: | 318 public: |
314 ConnectionGraph(Compile *C); | 319 ConnectionGraph(Compile *C); |
315 | 320 |
321 // Check for non-escaping candidates | |
322 static bool has_candidates(Compile *C); | |
323 | |
316 // Compute the escape information | 324 // Compute the escape information |
317 void compute_escape(); | 325 bool compute_escape(); |
318 | 326 |
319 // escape state of a node | 327 // escape state of a node |
320 PointsToNode::EscapeState escape_state(Node *n, PhaseTransform *phase); | 328 PointsToNode::EscapeState escape_state(Node *n, PhaseTransform *phase); |
321 // other information we have collected | 329 // other information we have collected |
322 bool is_scalar_replaceable(Node *n) { | 330 bool is_scalar_replaceable(Node *n) { |
323 if (_collecting) | 331 if (_collecting || (n->_idx >= nodes_size())) |
324 return false; | 332 return false; |
325 PointsToNode ptn = _nodes->at_grow(n->_idx); | 333 PointsToNode* ptn = ptnode_adr(n->_idx); |
326 return ptn.escape_state() == PointsToNode::NoEscape && ptn._scalar_replaceable; | 334 return ptn->escape_state() == PointsToNode::NoEscape && ptn->_scalar_replaceable; |
327 } | 335 } |
328 | 336 |
329 bool hidden_alias(Node *n) { | 337 bool hidden_alias(Node *n) { |
330 if (_collecting) | 338 if (_collecting || (n->_idx >= nodes_size())) |
331 return true; | 339 return true; |
332 PointsToNode ptn = _nodes->at_grow(n->_idx); | 340 PointsToNode* ptn = ptnode_adr(n->_idx); |
333 return (ptn.escape_state() != PointsToNode::NoEscape) || ptn._hidden_alias; | 341 return (ptn->escape_state() != PointsToNode::NoEscape) || ptn->_hidden_alias; |
334 } | 342 } |
335 | 343 |
336 #ifndef PRODUCT | 344 #ifndef PRODUCT |
337 void dump(); | 345 void dump(); |
338 #endif | 346 #endif |