--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java 2017-07-07 09:31:08.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/stackslotalloc/SimpleStackSlotAllocator.java 2017-07-07 09:31:08.000000000 -0700 @@ -29,10 +29,9 @@ import static org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize; 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.Indent; +import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.GraalError; +import org.graalvm.compiler.debug.Indent; import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.ValueProcedure; import org.graalvm.compiler.lir.VirtualStackSlot; @@ -54,44 +53,47 @@ } public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) { + DebugContext debug = res.getLIR().getDebug(); StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()]; - long currentFrameSize = allocatedFramesize.isEnabled() ? builder.getFrameMap().currentFrameSize() : 0; + boolean allocatedFramesizeEnabled = allocatedFramesize.isEnabled(debug); + long currentFrameSize = allocatedFramesizeEnabled ? builder.getFrameMap().currentFrameSize() : 0; for (VirtualStackSlot virtualSlot : builder.getStackSlots()) { final StackSlot slot; if (virtualSlot instanceof SimpleVirtualStackSlot) { slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot); - virtualFramesize.add(builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind())); + virtualFramesize.add(debug, builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind())); } else if (virtualSlot instanceof VirtualStackSlotRange) { VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot; slot = mapVirtualStackSlotRange(builder, slotRange); - virtualFramesize.add(builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots())); + virtualFramesize.add(debug, builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots())); } else { throw GraalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot); } - allocatedSlots.increment(); + allocatedSlots.increment(debug); mapping[virtualSlot.getId()] = slot; } updateLIR(res, mapping); - if (allocatedFramesize.isEnabled()) { - allocatedFramesize.add(builder.getFrameMap().currentFrameSize() - currentFrameSize); + if (allocatedFramesizeEnabled) { + allocatedFramesize.add(debug, builder.getFrameMap().currentFrameSize() - currentFrameSize); } } @SuppressWarnings("try") protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) { - try (Scope scope = Debug.scope("StackSlotMappingLIR")) { + DebugContext debug = res.getLIR().getDebug(); + try (DebugContext.Scope scope = debug.scope("StackSlotMappingLIR")) { ValueProcedure updateProc = (value, mode, flags) -> { if (isVirtualStackSlot(value)) { StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()]; - Debug.log("map %s -> %s", value, stackSlot); + debug.log("map %s -> %s", value, stackSlot); return stackSlot; } return value; }; for (AbstractBlockBase block : res.getLIR().getControlFlowGraph().getBlocks()) { - try (Indent indent0 = Debug.logAndIndent("block: %s", block)) { + try (Indent indent0 = debug.logAndIndent("block: %s", block)) { for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) { - try (Indent indent1 = Debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) { + try (Indent indent1 = debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) { inst.forEachAlive(updateProc); inst.forEachInput(updateProc); inst.forEachOutput(updateProc);