--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/RegisterVerifier.java 2017-07-07 09:30:44.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/RegisterVerifier.java 2017-07-07 09:30:44.000000000 -0700 @@ -30,8 +30,7 @@ import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; import org.graalvm.compiler.core.common.cfg.BlockMap; -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.InstructionValueConsumer; @@ -84,7 +83,8 @@ @SuppressWarnings("try") void verify(AbstractBlockBase start) { - try (Scope s = Debug.scope("RegisterVerifier")) { + DebugContext debug = allocator.getDebug(); + try (DebugContext.Scope s = debug.scope("RegisterVerifier")) { // setup input registers (method arguments) for first block Interval[] inputState = new Interval[stateSize()]; setStateForBlock(start, inputState); @@ -102,18 +102,19 @@ @SuppressWarnings("try") private void processBlock(AbstractBlockBase block) { - try (Indent indent = Debug.logAndIndent("processBlock B%d", block.getId())) { + DebugContext debug = allocator.getDebug(); + try (Indent indent = debug.logAndIndent("processBlock B%d", block.getId())) { // must copy state because it is modified Interval[] inputState = copy(stateForBlock(block)); - try (Indent indent2 = Debug.logAndIndent("Input-State of intervals:")) { + try (Indent indent2 = debug.logAndIndent("Input-State of intervals:")) { printState(inputState); } // process all operations of the block processOperations(block, inputState); - try (Indent indent2 = Debug.logAndIndent("Output-State of intervals:")) { + try (Indent indent2 = debug.logAndIndent("Output-State of intervals:")) { printState(inputState); } @@ -125,18 +126,20 @@ } protected void printState(Interval[] inputState) { + DebugContext debug = allocator.getDebug(); for (int i = 0; i < stateSize(); i++) { Register reg = allocator.getRegisters().get(i); assert reg.number == i; if (inputState[i] != null) { - Debug.log(" %6s %4d -- %s", reg, inputState[i].operandNumber, inputState[i]); + debug.log(" %6s %4d -- %s", reg, inputState[i].operandNumber, inputState[i]); } else { - Debug.log(" %6s __", reg); + debug.log(" %6s __", reg); } } } private void processSuccessor(AbstractBlockBase block, Interval[] inputState) { + DebugContext debug = allocator.getDebug(); Interval[] savedState = stateForBlock(block); if (savedState != null) { @@ -155,23 +158,23 @@ savedStateCorrect = false; savedState[i] = null; - Debug.log("processSuccessor B%d: invalidating slot %d", block.getId(), i); + debug.log("processSuccessor B%d: invalidating slot %d", block.getId(), i); } } } if (savedStateCorrect) { // already processed block with correct inputState - Debug.log("processSuccessor B%d: previous visit already correct", block.getId()); + debug.log("processSuccessor B%d: previous visit already correct", block.getId()); } else { // must re-visit this block - Debug.log("processSuccessor B%d: must re-visit because input state changed", block.getId()); + debug.log("processSuccessor B%d: must re-visit because input state changed", block.getId()); addToWorkList(block); } } else { // block was not processed before, so set initial inputState - Debug.log("processSuccessor B%d: initial visit", block.getId()); + debug.log("processSuccessor B%d: initial visit", block.getId()); setStateForBlock(block, copy(inputState)); addToWorkList(block); @@ -182,14 +185,14 @@ return inputState.clone(); } - static void statePut(Interval[] inputState, Value location, Interval interval) { + static void statePut(DebugContext debug, Interval[] inputState, Value location, Interval interval) { if (location != null && isRegister(location)) { Register reg = asRegister(location); int regNum = reg.number; if (interval != null) { - Debug.log("%s = %s", reg, interval.operand); + debug.log("%s = %s", reg, interval.operand); } else if (inputState[regNum] != null) { - Debug.log("%s = null", reg); + debug.log("%s = null", reg); } inputState[regNum] = interval; @@ -209,6 +212,7 @@ void processOperations(AbstractBlockBase block, final Interval[] inputState) { ArrayList ops = allocator.getLIR().getLIRforBlock(block); + DebugContext debug = allocator.getDebug(); InstructionValueConsumer useConsumer = new InstructionValueConsumer() { @Override @@ -232,7 +236,7 @@ interval = interval.getSplitChildAtOpId(op.id(), mode, allocator); } - statePut(inputState, interval.location(), interval.splitParent()); + statePut(debug, inputState, interval.location(), interval.splitParent()); } }; @@ -240,8 +244,8 @@ for (int i = 0; i < ops.size(); i++) { final LIRInstruction op = ops.get(i); - if (Debug.isLogEnabled()) { - Debug.log("%s", op.toStringWithIdPrefix()); + if (debug.isLogEnabled()) { + debug.log("%s", op.toStringWithIdPrefix()); } // check if input operands are correct @@ -249,7 +253,7 @@ // invalidate all caller save registers at calls if (op.destroysCallerSavedRegisters()) { for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) { - statePut(inputState, r.asValue(), null); + statePut(debug, inputState, r.asValue(), null); } } op.visitEachAlive(useConsumer);