--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/lsra/TraceLinearScanLifetimeAnalysisPhase.java 2017-07-07 09:30:56.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/lsra/TraceLinearScanLifetimeAnalysisPhase.java 2017-07-07 09:30:56.000000000 -0700 @@ -43,8 +43,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.InstructionValueConsumer; @@ -86,11 +85,13 @@ public static final class Analyser { private final TraceLinearScan allocator; + private final DebugContext debug; private final TraceBuilderResult traceBuilderResult; private int numInstructions; public Analyser(TraceLinearScan allocator, TraceBuilderResult traceBuilderResult) { this.allocator = allocator; + this.debug = allocator.getDebug(); this.traceBuilderResult = traceBuilderResult; } @@ -205,8 +206,8 @@ private void addFixedUse(RegisterValue reg, int from, int to) { FixedInterval interval = allocator.getOrCreateFixedInterval(reg); interval.addRange(from, to); - if (Debug.isLogEnabled()) { - Debug.log("add fixed use: %s, at %d", interval, to); + if (debug.isLogEnabled()) { + debug.log("add fixed use: %s, at %d", interval, to); } } @@ -217,8 +218,8 @@ // Register use position at even instruction id. interval.addUsePos(to & ~1, registerPriority, allocator.getOptions()); - if (Debug.isLogEnabled()) { - Debug.log("add use: %s, at %d (%s)", interval, to, registerPriority.name()); + if (debug.isLogEnabled()) { + debug.log("add use: %s, at %d (%s)", interval, to, registerPriority.name()); } } @@ -249,12 +250,12 @@ * Dead value - make vacuous interval also add register priority for dead intervals */ interval.addRange(defPos, defPos + 1); - if (Debug.isLogEnabled()) { - Debug.log("Warning: def of operand %s at %d occurs without use", reg, defPos); + if (debug.isLogEnabled()) { + debug.log("Warning: def of operand %s at %d occurs without use", reg, defPos); } } - if (Debug.isLogEnabled()) { - Debug.log("add fixed def: %s, at %d", interval, defPos); + if (debug.isLogEnabled()) { + debug.log("add fixed def: %s, at %d", interval, defPos); } } @@ -268,8 +269,8 @@ * Dead value - make vacuous interval also add register priority for dead intervals */ interval.addRange(defPos, defPos + 1); - if (Debug.isLogEnabled()) { - Debug.log("Warning: def of operand %s at %d occurs without use", operand, defPos); + if (debug.isLogEnabled()) { + debug.log("Warning: def of operand %s at %d occurs without use", operand, defPos); } } else { /* @@ -290,8 +291,8 @@ } interval.addMaterializationValue(getMaterializedValue(op, operand, interval, allocator.neverSpillConstants(), allocator.getSpillMoveFactory())); - if (Debug.isLogEnabled()) { - Debug.log("add def: %s defPos %d (%s)", interval, defPos, registerPriority.name()); + if (debug.isLogEnabled()) { + debug.log("add def: %s defPos %d (%s)", interval, defPos, registerPriority.name()); } return interval; } @@ -311,8 +312,8 @@ private void addFixedTemp(RegisterValue reg, int tempPos) { FixedInterval interval = allocator.getOrCreateFixedInterval(reg); interval.addRange(tempPos, tempPos + 1); - if (Debug.isLogEnabled()) { - Debug.log("add fixed temp: %s, at %d", interval, tempPos); + if (debug.isLogEnabled()) { + debug.log("add fixed temp: %s, at %d", interval, tempPos); } } @@ -328,8 +329,8 @@ interval.addUsePos(tempPos, registerPriority, allocator.getOptions()); interval.addMaterializationValue(null); - if (Debug.isLogEnabled()) { - Debug.log("add temp: %s tempPos %d (%s)", interval, tempPos, RegisterPriority.MustHaveRegister.name()); + if (debug.isLogEnabled()) { + debug.log("add temp: %s tempPos %d (%s)", interval, tempPos, RegisterPriority.MustHaveRegister.name()); } } @@ -395,7 +396,7 @@ fromValue = (AllocatableValue) targetValue; toValue = (AllocatableValue) registerHint; } - Debug.log("addRegisterHint %s to %s", fromValue, toValue); + debug.log("addRegisterHint %s to %s", fromValue, toValue); final TraceInterval to; final IntervalHint from; if (isRegister(toValue)) { @@ -411,8 +412,8 @@ } to.setLocationHint(from); - if (Debug.isLogEnabled()) { - Debug.log("operation at opId %d: added hint from interval %s to %s", op.id(), from, to); + if (debug.isLogEnabled()) { + debug.log("operation at opId %d: added hint from interval %s to %s", op.id(), from, to); } return registerHint; @@ -469,7 +470,7 @@ @SuppressWarnings("try") private void buildIntervals() { - try (Indent indent = Debug.logAndIndent("build intervals")) { + try (Indent indent = debug.logAndIndent("build intervals")) { // create a list with all caller-save registers (cpu, fpu, xmm) RegisterArray callerSaveRegs = getCallerSavedRegisters(); @@ -480,7 +481,7 @@ for (int blockId = blocks.length - 1; blockId >= 0; blockId--) { final AbstractBlockBase block = blocks[blockId]; - try (Indent indent2 = Debug.logAndIndent("handle block %d", block.getId())) { + try (Indent indent2 = debug.logAndIndent("handle block %d", block.getId())) { handleBlockEnd(block, (instructionIndex - 1) << 1); /* @@ -495,7 +496,7 @@ numberInstruction(block, op, instructionIndex); final int opId = op.id(); - try (Indent indent3 = Debug.logAndIndent("handle inst %d: %s", opId, op)) { + try (Indent indent3 = debug.logAndIndent("handle inst %d: %s", opId, op)) { /* * Add a temp range for each register if operation destroys @@ -507,8 +508,8 @@ addTemp(r.asValue(), opId, RegisterPriority.None); } } - if (Debug.isLogEnabled()) { - Debug.log("operation destroys all caller-save registers"); + if (debug.isLogEnabled()) { + debug.log("operation destroys all caller-save registers"); } } @@ -533,7 +534,7 @@ AbstractBlockBase pred = blockId == 0 ? null : blocks[blockId - 1]; handleBlockBegin(block, pred); } - if (Debug.isDumpEnabled(Debug.VERY_DETAILED_LEVEL)) { + if (debug.isDumpEnabled(DebugContext.VERY_DETAILED_LEVEL)) { allocator.printIntervals("After Block " + block); } } // end of block iteration @@ -615,7 +616,7 @@ @SuppressWarnings("try") private void addInterTraceHints() { - try (Scope s = Debug.scope("InterTraceHints", allocator)) { + try (DebugContext.Scope s = debug.scope("InterTraceHints", allocator)) { GlobalLivenessInfo livenessInfo = allocator.getGlobalLivenessInfo(); // set hints for phi/incoming intervals for (AbstractBlockBase block : sortedBlocks()) { @@ -625,7 +626,7 @@ } } } catch (Throwable e) { - throw Debug.handle(e); + throw debug.handle(e); } } @@ -656,20 +657,20 @@ } if (isVariableOrRegister(fromValue)) { IntervalHint from = getIntervalHint((AllocatableValue) fromValue); - setHint(label, to, from); + setHint(label, to, from, debug); } else if (isStackSlotValue(fromValue)) { - setSpillSlot(label, to, (AllocatableValue) fromValue); + setSpillSlot(label, to, (AllocatableValue) fromValue, debug); } else if (TraceRAshareSpillInformation.getValue(allocator.getLIR().getOptions()) && isShadowedRegisterValue(fromValue)) { ShadowedRegisterValue shadowedRegisterValue = asShadowedRegisterValue(fromValue); IntervalHint from = getIntervalHint(shadowedRegisterValue.getRegister()); - setHint(label, to, from); - setSpillSlot(label, to, shadowedRegisterValue.getStackSlot()); + setHint(label, to, from, debug); + setSpillSlot(label, to, shadowedRegisterValue.getStackSlot(), debug); } else { throw GraalError.shouldNotReachHere(); } } - private static void setHint(final LIRInstruction op, TraceInterval to, IntervalHint from) { + private static void setHint(final LIRInstruction op, TraceInterval to, IntervalHint from, DebugContext debug) { IntervalHint currentHint = to.locationHint(false); if (currentHint == null) { /* @@ -677,21 +678,21 @@ * interval. */ to.setLocationHint(from); - if (Debug.isLogEnabled()) { - Debug.log("operation at opId %d: added hint from interval %s to %s", op.id(), from, to); + if (debug.isLogEnabled()) { + debug.log("operation at opId %d: added hint from interval %s to %s", op.id(), from, to); } } } - private static void setSpillSlot(LIRInstruction op, TraceInterval interval, AllocatableValue spillSlot) { + private static void setSpillSlot(LIRInstruction op, TraceInterval interval, AllocatableValue spillSlot, DebugContext debug) { if (interval.spillSlot() == null) { interval.setSpillSlot(spillSlot); interval.setSpillState(SpillState.StartInMemory); - if (Debug.isLogEnabled()) { - Debug.log("operation at opId %d: added spill slot %s to interval %s", op.id(), spillSlot, interval); + if (debug.isLogEnabled()) { + debug.log("operation at opId %d: added spill slot %s to interval %s", op.id(), spillSlot, interval); } - } else if (Debug.isLogEnabled()) { - Debug.log("operation at opId %d: has already a slot assigned %s", op.id(), interval.spillSlot()); + } else if (debug.isLogEnabled()) { + debug.log("operation at opId %d: has already a slot assigned %s", op.id(), interval.spillSlot()); } }