--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/alloc/BiDirectionalTraceBuilder.java 2017-07-07 09:29:25.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/alloc/BiDirectionalTraceBuilder.java 2017-07-07 09:29:25.000000000 -0700 @@ -31,7 +31,7 @@ import org.graalvm.compiler.core.common.alloc.TraceBuilderResult.TrivialTracePredicate; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; -import org.graalvm.compiler.debug.Debug; +import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.Indent; /** @@ -40,8 +40,8 @@ */ public final class BiDirectionalTraceBuilder { - public static TraceBuilderResult computeTraces(AbstractBlockBase startBlock, AbstractBlockBase[] blocks, TrivialTracePredicate pred) { - return new BiDirectionalTraceBuilder(blocks).build(startBlock, blocks, pred); + public static TraceBuilderResult computeTraces(DebugContext debug, AbstractBlockBase startBlock, AbstractBlockBase[] blocks, TrivialTracePredicate pred) { + return new BiDirectionalTraceBuilder(blocks).build(debug, startBlock, blocks, pred); } private final Deque> worklist; @@ -69,22 +69,22 @@ } @SuppressWarnings("try") - private TraceBuilderResult build(AbstractBlockBase startBlock, AbstractBlockBase[] blocks, TrivialTracePredicate pred) { - try (Indent indent = Debug.logAndIndent("BiDirectionalTraceBuilder: start trace building")) { - ArrayList traces = buildTraces(); + private TraceBuilderResult build(DebugContext debug, AbstractBlockBase startBlock, AbstractBlockBase[] blocks, TrivialTracePredicate pred) { + try (Indent indent = debug.logAndIndent("BiDirectionalTraceBuilder: start trace building")) { + ArrayList traces = buildTraces(debug); assert traces.get(0).getBlocks()[0].equals(startBlock) : "The first traces always contains the start block"; - return TraceBuilderResult.create(blocks, traces, blockToTrace, pred); + return TraceBuilderResult.create(debug, blocks, traces, blockToTrace, pred); } } - protected ArrayList buildTraces() { + protected ArrayList buildTraces(DebugContext debug) { ArrayList traces = new ArrayList<>(); // process worklist while (!worklist.isEmpty()) { AbstractBlockBase block = worklist.pollFirst(); assert block != null; if (!processed(block)) { - Trace trace = new Trace(startTrace(block)); + Trace trace = new Trace(startTrace(debug, block)); for (AbstractBlockBase traceBlock : trace.getBlocks()) { blockToTrace[traceBlock.getId()] = trace; } @@ -97,14 +97,16 @@ /** * Build a new trace starting at {@code block}. + * + * @param debug */ @SuppressWarnings("try") - private Collection> startTrace(AbstractBlockBase block) { + private Collection> startTrace(DebugContext debug, AbstractBlockBase block) { ArrayDeque> trace = new ArrayDeque<>(); - try (Indent i = Debug.logAndIndent("StartTrace: %s", block)) { - try (Indent indentFront = Debug.logAndIndent("Head:")) { + try (Indent i = debug.logAndIndent("StartTrace: %s", block)) { + try (Indent indentFront = debug.logAndIndent("Head:")) { for (AbstractBlockBase currentBlock = block; currentBlock != null; currentBlock = selectPredecessor(currentBlock)) { - addBlockToTrace(currentBlock); + addBlockToTrace(debug, currentBlock); trace.addFirst(currentBlock); } } @@ -114,21 +116,21 @@ b.setLinearScanNumber(blockNr++); } - try (Indent indentBack = Debug.logAndIndent("Tail:")) { + try (Indent indentBack = debug.logAndIndent("Tail:")) { for (AbstractBlockBase currentBlock = selectSuccessor(block); currentBlock != null; currentBlock = selectSuccessor(currentBlock)) { - addBlockToTrace(currentBlock); + addBlockToTrace(debug, currentBlock); trace.addLast(currentBlock); /* This time we can number the blocks immediately as we go forwards. */ currentBlock.setLinearScanNumber(blockNr++); } } } - Debug.log("Trace: %s", trace); + debug.log("Trace: %s", trace); return trace; } - private void addBlockToTrace(AbstractBlockBase currentBlock) { - Debug.log("add %s (prob: %f)", currentBlock, currentBlock.probability()); + private void addBlockToTrace(DebugContext debug, AbstractBlockBase currentBlock) { + debug.log("add %s (prob: %f)", currentBlock, currentBlock.probability()); processed.set(currentBlock.getId()); }