Mercurial > hg > truffle
comparison src/share/vm/opto/node.cpp @ 155:723be81c1212
6701887: JDK7 server VM in endless loop in Node::dominates
Summary: The method Node::dominates loops in the dead code which does not have a Region node.
Reviewed-by: jrose, never
author | kvn |
---|---|
date | Thu, 15 May 2008 22:43:11 -0700 |
parents | ec73d88d5b43 |
children | 885ed790ecf0 |
comparison
equal
deleted
inserted
replaced
154:09c2ba680204 | 155:723be81c1212 |
---|---|
1041 // Check if 'this' control node dominates or equal to 'sub' control node. | 1041 // Check if 'this' control node dominates or equal to 'sub' control node. |
1042 bool Node::dominates(Node* sub, Node_List &nlist) { | 1042 bool Node::dominates(Node* sub, Node_List &nlist) { |
1043 assert(this->is_CFG(), "expecting control"); | 1043 assert(this->is_CFG(), "expecting control"); |
1044 assert(sub != NULL && sub->is_CFG(), "expecting control"); | 1044 assert(sub != NULL && sub->is_CFG(), "expecting control"); |
1045 | 1045 |
1046 // detect dead cycle without regions | |
1047 int iterations_without_region_limit = DominatorSearchLimit; | |
1048 | |
1046 Node* orig_sub = sub; | 1049 Node* orig_sub = sub; |
1047 nlist.clear(); | 1050 nlist.clear(); |
1048 bool this_dominates = false; | 1051 bool this_dominates = false; |
1049 uint region_input = 0; | 1052 uint region_input = 0; |
1050 while (sub != NULL) { // walk 'sub' up the chain to 'this' | 1053 while (sub != NULL) { // walk 'sub' up the chain to 'this' |
1055 return true; | 1058 return true; |
1056 } else if (!this_dominates) { | 1059 } else if (!this_dominates) { |
1057 // Region nodes were visited. Continue walk up to Start or Root | 1060 // Region nodes were visited. Continue walk up to Start or Root |
1058 // to make sure that it did not walk in a cycle. | 1061 // to make sure that it did not walk in a cycle. |
1059 this_dominates = true; // first time meet | 1062 this_dominates = true; // first time meet |
1063 iterations_without_region_limit = DominatorSearchLimit; // Reset | |
1060 } else { | 1064 } else { |
1061 return false; // already met before: walk in a cycle | 1065 return false; // already met before: walk in a cycle |
1062 } | 1066 } |
1063 } | 1067 } |
1064 if (sub->is_Start() || sub->is_Root()) | 1068 if (sub->is_Start() || sub->is_Root()) |
1067 Node* up = sub->find_exact_control(sub->in(0)); | 1071 Node* up = sub->find_exact_control(sub->in(0)); |
1068 if (up == NULL || up->is_top()) | 1072 if (up == NULL || up->is_top()) |
1069 return false; // Conservative answer for dead code | 1073 return false; // Conservative answer for dead code |
1070 | 1074 |
1071 if (sub == up && sub->is_Loop()) { | 1075 if (sub == up && sub->is_Loop()) { |
1072 up = sub->in(0); // in(LoopNode::EntryControl); | 1076 up = sub->in(1); // in(LoopNode::EntryControl); |
1073 } else if (sub == up && sub->is_Region()) { | 1077 } else if (sub == up && sub->is_Region() && sub->req() == 3) { |
1078 iterations_without_region_limit = DominatorSearchLimit; // Reset | |
1074 uint i = 1; | 1079 uint i = 1; |
1075 if (nlist.size() == 0) { | 1080 uint size = nlist.size(); |
1081 if (size == 0) { | |
1076 // No Region nodes (except Loops) were visited before. | 1082 // No Region nodes (except Loops) were visited before. |
1077 // Take first valid path on the way up to 'this'. | 1083 // Take first valid path on the way up to 'this'. |
1078 } else if (nlist.at(nlist.size() - 1) == sub) { | 1084 } else if (nlist.at(size - 1) == sub) { |
1079 // This Region node was just visited. Take other path. | 1085 // This Region node was just visited. Take other path. |
1080 i = region_input + 1; | 1086 i = region_input + 1; |
1081 nlist.pop(); | 1087 nlist.pop(); |
1082 } else { | 1088 } else { |
1083 // Was this Region node visited before? | 1089 // Was this Region node visited before? |
1084 uint size = nlist.size(); | |
1085 for (uint j = 0; j < size; j++) { | 1090 for (uint j = 0; j < size; j++) { |
1086 if (nlist.at(j) == sub) { | 1091 if (nlist.at(j) == sub) { |
1087 return false; // The Region node was visited before. Give up. | 1092 return false; // The Region node was visited before. Give up. |
1088 } | 1093 } |
1089 } | 1094 } |
1102 region_input = i; | 1107 region_input = i; |
1103 } | 1108 } |
1104 } | 1109 } |
1105 if (sub == up) | 1110 if (sub == up) |
1106 return false; // some kind of tight cycle | 1111 return false; // some kind of tight cycle |
1107 if (orig_sub == up) | 1112 |
1108 return false; // walk in a cycle | 1113 if (--iterations_without_region_limit < 0) |
1114 return false; // dead cycle | |
1109 | 1115 |
1110 sub = up; | 1116 sub = up; |
1111 } | 1117 } |
1112 return false; | 1118 return false; |
1113 } | 1119 } |