# HG changeset patch # User Miguel Garcia # Date 1401462097 -7200 # Node ID 114ca0838327c7ab6c46b5bb4a0634a13ef1f812 # Parent 1fbefda059a6711b21b9a6a8d5f862b9605ebed0 [inlining] made explicit an invariant of InliningData diff -r 1fbefda059a6 -r 114ca0838327 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Thu May 29 16:35:01 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Fri May 30 17:01:37 2014 +0200 @@ -140,8 +140,10 @@ protected void run(final StructuredGraph graph, final HighTierContext context) { final InliningData data = new InliningData(graph, context, maxMethodPerInlining, canonicalizer, inliningPolicy); + assert data.repOK(); while (data.hasUnprocessedGraphs()) { boolean wasInlined = data.moveForward(); + assert data.repOK(); if (wasInlined) { inliningCount++; } diff -r 1fbefda059a6 -r 114ca0838327 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Thu May 29 16:35:01 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Fri May 30 17:01:37 2014 +0200 @@ -610,4 +610,48 @@ return false; } + + /** + * This method checks an invariant that {@link #moveForward()} must maintain: "the top + * invocation records how many concrete target methods (for it) remain on the + * {@link #graphQueue}; those targets 'belong' to the current invocation in question." + */ + private boolean topGraphsForTopInvocation() { + if (invocationQueue.isEmpty()) { + assert graphQueue.isEmpty(); + return true; + } + if (currentInvocation().isRoot()) { + if (!graphQueue.isEmpty()) { + assert graphQueue.size() == 1; + } + return true; + } + final int remainingGraphs = currentInvocation().totalGraphs() - currentInvocation().processedGraphs(); + final Iterator iter = graphQueue.iterator(); + for (int i = (remainingGraphs - 1); i >= 0; i--) { + if (!iter.hasNext()) { + assert false; + return false; + } + CallsiteHolder queuedTargetCH = iter.next(); + Inlineable targetIE = currentInvocation().callee().inlineableElementAt(i); + if (targetIE instanceof InlineableMacroNode) { + assert queuedTargetCH == DUMMY_CALLSITE_HOLDER; + } else { + InlineableGraph targetIG = (InlineableGraph) targetIE; + assert queuedTargetCH.method().equals(targetIG.getGraph().method()); + } + } + return true; + } + + /** + * This method checks invariants for this class. Named after shorthand for + * "internal representation is ok". + */ + public boolean repOK() { + assert topGraphsForTopInvocation(); + return true; + } }