65 // are represented by ideal Macro nodes. 66 int cnt = C->macro_count(); 67 for (int i = 0; i < cnt; i++) { 68 Node *n = C->macro_node(i); 69 if (n->is_Allocate()) 70 return true; 71 if (n->is_Lock()) { 72 Node* obj = n->as_Lock()->obj_node()->uncast(); 73 if (!(obj->is_Parm() || obj->is_Con())) 74 return true; 75 } 76 if (n->is_CallStaticJava() && 77 n->as_CallStaticJava()->is_boxing_method()) { 78 return true; 79 } 80 } 81 return false; 82 } 83 84 void ConnectionGraph::do_analysis(Compile *C, PhaseIterGVN *igvn) { 85 Compile::TracePhase t2("escapeAnalysis", &Phase::_t_escapeAnalysis, true); 86 ResourceMark rm; 87 88 // Add ConP#NULL and ConN#NULL nodes before ConnectionGraph construction 89 // to create space for them in ConnectionGraph::_nodes[]. 90 Node* oop_null = igvn->zerocon(T_OBJECT); 91 Node* noop_null = igvn->zerocon(T_NARROWOOP); 92 ConnectionGraph* congraph = new(C->comp_arena()) ConnectionGraph(C, igvn); 93 // Perform escape analysis 94 if (congraph->compute_escape()) { 95 // There are non escaping objects. 96 C->set_congraph(congraph); 97 } 98 // Cleanup. 99 if (oop_null->outcnt() == 0) 100 igvn->hash_delete(oop_null); 101 if (noop_null->outcnt() == 0) 102 igvn->hash_delete(noop_null); 103 } 104 105 bool ConnectionGraph::compute_escape() { 106 Compile* C = _compile; 107 PhaseGVN* igvn = _igvn; 108 109 // Worklists used by EA. 110 Unique_Node_List delayed_worklist; 111 GrowableArray<Node*> alloc_worklist; 112 GrowableArray<Node*> ptr_cmp_worklist; 113 GrowableArray<Node*> storestore_worklist; 114 GrowableArray<PointsToNode*> ptnodes_worklist; 115 GrowableArray<JavaObjectNode*> java_objects_worklist; 116 GrowableArray<JavaObjectNode*> non_escaped_worklist; 117 GrowableArray<FieldNode*> oop_fields_worklist; 118 DEBUG_ONLY( GrowableArray<Node*> addp_worklist; ) 119 120 { Compile::TracePhase t3("connectionGraph", &Phase::_t_connectionGraph, true); 121 122 // 1. Populate Connection Graph (CG) with PointsTo nodes. 123 ideal_nodes.map(C->live_nodes(), NULL); // preallocate space 124 // Initialize worklist 125 if (C->root() != NULL) { 126 ideal_nodes.push(C->root()); 127 } 128 for( uint next = 0; next < ideal_nodes.size(); ++next ) { 129 Node* n = ideal_nodes.at(next); 130 // Create PointsTo nodes and add them to Connection Graph. Called 131 // only once per ideal node since ideal_nodes is Unique_Node list. 132 add_node_to_connection_graph(n, &delayed_worklist); 133 PointsToNode* ptn = ptnode_adr(n->_idx); 134 if (ptn != NULL) { 135 ptnodes_worklist.append(ptn); 136 if (ptn->is_JavaObject()) { 137 java_objects_worklist.append(ptn->as_JavaObject()); 138 if ((n->is_Allocate() || n->is_CallStaticJava()) && 139 (ptn->escape_state() < PointsToNode::GlobalEscape)) { 140 // Only allocations and java static calls results are interesting. | 65 // are represented by ideal Macro nodes. 66 int cnt = C->macro_count(); 67 for (int i = 0; i < cnt; i++) { 68 Node *n = C->macro_node(i); 69 if (n->is_Allocate()) 70 return true; 71 if (n->is_Lock()) { 72 Node* obj = n->as_Lock()->obj_node()->uncast(); 73 if (!(obj->is_Parm() || obj->is_Con())) 74 return true; 75 } 76 if (n->is_CallStaticJava() && 77 n->as_CallStaticJava()->is_boxing_method()) { 78 return true; 79 } 80 } 81 return false; 82 } 83 84 void ConnectionGraph::do_analysis(Compile *C, PhaseIterGVN *igvn) { 85 Compile::TracePhase t2("escapeAnalysis", &Phase::timers[Phase::_t_escapeAnalysis]); 86 ResourceMark rm; 87 88 // Add ConP#NULL and ConN#NULL nodes before ConnectionGraph construction 89 // to create space for them in ConnectionGraph::_nodes[]. 90 Node* oop_null = igvn->zerocon(T_OBJECT); 91 Node* noop_null = igvn->zerocon(T_NARROWOOP); 92 ConnectionGraph* congraph = new(C->comp_arena()) ConnectionGraph(C, igvn); 93 // Perform escape analysis 94 if (congraph->compute_escape()) { 95 // There are non escaping objects. 96 C->set_congraph(congraph); 97 } 98 // Cleanup. 99 if (oop_null->outcnt() == 0) 100 igvn->hash_delete(oop_null); 101 if (noop_null->outcnt() == 0) 102 igvn->hash_delete(noop_null); 103 } 104 105 bool ConnectionGraph::compute_escape() { 106 Compile* C = _compile; 107 PhaseGVN* igvn = _igvn; 108 109 // Worklists used by EA. 110 Unique_Node_List delayed_worklist; 111 GrowableArray<Node*> alloc_worklist; 112 GrowableArray<Node*> ptr_cmp_worklist; 113 GrowableArray<Node*> storestore_worklist; 114 GrowableArray<PointsToNode*> ptnodes_worklist; 115 GrowableArray<JavaObjectNode*> java_objects_worklist; 116 GrowableArray<JavaObjectNode*> non_escaped_worklist; 117 GrowableArray<FieldNode*> oop_fields_worklist; 118 DEBUG_ONLY( GrowableArray<Node*> addp_worklist; ) 119 120 { Compile::TracePhase t3("connectionGraph", &Phase::timers[Phase::_t_connectionGraph]); 121 122 // 1. Populate Connection Graph (CG) with PointsTo nodes. 123 ideal_nodes.map(C->live_nodes(), NULL); // preallocate space 124 // Initialize worklist 125 if (C->root() != NULL) { 126 ideal_nodes.push(C->root()); 127 } 128 for( uint next = 0; next < ideal_nodes.size(); ++next ) { 129 Node* n = ideal_nodes.at(next); 130 // Create PointsTo nodes and add them to Connection Graph. Called 131 // only once per ideal node since ideal_nodes is Unique_Node list. 132 add_node_to_connection_graph(n, &delayed_worklist); 133 PointsToNode* ptn = ptnode_adr(n->_idx); 134 if (ptn != NULL) { 135 ptnodes_worklist.append(ptn); 136 if (ptn->is_JavaObject()) { 137 java_objects_worklist.append(ptn->as_JavaObject()); 138 if ((n->is_Allocate() || n->is_CallStaticJava()) && 139 (ptn->escape_state() < PointsToNode::GlobalEscape)) { 140 // Only allocations and java static calls results are interesting. |