--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/lsra/TraceLinearScanPhase.java 2017-07-07 09:30:57.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/lsra/TraceLinearScanPhase.java 2017-07-07 09:30:57.000000000 -0700 @@ -39,8 +39,7 @@ import org.graalvm.compiler.core.common.alloc.Trace; import org.graalvm.compiler.core.common.alloc.TraceBuilderResult; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; -import org.graalvm.compiler.debug.Debug; -import org.graalvm.compiler.debug.Debug.Scope; +import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.lir.LIR; @@ -136,6 +135,10 @@ assert livenessInfo != null; } + protected DebugContext getDebug() { + return res.getLIR().getDebug(); + } + public static boolean isVariableOrRegister(Value value) { return isVariable(value) || isRegister(value); } @@ -256,6 +259,10 @@ return getLIR().getOptions(); } + DebugContext getDebug() { + return getLIR().getDebug(); + } + /** * Gets the number of operands. This value will increase by 1 for new variable. */ @@ -326,12 +333,13 @@ * {@linkplain TraceInterval variable}. */ private AllocatableValue allocateSpillSlot(TraceInterval interval) { + DebugContext debug = res.getLIR().getDebug(); int variableIndex = interval.splitParent().operandNumber; OptionValues options = getOptions(); if (TraceRegisterAllocationPhase.Options.TraceRACacheStackSlots.getValue(options)) { AllocatableValue cachedStackSlot = cachedStackSlots[variableIndex]; if (cachedStackSlot != null) { - TraceRegisterAllocationPhase.globalStackSlots.increment(); + TraceRegisterAllocationPhase.globalStackSlots.increment(debug); assert cachedStackSlot.getValueKind().equals(getKind(interval)) : "CachedStackSlot: kind mismatch? " + getKind(interval) + " vs. " + cachedStackSlot.getValueKind(); return cachedStackSlot; } @@ -340,7 +348,7 @@ if (TraceRegisterAllocationPhase.Options.TraceRACacheStackSlots.getValue(options)) { cachedStackSlots[variableIndex] = slot; } - TraceRegisterAllocationPhase.allocatedStackSlots.increment(); + TraceRegisterAllocationPhase.allocatedStackSlots.increment(debug); return slot; } @@ -531,8 +539,8 @@ TraceInterval result = interval.getSplitChildAtOpId(opId, mode); if (result != null) { - if (Debug.isLogEnabled()) { - Debug.log("Split child at pos %d of interval %s is %s", opId, interval, result); + if (getDebug().isLogEnabled()) { + getDebug().log("Split child at pos %d of interval %s is %s", opId, interval, result); } return result; } @@ -570,10 +578,11 @@ /* * This is the point to enable debug logging for the whole register allocation. */ - try (Indent indent = Debug.logAndIndent("LinearScan allocate")) { + DebugContext debug = res.getLIR().getDebug(); + try (Indent indent = debug.logAndIndent("LinearScan allocate")) { TRACE_LINEAR_SCAN_LIFETIME_ANALYSIS_PHASE.apply(target, lirGenRes, trace, spillMoveFactory, registerAllocationConfig, traceBuilderResult, this, false); - try (Scope s = Debug.scope("AfterLifetimeAnalysis", this)) { + try (DebugContext.Scope s = debug.scope("AfterLifetimeAnalysis", this)) { printLir("After instruction numbering"); printIntervals("Before register allocation"); @@ -598,14 +607,14 @@ verifyIntervals(); } } catch (Throwable e) { - throw Debug.handle(e); + throw debug.handle(e); } } } public void printLir(String label) { - if (Debug.isDumpEnabled(Debug.DETAILED_LEVEL)) { - Debug.dump(Debug.DETAILED_LEVEL, sortedBlocks(), "%s (Trace%d)", label, trace.getId()); + if (getDebug().isDumpEnabled(DebugContext.DETAILED_LEVEL)) { + getDebug().dump(DebugContext.DETAILED_LEVEL, sortedBlocks(), "%s (Trace%d)", label, trace.getId()); } } @@ -616,7 +625,7 @@ verifyRegisters(); - Debug.log("no errors found"); + getDebug().log("no errors found"); return true; } @@ -624,7 +633,7 @@ @SuppressWarnings("try") private void verifyRegisters() { // Enable this logging to get output for the verification process. - try (Indent indent = Debug.logAndIndent("verifying register allocation")) { + try (Indent indent = getDebug().logAndIndent("verifying register allocation")) { RegisterVerifier verifier = new RegisterVerifier(this); verifier.verify(blockAt(0)); } @@ -632,7 +641,8 @@ @SuppressWarnings("try") protected void verifyIntervals() { - try (Indent indent = Debug.logAndIndent("verifying intervals")) { + DebugContext debug = getDebug(); + try (Indent indent = debug.logAndIndent("verifying intervals")) { int len = intervalsSize(); for (int i = 0; i < len; i++) { @@ -644,32 +654,32 @@ i1.checkSplitChildren(); if (i1.operandNumber != i) { - Debug.log("Interval %d is on position %d in list", i1.operandNumber, i); - Debug.log(i1.logString()); + debug.log("Interval %d is on position %d in list", i1.operandNumber, i); + debug.log(i1.logString()); throw new GraalError(""); } if (getKind(i1).equals(LIRKind.Illegal)) { - Debug.log("Interval %d has no type assigned", i1.operandNumber); - Debug.log(i1.logString()); + debug.log("Interval %d has no type assigned", i1.operandNumber); + debug.log(i1.logString()); throw new GraalError(""); } if (i1.location() == null) { - Debug.log("Interval %d has no register assigned", i1.operandNumber); - Debug.log(i1.logString()); + debug.log("Interval %d has no register assigned", i1.operandNumber); + debug.log(i1.logString()); throw new GraalError(""); } if (i1.isEmpty()) { - Debug.log("Interval %d has no Range", i1.operandNumber); - Debug.log(i1.logString()); + debug.log("Interval %d has no Range", i1.operandNumber); + debug.log(i1.logString()); throw new GraalError(""); } if (i1.from() >= i1.to()) { - Debug.log("Interval %d has zero length range", i1.operandNumber); - Debug.log(i1.logString()); + debug.log("Interval %d has zero length range", i1.operandNumber); + debug.log(i1.logString()); throw new GraalError(""); } @@ -958,29 +968,30 @@ @SuppressWarnings("try") public void printIntervals(String label) { - if (Debug.isDumpEnabled(Debug.DETAILED_LEVEL)) { - if (Debug.isLogEnabled()) { - try (Indent indent = Debug.logAndIndent("intervals %s", label)) { + DebugContext debug = getDebug(); + if (debug.isDumpEnabled(DebugContext.DETAILED_LEVEL)) { + if (debug.isLogEnabled()) { + try (Indent indent = debug.logAndIndent("intervals %s", label)) { for (FixedInterval interval : fixedIntervals) { if (interval != null) { - Debug.log("%s", interval.logString()); + debug.log("%s", interval.logString()); } } for (TraceInterval interval : intervals) { if (interval != null) { - Debug.log("%s", interval.logString()); + debug.log("%s", interval.logString()); } } - try (Indent indent2 = Debug.logAndIndent("Basic Blocks")) { + try (Indent indent2 = debug.logAndIndent("Basic Blocks")) { for (AbstractBlockBase block : trace.getBlocks()) { - Debug.log("B%d [%d, %d, %s] ", block.getId(), getFirstLirInstructionId(block), getLastLirInstructionId(block), block.getLoop()); + debug.log("B%d [%d, %d, %s] ", block.getId(), getFirstLirInstructionId(block), getLastLirInstructionId(block), block.getLoop()); } } } } - Debug.dump(Debug.DETAILED_LEVEL, this, "%s (Trace%d)", label, trace.getId()); + debug.dump(DebugContext.DETAILED_LEVEL, this, "%s (Trace%d)", label, trace.getId()); } }