Mercurial > hg > truffle
changeset 19630:5e31fe50d330
Make isDominatedBy faster
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 27 Feb 2015 15:34:43 -0800 |
parents | 5762e1d007b6 |
children | 312bf1b3f410 |
files | graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java |
diffstat | 1 files changed, 9 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Fri Feb 27 20:17:59 2015 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractControlFlowGraph.java Fri Feb 27 15:34:43 2015 -0800 @@ -24,8 +24,6 @@ import java.util.*; -import com.oracle.graal.compiler.common.*; - public interface AbstractControlFlowGraph<T extends AbstractBlockBase<T>> { int BLOCK_ID_INITIAL = -1; @@ -73,26 +71,22 @@ * True if block {@code a} is dominated by block {@code b}. */ static boolean isDominatedBy(AbstractBlockBase<?> a, AbstractBlockBase<?> b) { - assert a != null; - AbstractBlockBase<?> 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(); + assert a != null && b != null; + if (a == b) { + return true; } - return false; + if (a.getDominatorDepth() < b.getDominatorDepth()) { + return false; + } + + return b == (AbstractBlockBase<?>) a.getDominator(a.getDominatorDepth() - b.getDominatorDepth()); } /** * True if block {@code a} dominates block {@code b}. */ static boolean dominates(AbstractBlockBase<?> a, AbstractBlockBase<?> b) { - assert a != null; + assert a != null && b != null; return isDominatedBy(b, a); }