138 // and it does not escape during call. |
156 // and it does not escape during call. |
139 GlobalEscape = 3 // An object escapes the method or thread. |
157 GlobalEscape = 3 // An object escapes the method or thread. |
140 } EscapeState; |
158 } EscapeState; |
141 |
159 |
142 typedef enum { |
160 typedef enum { |
143 UnknownEdge = 0, |
161 ScalarReplaceable = 1, // Not escaped object could be replaced with scalar |
144 PointsToEdge = 1, |
162 PointsToUnknown = 2, // Has edge to phantom_object |
145 DeferredEdge = 2, |
163 ArraycopySrc = 4, // Has edge from Arraycopy node |
146 FieldEdge = 3 |
164 ArraycopyDst = 8 // Has edge to Arraycopy node |
147 } EdgeType; |
165 } NodeFlags; |
148 |
166 |
149 private: |
167 |
150 enum { |
168 PointsToNode(Compile *C, Node* n, EscapeState es, NodeType type): |
151 EdgeMask = 3, |
169 _edges(C->comp_arena(), 2, 0, NULL), |
152 EdgeShift = 2, |
170 _uses (C->comp_arena(), 2, 0, NULL), |
153 |
171 _node(n), |
154 INITIAL_EDGE_COUNT = 4 |
172 _idx(n->_idx), |
155 }; |
173 _type((u1)type), |
156 |
174 _escape((u1)es), |
157 NodeType _type; |
175 _fields_escape((u1)es), |
158 EscapeState _escape; |
176 _flags(ScalarReplaceable) { |
159 GrowableArray<uint>* _edges; // outgoing edges |
177 assert(n != NULL && es != UnknownEscape, "sanity"); |
160 Node* _node; // Ideal node corresponding to this PointsTo node. |
178 } |
161 int _offset; // Object fields offsets. |
179 |
162 bool _scalar_replaceable; // Not escaped object could be replaced with scalar |
180 Node* ideal_node() const { return _node; } |
163 bool _has_unknown_ptr; // Has edge to phantom_object |
181 int idx() const { return _idx; } |
164 |
182 |
165 public: |
183 bool is_JavaObject() const { return _type == (u1)JavaObject; } |
166 PointsToNode(): |
184 bool is_LocalVar() const { return _type == (u1)LocalVar; } |
167 _type(UnknownType), |
185 bool is_Field() const { return _type == (u1)Field; } |
168 _escape(UnknownEscape), |
186 bool is_Arraycopy() const { return _type == (u1)Arraycopy; } |
169 _edges(NULL), |
187 |
170 _node(NULL), |
188 JavaObjectNode* as_JavaObject() { assert(is_JavaObject(),""); return (JavaObjectNode*)this; } |
171 _offset(-1), |
189 LocalVarNode* as_LocalVar() { assert(is_LocalVar(),""); return (LocalVarNode*)this; } |
172 _has_unknown_ptr(false), |
190 FieldNode* as_Field() { assert(is_Field(),""); return (FieldNode*)this; } |
173 _scalar_replaceable(true) {} |
191 ArraycopyNode* as_Arraycopy() { assert(is_Arraycopy(),""); return (ArraycopyNode*)this; } |
174 |
192 |
175 |
193 EscapeState escape_state() const { return (EscapeState)_escape; } |
176 EscapeState escape_state() const { return _escape; } |
194 void set_escape_state(EscapeState state) { _escape = (u1)state; } |
177 NodeType node_type() const { return _type;} |
195 |
178 int offset() { return _offset;} |
196 EscapeState fields_escape_state() const { return (EscapeState)_fields_escape; } |
179 bool scalar_replaceable() { return _scalar_replaceable;} |
197 void set_fields_escape_state(EscapeState state) { _fields_escape = (u1)state; } |
180 bool has_unknown_ptr() { return _has_unknown_ptr;} |
198 |
181 |
199 bool has_unknown_ptr() const { return (_flags & PointsToUnknown) != 0; } |
182 void set_offset(int offs) { _offset = offs;} |
200 void set_has_unknown_ptr() { _flags |= PointsToUnknown; } |
183 void set_escape_state(EscapeState state) { _escape = state; } |
201 |
184 void set_node_type(NodeType ntype) { |
202 bool arraycopy_src() const { return (_flags & ArraycopySrc) != 0; } |
185 assert(_type == UnknownType || _type == ntype, "Can't change node type"); |
203 void set_arraycopy_src() { _flags |= ArraycopySrc; } |
186 _type = ntype; |
204 bool arraycopy_dst() const { return (_flags & ArraycopyDst) != 0; } |
187 } |
205 void set_arraycopy_dst() { _flags |= ArraycopyDst; } |
188 void set_scalar_replaceable(bool v) { _scalar_replaceable = v; } |
206 |
189 void set_has_unknown_ptr() { _has_unknown_ptr = true; } |
207 bool scalar_replaceable() const { return (_flags & ScalarReplaceable) != 0;} |
190 |
208 void set_scalar_replaceable(bool v) { |
191 // count of outgoing edges |
209 if (v) |
192 uint edge_count() const { return (_edges == NULL) ? 0 : _edges->length(); } |
210 _flags |= ScalarReplaceable; |
193 |
211 else |
194 // node index of target of outgoing edge "e" |
212 _flags &= ~ScalarReplaceable; |
195 uint edge_target(uint e) const { |
213 } |
196 assert(_edges != NULL, "valid edge index"); |
214 |
197 return (_edges->at(e) >> EdgeShift); |
215 int edge_count() const { return _edges.length(); } |
198 } |
216 PointsToNode* edge(int e) const { return _edges.at(e); } |
199 // type of outgoing edge "e" |
217 bool add_edge(PointsToNode* edge) { return _edges.append_if_missing(edge); } |
200 EdgeType edge_type(uint e) const { |
218 |
201 assert(_edges != NULL, "valid edge index"); |
219 int use_count() const { return _uses.length(); } |
202 return (EdgeType) (_edges->at(e) & EdgeMask); |
220 PointsToNode* use(int e) const { return _uses.at(e); } |
203 } |
221 bool add_use(PointsToNode* use) { return _uses.append_if_missing(use); } |
204 |
222 |
205 // add a edge of the specified type pointing to the specified target |
223 // Mark base edge use to distinguish from stored value edge. |
206 void add_edge(uint targIdx, EdgeType et); |
224 bool add_base_use(FieldNode* use) { return _uses.append_if_missing((PointsToNode*)((intptr_t)use + 1)); } |
207 |
225 static bool is_base_use(PointsToNode* use) { return (((intptr_t)use) & 1); } |
208 // remove an edge of the specified type pointing to the specified target |
226 static PointsToNode* get_use_node(PointsToNode* use) { return (PointsToNode*)(((intptr_t)use) & ~1); } |
209 void remove_edge(uint targIdx, EdgeType et); |
227 |
|
228 // Return true if this node points to specified node or nodes it points to. |
|
229 bool points_to(JavaObjectNode* ptn) const; |
|
230 |
|
231 // Return true if this node points only to non-escaping allocations. |
|
232 bool non_escaping_allocation(); |
|
233 |
|
234 // Return true if one node points to an other. |
|
235 bool meet(PointsToNode* ptn); |
210 |
236 |
211 #ifndef PRODUCT |
237 #ifndef PRODUCT |
|
238 NodeType node_type() const { return (NodeType)_type;} |
212 void dump(bool print_state=true) const; |
239 void dump(bool print_state=true) const; |
213 #endif |
240 #endif |
214 |
241 |
215 }; |
242 }; |
216 |
243 |
|
244 class LocalVarNode: public PointsToNode { |
|
245 public: |
|
246 LocalVarNode(Compile *C, Node* n, EscapeState es): |
|
247 PointsToNode(C, n, es, LocalVar) {} |
|
248 }; |
|
249 |
|
250 class JavaObjectNode: public PointsToNode { |
|
251 public: |
|
252 JavaObjectNode(Compile *C, Node* n, EscapeState es): |
|
253 PointsToNode(C, n, es, JavaObject) { |
|
254 if (es > NoEscape) |
|
255 set_scalar_replaceable(false); |
|
256 } |
|
257 }; |
|
258 |
|
259 class FieldNode: public PointsToNode { |
|
260 GrowableArray<PointsToNode*> _bases; // List of JavaObject nodes which point to this node |
|
261 const int _offset; // Field's offset. |
|
262 const bool _is_oop; // Field points to object |
|
263 bool _has_unknown_base; // Has phantom_object base |
|
264 public: |
|
265 FieldNode(Compile *C, Node* n, EscapeState es, int offs, bool is_oop): |
|
266 PointsToNode(C, n, es, Field), |
|
267 _offset(offs), _is_oop(is_oop), |
|
268 _has_unknown_base(false) {} |
|
269 |
|
270 int offset() const { return _offset;} |
|
271 bool is_oop() const { return _is_oop;} |
|
272 bool has_unknown_base() const { return _has_unknown_base; } |
|
273 void set_has_unknown_base() { _has_unknown_base = true; } |
|
274 |
|
275 int base_count() const { return _bases.length(); } |
|
276 PointsToNode* base(int e) const { return _bases.at(e); } |
|
277 bool add_base(PointsToNode* base) { return _bases.append_if_missing(base); } |
|
278 #ifdef ASSERT |
|
279 // Return true if bases points to this java object. |
|
280 bool has_base(JavaObjectNode* ptn) const; |
|
281 #endif |
|
282 |
|
283 }; |
|
284 |
|
285 class ArraycopyNode: public PointsToNode { |
|
286 public: |
|
287 ArraycopyNode(Compile *C, Node* n, EscapeState es): |
|
288 PointsToNode(C, n, es, Arraycopy) {} |
|
289 }; |
|
290 |
|
291 // Iterators for PointsTo node's edges: |
|
292 // for (EdgeIterator i(n); i.has_next(); i.next()) { |
|
293 // PointsToNode* u = i.get(); |
|
294 class PointsToIterator: public StackObj { |
|
295 protected: |
|
296 const PointsToNode* node; |
|
297 const int cnt; |
|
298 int i; |
|
299 public: |
|
300 inline PointsToIterator(const PointsToNode* n, int cnt) : node(n), cnt(cnt), i(0) { } |
|
301 inline bool has_next() const { return i < cnt; } |
|
302 inline void next() { i++; } |
|
303 PointsToNode* get() const { ShouldNotCallThis(); return NULL; } |
|
304 }; |
|
305 |
|
306 class EdgeIterator: public PointsToIterator { |
|
307 public: |
|
308 inline EdgeIterator(const PointsToNode* n) : PointsToIterator(n, n->edge_count()) { } |
|
309 inline PointsToNode* get() const { return node->edge(i); } |
|
310 }; |
|
311 |
|
312 class UseIterator: public PointsToIterator { |
|
313 public: |
|
314 inline UseIterator(const PointsToNode* n) : PointsToIterator(n, n->use_count()) { } |
|
315 inline PointsToNode* get() const { return node->use(i); } |
|
316 }; |
|
317 |
|
318 class BaseIterator: public PointsToIterator { |
|
319 public: |
|
320 inline BaseIterator(const FieldNode* n) : PointsToIterator(n, n->base_count()) { } |
|
321 inline PointsToNode* get() const { return ((PointsToNode*)node)->as_Field()->base(i); } |
|
322 }; |
|
323 |
|
324 |
217 class ConnectionGraph: public ResourceObj { |
325 class ConnectionGraph: public ResourceObj { |
218 private: |
326 private: |
219 GrowableArray<PointsToNode> _nodes; // Connection graph nodes indexed |
327 GrowableArray<PointsToNode*> _nodes; // Map from ideal nodes to |
220 // by ideal node index. |
328 // ConnectionGraph nodes. |
221 |
329 |
222 Unique_Node_List _delayed_worklist; // Nodes to be processed before |
330 GrowableArray<PointsToNode*> _worklist; // Nodes to be processed |
223 // the call build_connection_graph(). |
331 |
224 |
332 bool _collecting; // Indicates whether escape information |
225 GrowableArray<MergeMemNode *> _mergemem_worklist; // List of all MergeMem nodes |
333 // is still being collected. If false, |
226 |
334 // no new nodes will be processed. |
227 VectorSet _processed; // Records which nodes have been |
335 |
228 // processed. |
336 bool _verify; // verify graph |
229 |
337 |
230 bool _collecting; // Indicates whether escape information |
338 JavaObjectNode* phantom_obj; // Unknown object |
231 // is still being collected. If false, |
339 JavaObjectNode* null_obj; |
232 // no new nodes will be processed. |
340 Node* _pcmp_neq; // ConI(#CC_GT) |
233 |
341 Node* _pcmp_eq; // ConI(#CC_EQ) |
234 bool _progress; // Indicates whether new Graph's edges |
342 |
235 // were created. |
343 Compile* _compile; // Compile object for current compilation |
236 |
344 PhaseIterGVN* _igvn; // Value numbering |
237 uint _phantom_object; // Index of globally escaping object |
345 |
238 // that pointer values loaded from |
346 Unique_Node_List ideal_nodes; // Used by CG construction and types splitting. |
239 // a field which has not been set |
|
240 // are assumed to point to. |
|
241 uint _oop_null; // ConP(#NULL)->_idx |
|
242 uint _noop_null; // ConN(#NULL)->_idx |
|
243 Node* _pcmp_neq; // ConI(#CC_GT) |
|
244 Node* _pcmp_eq; // ConI(#CC_EQ) |
|
245 |
|
246 Compile * _compile; // Compile object for current compilation |
|
247 PhaseIterGVN * _igvn; // Value numbering |
|
248 |
347 |
249 // Address of an element in _nodes. Used when the element is to be modified |
348 // Address of an element in _nodes. Used when the element is to be modified |
250 PointsToNode *ptnode_adr(uint idx) const { |
349 PointsToNode* ptnode_adr(int idx) const { |
251 // There should be no new ideal nodes during ConnectionGraph build, |
350 // There should be no new ideal nodes during ConnectionGraph build, |
252 // growableArray::adr_at() will throw assert otherwise. |
351 // growableArray::at() will throw assert otherwise. |
253 return _nodes.adr_at(idx); |
352 return _nodes.at(idx); |
254 } |
353 } |
255 uint nodes_size() const { return _nodes.length(); } |
354 uint nodes_size() const { return _nodes.length(); } |
256 |
355 |
257 bool is_null_ptr(uint idx) const { return (idx == _noop_null || idx == _oop_null); } |
356 // Add nodes to ConnectionGraph. |
258 |
357 void add_local_var(Node* n, PointsToNode::EscapeState es); |
259 // Add node to ConnectionGraph. |
358 void add_java_object(Node* n, PointsToNode::EscapeState es); |
260 void add_node(Node *n, PointsToNode::NodeType nt, PointsToNode::EscapeState es, bool done); |
359 void add_field(Node* n, PointsToNode::EscapeState es, int offset); |
|
360 void add_arraycopy(Node* n, PointsToNode::EscapeState es, PointsToNode* src, PointsToNode* dst); |
|
361 |
|
362 // Compute the escape state for arguments to a call. |
|
363 void process_call_arguments(CallNode *call); |
|
364 |
|
365 // Add PointsToNode node corresponding to a call |
|
366 void add_call_node(CallNode* call); |
|
367 |
|
368 // Map ideal node to existing PointsTo node (usually phantom_object). |
|
369 void map_ideal_node(Node *n, PointsToNode* ptn) { |
|
370 assert(ptn != NULL, "only existing PointsTo node"); |
|
371 _nodes.at_put(n->_idx, ptn); |
|
372 } |
|
373 |
|
374 // Create PointsToNode node and add it to Connection Graph. |
|
375 void add_node_to_connection_graph(Node *n, Unique_Node_List *delayed_worklist); |
|
376 |
|
377 // Add final simple edges to graph. |
|
378 void add_final_edges(Node *n); |
|
379 |
|
380 // Finish Graph construction. |
|
381 bool complete_connection_graph(GrowableArray<PointsToNode*>& ptnodes_worklist, |
|
382 GrowableArray<JavaObjectNode*>& non_escaped_worklist, |
|
383 GrowableArray<JavaObjectNode*>& java_objects_worklist, |
|
384 GrowableArray<FieldNode*>& oop_fields_worklist); |
|
385 |
|
386 #ifdef ASSERT |
|
387 void verify_connection_graph(GrowableArray<PointsToNode*>& ptnodes_worklist, |
|
388 GrowableArray<JavaObjectNode*>& non_escaped_worklist, |
|
389 GrowableArray<JavaObjectNode*>& java_objects_worklist, |
|
390 GrowableArray<Node*>& addp_worklist); |
|
391 #endif |
|
392 |
|
393 // Add all references to this JavaObject node. |
|
394 int add_java_object_edges(JavaObjectNode* jobj, bool populate_worklist); |
|
395 |
|
396 // Put node on worklist if it is (or was) not there. |
|
397 void add_to_worklist(PointsToNode* pt) { |
|
398 _worklist.push(pt); |
|
399 return; |
|
400 } |
|
401 |
|
402 // Put on worklist all uses of this node. |
|
403 void add_uses_to_worklist(PointsToNode* pt) { |
|
404 for (UseIterator i(pt); i.has_next(); i.next()) |
|
405 _worklist.push(i.get()); |
|
406 } |
|
407 |
|
408 // Put on worklist all field's uses and related field nodes. |
|
409 void add_field_uses_to_worklist(FieldNode* field); |
|
410 |
|
411 // Put on worklist all related field nodes. |
|
412 void add_fields_to_worklist(FieldNode* field, PointsToNode* base); |
|
413 |
|
414 // Find fields which have unknown value. |
|
415 int find_field_value(FieldNode* field); |
|
416 |
|
417 // Find fields initializing values for allocations. |
|
418 int find_init_values(JavaObjectNode* ptn, PointsToNode* init_val, PhaseTransform* phase); |
|
419 |
|
420 // Set the escape state of an object and its fields. |
|
421 void set_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) { |
|
422 // Don't change non-escaping state of NULL pointer. |
|
423 if (ptn != null_obj) { |
|
424 if (ptn->escape_state() < esc) |
|
425 ptn->set_escape_state(esc); |
|
426 if (ptn->fields_escape_state() < esc) |
|
427 ptn->set_fields_escape_state(esc); |
|
428 } |
|
429 } |
|
430 void set_fields_escape_state(PointsToNode* ptn, PointsToNode::EscapeState esc) { |
|
431 // Don't change non-escaping state of NULL pointer. |
|
432 if (ptn != null_obj) { |
|
433 if (ptn->fields_escape_state() < esc) |
|
434 ptn->set_fields_escape_state(esc); |
|
435 } |
|
436 } |
|
437 |
|
438 // Propagate GlobalEscape and ArgEscape escape states to all nodes |
|
439 // and check that we still have non-escaping java objects. |
|
440 bool find_non_escaped_objects(GrowableArray<PointsToNode*>& ptnodes_worklist, |
|
441 GrowableArray<JavaObjectNode*>& non_escaped_worklist); |
|
442 |
|
443 // Adjust scalar_replaceable state after Connection Graph is built. |
|
444 void adjust_scalar_replaceable_state(JavaObjectNode* jobj); |
|
445 |
|
446 // Optimize ideal graph. |
|
447 void optimize_ideal_graph(GrowableArray<Node*>& ptr_cmp_worklist, |
|
448 GrowableArray<Node*>& storestore_worklist); |
|
449 // Optimize objects compare. |
|
450 Node* optimize_ptr_compare(Node* n); |
|
451 |
|
452 // Returns unique corresponding java object or NULL. |
|
453 JavaObjectNode* unique_java_object(Node *n); |
|
454 |
|
455 // Add an edge of the specified type pointing to the specified target. |
|
456 bool add_edge(PointsToNode* from, PointsToNode* to) { |
|
457 assert(!from->is_Field() || from->as_Field()->is_oop(), "sanity"); |
|
458 |
|
459 if (to == phantom_obj) { |
|
460 if (from->has_unknown_ptr()) { |
|
461 return false; // already points to phantom_obj |
|
462 } |
|
463 from->set_has_unknown_ptr(); |
|
464 } |
|
465 |
|
466 bool is_new = from->add_edge(to); |
|
467 assert(to != phantom_obj || is_new, "sanity"); |
|
468 if (is_new) { // New edge? |
|
469 assert(!_verify, "graph is incomplete"); |
|
470 is_new = to->add_use(from); |
|
471 assert(is_new, "use should be also new"); |
|
472 } |
|
473 return is_new; |
|
474 } |
|
475 |
|
476 // Add an edge from Field node to its base and back. |
|
477 bool add_base(FieldNode* from, PointsToNode* to) { |
|
478 assert(!to->is_Arraycopy(), "sanity"); |
|
479 if (to == phantom_obj) { |
|
480 if (from->has_unknown_base()) { |
|
481 return false; // already has phantom_obj base |
|
482 } |
|
483 from->set_has_unknown_base(); |
|
484 } |
|
485 bool is_new = from->add_base(to); |
|
486 assert(to != phantom_obj || is_new, "sanity"); |
|
487 if (is_new) { // New edge? |
|
488 assert(!_verify, "graph is incomplete"); |
|
489 if (to == null_obj) |
|
490 return is_new; // Don't add fields to NULL pointer. |
|
491 if (to->is_JavaObject()) { |
|
492 is_new = to->add_edge(from); |
|
493 } else { |
|
494 is_new = to->add_base_use(from); |
|
495 } |
|
496 assert(is_new, "use should be also new"); |
|
497 } |
|
498 return is_new; |
|
499 } |
|
500 |
|
501 // Add LocalVar node and edge if possible |
|
502 void add_local_var_and_edge(Node* n, PointsToNode::EscapeState es, Node* to, |
|
503 Unique_Node_List *delayed_worklist) { |
|
504 PointsToNode* ptn = ptnode_adr(to->_idx); |
|
505 if (delayed_worklist != NULL) { // First iteration of CG construction |
|
506 add_local_var(n, es); |
|
507 if (ptn == NULL) { |
|
508 delayed_worklist->push(n); |
|
509 return; // Process it later. |
|
510 } |
|
511 } else { |
|
512 assert(ptn != NULL, "node should be registered"); |
|
513 } |
|
514 add_edge(ptnode_adr(n->_idx), ptn); |
|
515 } |
|
516 |
|
517 // Helper functions |
|
518 bool is_oop_field(Node* n, int offset); |
|
519 static Node* get_addp_base(Node *addp); |
|
520 static Node* find_second_addp(Node* addp, Node* n); |
261 |
521 |
262 // offset of a field reference |
522 // offset of a field reference |
263 int address_offset(Node* adr, PhaseTransform *phase); |
523 int address_offset(Node* adr, PhaseTransform *phase); |
264 |
524 |
265 // compute the escape state for arguments to a call |
525 |
266 void process_call_arguments(CallNode *call, PhaseTransform *phase); |
526 // Propagate unique types created for unescaped allocated objects |
267 |
527 // through the graph |
268 // compute the escape state for the return value of a call |
528 void split_unique_types(GrowableArray<Node *> &alloc_worklist); |
269 void process_call_result(ProjNode *resproj, PhaseTransform *phase); |
529 |
270 |
530 // Helper methods for unique types split. |
271 // Populate Connection Graph with Ideal nodes. |
531 bool split_AddP(Node *addp, Node *base); |
272 void record_for_escape_analysis(Node *n, PhaseTransform *phase); |
532 |
273 |
533 PhiNode *create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, bool &new_created); |
274 // Build Connection Graph and set nodes escape state. |
534 PhiNode *split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist); |
275 void build_connection_graph(Node *n, PhaseTransform *phase); |
535 |
276 |
536 void move_inst_mem(Node* n, GrowableArray<PhiNode *> &orig_phis); |
277 // walk the connection graph starting at the node corresponding to "n" and |
537 Node* find_inst_mem(Node* mem, int alias_idx,GrowableArray<PhiNode *> &orig_phi_worklist); |
278 // add the index of everything it could point to, to "ptset". This may cause |
538 Node* step_through_mergemem(MergeMemNode *mmem, int alias_idx, const TypeOopPtr *toop); |
279 // Phi's encountered to get (re)processed (which requires "phase".) |
539 |
280 VectorSet* PointsTo(Node * n); |
540 |
281 |
541 GrowableArray<MergeMemNode*> _mergemem_worklist; // List of all MergeMem nodes |
282 // Reused structures for PointsTo(). |
|
283 VectorSet pt_ptset; |
|
284 VectorSet pt_visited; |
|
285 GrowableArray<uint> pt_worklist; |
|
286 |
|
287 // Edge manipulation. The "from_i" and "to_i" arguments are the |
|
288 // node indices of the source and destination of the edge |
|
289 void add_pointsto_edge(uint from_i, uint to_i); |
|
290 void add_deferred_edge(uint from_i, uint to_i); |
|
291 void add_field_edge(uint from_i, uint to_i, int offs); |
|
292 |
|
293 // Add an edge of the specified type pointing to the specified target. |
|
294 // Set _progress if new edge is added. |
|
295 void add_edge(PointsToNode *f, uint to_i, PointsToNode::EdgeType et) { |
|
296 uint e_cnt = f->edge_count(); |
|
297 f->add_edge(to_i, et); |
|
298 _progress |= (f->edge_count() != e_cnt); |
|
299 } |
|
300 |
|
301 // Add an edge to node given by "to_i" from any field of adr_i whose offset |
|
302 // matches "offset" A deferred edge is added if to_i is a LocalVar, and |
|
303 // a pointsto edge is added if it is a JavaObject |
|
304 void add_edge_from_fields(uint adr, uint to_i, int offs); |
|
305 |
|
306 // Add a deferred edge from node given by "from_i" to any field |
|
307 // of adr_i whose offset matches "offset" |
|
308 void add_deferred_edge_to_fields(uint from_i, uint adr, int offs); |
|
309 |
|
310 |
|
311 // Remove outgoing deferred edges from the node referenced by "ni". |
|
312 // Any outgoing edges from the target of the deferred edge are copied |
|
313 // to "ni". |
|
314 void remove_deferred(uint ni, GrowableArray<uint>* deferred_edges, VectorSet* visited); |
|
315 |
542 |
316 Node_Array _node_map; // used for bookeeping during type splitting |
543 Node_Array _node_map; // used for bookeeping during type splitting |
317 // Used for the following purposes: |
544 // Used for the following purposes: |
318 // Memory Phi - most recent unique Phi split out |
545 // Memory Phi - most recent unique Phi split out |
319 // from this Phi |
546 // from this Phi |
320 // MemNode - new memory input for this node |
547 // MemNode - new memory input for this node |
321 // ChecCastPP - allocation that this is a cast of |
548 // ChecCastPP - allocation that this is a cast of |
322 // allocation - CheckCastPP of the allocation |
549 // allocation - CheckCastPP of the allocation |
323 bool split_AddP(Node *addp, Node *base, PhaseGVN *igvn); |
|
324 PhiNode *create_split_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn, bool &new_created); |
|
325 PhiNode *split_memory_phi(PhiNode *orig_phi, int alias_idx, GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn); |
|
326 void move_inst_mem(Node* n, GrowableArray<PhiNode *> &orig_phis, PhaseGVN *igvn); |
|
327 Node *find_inst_mem(Node *mem, int alias_idx,GrowableArray<PhiNode *> &orig_phi_worklist, PhaseGVN *igvn); |
|
328 |
|
329 // Propagate unique types created for unescaped allocated objects |
|
330 // through the graph |
|
331 void split_unique_types(GrowableArray<Node *> &alloc_worklist); |
|
332 |
550 |
333 // manage entries in _node_map |
551 // manage entries in _node_map |
334 void set_map(int idx, Node *n) { _node_map.map(idx, n); } |
552 |
335 Node *get_map(int idx) { return _node_map[idx]; } |
553 void set_map(Node* from, Node* to) { |
336 PhiNode *get_map_phi(int idx) { |
554 ideal_nodes.push(from); |
337 Node *phi = _node_map[idx]; |
555 _node_map.map(from->_idx, to); |
|
556 } |
|
557 |
|
558 Node* get_map(int idx) { return _node_map[idx]; } |
|
559 |
|
560 PhiNode* get_map_phi(int idx) { |
|
561 Node* phi = _node_map[idx]; |
338 return (phi == NULL) ? NULL : phi->as_Phi(); |
562 return (phi == NULL) ? NULL : phi->as_Phi(); |
339 } |
563 } |
340 |
564 |
341 // Notify optimizer that a node has been modified |
565 // Notify optimizer that a node has been modified |
342 void record_for_optimizer(Node *n) { |
566 void record_for_optimizer(Node *n) { |
343 _igvn->_worklist.push(n); |
567 _igvn->_worklist.push(n); |
344 _igvn->add_users_to_worklist(n); |
568 _igvn->add_users_to_worklist(n); |
345 } |
569 } |
346 |
570 |
347 // Set the escape state of a node |
|
348 void set_escape_state(uint ni, PointsToNode::EscapeState es); |
|
349 |
|
350 // Find fields initializing values for allocations. |
|
351 void find_init_values(Node* n, VectorSet* visited, PhaseTransform* phase); |
|
352 |
|
353 // Adjust escape state after Connection Graph is built. |
|
354 void adjust_escape_state(Node* n); |
|
355 |
|
356 // Propagate escape states to referenced nodes. |
|
357 bool propagate_escape_state(GrowableArray<int>* cg_worklist, |
|
358 GrowableArray<uint>* worklist, |
|
359 PointsToNode::EscapeState esc_state); |
|
360 |
|
361 // Optimize objects compare. |
|
362 Node* optimize_ptr_compare(Node* n); |
|
363 |
|
364 // Compute the escape information |
571 // Compute the escape information |
365 bool compute_escape(); |
572 bool compute_escape(); |
366 |
573 |
367 public: |
574 public: |
368 ConnectionGraph(Compile *C, PhaseIterGVN *igvn); |
575 ConnectionGraph(Compile *C, PhaseIterGVN *igvn); |