Mercurial > hg > graal-compiler
changeset 17023:586c1bdd73b8
isDominatedBy made iterative as in huge graphs it may cause stackoverflow (dacapo tomcat tests max depth is about 2.5k recursions)
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Tue, 02 Sep 2014 17:08:14 -0700 |
parents | 9364a47125ef |
children | 4e2d34d7715b |
files | graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Tue Sep 02 11:49:12 2014 -0700 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Tue Sep 02 17:08:14 2014 -0700 @@ -24,6 +24,8 @@ import java.util.*; +import com.oracle.graal.compiler.common.*; + public interface AbstractControlFlowGraph<T extends AbstractBlock<T>> { static final int BLOCK_ID_INITIAL = -1; @@ -72,13 +74,18 @@ */ static boolean isDominatedBy(AbstractBlock<?> a, AbstractBlock<?> b) { assert a != null; - if (a == b) { - return true; + AbstractBlock<?> dominator = a; + int i = 0; + while (dominator != null) { + if (i++ == Integer.MAX_VALUE) { // For safety + throw GraalInternalError.shouldNotReachHere(); + } + if (dominator == b) { + return true; + } + dominator = dominator.getDominator(); } - if (a.getDominator() == null) { - return false; - } - return isDominatedBy(a.getDominator(), b); + return false; } /**