# HG changeset patch # User Stefan Anzinger # Date 1409702894 25200 # Node ID 586c1bdd73b81dbb33d19c8f4b63e4d764fb4ad3 # Parent 9364a47125ef1bab312e88fe59d196a7a3c1dc44 isDominatedBy made iterative as in huge graphs it may cause stackoverflow (dacapo tomcat tests max depth is about 2.5k recursions) diff -r 9364a47125ef -r 586c1bdd73b8 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java --- 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> { 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; } /**